| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // If the WebView is on a layer, WebView does not know what transform is | 252 // If the WebView is on a layer, WebView does not know what transform is |
| 253 // applied onto the layer so global visible rect does not make sense here. | 253 // applied onto the layer so global visible rect does not make sense here. |
| 254 // In this case, just use the surface rect for tiling. | 254 // In this case, just use the surface rect for tiling. |
| 255 gfx::Rect viewport_rect_for_tile_priority; | 255 gfx::Rect viewport_rect_for_tile_priority; |
| 256 | 256 |
| 257 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. | 257 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. |
| 258 if (!offscreen_pre_raster_ && !parent_draw_constraints.is_layer) { | 258 if (!offscreen_pre_raster_ && !parent_draw_constraints.is_layer) { |
| 259 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; | 259 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; |
| 260 } | 260 } |
| 261 | 261 |
| 262 scoped_ptr<cc::CompositorFrame> frame = | 262 content::SynchronousCompositor::Frame frame = |
| 263 compositor_->DemandDrawHw(surface_size, | 263 compositor_->DemandDrawHw(surface_size, |
| 264 gfx::Transform(), | 264 gfx::Transform(), |
| 265 viewport, | 265 viewport, |
| 266 clip, | 266 clip, |
| 267 viewport_rect_for_tile_priority, | 267 viewport_rect_for_tile_priority, |
| 268 transform_for_tile_priority); | 268 transform_for_tile_priority); |
| 269 if (!frame.get()) { | 269 if (!frame.frame.get()) { |
| 270 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", | 270 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", |
| 271 TRACE_EVENT_SCOPE_THREAD); | 271 TRACE_EVENT_SCOPE_THREAD); |
| 272 return shared_renderer_state_.HasFrameOnUI(); | 272 return shared_renderer_state_.HasFrameOnUI(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 scoped_ptr<ChildFrame> child_frame = make_scoped_ptr(new ChildFrame( | 275 scoped_ptr<ChildFrame> child_frame = make_scoped_ptr(new ChildFrame( |
| 276 std::move(frame), GetCompositorID(compositor_), | 276 frame.output_surface_id, std::move(frame.frame), |
| 277 viewport_rect_for_tile_priority.IsEmpty(), transform_for_tile_priority, | 277 GetCompositorID(compositor_), viewport_rect_for_tile_priority.IsEmpty(), |
| 278 offscreen_pre_raster_, parent_draw_constraints.is_layer)); | 278 transform_for_tile_priority, offscreen_pre_raster_, |
| 279 parent_draw_constraints.is_layer)); |
| 279 | 280 |
| 280 // Uncommitted frame can happen with consecutive fallback ticks. | 281 // Uncommitted frame can happen with consecutive fallback ticks. |
| 281 ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI()); | 282 ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI()); |
| 282 shared_renderer_state_.SetCompositorFrameOnUI(std::move(child_frame)); | 283 shared_renderer_state_.SetCompositorFrameOnUI(std::move(child_frame)); |
| 283 return true; | 284 return true; |
| 284 } | 285 } |
| 285 | 286 |
| 286 void BrowserViewRenderer::UpdateParentDrawConstraints() { | 287 void BrowserViewRenderer::UpdateParentDrawConstraints() { |
| 287 PostInvalidateWithFallback(); | 288 PostInvalidateWithFallback(); |
| 288 ParentCompositorDrawConstraints parent_draw_constraints = | 289 ParentCompositorDrawConstraints parent_draw_constraints = |
| 289 shared_renderer_state_.GetParentDrawConstraintsOnUI(); | 290 shared_renderer_state_.GetParentDrawConstraintsOnUI(); |
| 290 client_->ParentDrawConstraintsUpdated(parent_draw_constraints); | 291 client_->ParentDrawConstraintsUpdated(parent_draw_constraints); |
| 291 } | 292 } |
| 292 | 293 |
| 293 void BrowserViewRenderer::ReturnUnusedResource( | 294 void BrowserViewRenderer::ReturnUnusedResource( |
| 294 scoped_ptr<ChildFrame> child_frame) { | 295 scoped_ptr<ChildFrame> child_frame) { |
| 295 if (!child_frame.get() || !child_frame->frame.get()) | 296 if (!child_frame.get() || !child_frame->frame.get()) |
| 296 return; | 297 return; |
| 297 | 298 |
| 298 cc::CompositorFrameAck frame_ack; | 299 cc::CompositorFrameAck frame_ack; |
| 299 cc::TransferableResource::ReturnResources( | 300 cc::TransferableResource::ReturnResources( |
| 300 child_frame->frame->delegated_frame_data->resource_list, | 301 child_frame->frame->delegated_frame_data->resource_list, |
| 301 &frame_ack.resources); | 302 &frame_ack.resources); |
| 302 content::SynchronousCompositor* compositor = | 303 content::SynchronousCompositor* compositor = |
| 303 compositor_map_[child_frame->compositor_id]; | 304 compositor_map_[child_frame->compositor_id]; |
| 304 if (compositor && !frame_ack.resources.empty()) | 305 if (compositor && !frame_ack.resources.empty()) |
| 305 compositor->ReturnResources(frame_ack); | 306 compositor->ReturnResources(child_frame->output_surface_id, frame_ack); |
| 306 } | 307 } |
| 307 | 308 |
| 308 void BrowserViewRenderer::ReturnResourceFromParent() { | 309 void BrowserViewRenderer::ReturnResourceFromParent() { |
| 309 std::map<unsigned int, cc::ReturnedResourceArray> returned_resource_map; | 310 SharedRendererState::ReturnedResourcesMap returned_resource_map; |
| 310 shared_renderer_state_.SwapReturnedResourcesOnUI(&returned_resource_map); | 311 shared_renderer_state_.SwapReturnedResourcesOnUI(&returned_resource_map); |
| 311 for (auto iterator = returned_resource_map.begin(); | 312 for (auto iterator = returned_resource_map.begin(); |
| 312 iterator != returned_resource_map.end(); iterator++) { | 313 iterator != returned_resource_map.end(); iterator++) { |
| 313 unsigned int compositor_id = iterator->first; | 314 unsigned int compositor_id = iterator->first; |
| 314 content::SynchronousCompositor* compositor = compositor_map_[compositor_id]; | 315 content::SynchronousCompositor* compositor = compositor_map_[compositor_id]; |
| 315 cc::CompositorFrameAck frame_ack; | 316 cc::CompositorFrameAck frame_ack; |
| 316 frame_ack.resources.swap(iterator->second); | 317 frame_ack.resources.swap(iterator->second.resources); |
| 317 | 318 |
| 318 if (compositor && !frame_ack.resources.empty()) | 319 if (compositor && !frame_ack.resources.empty()) { |
| 319 compositor->ReturnResources(frame_ack); | 320 compositor->ReturnResources(iterator->second.output_surface_id, |
| 321 frame_ack); |
| 322 } |
| 320 } | 323 } |
| 321 } | 324 } |
| 322 | 325 |
| 323 void BrowserViewRenderer::DetachFunctorFromView() { | 326 void BrowserViewRenderer::DetachFunctorFromView() { |
| 324 client_->DetachFunctorFromView(); | 327 client_->DetachFunctorFromView(); |
| 325 } | 328 } |
| 326 | 329 |
| 327 bool BrowserViewRenderer::OnDrawSoftware(SkCanvas* canvas) { | 330 bool BrowserViewRenderer::OnDrawSoftware(SkCanvas* canvas) { |
| 328 return CanOnDraw() && CompositeSW(canvas); | 331 return CanOnDraw() && CompositeSW(canvas); |
| 329 } | 332 } |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 base::StringAppendF(&str, | 807 base::StringAppendF(&str, |
| 805 "overscroll_rounding_error_: %s ", | 808 "overscroll_rounding_error_: %s ", |
| 806 overscroll_rounding_error_.ToString().c_str()); | 809 overscroll_rounding_error_.ToString().c_str()); |
| 807 base::StringAppendF( | 810 base::StringAppendF( |
| 808 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 811 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
| 809 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 812 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
| 810 return str; | 813 return str; |
| 811 } | 814 } |
| 812 | 815 |
| 813 } // namespace android_webview | 816 } // namespace android_webview |
| OLD | NEW |