Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "android_webview/browser/browser_view_renderer_client.h" | 9 #include "android_webview/browser/browser_view_renderer_client.h" |
| 10 #include "android_webview/browser/child_frame.h" | 10 #include "android_webview/browser/child_frame.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 | 225 |
| 226 ReturnResourceFromParent(current_compositor_frame_consumer_); | 226 ReturnResourceFromParent(current_compositor_frame_consumer_); |
| 227 UpdateMemoryPolicy(); | 227 UpdateMemoryPolicy(); |
| 228 | 228 |
| 229 gfx::Transform transform_for_tile_priority = | 229 gfx::Transform transform_for_tile_priority = |
| 230 external_draw_constraints_.transform; | 230 external_draw_constraints_.transform; |
| 231 | 231 |
| 232 gfx::Rect viewport_rect_for_tile_priority = | 232 gfx::Rect viewport_rect_for_tile_priority = |
| 233 ComputeViewportRectForTilePriority(); | 233 ComputeViewportRectForTilePriority(); |
| 234 | 234 |
| 235 scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future; | |
| 236 | |
| 235 if (async_on_draw_hardware_) { | 237 if (async_on_draw_hardware_) { |
| 236 compositor_->DemandDrawHwAsync(size_, viewport_rect_for_tile_priority, | 238 frame_future = compositor_->DemandDrawHwAsync( |
| 237 transform_for_tile_priority); | 239 size_, viewport_rect_for_tile_priority, transform_for_tile_priority); |
| 238 return current_compositor_frame_consumer_->HasFrameOnUI(); | 240 // return current_compositor_frame_consumer_->HasFrameOnUI(); |
|
boliu
2016/09/16 16:26:11
why is this commented out?
ojars
2016/09/19 22:02:36
Changed back.
ojars
2016/09/19 22:02:36
Done.
| |
| 241 } else { | |
| 242 frame_future = compositor_->DemandDrawHw( | |
| 243 size_, viewport_rect_for_tile_priority, transform_for_tile_priority); | |
| 239 } | 244 } |
| 240 | 245 |
| 241 content::SynchronousCompositor::Frame frame = compositor_->DemandDrawHw( | 246 // if (!frame.frame) { |
|
boliu
2016/09/16 16:26:11
why is this commented out?
ojars
2016/09/19 22:02:36
Changed back.
ojars
2016/09/19 22:02:36
Done.
| |
| 242 size_, viewport_rect_for_tile_priority, transform_for_tile_priority); | 247 // TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", |
| 243 if (!frame.frame) { | 248 // TRACE_EVENT_SCOPE_THREAD); |
| 244 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", | 249 // return current_compositor_frame_consumer_->HasFrameOnUI(); |
| 245 TRACE_EVENT_SCOPE_THREAD); | 250 // } |
| 246 return current_compositor_frame_consumer_->HasFrameOnUI(); | |
| 247 } | |
| 248 | 251 |
| 249 OnDrawHardwareProcessFrame(std::move(frame)); | 252 OnDrawHardwareProcessFrame(std::move(frame_future)); |
| 250 return true; | 253 return true; |
| 251 } | 254 } |
| 252 | 255 |
| 253 void BrowserViewRenderer::OnDrawHardwareProcessFrame( | 256 std::unique_ptr<ChildFrame> BrowserViewRenderer::CreateChildFrame( |
|
boliu
2016/09/16 16:26:11
there is only one caller for this method, just inl
ojars
2016/09/19 22:02:36
Done.
| |
| 254 content::SynchronousCompositor::Frame frame) { | 257 scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future) { |
| 255 TRACE_EVENT0("android_webview", | |
| 256 "BrowserViewRenderer::OnDrawHardwareProcessFrame"); | |
| 257 if (!frame.frame) | |
| 258 return; | |
| 259 | |
| 260 gfx::Transform transform_for_tile_priority = | 258 gfx::Transform transform_for_tile_priority = |
| 261 external_draw_constraints_.transform; | 259 external_draw_constraints_.transform; |
| 262 gfx::Rect viewport_rect_for_tile_priority = | 260 gfx::Rect viewport_rect_for_tile_priority; |
| 263 ComputeViewportRectForTilePriority(); | 261 |
| 264 std::unique_ptr<ChildFrame> child_frame = base::MakeUnique<ChildFrame>( | 262 if (!offscreen_pre_raster_ && !external_draw_constraints_.is_layer) { |
| 265 frame.output_surface_id, std::move(frame.frame), compositor_id_, | 263 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; |
| 264 } | |
| 265 | |
| 266 return base::MakeUnique<ChildFrame>( | |
| 267 std::move(frame_future), compositor_id_, | |
| 266 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority, | 268 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority, |
| 267 offscreen_pre_raster_, external_draw_constraints_.is_layer); | 269 offscreen_pre_raster_, external_draw_constraints_.is_layer); |
| 270 } | |
| 271 | |
| 272 void BrowserViewRenderer::OnDrawHardwareProcessFrame( | |
| 273 scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future) { | |
| 274 std::unique_ptr<ChildFrame> child_frame = | |
| 275 CreateChildFrame(std::move(frame_future)); | |
| 268 | 276 |
| 269 ReturnUnusedResource( | 277 ReturnUnusedResource( |
| 270 current_compositor_frame_consumer_->PassUncommittedFrameOnUI()); | 278 current_compositor_frame_consumer_->PassUncommittedFrameOnUI()); |
| 279 | |
| 271 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame)); | 280 current_compositor_frame_consumer_->SetFrameOnUI(std::move(child_frame)); |
| 272 } | 281 } |
| 273 | 282 |
| 274 gfx::Rect BrowserViewRenderer::ComputeViewportRectForTilePriority() { | 283 gfx::Rect BrowserViewRenderer::ComputeViewportRectForTilePriority() { |
| 275 // If the WebView is on a layer, WebView does not know what transform is | 284 // If the WebView is on a layer, WebView does not know what transform is |
| 276 // applied onto the layer so global visible rect does not make sense here. | 285 // applied onto the layer so global visible rect does not make sense here. |
| 277 // In this case, just use the surface rect for tiling. | 286 // In this case, just use the surface rect for tiling. |
| 278 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. | 287 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. |
| 279 gfx::Rect viewport_rect_for_tile_priority; | 288 gfx::Rect viewport_rect_for_tile_priority; |
| 280 | 289 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 306 // At this point the compositor frame consumer has to hand back all resources | 315 // At this point the compositor frame consumer has to hand back all resources |
| 307 // to the child compositor. | 316 // to the child compositor. |
| 308 compositor_frame_consumer->DeleteHardwareRendererOnUI(); | 317 compositor_frame_consumer->DeleteHardwareRendererOnUI(); |
| 309 ReturnUnusedResource(compositor_frame_consumer->PassUncommittedFrameOnUI()); | 318 ReturnUnusedResource(compositor_frame_consumer->PassUncommittedFrameOnUI()); |
| 310 ReturnResourceFromParent(compositor_frame_consumer); | 319 ReturnResourceFromParent(compositor_frame_consumer); |
| 311 compositor_frame_consumer->SetCompositorFrameProducer(nullptr); | 320 compositor_frame_consumer->SetCompositorFrameProducer(nullptr); |
| 312 } | 321 } |
| 313 | 322 |
| 314 void BrowserViewRenderer::ReturnUnusedResource( | 323 void BrowserViewRenderer::ReturnUnusedResource( |
| 315 std::unique_ptr<ChildFrame> child_frame) { | 324 std::unique_ptr<ChildFrame> child_frame) { |
| 316 if (!child_frame.get() || !child_frame->frame.get()) | 325 // if (!child_frame.get() || !child_frame->frame.get()) |
|
boliu
2016/09/16 16:26:11
remove?
ojars
2016/09/19 22:02:36
Done.
| |
| 326 if (!child_frame.get() || !child_frame->frame_future->hasFrame()) | |
| 317 return; | 327 return; |
| 318 | 328 |
| 319 cc::ReturnedResourceArray resources; | 329 cc::ReturnedResourceArray resources; |
| 320 cc::TransferableResource::ReturnResources( | 330 cc::TransferableResource::ReturnResources( |
| 321 child_frame->frame->delegated_frame_data->resource_list, &resources); | 331 child_frame->frame_future->getFrame() |
| 332 ->frame->delegated_frame_data->resource_list, | |
| 333 &resources); | |
| 322 content::SynchronousCompositor* compositor = | 334 content::SynchronousCompositor* compositor = |
| 323 FindCompositor(child_frame->compositor_id); | 335 FindCompositor(child_frame->compositor_id); |
| 324 if (compositor && !resources.empty()) | 336 if (compositor && !resources.empty()) |
| 325 compositor->ReturnResources(child_frame->output_surface_id, resources); | 337 compositor->ReturnResources( |
| 338 child_frame->frame_future->getFrame()->output_surface_id, resources); | |
| 326 } | 339 } |
| 327 | 340 |
| 328 void BrowserViewRenderer::ReturnResourceFromParent( | 341 void BrowserViewRenderer::ReturnResourceFromParent( |
| 329 CompositorFrameConsumer* compositor_frame_consumer) { | 342 CompositorFrameConsumer* compositor_frame_consumer) { |
| 330 CompositorFrameConsumer::ReturnedResourcesMap returned_resource_map; | 343 CompositorFrameConsumer::ReturnedResourcesMap returned_resource_map; |
| 331 compositor_frame_consumer->SwapReturnedResourcesOnUI(&returned_resource_map); | 344 compositor_frame_consumer->SwapReturnedResourcesOnUI(&returned_resource_map); |
| 332 for (auto& pair : returned_resource_map) { | 345 for (auto& pair : returned_resource_map) { |
| 333 CompositorID compositor_id = pair.first; | 346 CompositorID compositor_id = pair.first; |
| 334 content::SynchronousCompositor* compositor = FindCompositor(compositor_id); | 347 content::SynchronousCompositor* compositor = FindCompositor(compositor_id); |
| 335 cc::ReturnedResourceArray resources; | 348 cc::ReturnedResourceArray resources; |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 base::StringAppendF(&str, | 778 base::StringAppendF(&str, |
| 766 "overscroll_rounding_error_: %s ", | 779 "overscroll_rounding_error_: %s ", |
| 767 overscroll_rounding_error_.ToString().c_str()); | 780 overscroll_rounding_error_.ToString().c_str()); |
| 768 base::StringAppendF( | 781 base::StringAppendF( |
| 769 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 782 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
| 770 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 783 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
| 771 return str; | 784 return str; |
| 772 } | 785 } |
| 773 | 786 |
| 774 } // namespace android_webview | 787 } // namespace android_webview |
| OLD | NEW |