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

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

Issue 394113002: Tiling priorities in Android Webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up the APIs in BVR client a little Created 6 years, 4 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 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/browser_view_renderer.h" 5 #include "android_webview/browser/browser_view_renderer.h"
6 6
7 #include "android_webview/browser/browser_view_renderer_client.h" 7 #include "android_webview/browser/browser_view_renderer_client.h"
8 #include "android_webview/browser/shared_renderer_state.h" 8 #include "android_webview/browser/shared_renderer_state.h"
9 #include "android_webview/common/aw_switches.h" 9 #include "android_webview/common/aw_switches.h"
10 #include "android_webview/public/browser/draw_gl.h" 10 #include "android_webview/public/browser/draw_gl.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 ReturnResourceFromParent(); 252 ReturnResourceFromParent();
253 SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy(); 253 SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy();
254 RequestMemoryPolicy(new_policy); 254 RequestMemoryPolicy(new_policy);
255 compositor_->SetMemoryPolicy(memory_policy_); 255 compositor_->SetMemoryPolicy(memory_policy_);
256 256
257 scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput); 257 scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput);
258 draw_gl_input->scroll_offset = last_on_draw_scroll_offset_; 258 draw_gl_input->scroll_offset = last_on_draw_scroll_offset_;
259 draw_gl_input->width = width_; 259 draw_gl_input->width = width_;
260 draw_gl_input->height = height_; 260 draw_gl_input->height = height_;
261 261
262 gfx::Transform transform; 262 parent_draw_constraints_ = shared_renderer_state_->ParentDrawConstraints();
263 gfx::Size surface_size(width_, height_); 263 gfx::Size surface_size(width_, height_);
264 gfx::Rect viewport(surface_size); 264 gfx::Rect viewport(surface_size);
265 // TODO(boliu): Should really be |last_on_draw_global_visible_rect_|.
266 // See crbug.com/372073.
267 gfx::Rect clip = viewport; 265 gfx::Rect clip = viewport;
268 scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw( 266 gfx::Transform transform_for_tile_priority =
269 surface_size, transform, viewport, clip); 267 parent_draw_constraints_.transform;
268
269 // If the WebView is on a layer, the parent transform is just an identity
270 // matrix and WebView does not know what transform is applied onto the layer.
271 // In this case, just use the surface rect for tiling.
272 gfx::Rect viewport_rect_for_tile_priority;
273 if (parent_draw_constraints_.is_layer)
274 viewport_rect_for_tile_priority = parent_draw_constraints_.surface_rect;
275 else
276 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_;
277
278 scoped_ptr<cc::CompositorFrame> frame =
279 compositor_->DemandDrawHw(surface_size,
280 gfx::Transform(),
281 viewport,
282 clip,
283 viewport_rect_for_tile_priority,
284 transform_for_tile_priority);
270 if (!frame.get()) 285 if (!frame.get())
271 return false; 286 return false;
272 287
273 GlobalTileManager::GetInstance()->DidUse(tile_manager_key_); 288 GlobalTileManager::GetInstance()->DidUse(tile_manager_key_);
274 289
275 frame->AssignTo(&draw_gl_input->frame); 290 frame->AssignTo(&draw_gl_input->frame);
276 ReturnUnusedResource(shared_renderer_state_->PassDrawGLInput()); 291 ReturnUnusedResource(shared_renderer_state_->PassDrawGLInput());
277 shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass()); 292 shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass());
278 DidComposite(); 293 DidComposite();
279 return client_->RequestDrawGL(java_canvas, false); 294 return client_->RequestDrawGL(java_canvas, false);
280 } 295 }
281 296
297 void BrowserViewRenderer::InvalidateOnceIfNeeded() {
298 if (!parent_draw_constraints_.Equals(
299 shared_renderer_state_->ParentDrawConstraints()))
300 EnsureContinuousInvalidation(true);
301 }
302
282 void BrowserViewRenderer::ReturnUnusedResource(scoped_ptr<DrawGLInput> input) { 303 void BrowserViewRenderer::ReturnUnusedResource(scoped_ptr<DrawGLInput> input) {
283 if (!input.get()) 304 if (!input.get())
284 return; 305 return;
285 306
286 cc::CompositorFrameAck frame_ack; 307 cc::CompositorFrameAck frame_ack;
287 cc::TransferableResource::ReturnResources( 308 cc::TransferableResource::ReturnResources(
288 input->frame.delegated_frame_data->resource_list, 309 input->frame.delegated_frame_data->resource_list,
289 &frame_ack.resources); 310 &frame_ack.resources);
290 if (!frame_ack.resources.empty()) 311 if (!frame_ack.resources.empty())
291 compositor_->ReturnResources(frame_ack); 312 compositor_->ReturnResources(frame_ack);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 base::StringAppendF(&str, 779 base::StringAppendF(&str,
759 "surface width height: [%d %d] ", 780 "surface width height: [%d %d] ",
760 draw_info->width, 781 draw_info->width,
761 draw_info->height); 782 draw_info->height);
762 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); 783 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer);
763 } 784 }
764 return str; 785 return str;
765 } 786 }
766 787
767 } // namespace android_webview 788 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698