| OLD | NEW |
| 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 Loading... |
| 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, WebView does not know what transform is |
| 270 // applied onto the layer so global visible rect does not make sense here. |
| 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::UpdateParentDrawConstraints() { |
| 298 // Post an invalidate if the parent draw constraints are stale and there is |
| 299 // no pending invalidate. |
| 300 if (!parent_draw_constraints_.Equals( |
| 301 shared_renderer_state_->ParentDrawConstraints())) |
| 302 EnsureContinuousInvalidation(true); |
| 303 } |
| 304 |
| 282 void BrowserViewRenderer::ReturnUnusedResource(scoped_ptr<DrawGLInput> input) { | 305 void BrowserViewRenderer::ReturnUnusedResource(scoped_ptr<DrawGLInput> input) { |
| 283 if (!input.get()) | 306 if (!input.get()) |
| 284 return; | 307 return; |
| 285 | 308 |
| 286 cc::CompositorFrameAck frame_ack; | 309 cc::CompositorFrameAck frame_ack; |
| 287 cc::TransferableResource::ReturnResources( | 310 cc::TransferableResource::ReturnResources( |
| 288 input->frame.delegated_frame_data->resource_list, | 311 input->frame.delegated_frame_data->resource_list, |
| 289 &frame_ack.resources); | 312 &frame_ack.resources); |
| 290 if (!frame_ack.resources.empty()) | 313 if (!frame_ack.resources.empty()) |
| 291 compositor_->ReturnResources(frame_ack); | 314 compositor_->ReturnResources(frame_ack); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 base::StringAppendF(&str, | 781 base::StringAppendF(&str, |
| 759 "surface width height: [%d %d] ", | 782 "surface width height: [%d %d] ", |
| 760 draw_info->width, | 783 draw_info->width, |
| 761 draw_info->height); | 784 draw_info->height); |
| 762 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 785 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
| 763 } | 786 } |
| 764 return str; | 787 return str; |
| 765 } | 788 } |
| 766 | 789 |
| 767 } // namespace android_webview | 790 } // namespace android_webview |
| OLD | NEW |