Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: android_webview/browser/surfaces_instance.cc

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Address comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/surfaces_instance.h" 5 #include "android_webview/browser/surfaces_instance.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "android_webview/browser/aw_gl_surface.h" 10 #include "android_webview/browser/aw_gl_surface.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); 132 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
133 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_rect), 133 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_rect),
134 gfx::Rect(quad_state->quad_layer_rect), child_id, 134 gfx::Rect(quad_state->quad_layer_rect), child_id,
135 cc::SurfaceDrawQuadType::PRIMARY, nullptr); 135 cc::SurfaceDrawQuadType::PRIMARY, nullptr);
136 136
137 cc::CompositorFrame frame; 137 cc::CompositorFrame frame;
138 // We draw synchronously, so acknowledge a manual BeginFrame. 138 // We draw synchronously, so acknowledge a manual BeginFrame.
139 frame.metadata.begin_frame_ack = 139 frame.metadata.begin_frame_ack =
140 cc::BeginFrameAck::CreateManualAckWithDamage(); 140 cc::BeginFrameAck::CreateManualAckWithDamage();
141 frame.render_pass_list.push_back(std::move(render_pass)); 141 frame.render_pass_list.push_back(std::move(render_pass));
142 frame.metadata.device_scale_factor = 1.f;
142 frame.metadata.referenced_surfaces = child_ids_; 143 frame.metadata.referenced_surfaces = child_ids_;
143 144
144 if (!root_id_.is_valid() || frame_size != surface_size_) { 145 if (!root_id_.is_valid() || frame_size != surface_size_) {
145 root_id_ = local_surface_id_allocator_->GenerateId(); 146 root_id_ = local_surface_id_allocator_->GenerateId();
146 surface_size_ = frame_size; 147 surface_size_ = frame_size;
147 display_->SetLocalSurfaceId(root_id_, 1.f); 148 display_->SetLocalSurfaceId(root_id_, 1.f);
148 } 149 }
149 support_->SubmitCompositorFrame(root_id_, std::move(frame)); 150 bool result = support_->SubmitCompositorFrame(root_id_, std::move(frame));
151 DCHECK(result);
150 152
151 display_->Resize(viewport); 153 display_->Resize(viewport);
152 display_->DrawAndSwap(); 154 display_->DrawAndSwap();
153 } 155 }
154 156
155 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { 157 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) {
156 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) == 158 DCHECK(std::find(child_ids_.begin(), child_ids_.end(), child_id) ==
157 child_ids_.end()); 159 child_ids_.end());
158 child_ids_.push_back(child_id); 160 child_ids_.push_back(child_id);
159 if (root_id_.is_valid()) 161 if (root_id_.is_valid())
(...skipping 19 matching lines...) Expand all
179 SkBlendMode::kSrcOver, 0); 181 SkBlendMode::kSrcOver, 0);
180 cc::SolidColorDrawQuad* solid_quad = 182 cc::SolidColorDrawQuad* solid_quad =
181 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); 183 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
182 solid_quad->SetNew(quad_state, rect, rect, SK_ColorBLACK, false); 184 solid_quad->SetNew(quad_state, rect, rect, SK_ColorBLACK, false);
183 cc::CompositorFrame frame; 185 cc::CompositorFrame frame;
184 frame.render_pass_list.push_back(std::move(render_pass)); 186 frame.render_pass_list.push_back(std::move(render_pass));
185 // We draw synchronously, so acknowledge a manual BeginFrame. 187 // We draw synchronously, so acknowledge a manual BeginFrame.
186 frame.metadata.begin_frame_ack = 188 frame.metadata.begin_frame_ack =
187 cc::BeginFrameAck::CreateManualAckWithDamage(); 189 cc::BeginFrameAck::CreateManualAckWithDamage();
188 frame.metadata.referenced_surfaces = child_ids_; 190 frame.metadata.referenced_surfaces = child_ids_;
189 support_->SubmitCompositorFrame(root_id_, std::move(frame)); 191 frame.metadata.device_scale_factor = 1;
192 bool result = support_->SubmitCompositorFrame(root_id_, std::move(frame));
193 DCHECK(result);
190 } 194 }
191 195
192 void SurfacesInstance::DidReceiveCompositorFrameAck( 196 void SurfacesInstance::DidReceiveCompositorFrameAck(
193 const cc::ReturnedResourceArray& resources) { 197 const cc::ReturnedResourceArray& resources) {
194 ReclaimResources(resources); 198 ReclaimResources(resources);
195 } 199 }
196 200
197 void SurfacesInstance::OnBeginFrame(const cc::BeginFrameArgs& args) {} 201 void SurfacesInstance::OnBeginFrame(const cc::BeginFrameArgs& args) {}
198 202
199 void SurfacesInstance::WillDrawSurface( 203 void SurfacesInstance::WillDrawSurface(
200 const cc::LocalSurfaceId& local_surface_id, 204 const cc::LocalSurfaceId& local_surface_id,
201 const gfx::Rect& damage_rect) {} 205 const gfx::Rect& damage_rect) {}
202 206
203 void SurfacesInstance::ReclaimResources( 207 void SurfacesInstance::ReclaimResources(
204 const cc::ReturnedResourceArray& resources) { 208 const cc::ReturnedResourceArray& resources) {
205 // Root surface should have no resources to return. 209 // Root surface should have no resources to return.
206 CHECK(resources.empty()); 210 CHECK(resources.empty());
207 } 211 }
208 212
209 } // namespace android_webview 213 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/hardware_renderer.cc ('k') | android_webview/browser/test/rendering_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698