OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 TaskRunnerProvider* task_runner_provider, | 190 TaskRunnerProvider* task_runner_provider, |
191 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 191 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
192 SharedBitmapManager* shared_bitmap_manager, | 192 SharedBitmapManager* shared_bitmap_manager, |
193 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 193 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
194 TaskGraphRunner* task_graph_runner, | 194 TaskGraphRunner* task_graph_runner, |
195 std::unique_ptr<AnimationHost> animation_host, | 195 std::unique_ptr<AnimationHost> animation_host, |
196 int id) | 196 int id) |
197 : client_(client), | 197 : client_(client), |
198 task_runner_provider_(task_runner_provider), | 198 task_runner_provider_(task_runner_provider), |
199 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | 199 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
200 output_surface_(nullptr), | 200 compositor_frame_sink_(nullptr), |
201 need_update_gpu_rasterization_status_(false), | 201 need_update_gpu_rasterization_status_(false), |
202 content_is_suitable_for_gpu_rasterization_(true), | 202 content_is_suitable_for_gpu_rasterization_(true), |
203 has_gpu_rasterization_trigger_(false), | 203 has_gpu_rasterization_trigger_(false), |
204 use_gpu_rasterization_(false), | 204 use_gpu_rasterization_(false), |
205 use_msaa_(false), | 205 use_msaa_(false), |
206 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), | 206 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), |
207 input_handler_client_(NULL), | 207 input_handler_client_(NULL), |
208 did_lock_scrolling_layer_(false), | 208 did_lock_scrolling_layer_(false), |
209 wheel_scrolling_(false), | 209 wheel_scrolling_(false), |
210 scroll_affects_scroll_handler_(false), | 210 scroll_affects_scroll_handler_(false), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 settings.top_controls_hide_threshold); | 265 settings.top_controls_hide_threshold); |
266 } | 266 } |
267 | 267 |
268 LayerTreeHostImpl::~LayerTreeHostImpl() { | 268 LayerTreeHostImpl::~LayerTreeHostImpl() { |
269 DCHECK(task_runner_provider_->IsImplThread()); | 269 DCHECK(task_runner_provider_->IsImplThread()); |
270 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 270 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
271 TRACE_EVENT_OBJECT_DELETED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 271 TRACE_EVENT_OBJECT_DELETED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
272 "cc::LayerTreeHostImpl", id_); | 272 "cc::LayerTreeHostImpl", id_); |
273 | 273 |
274 // It is released before shutdown. | 274 // It is released before shutdown. |
275 DCHECK(!output_surface_); | 275 DCHECK(!compositor_frame_sink_); |
276 | 276 |
277 DCHECK(!resource_provider_); | 277 DCHECK(!resource_provider_); |
278 DCHECK(!resource_pool_); | 278 DCHECK(!resource_pool_); |
279 DCHECK(!tile_task_manager_); | 279 DCHECK(!tile_task_manager_); |
280 DCHECK(!single_thread_synchronous_task_graph_runner_); | 280 DCHECK(!single_thread_synchronous_task_graph_runner_); |
281 DCHECK(!image_decode_controller_); | 281 DCHECK(!image_decode_controller_); |
282 | 282 |
283 if (input_handler_client_) { | 283 if (input_handler_client_) { |
284 input_handler_client_->WillShutdown(); | 284 input_handler_client_->WillShutdown(); |
285 input_handler_client_ = NULL; | 285 input_handler_client_ = NULL; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 void LayerTreeHostImpl::BeginCommit() { | 323 void LayerTreeHostImpl::BeginCommit() { |
324 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); | 324 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); |
325 | 325 |
326 // Ensure all textures are returned so partial texture updates can happen | 326 // Ensure all textures are returned so partial texture updates can happen |
327 // during the commit. | 327 // during the commit. |
328 // TODO(ericrk): We should not need to ForceReclaimResources when using | 328 // TODO(ericrk): We should not need to ForceReclaimResources when using |
329 // Impl-side-painting as it doesn't upload during commits. However, | 329 // Impl-side-painting as it doesn't upload during commits. However, |
330 // Display::Draw currently relies on resource being reclaimed to block drawing | 330 // Display::Draw currently relies on resource being reclaimed to block drawing |
331 // between BeginCommit / Swap. See crbug.com/489515. | 331 // between BeginCommit / Swap. See crbug.com/489515. |
332 if (output_surface_) | 332 if (compositor_frame_sink_) |
333 output_surface_->ForceReclaimResources(); | 333 compositor_frame_sink_->ForceReclaimResources(); |
334 | 334 |
335 if (!CommitToActiveTree()) | 335 if (!CommitToActiveTree()) |
336 CreatePendingTree(); | 336 CreatePendingTree(); |
337 } | 337 } |
338 | 338 |
339 void LayerTreeHostImpl::CommitComplete() { | 339 void LayerTreeHostImpl::CommitComplete() { |
340 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 340 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
341 | 341 |
342 if (CommitToActiveTree()) { | 342 if (CommitToActiveTree()) { |
343 // We have to activate animations here or "IsActive()" is true on the layers | 343 // We have to activate animations here or "IsActive()" is true on the layers |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 383 |
384 micro_benchmark_controller_.DidCompleteCommit(); | 384 micro_benchmark_controller_.DidCompleteCommit(); |
385 } | 385 } |
386 | 386 |
387 bool LayerTreeHostImpl::CanDraw() const { | 387 bool LayerTreeHostImpl::CanDraw() const { |
388 // Note: If you are changing this function or any other function that might | 388 // Note: If you are changing this function or any other function that might |
389 // affect the result of CanDraw, make sure to call | 389 // affect the result of CanDraw, make sure to call |
390 // client_->OnCanDrawStateChanged in the proper places and update the | 390 // client_->OnCanDrawStateChanged in the proper places and update the |
391 // NotifyIfCanDrawChanged test. | 391 // NotifyIfCanDrawChanged test. |
392 | 392 |
393 if (!output_surface_) { | 393 if (!compositor_frame_sink_) { |
394 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no output surface", | 394 TRACE_EVENT_INSTANT0("cc", |
| 395 "LayerTreeHostImpl::CanDraw no CompositorFrameSink", |
395 TRACE_EVENT_SCOPE_THREAD); | 396 TRACE_EVENT_SCOPE_THREAD); |
396 return false; | 397 return false; |
397 } | 398 } |
398 | 399 |
399 // TODO(boliu): Make draws without layers work and move this below | 400 // TODO(boliu): Make draws without layers work and move this below |
400 // |resourceless_software_draw_| check. Tracked in crbug.com/264967. | 401 // |resourceless_software_draw_| check. Tracked in crbug.com/264967. |
401 if (active_tree_->LayerListIsEmpty()) { | 402 if (active_tree_->LayerListIsEmpty()) { |
402 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no root layer", | 403 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no root layer", |
403 TRACE_EVENT_SCOPE_THREAD); | 404 TRACE_EVENT_SCOPE_THREAD); |
404 return false; | 405 return false; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 690 } |
690 | 691 |
691 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 692 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
692 std::unique_ptr<RenderPass> render_pass) { | 693 std::unique_ptr<RenderPass> render_pass) { |
693 render_passes.push_back(std::move(render_pass)); | 694 render_passes.push_back(std::move(render_pass)); |
694 } | 695 } |
695 | 696 |
696 DrawMode LayerTreeHostImpl::GetDrawMode() const { | 697 DrawMode LayerTreeHostImpl::GetDrawMode() const { |
697 if (resourceless_software_draw_) { | 698 if (resourceless_software_draw_) { |
698 return DRAW_MODE_RESOURCELESS_SOFTWARE; | 699 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
699 } else if (output_surface_->context_provider()) { | 700 } else if (compositor_frame_sink_->context_provider()) { |
700 return DRAW_MODE_HARDWARE; | 701 return DRAW_MODE_HARDWARE; |
701 } else { | 702 } else { |
702 return DRAW_MODE_SOFTWARE; | 703 return DRAW_MODE_SOFTWARE; |
703 } | 704 } |
704 } | 705 } |
705 | 706 |
706 static void AppendQuadsForRenderSurfaceLayer( | 707 static void AppendQuadsForRenderSurfaceLayer( |
707 RenderPass* target_render_pass, | 708 RenderPass* target_render_pass, |
708 LayerImpl* layer, | 709 LayerImpl* layer, |
709 const RenderPass* contributing_render_pass, | 710 const RenderPass* contributing_render_pass, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 // frame at all. | 801 // frame at all. |
801 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface(); | 802 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface(); |
802 bool root_surface_has_no_visible_damage = | 803 bool root_surface_has_no_visible_damage = |
803 !root_surface->damage_tracker()->current_damage_rect().Intersects( | 804 !root_surface->damage_tracker()->current_damage_rect().Intersects( |
804 root_surface->content_rect()); | 805 root_surface->content_rect()); |
805 bool root_surface_has_contributing_layers = | 806 bool root_surface_has_contributing_layers = |
806 !root_surface->layer_list().empty(); | 807 !root_surface->layer_list().empty(); |
807 bool hud_wants_to_draw_ = active_tree_->hud_layer() && | 808 bool hud_wants_to_draw_ = active_tree_->hud_layer() && |
808 active_tree_->hud_layer()->IsAnimatingHUDContents(); | 809 active_tree_->hud_layer()->IsAnimatingHUDContents(); |
809 bool resources_must_be_resent = | 810 bool resources_must_be_resent = |
810 output_surface_->capabilities().can_force_reclaim_resources; | 811 compositor_frame_sink_->capabilities().can_force_reclaim_resources; |
811 if (root_surface_has_contributing_layers && | 812 if (root_surface_has_contributing_layers && |
812 root_surface_has_no_visible_damage && | 813 root_surface_has_no_visible_damage && |
813 !active_tree_->property_trees()->effect_tree.HasCopyRequests() && | 814 !active_tree_->property_trees()->effect_tree.HasCopyRequests() && |
814 !resources_must_be_resent && !hud_wants_to_draw_) { | 815 !resources_must_be_resent && !hud_wants_to_draw_) { |
815 TRACE_EVENT0("cc", | 816 TRACE_EVENT0("cc", |
816 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); | 817 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); |
817 frame->has_no_damage = true; | 818 frame->has_no_damage = true; |
818 DCHECK(!resourceless_software_draw_); | 819 DCHECK(!resourceless_software_draw_); |
819 return DRAW_SUCCESS; | 820 return DRAW_SUCCESS; |
820 } | 821 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 | 1035 |
1035 TRACE_EVENT_END2("cc", "LayerTreeHostImpl::CalculateRenderPasses", | 1036 TRACE_EVENT_END2("cc", "LayerTreeHostImpl::CalculateRenderPasses", |
1036 "draw_result", draw_result, "missing tiles", | 1037 "draw_result", draw_result, "missing tiles", |
1037 num_missing_tiles); | 1038 num_missing_tiles); |
1038 | 1039 |
1039 // Draw has to be successful to not drop the copy request layer. | 1040 // Draw has to be successful to not drop the copy request layer. |
1040 // When we have a copy request for a layer, we need to draw even if there | 1041 // When we have a copy request for a layer, we need to draw even if there |
1041 // would be animating checkerboards, because failing under those conditions | 1042 // would be animating checkerboards, because failing under those conditions |
1042 // triggers a new main frame, which may cause the copy request layer to be | 1043 // triggers a new main frame, which may cause the copy request layer to be |
1043 // destroyed. | 1044 // destroyed. |
1044 // TODO(weiliangc): Test copy request w/ output surface recreation. Would | 1045 // TODO(weiliangc): Test copy request w/ CompositorFrameSink recreation. Would |
1045 // trigger this DCHECK. | 1046 // trigger this DCHECK. |
1046 DCHECK(!have_copy_request || draw_result == DRAW_SUCCESS); | 1047 DCHECK(!have_copy_request || draw_result == DRAW_SUCCESS); |
1047 | 1048 |
1048 // TODO(crbug.com/564832): This workaround to prevent creating unnecessarily | 1049 // TODO(crbug.com/564832): This workaround to prevent creating unnecessarily |
1049 // persistent render passes. When a copy request is made, it may force a | 1050 // persistent render passes. When a copy request is made, it may force a |
1050 // separate render pass for the layer, which will persist until a new commit | 1051 // separate render pass for the layer, which will persist until a new commit |
1051 // removes it. Force a commit after copy requests, to remove extra render | 1052 // removes it. Force a commit after copy requests, to remove extra render |
1052 // passes. | 1053 // passes. |
1053 if (have_copy_request) | 1054 if (have_copy_request) |
1054 client_->SetNeedsCommitOnImplThread(); | 1055 client_->SetNeedsCommitOnImplThread(); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 viewport_rect_for_tile_priority_in_view_space; | 1452 viewport_rect_for_tile_priority_in_view_space; |
1452 | 1453 |
1453 viewport_rect_for_tile_priority_ = | 1454 viewport_rect_for_tile_priority_ = |
1454 viewport_rect_for_tile_priority_in_view_space; | 1455 viewport_rect_for_tile_priority_in_view_space; |
1455 | 1456 |
1456 if (tile_priority_params_changed) { | 1457 if (tile_priority_params_changed) { |
1457 active_tree_->set_needs_update_draw_properties(); | 1458 active_tree_->set_needs_update_draw_properties(); |
1458 if (pending_tree_) | 1459 if (pending_tree_) |
1459 pending_tree_->set_needs_update_draw_properties(); | 1460 pending_tree_->set_needs_update_draw_properties(); |
1460 | 1461 |
1461 // Compositor, not OutputSurface, is responsible for setting damage and | 1462 // Compositor, not CompositorFrameSink, is responsible for setting damage |
1462 // triggering redraw for constraint changes. | 1463 // and triggering redraw for constraint changes. |
1463 SetFullViewportDamage(); | 1464 SetFullViewportDamage(); |
1464 SetNeedsRedraw(); | 1465 SetNeedsRedraw(); |
1465 } | 1466 } |
1466 } | 1467 } |
1467 | 1468 |
1468 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1469 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
1469 if (damage_rect.IsEmpty()) | 1470 if (damage_rect.IsEmpty()) |
1470 return; | 1471 return; |
1471 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1472 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
1472 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1473 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
(...skipping 29 matching lines...) Expand all Loading... |
1502 static_cast<int>(resource_pool_->memory_usage_bytes() / kMegabyte)); | 1503 static_cast<int>(resource_pool_->memory_usage_bytes() / kMegabyte)); |
1503 } | 1504 } |
1504 | 1505 |
1505 resource_pool_->CheckBusyResources(); | 1506 resource_pool_->CheckBusyResources(); |
1506 resource_pool_->ReduceResourceUsage(); | 1507 resource_pool_->ReduceResourceUsage(); |
1507 } | 1508 } |
1508 | 1509 |
1509 // If we're not visible, we likely released resources, so we want to | 1510 // If we're not visible, we likely released resources, so we want to |
1510 // aggressively flush here to make sure those DeleteTextures make it to the | 1511 // aggressively flush here to make sure those DeleteTextures make it to the |
1511 // GPU process to free up the memory. | 1512 // GPU process to free up the memory. |
1512 if (output_surface_->context_provider() && !visible_) { | 1513 if (compositor_frame_sink_->context_provider() && !visible_) { |
1513 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); | 1514 compositor_frame_sink_->context_provider() |
| 1515 ->ContextGL() |
| 1516 ->ShallowFlushCHROMIUM(); |
1514 } | 1517 } |
1515 } | 1518 } |
1516 | 1519 |
1517 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, | 1520 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, |
1518 const gfx::Rect& viewport, | 1521 const gfx::Rect& viewport, |
1519 bool resourceless_software_draw) { | 1522 bool resourceless_software_draw) { |
1520 DCHECK(!resourceless_software_draw_); | 1523 DCHECK(!resourceless_software_draw_); |
1521 const bool transform_changed = external_transform_ != transform; | 1524 const bool transform_changed = external_transform_ != transform; |
1522 const bool viewport_changed = external_viewport_ != viewport; | 1525 const bool viewport_changed = external_viewport_ != viewport; |
1523 | 1526 |
(...skipping 10 matching lines...) Expand all Loading... |
1534 if (transform_changed || viewport_changed || resourceless_software_draw_) { | 1537 if (transform_changed || viewport_changed || resourceless_software_draw_) { |
1535 SetFullViewportDamage(); | 1538 SetFullViewportDamage(); |
1536 SetNeedsRedraw(); | 1539 SetNeedsRedraw(); |
1537 active_tree_->set_needs_update_draw_properties(); | 1540 active_tree_->set_needs_update_draw_properties(); |
1538 } | 1541 } |
1539 | 1542 |
1540 if (resourceless_software_draw) { | 1543 if (resourceless_software_draw) { |
1541 client_->OnCanDrawStateChanged(CanDraw()); | 1544 client_->OnCanDrawStateChanged(CanDraw()); |
1542 } | 1545 } |
1543 | 1546 |
1544 client_->OnDrawForOutputSurface(resourceless_software_draw_); | 1547 client_->OnDrawForCompositorFrameSink(resourceless_software_draw_); |
1545 } | 1548 } |
1546 | 1549 |
1547 if (resourceless_software_draw) { | 1550 if (resourceless_software_draw) { |
1548 active_tree_->set_needs_update_draw_properties(); | 1551 active_tree_->set_needs_update_draw_properties(); |
1549 client_->OnCanDrawStateChanged(CanDraw()); | 1552 client_->OnCanDrawStateChanged(CanDraw()); |
1550 // This draw may have reset all damage, which would lead to subsequent | 1553 // This draw may have reset all damage, which would lead to subsequent |
1551 // incorrect hardware draw, so explicitly set damage for next hardware | 1554 // incorrect hardware draw, so explicitly set damage for next hardware |
1552 // draw as well. | 1555 // draw as well. |
1553 SetFullViewportDamage(); | 1556 SetFullViewportDamage(); |
1554 } | 1557 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 | 1623 |
1621 if (frame->has_no_damage) { | 1624 if (frame->has_no_damage) { |
1622 DCHECK(!resourceless_software_draw_); | 1625 DCHECK(!resourceless_software_draw_); |
1623 | 1626 |
1624 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); | 1627 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); |
1625 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1628 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1626 return false; | 1629 return false; |
1627 } | 1630 } |
1628 | 1631 |
1629 fps_counter_->SaveTimeStamp(CurrentBeginFrameArgs().frame_time, | 1632 fps_counter_->SaveTimeStamp(CurrentBeginFrameArgs().frame_time, |
1630 !output_surface_->context_provider()); | 1633 !compositor_frame_sink_->context_provider()); |
1631 rendering_stats_instrumentation_->IncrementFrameCount(1); | 1634 rendering_stats_instrumentation_->IncrementFrameCount(1); |
1632 | 1635 |
1633 memory_history_->SaveEntry(tile_manager_.memory_stats_from_last_assign()); | 1636 memory_history_->SaveEntry(tile_manager_.memory_stats_from_last_assign()); |
1634 | 1637 |
1635 if (debug_state_.ShowHudRects()) { | 1638 if (debug_state_.ShowHudRects()) { |
1636 debug_rect_history_->SaveDebugRectsForCurrentFrame( | 1639 debug_rect_history_->SaveDebugRectsForCurrentFrame( |
1637 active_tree(), active_tree_->hud_layer(), | 1640 active_tree(), active_tree_->hud_layer(), |
1638 *frame->render_surface_layer_list, debug_state_); | 1641 *frame->render_surface_layer_list, debug_state_); |
1639 } | 1642 } |
1640 | 1643 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 } | 1696 } |
1694 } | 1697 } |
1695 | 1698 |
1696 auto data = base::MakeUnique<DelegatedFrameData>(); | 1699 auto data = base::MakeUnique<DelegatedFrameData>(); |
1697 resource_provider_->PrepareSendToParent(resources, &data->resource_list); | 1700 resource_provider_->PrepareSendToParent(resources, &data->resource_list); |
1698 data->render_pass_list = std::move(frame->render_passes); | 1701 data->render_pass_list = std::move(frame->render_passes); |
1699 | 1702 |
1700 CompositorFrame compositor_frame; | 1703 CompositorFrame compositor_frame; |
1701 compositor_frame.metadata = std::move(metadata); | 1704 compositor_frame.metadata = std::move(metadata); |
1702 compositor_frame.delegated_frame_data = std::move(data); | 1705 compositor_frame.delegated_frame_data = std::move(data); |
1703 output_surface_->SwapBuffers(std::move(compositor_frame)); | 1706 compositor_frame_sink_->SwapBuffers(std::move(compositor_frame)); |
1704 | 1707 |
1705 // The next frame should start by assuming nothing has changed, and changes | 1708 // The next frame should start by assuming nothing has changed, and changes |
1706 // are noted as they occur. | 1709 // are noted as they occur. |
1707 // TODO(boliu): If we did a temporary software renderer frame, propogate the | 1710 // TODO(boliu): If we did a temporary software renderer frame, propogate the |
1708 // damage forward to the next frame. | 1711 // damage forward to the next frame. |
1709 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { | 1712 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { |
1710 auto* surface = (*frame->render_surface_layer_list)[i]->render_surface(); | 1713 auto* surface = (*frame->render_surface_layer_list)[i]->render_surface(); |
1711 surface->damage_tracker()->DidDrawDamagedArea(); | 1714 surface->damage_tracker()->DidDrawDamagedArea(); |
1712 } | 1715 } |
1713 active_tree_->ResetAllChangeTracking(); | 1716 active_tree_->ResetAllChangeTracking(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 } | 1751 } |
1749 | 1752 |
1750 void LayerTreeHostImpl::SetContentIsSuitableForGpuRasterization(bool flag) { | 1753 void LayerTreeHostImpl::SetContentIsSuitableForGpuRasterization(bool flag) { |
1751 if (content_is_suitable_for_gpu_rasterization_ != flag) { | 1754 if (content_is_suitable_for_gpu_rasterization_ != flag) { |
1752 content_is_suitable_for_gpu_rasterization_ = flag; | 1755 content_is_suitable_for_gpu_rasterization_ = flag; |
1753 need_update_gpu_rasterization_status_ = true; | 1756 need_update_gpu_rasterization_status_ = true; |
1754 } | 1757 } |
1755 } | 1758 } |
1756 | 1759 |
1757 bool LayerTreeHostImpl::CanUseGpuRasterization() { | 1760 bool LayerTreeHostImpl::CanUseGpuRasterization() { |
1758 if (!(output_surface_ && output_surface_->context_provider() && | 1761 if (!(compositor_frame_sink_ && compositor_frame_sink_->context_provider() && |
1759 output_surface_->worker_context_provider())) | 1762 compositor_frame_sink_->worker_context_provider())) |
1760 return false; | 1763 return false; |
1761 | 1764 |
1762 ContextProvider* context_provider = | 1765 ContextProvider* context_provider = |
1763 output_surface_->worker_context_provider(); | 1766 compositor_frame_sink_->worker_context_provider(); |
1764 ContextProvider::ScopedContextLock scoped_context(context_provider); | 1767 ContextProvider::ScopedContextLock scoped_context(context_provider); |
1765 if (!context_provider->GrContext()) | 1768 if (!context_provider->GrContext()) |
1766 return false; | 1769 return false; |
1767 | 1770 |
1768 return true; | 1771 return true; |
1769 } | 1772 } |
1770 | 1773 |
1771 bool LayerTreeHostImpl::UpdateGpuRasterizationStatus() { | 1774 bool LayerTreeHostImpl::UpdateGpuRasterizationStatus() { |
1772 // TODO(danakj): Can we avoid having this run when there's no output surface? | 1775 // TODO(danakj): Can we avoid having this run when there's no |
| 1776 // CompositorFrameSink? |
1773 // For now just early out and leave things unchanged, we'll come back here | 1777 // For now just early out and leave things unchanged, we'll come back here |
1774 // when we get an output surface. | 1778 // when we get an CompositorFrameSink. |
1775 if (!output_surface_) | 1779 if (!compositor_frame_sink_) |
1776 return false; | 1780 return false; |
1777 | 1781 |
1778 int requested_msaa_samples = RequestedMSAASampleCount(); | 1782 int requested_msaa_samples = RequestedMSAASampleCount(); |
1779 int max_msaa_samples = 0; | 1783 int max_msaa_samples = 0; |
1780 ContextProvider* compositor_context_provider = | 1784 ContextProvider* compositor_context_provider = |
1781 output_surface_->context_provider(); | 1785 compositor_frame_sink_->context_provider(); |
1782 if (compositor_context_provider) { | 1786 if (compositor_context_provider) { |
1783 const auto& caps = compositor_context_provider->ContextCapabilities(); | 1787 const auto& caps = compositor_context_provider->ContextCapabilities(); |
1784 if (!caps.msaa_is_slow) | 1788 if (!caps.msaa_is_slow) |
1785 max_msaa_samples = caps.max_samples; | 1789 max_msaa_samples = caps.max_samples; |
1786 } | 1790 } |
1787 | 1791 |
1788 bool use_gpu = false; | 1792 bool use_gpu = false; |
1789 bool use_msaa = false; | 1793 bool use_msaa = false; |
1790 bool using_msaa_for_complex_content = | 1794 bool using_msaa_for_complex_content = |
1791 requested_msaa_samples > 0 && max_msaa_samples >= requested_msaa_samples; | 1795 requested_msaa_samples > 0 && max_msaa_samples >= requested_msaa_samples; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 anchor.ResetViewportToAnchoredPosition(); | 1921 anchor.ResetViewportToAnchoredPosition(); |
1918 } | 1922 } |
1919 } | 1923 } |
1920 | 1924 |
1921 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { | 1925 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { |
1922 // Only valid for the single-threaded non-scheduled/synchronous case | 1926 // Only valid for the single-threaded non-scheduled/synchronous case |
1923 // using the zero copy raster worker pool. | 1927 // using the zero copy raster worker pool. |
1924 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); | 1928 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); |
1925 } | 1929 } |
1926 | 1930 |
1927 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1931 void LayerTreeHostImpl::DidLoseCompositorFrameSink() { |
1928 if (resource_provider_) | 1932 if (resource_provider_) |
1929 resource_provider_->DidLoseOutputSurface(); | 1933 resource_provider_->DidLoseContextProvider(); |
1930 client_->DidLoseOutputSurfaceOnImplThread(); | 1934 client_->DidLoseCompositorFrameSinkOnImplThread(); |
1931 } | 1935 } |
1932 | 1936 |
1933 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1937 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
1934 return !!InnerViewportScrollLayer(); | 1938 return !!InnerViewportScrollLayer(); |
1935 } | 1939 } |
1936 | 1940 |
1937 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const { | 1941 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const { |
1938 return active_tree_->InnerViewportScrollLayer(); | 1942 return active_tree_->InnerViewportScrollLayer(); |
1939 } | 1943 } |
1940 | 1944 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 if (recycle_tree_) | 2126 if (recycle_tree_) |
2123 recycle_tree_->RecreateResources(); | 2127 recycle_tree_->RecreateResources(); |
2124 } | 2128 } |
2125 | 2129 |
2126 void LayerTreeHostImpl::CreateTileManagerResources() { | 2130 void LayerTreeHostImpl::CreateTileManagerResources() { |
2127 CreateResourceAndRasterBufferProvider(&raster_buffer_provider_, | 2131 CreateResourceAndRasterBufferProvider(&raster_buffer_provider_, |
2128 &resource_pool_); | 2132 &resource_pool_); |
2129 | 2133 |
2130 if (use_gpu_rasterization_) { | 2134 if (use_gpu_rasterization_) { |
2131 image_decode_controller_ = base::MakeUnique<GpuImageDecodeController>( | 2135 image_decode_controller_ = base::MakeUnique<GpuImageDecodeController>( |
2132 output_surface_->worker_context_provider(), | 2136 compositor_frame_sink_->worker_context_provider(), |
2133 settings_.renderer_settings.preferred_tile_format, | 2137 settings_.renderer_settings.preferred_tile_format, |
2134 settings_.gpu_decoded_image_budget_bytes); | 2138 settings_.gpu_decoded_image_budget_bytes); |
2135 } else { | 2139 } else { |
2136 image_decode_controller_ = base::MakeUnique<SoftwareImageDecodeController>( | 2140 image_decode_controller_ = base::MakeUnique<SoftwareImageDecodeController>( |
2137 settings_.renderer_settings.preferred_tile_format, | 2141 settings_.renderer_settings.preferred_tile_format, |
2138 settings_.software_decoded_image_budget_bytes); | 2142 settings_.software_decoded_image_budget_bytes); |
2139 } | 2143 } |
2140 | 2144 |
2141 // Pass the single-threaded synchronous task graph runner to the worker pool | 2145 // Pass the single-threaded synchronous task graph runner to the worker pool |
2142 // if we're in synchronous single-threaded mode. | 2146 // if we're in synchronous single-threaded mode. |
(...skipping 19 matching lines...) Expand all Loading... |
2162 | 2166 |
2163 void LayerTreeHostImpl::CreateResourceAndRasterBufferProvider( | 2167 void LayerTreeHostImpl::CreateResourceAndRasterBufferProvider( |
2164 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, | 2168 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, |
2165 std::unique_ptr<ResourcePool>* resource_pool) { | 2169 std::unique_ptr<ResourcePool>* resource_pool) { |
2166 DCHECK(GetTaskRunner()); | 2170 DCHECK(GetTaskRunner()); |
2167 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is | 2171 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is |
2168 // resolved. | 2172 // resolved. |
2169 CHECK(resource_provider_); | 2173 CHECK(resource_provider_); |
2170 | 2174 |
2171 ContextProvider* compositor_context_provider = | 2175 ContextProvider* compositor_context_provider = |
2172 output_surface_->context_provider(); | 2176 compositor_frame_sink_->context_provider(); |
2173 if (!compositor_context_provider) { | 2177 if (!compositor_context_provider) { |
2174 *resource_pool = | 2178 *resource_pool = |
2175 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), | 2179 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), |
2176 ResourcePool::kDefaultExpirationDelay); | 2180 ResourcePool::kDefaultExpirationDelay); |
2177 | 2181 |
2178 *raster_buffer_provider = | 2182 *raster_buffer_provider = |
2179 BitmapRasterBufferProvider::Create(resource_provider_.get()); | 2183 BitmapRasterBufferProvider::Create(resource_provider_.get()); |
2180 return; | 2184 return; |
2181 } | 2185 } |
2182 | 2186 |
2183 ContextProvider* worker_context_provider = | 2187 ContextProvider* worker_context_provider = |
2184 output_surface_->worker_context_provider(); | 2188 compositor_frame_sink_->worker_context_provider(); |
2185 if (use_gpu_rasterization_) { | 2189 if (use_gpu_rasterization_) { |
2186 DCHECK(worker_context_provider); | 2190 DCHECK(worker_context_provider); |
2187 | 2191 |
2188 *resource_pool = | 2192 *resource_pool = |
2189 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), | 2193 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), |
2190 ResourcePool::kDefaultExpirationDelay); | 2194 ResourcePool::kDefaultExpirationDelay); |
2191 | 2195 |
2192 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; | 2196 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; |
2193 | 2197 |
2194 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( | 2198 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 | 2253 |
2250 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2254 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2251 ClearUIResources(); | 2255 ClearUIResources(); |
2252 tile_manager_.FinishTasksAndCleanUp(); | 2256 tile_manager_.FinishTasksAndCleanUp(); |
2253 resource_pool_ = nullptr; | 2257 resource_pool_ = nullptr; |
2254 tile_task_manager_ = nullptr; | 2258 tile_task_manager_ = nullptr; |
2255 single_thread_synchronous_task_graph_runner_ = nullptr; | 2259 single_thread_synchronous_task_graph_runner_ = nullptr; |
2256 image_decode_controller_ = nullptr; | 2260 image_decode_controller_ = nullptr; |
2257 } | 2261 } |
2258 | 2262 |
2259 void LayerTreeHostImpl::ReleaseOutputSurface() { | 2263 void LayerTreeHostImpl::ReleaseCompositorFrameSink() { |
2260 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseOutputSurface"); | 2264 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseCompositorFrameSink"); |
2261 | 2265 |
2262 if (!output_surface_) | 2266 if (!compositor_frame_sink_) |
2263 return; | 2267 return; |
2264 | 2268 |
2265 // Since we will create a new resource provider, we cannot continue to use | 2269 // Since we will create a new resource provider, we cannot continue to use |
2266 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 2270 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
2267 // before we destroy the old resource provider. | 2271 // before we destroy the old resource provider. |
2268 ReleaseTreeResources(); | 2272 ReleaseTreeResources(); |
2269 | 2273 |
2270 // Note: ui resource cleanup uses the |resource_provider_|. | 2274 // Note: ui resource cleanup uses the |resource_provider_|. |
2271 CleanUpTileManagerAndUIResources(); | 2275 CleanUpTileManagerAndUIResources(); |
2272 resource_provider_ = nullptr; | 2276 resource_provider_ = nullptr; |
2273 | 2277 |
2274 // Release any context visibility before we destroy the OutputSurface. | 2278 // Release any context visibility before we destroy the CompositorFrameSink. |
2275 if (visible_) | 2279 if (visible_) |
2276 SetCompositorContextVisibility(false); | 2280 SetCompositorContextVisibility(false); |
2277 // Worker context visibility is based on both LTHI visibility as well as | 2281 // Worker context visibility is based on both LTHI visibility as well as |
2278 // memory policy, so we directly check |worker_context_visibility_| here, | 2282 // memory policy, so we directly check |worker_context_visibility_| here, |
2279 // rather than just relying on |visibility_|. | 2283 // rather than just relying on |visibility_|. |
2280 if (worker_context_visibility_) | 2284 if (worker_context_visibility_) |
2281 SetWorkerContextVisibility(false); | 2285 SetWorkerContextVisibility(false); |
2282 | 2286 |
2283 // Detach from the old output surface and reset |output_surface_| pointer | 2287 // Detach from the old CompositorFrameSink and reset |compositor_frame_sink_| |
2284 // as this surface is going to be destroyed independent of if binding the | 2288 // pointer as this surface is going to be destroyed independent of if binding |
2285 // new output surface succeeds or not. | 2289 // the new CompositorFrameSink succeeds or not. |
2286 output_surface_->DetachFromClient(); | 2290 compositor_frame_sink_->DetachFromClient(); |
2287 output_surface_ = nullptr; | 2291 compositor_frame_sink_ = nullptr; |
2288 | 2292 |
2289 // We don't know if the next OutputSurface will support GPU rasterization. | 2293 // We don't know if the next CompositorFrameSink will support GPU |
2290 // Make sure to clear the flag so that we force a re-computation. | 2294 // rasterization. Make sure to clear the flag so that we force a |
| 2295 // re-computation. |
2291 use_gpu_rasterization_ = false; | 2296 use_gpu_rasterization_ = false; |
2292 } | 2297 } |
2293 | 2298 |
2294 bool LayerTreeHostImpl::InitializeRenderer(OutputSurface* output_surface) { | 2299 bool LayerTreeHostImpl::InitializeRenderer( |
2295 DCHECK(output_surface->capabilities().delegated_rendering); | 2300 CompositorFrameSink* compositor_frame_sink) { |
| 2301 DCHECK(compositor_frame_sink->capabilities().delegated_rendering); |
2296 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); | 2302 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); |
2297 | 2303 |
2298 ReleaseOutputSurface(); | 2304 ReleaseCompositorFrameSink(); |
2299 if (!output_surface->BindToClient(this)) { | 2305 if (!compositor_frame_sink->BindToClient(this)) { |
2300 // Avoid recreating tree resources because we might not have enough | 2306 // Avoid recreating tree resources because we might not have enough |
2301 // information to do this yet (eg. we don't have a TileManager at this | 2307 // information to do this yet (eg. we don't have a TileManager at this |
2302 // point). | 2308 // point). |
2303 return false; | 2309 return false; |
2304 } | 2310 } |
2305 | 2311 |
2306 // When using software compositing, change to the limits specified for it. | 2312 // When using software compositing, change to the limits specified for it. |
2307 // Since this is a one way trip, we don't need to worry about going back to | 2313 // Since this is a one way trip, we don't need to worry about going back to |
2308 // GPU compositing. | 2314 // GPU compositing. |
2309 if (!output_surface->context_provider()) | 2315 if (!compositor_frame_sink->context_provider()) |
2310 SetMemoryPolicy(settings_.software_memory_policy); | 2316 SetMemoryPolicy(settings_.software_memory_policy); |
2311 | 2317 |
2312 output_surface_ = output_surface; | 2318 compositor_frame_sink_ = compositor_frame_sink; |
2313 resource_provider_ = base::MakeUnique<ResourceProvider>( | 2319 resource_provider_ = base::MakeUnique<ResourceProvider>( |
2314 output_surface_->context_provider(), shared_bitmap_manager_, | 2320 compositor_frame_sink_->context_provider(), shared_bitmap_manager_, |
2315 gpu_memory_buffer_manager_, | 2321 gpu_memory_buffer_manager_, |
2316 task_runner_provider_->blocking_main_thread_task_runner(), | 2322 task_runner_provider_->blocking_main_thread_task_runner(), |
2317 settings_.renderer_settings.highp_threshold_min, | 2323 settings_.renderer_settings.highp_threshold_min, |
2318 settings_.renderer_settings.texture_id_allocation_chunk_size, | 2324 settings_.renderer_settings.texture_id_allocation_chunk_size, |
2319 output_surface_->capabilities().delegated_sync_points_required, | 2325 compositor_frame_sink_->capabilities().delegated_sync_points_required, |
2320 settings_.renderer_settings.use_gpu_memory_buffer_resources, false, | 2326 settings_.renderer_settings.use_gpu_memory_buffer_resources, false, |
2321 settings_.renderer_settings.buffer_to_texture_target_map); | 2327 settings_.renderer_settings.buffer_to_texture_target_map); |
2322 | 2328 |
2323 // Make sure the main context visibility is restored. Worker context | 2329 // Make sure the main context visibility is restored. Worker context |
2324 // visibility will be set via the memory policy update in | 2330 // visibility will be set via the memory policy update in |
2325 // CreateTileManagerResources below. | 2331 // CreateTileManagerResources below. |
2326 if (visible_) | 2332 if (visible_) |
2327 SetCompositorContextVisibility(true); | 2333 SetCompositorContextVisibility(true); |
2328 | 2334 |
2329 // Since the new context may be capable of MSAA, update status here. We don't | 2335 // Since the new context may be capable of MSAA, update status here. We don't |
2330 // need to check the return value since we are recreating all resources | 2336 // need to check the return value since we are recreating all resources |
2331 // already. | 2337 // already. |
2332 UpdateGpuRasterizationStatus(); | 2338 UpdateGpuRasterizationStatus(); |
2333 | 2339 |
2334 // See note in LayerTreeImpl::UpdateDrawProperties, new OutputSurface means a | 2340 // See note in LayerTreeImpl::UpdateDrawProperties, new CompositorFrameSink |
2335 // new max texture size which affects draw properties. Also, if the draw | 2341 // means a new max texture size which affects draw properties. Also, if the |
2336 // properties were up to date, layers still lost resources and we need to | 2342 // draw properties were up to date, layers still lost resources and we need to |
2337 // UpdateDrawProperties() after calling RecreateTreeResources(). | 2343 // UpdateDrawProperties() after calling RecreateTreeResources(). |
2338 active_tree_->set_needs_update_draw_properties(); | 2344 active_tree_->set_needs_update_draw_properties(); |
2339 if (pending_tree_) | 2345 if (pending_tree_) |
2340 pending_tree_->set_needs_update_draw_properties(); | 2346 pending_tree_->set_needs_update_draw_properties(); |
2341 | 2347 |
2342 CreateTileManagerResources(); | 2348 CreateTileManagerResources(); |
2343 RecreateTreeResources(); | 2349 RecreateTreeResources(); |
2344 | 2350 |
2345 // TODO(brianderson): Don't use a hard-coded parent draw time. | 2351 // TODO(brianderson): Don't use a hard-coded parent draw time. |
2346 base::TimeDelta parent_draw_time = | 2352 base::TimeDelta parent_draw_time = |
2347 (!settings_.use_external_begin_frame_source && | 2353 (!settings_.use_external_begin_frame_source && |
2348 output_surface_->capabilities().adjust_deadline_for_parent) | 2354 compositor_frame_sink_->capabilities().adjust_deadline_for_parent) |
2349 ? BeginFrameArgs::DefaultEstimatedParentDrawTime() | 2355 ? BeginFrameArgs::DefaultEstimatedParentDrawTime() |
2350 : base::TimeDelta(); | 2356 : base::TimeDelta(); |
2351 client_->SetEstimatedParentDrawTime(parent_draw_time); | 2357 client_->SetEstimatedParentDrawTime(parent_draw_time); |
2352 | 2358 |
2353 DCHECK_EQ(1, output_surface_->capabilities().max_frames_pending); | 2359 DCHECK_EQ(1, compositor_frame_sink_->capabilities().max_frames_pending); |
2354 client_->OnCanDrawStateChanged(CanDraw()); | 2360 client_->OnCanDrawStateChanged(CanDraw()); |
2355 | 2361 |
2356 SetFullViewportDamage(); | 2362 SetFullViewportDamage(); |
2357 // There will not be anything to draw here, so set high res | 2363 // There will not be anything to draw here, so set high res |
2358 // to avoid checkerboards, typically when we are recovering | 2364 // to avoid checkerboards, typically when we are recovering |
2359 // from lost context. | 2365 // from lost context. |
2360 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. | 2366 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. |
2361 SetRequiresHighResToDraw(); | 2367 SetRequiresHighResToDraw(); |
2362 | 2368 |
2363 return true; | 2369 return true; |
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4152 return task_runner_provider_->HasImplThread(); | 4158 return task_runner_provider_->HasImplThread(); |
4153 } | 4159 } |
4154 | 4160 |
4155 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4161 bool LayerTreeHostImpl::CommitToActiveTree() const { |
4156 // In single threaded mode we skip the pending tree and commit directly to the | 4162 // In single threaded mode we skip the pending tree and commit directly to the |
4157 // active tree. | 4163 // active tree. |
4158 return !task_runner_provider_->HasImplThread(); | 4164 return !task_runner_provider_->HasImplThread(); |
4159 } | 4165 } |
4160 | 4166 |
4161 void LayerTreeHostImpl::SetCompositorContextVisibility(bool is_visible) { | 4167 void LayerTreeHostImpl::SetCompositorContextVisibility(bool is_visible) { |
4162 if (!output_surface_) | 4168 if (!compositor_frame_sink_) |
4163 return; | 4169 return; |
4164 | 4170 |
4165 auto* compositor_context = output_surface_->context_provider(); | 4171 auto* compositor_context = compositor_frame_sink_->context_provider(); |
4166 if (!compositor_context) | 4172 if (!compositor_context) |
4167 return; | 4173 return; |
4168 | 4174 |
4169 DCHECK_NE(is_visible, !!compositor_context_visibility_); | 4175 DCHECK_NE(is_visible, !!compositor_context_visibility_); |
4170 | 4176 |
4171 if (is_visible) { | 4177 if (is_visible) { |
4172 compositor_context_visibility_ = | 4178 compositor_context_visibility_ = |
4173 compositor_context->CacheController()->ClientBecameVisible(); | 4179 compositor_context->CacheController()->ClientBecameVisible(); |
4174 } else { | 4180 } else { |
4175 compositor_context->CacheController()->ClientBecameNotVisible( | 4181 compositor_context->CacheController()->ClientBecameNotVisible( |
4176 std::move(compositor_context_visibility_)); | 4182 std::move(compositor_context_visibility_)); |
4177 } | 4183 } |
4178 } | 4184 } |
4179 | 4185 |
4180 void LayerTreeHostImpl::SetWorkerContextVisibility(bool is_visible) { | 4186 void LayerTreeHostImpl::SetWorkerContextVisibility(bool is_visible) { |
4181 if (!output_surface_) | 4187 if (!compositor_frame_sink_) |
4182 return; | 4188 return; |
4183 | 4189 |
4184 auto* worker_context = output_surface_->worker_context_provider(); | 4190 auto* worker_context = compositor_frame_sink_->worker_context_provider(); |
4185 if (!worker_context) | 4191 if (!worker_context) |
4186 return; | 4192 return; |
4187 | 4193 |
4188 // TODO(ericrk): This check is here because worker context visibility is a | 4194 // TODO(ericrk): This check is here because worker context visibility is a |
4189 // bit less controlled, being settable both by memory policy changes as well | 4195 // bit less controlled, being settable both by memory policy changes as well |
4190 // as direct visibility changes. We should simplify this. crbug.com/642154 | 4196 // as direct visibility changes. We should simplify this. crbug.com/642154 |
4191 if (is_visible == !!worker_context_visibility_) | 4197 if (is_visible == !!worker_context_visibility_) |
4192 return; | 4198 return; |
4193 | 4199 |
4194 ContextProvider::ScopedContextLock hold(worker_context); | 4200 ContextProvider::ScopedContextLock hold(worker_context); |
4195 if (is_visible) { | 4201 if (is_visible) { |
4196 worker_context_visibility_ = | 4202 worker_context_visibility_ = |
4197 worker_context->CacheController()->ClientBecameVisible(); | 4203 worker_context->CacheController()->ClientBecameVisible(); |
4198 } else { | 4204 } else { |
4199 worker_context->CacheController()->ClientBecameNotVisible( | 4205 worker_context->CacheController()->ClientBecameNotVisible( |
4200 std::move(worker_context_visibility_)); | 4206 std::move(worker_context_visibility_)); |
4201 } | 4207 } |
4202 } | 4208 } |
4203 | 4209 |
4204 } // namespace cc | 4210 } // namespace cc |
OLD | NEW |