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

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

Issue 551023002: aw: Skip hardware onDraw when visible rect is empty (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unrelated change Created 6 years, 3 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
« no previous file with comments | « android_webview/browser/browser_view_renderer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/hardware_renderer.h" 5 #include "android_webview/browser/hardware_renderer.h"
6 6
7 #include "android_webview/browser/aw_gl_surface.h" 7 #include "android_webview/browser/aw_gl_surface.h"
8 #include "android_webview/browser/deferred_gpu_command_service.h" 8 #include "android_webview/browser/deferred_gpu_command_service.h"
9 #include "android_webview/browser/parent_output_surface.h" 9 #include "android_webview/browser/parent_output_surface.h"
10 #include "android_webview/browser/shared_renderer_state.h" 10 #include "android_webview/browser/shared_renderer_state.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // This is called after OutputSurface is created, but before the impl frame 132 // This is called after OutputSurface is created, but before the impl frame
133 // starts. We set the draw constraints here. 133 // starts. We set the draw constraints here.
134 DCHECK(output_surface_); 134 DCHECK(output_surface_);
135 DCHECK(viewport_clip_valid_for_dcheck_); 135 DCHECK(viewport_clip_valid_for_dcheck_);
136 output_surface_->SetExternalStencilTest(stencil_enabled_); 136 output_surface_->SetExternalStencilTest(stencil_enabled_);
137 output_surface_->SetDrawConstraints(viewport_, clip_); 137 output_surface_->SetDrawConstraints(viewport_, clip_);
138 } 138 }
139 139
140 void HardwareRenderer::CommitFrame() { 140 void HardwareRenderer::CommitFrame() {
141 scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput(); 141 scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput();
142 if (!input.get()) { 142 // Happens with empty global visible rect.
143 DLOG(WARNING) << "No frame to commit"; 143 if (!input.get())
144 return; 144 return;
145 }
146 145
147 DCHECK(!input->frame.gl_frame_data); 146 DCHECK(!input->frame.gl_frame_data);
148 DCHECK(!input->frame.software_frame_data); 147 DCHECK(!input->frame.software_frame_data);
149 148
150 // DelegatedRendererLayerImpl applies the inverse device_scale_factor of the 149 // DelegatedRendererLayerImpl applies the inverse device_scale_factor of the
151 // renderer frame, assuming that the browser compositor will scale 150 // renderer frame, assuming that the browser compositor will scale
152 // it back up to device scale. But on Android we put our browser layers in 151 // it back up to device scale. But on Android we put our browser layers in
153 // physical pixels and set our browser CC device_scale_factor to 1, so this 152 // physical pixels and set our browser CC device_scale_factor to 1, so this
154 // suppresses the transform. 153 // suppresses the transform.
155 input->frame.delegated_frame_data->device_scale_factor = 1.0f; 154 input->frame.delegated_frame_data->device_scale_factor = 1.0f;
(...skipping 29 matching lines...) Expand all
185 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); 184 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL");
186 185
187 // We need to watch if the current Android context has changed and enforce 186 // We need to watch if the current Android context has changed and enforce
188 // a clean-up in the compositor. 187 // a clean-up in the compositor.
189 EGLContext current_context = eglGetCurrentContext(); 188 EGLContext current_context = eglGetCurrentContext();
190 if (!current_context) { 189 if (!current_context) {
191 DLOG(ERROR) << "DrawGL called without EGLContext"; 190 DLOG(ERROR) << "DrawGL called without EGLContext";
192 return; 191 return;
193 } 192 }
194 193
195 if (!delegated_layer_.get()) {
196 DLOG(ERROR) << "No frame committed";
197 return;
198 }
199
200 // TODO(boliu): Handle context loss. 194 // TODO(boliu): Handle context loss.
201 if (last_egl_context_ != current_context) 195 if (last_egl_context_ != current_context)
202 DLOG(WARNING) << "EGLContextChanged"; 196 DLOG(WARNING) << "EGLContextChanged";
203 197
204 gfx::Transform transform(gfx::Transform::kSkipInitialization); 198 gfx::Transform transform(gfx::Transform::kSkipInitialization);
205 transform.matrix().setColMajorf(draw_info->transform); 199 transform.matrix().setColMajorf(draw_info->transform);
206 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); 200 transform.Translate(scroll_offset_.x(), scroll_offset_.y());
207 201
208 // Need to post the new transform matrix back to child compositor 202 // Need to post the new transform matrix back to child compositor
209 // because there is no onDraw during a Render Thread animation, and child 203 // because there is no onDraw during a Render Thread animation, and child
210 // compositor might not have the tiles rasterized as the animation goes on. 204 // compositor might not have the tiles rasterized as the animation goes on.
211 ParentCompositorDrawConstraints draw_constraints( 205 ParentCompositorDrawConstraints draw_constraints(
212 draw_info->is_layer, transform, gfx::Rect(viewport_)); 206 draw_info->is_layer, transform, gfx::Rect(viewport_));
213 if (!draw_constraints_.Equals(draw_constraints)) { 207 if (!draw_constraints_.Equals(draw_constraints)) {
214 draw_constraints_ = draw_constraints; 208 draw_constraints_ = draw_constraints;
215 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor( 209 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor(
216 draw_constraints); 210 draw_constraints);
217 } 211 }
218 212
213 if (!delegated_layer_.get())
214 return;
215
219 viewport_.SetSize(draw_info->width, draw_info->height); 216 viewport_.SetSize(draw_info->width, draw_info->height);
220 layer_tree_host_->SetViewportSize(viewport_); 217 layer_tree_host_->SetViewportSize(viewport_);
221 clip_.SetRect(draw_info->clip_left, 218 clip_.SetRect(draw_info->clip_left,
222 draw_info->clip_top, 219 draw_info->clip_top,
223 draw_info->clip_right - draw_info->clip_left, 220 draw_info->clip_right - draw_info->clip_left,
224 draw_info->clip_bottom - draw_info->clip_top); 221 draw_info->clip_bottom - draw_info->clip_top);
225 stencil_enabled_ = stencil_enabled; 222 stencil_enabled_ = stencil_enabled;
226 223
227 delegated_layer_->SetTransform(transform); 224 delegated_layer_->SetTransform(transform);
228 225
(...skipping 22 matching lines...) Expand all
251 } 248 }
252 249
253 void HardwareRenderer::UnusedResourcesAreAvailable() { 250 void HardwareRenderer::UnusedResourcesAreAvailable() {
254 cc::ReturnedResourceArray returned_resources; 251 cc::ReturnedResourceArray returned_resources;
255 resource_collection_->TakeUnusedResourcesForChildCompositor( 252 resource_collection_->TakeUnusedResourcesForChildCompositor(
256 &returned_resources); 253 &returned_resources);
257 shared_renderer_state_->InsertReturnedResources(returned_resources); 254 shared_renderer_state_->InsertReturnedResources(returned_resources);
258 } 255 }
259 256
260 } // namespace android_webview 257 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/browser_view_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698