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 |
1463 // and | |
enne (OOO)
2016/09/14 00:35:45
@_@
| |
1462 // triggering redraw for constraint changes. | 1464 // triggering redraw for constraint changes. |
1463 SetFullViewportDamage(); | 1465 SetFullViewportDamage(); |
1464 SetNeedsRedraw(); | 1466 SetNeedsRedraw(); |
1465 } | 1467 } |
1466 } | 1468 } |
1467 | 1469 |
1468 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1470 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
1469 if (damage_rect.IsEmpty()) | 1471 if (damage_rect.IsEmpty()) |
1470 return; | 1472 return; |
1471 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1473 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
(...skipping 30 matching lines...) Expand all Loading... | |
1502 static_cast<int>(resource_pool_->memory_usage_bytes() / kMegabyte)); | 1504 static_cast<int>(resource_pool_->memory_usage_bytes() / kMegabyte)); |
1503 } | 1505 } |
1504 | 1506 |
1505 resource_pool_->CheckBusyResources(); | 1507 resource_pool_->CheckBusyResources(); |
1506 resource_pool_->ReduceResourceUsage(); | 1508 resource_pool_->ReduceResourceUsage(); |
1507 } | 1509 } |
1508 | 1510 |
1509 // If we're not visible, we likely released resources, so we want to | 1511 // 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 | 1512 // aggressively flush here to make sure those DeleteTextures make it to the |
1511 // GPU process to free up the memory. | 1513 // GPU process to free up the memory. |
1512 if (output_surface_->context_provider() && !visible_) { | 1514 if (compositor_frame_sink_->context_provider() && !visible_) { |
1513 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); | 1515 compositor_frame_sink_->context_provider() |
1516 ->ContextGL() | |
1517 ->ShallowFlushCHROMIUM(); | |
1514 } | 1518 } |
1515 } | 1519 } |
1516 | 1520 |
1517 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, | 1521 void LayerTreeHostImpl::OnDraw(const gfx::Transform& transform, |
1518 const gfx::Rect& viewport, | 1522 const gfx::Rect& viewport, |
1519 bool resourceless_software_draw) { | 1523 bool resourceless_software_draw) { |
1520 DCHECK(!resourceless_software_draw_); | 1524 DCHECK(!resourceless_software_draw_); |
1521 const bool transform_changed = external_transform_ != transform; | 1525 const bool transform_changed = external_transform_ != transform; |
1522 const bool viewport_changed = external_viewport_ != viewport; | 1526 const bool viewport_changed = external_viewport_ != viewport; |
1523 | 1527 |
(...skipping 10 matching lines...) Expand all Loading... | |
1534 if (transform_changed || viewport_changed || resourceless_software_draw_) { | 1538 if (transform_changed || viewport_changed || resourceless_software_draw_) { |
1535 SetFullViewportDamage(); | 1539 SetFullViewportDamage(); |
1536 SetNeedsRedraw(); | 1540 SetNeedsRedraw(); |
1537 active_tree_->set_needs_update_draw_properties(); | 1541 active_tree_->set_needs_update_draw_properties(); |
1538 } | 1542 } |
1539 | 1543 |
1540 if (resourceless_software_draw) { | 1544 if (resourceless_software_draw) { |
1541 client_->OnCanDrawStateChanged(CanDraw()); | 1545 client_->OnCanDrawStateChanged(CanDraw()); |
1542 } | 1546 } |
1543 | 1547 |
1544 client_->OnDrawForOutputSurface(resourceless_software_draw_); | 1548 client_->OnDrawForCompositorFrameSink(resourceless_software_draw_); |
1545 } | 1549 } |
1546 | 1550 |
1547 if (resourceless_software_draw) { | 1551 if (resourceless_software_draw) { |
1548 active_tree_->set_needs_update_draw_properties(); | 1552 active_tree_->set_needs_update_draw_properties(); |
1549 client_->OnCanDrawStateChanged(CanDraw()); | 1553 client_->OnCanDrawStateChanged(CanDraw()); |
1550 // This draw may have reset all damage, which would lead to subsequent | 1554 // This draw may have reset all damage, which would lead to subsequent |
1551 // incorrect hardware draw, so explicitly set damage for next hardware | 1555 // incorrect hardware draw, so explicitly set damage for next hardware |
1552 // draw as well. | 1556 // draw as well. |
1553 SetFullViewportDamage(); | 1557 SetFullViewportDamage(); |
1554 } | 1558 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1620 | 1624 |
1621 if (frame->has_no_damage) { | 1625 if (frame->has_no_damage) { |
1622 DCHECK(!resourceless_software_draw_); | 1626 DCHECK(!resourceless_software_draw_); |
1623 | 1627 |
1624 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); | 1628 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); |
1625 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1629 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1626 return false; | 1630 return false; |
1627 } | 1631 } |
1628 | 1632 |
1629 fps_counter_->SaveTimeStamp(CurrentBeginFrameArgs().frame_time, | 1633 fps_counter_->SaveTimeStamp(CurrentBeginFrameArgs().frame_time, |
1630 !output_surface_->context_provider()); | 1634 !compositor_frame_sink_->context_provider()); |
1631 rendering_stats_instrumentation_->IncrementFrameCount(1); | 1635 rendering_stats_instrumentation_->IncrementFrameCount(1); |
1632 | 1636 |
1633 memory_history_->SaveEntry(tile_manager_.memory_stats_from_last_assign()); | 1637 memory_history_->SaveEntry(tile_manager_.memory_stats_from_last_assign()); |
1634 | 1638 |
1635 if (debug_state_.ShowHudRects()) { | 1639 if (debug_state_.ShowHudRects()) { |
1636 debug_rect_history_->SaveDebugRectsForCurrentFrame( | 1640 debug_rect_history_->SaveDebugRectsForCurrentFrame( |
1637 active_tree(), active_tree_->hud_layer(), | 1641 active_tree(), active_tree_->hud_layer(), |
1638 *frame->render_surface_layer_list, debug_state_); | 1642 *frame->render_surface_layer_list, debug_state_); |
1639 } | 1643 } |
1640 | 1644 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1693 } | 1697 } |
1694 } | 1698 } |
1695 | 1699 |
1696 auto data = base::MakeUnique<DelegatedFrameData>(); | 1700 auto data = base::MakeUnique<DelegatedFrameData>(); |
1697 resource_provider_->PrepareSendToParent(resources, &data->resource_list); | 1701 resource_provider_->PrepareSendToParent(resources, &data->resource_list); |
1698 data->render_pass_list = std::move(frame->render_passes); | 1702 data->render_pass_list = std::move(frame->render_passes); |
1699 | 1703 |
1700 CompositorFrame compositor_frame; | 1704 CompositorFrame compositor_frame; |
1701 compositor_frame.metadata = std::move(metadata); | 1705 compositor_frame.metadata = std::move(metadata); |
1702 compositor_frame.delegated_frame_data = std::move(data); | 1706 compositor_frame.delegated_frame_data = std::move(data); |
1703 output_surface_->SwapBuffers(std::move(compositor_frame)); | 1707 compositor_frame_sink_->SwapBuffers(std::move(compositor_frame)); |
1704 | 1708 |
1705 // The next frame should start by assuming nothing has changed, and changes | 1709 // The next frame should start by assuming nothing has changed, and changes |
1706 // are noted as they occur. | 1710 // are noted as they occur. |
1707 // TODO(boliu): If we did a temporary software renderer frame, propogate the | 1711 // TODO(boliu): If we did a temporary software renderer frame, propogate the |
1708 // damage forward to the next frame. | 1712 // damage forward to the next frame. |
1709 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { | 1713 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { |
1710 auto* surface = (*frame->render_surface_layer_list)[i]->render_surface(); | 1714 auto* surface = (*frame->render_surface_layer_list)[i]->render_surface(); |
1711 surface->damage_tracker()->DidDrawDamagedArea(); | 1715 surface->damage_tracker()->DidDrawDamagedArea(); |
1712 } | 1716 } |
1713 active_tree_->ResetAllChangeTracking(); | 1717 active_tree_->ResetAllChangeTracking(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 } | 1752 } |
1749 | 1753 |
1750 void LayerTreeHostImpl::SetContentIsSuitableForGpuRasterization(bool flag) { | 1754 void LayerTreeHostImpl::SetContentIsSuitableForGpuRasterization(bool flag) { |
1751 if (content_is_suitable_for_gpu_rasterization_ != flag) { | 1755 if (content_is_suitable_for_gpu_rasterization_ != flag) { |
1752 content_is_suitable_for_gpu_rasterization_ = flag; | 1756 content_is_suitable_for_gpu_rasterization_ = flag; |
1753 need_update_gpu_rasterization_status_ = true; | 1757 need_update_gpu_rasterization_status_ = true; |
1754 } | 1758 } |
1755 } | 1759 } |
1756 | 1760 |
1757 bool LayerTreeHostImpl::CanUseGpuRasterization() { | 1761 bool LayerTreeHostImpl::CanUseGpuRasterization() { |
1758 if (!(output_surface_ && output_surface_->context_provider() && | 1762 if (!(compositor_frame_sink_ && compositor_frame_sink_->context_provider() && |
1759 output_surface_->worker_context_provider())) | 1763 compositor_frame_sink_->worker_context_provider())) |
1760 return false; | 1764 return false; |
1761 | 1765 |
1762 ContextProvider* context_provider = | 1766 ContextProvider* context_provider = |
1763 output_surface_->worker_context_provider(); | 1767 compositor_frame_sink_->worker_context_provider(); |
1764 ContextProvider::ScopedContextLock scoped_context(context_provider); | 1768 ContextProvider::ScopedContextLock scoped_context(context_provider); |
1765 if (!context_provider->GrContext()) | 1769 if (!context_provider->GrContext()) |
1766 return false; | 1770 return false; |
1767 | 1771 |
1768 return true; | 1772 return true; |
1769 } | 1773 } |
1770 | 1774 |
1771 bool LayerTreeHostImpl::UpdateGpuRasterizationStatus() { | 1775 bool LayerTreeHostImpl::UpdateGpuRasterizationStatus() { |
1772 // TODO(danakj): Can we avoid having this run when there's no output surface? | 1776 // TODO(danakj): Can we avoid having this run when there's no |
1777 // CompositorFrameSink? | |
1773 // For now just early out and leave things unchanged, we'll come back here | 1778 // For now just early out and leave things unchanged, we'll come back here |
1774 // when we get an output surface. | 1779 // when we get an CompositorFrameSink. |
1775 if (!output_surface_) | 1780 if (!compositor_frame_sink_) |
1776 return false; | 1781 return false; |
1777 | 1782 |
1778 int requested_msaa_samples = RequestedMSAASampleCount(); | 1783 int requested_msaa_samples = RequestedMSAASampleCount(); |
1779 int max_msaa_samples = 0; | 1784 int max_msaa_samples = 0; |
1780 ContextProvider* compositor_context_provider = | 1785 ContextProvider* compositor_context_provider = |
1781 output_surface_->context_provider(); | 1786 compositor_frame_sink_->context_provider(); |
1782 if (compositor_context_provider) { | 1787 if (compositor_context_provider) { |
1783 const auto& caps = compositor_context_provider->ContextCapabilities(); | 1788 const auto& caps = compositor_context_provider->ContextCapabilities(); |
1784 if (!caps.msaa_is_slow) | 1789 if (!caps.msaa_is_slow) |
1785 max_msaa_samples = caps.max_samples; | 1790 max_msaa_samples = caps.max_samples; |
1786 } | 1791 } |
1787 | 1792 |
1788 bool use_gpu = false; | 1793 bool use_gpu = false; |
1789 bool use_msaa = false; | 1794 bool use_msaa = false; |
1790 bool using_msaa_for_complex_content = | 1795 bool using_msaa_for_complex_content = |
1791 requested_msaa_samples > 0 && max_msaa_samples >= requested_msaa_samples; | 1796 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(); | 1922 anchor.ResetViewportToAnchoredPosition(); |
1918 } | 1923 } |
1919 } | 1924 } |
1920 | 1925 |
1921 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { | 1926 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { |
1922 // Only valid for the single-threaded non-scheduled/synchronous case | 1927 // Only valid for the single-threaded non-scheduled/synchronous case |
1923 // using the zero copy raster worker pool. | 1928 // using the zero copy raster worker pool. |
1924 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); | 1929 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); |
1925 } | 1930 } |
1926 | 1931 |
1927 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1932 void LayerTreeHostImpl::DidLoseCompositorFrameSink() { |
1928 if (resource_provider_) | 1933 if (resource_provider_) |
1929 resource_provider_->DidLoseOutputSurface(); | 1934 resource_provider_->DidLoseContextProvider(); |
1930 client_->DidLoseOutputSurfaceOnImplThread(); | 1935 client_->DidLoseCompositorFrameSinkOnImplThread(); |
1931 } | 1936 } |
1932 | 1937 |
1933 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1938 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
1934 return !!InnerViewportScrollLayer(); | 1939 return !!InnerViewportScrollLayer(); |
1935 } | 1940 } |
1936 | 1941 |
1937 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const { | 1942 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const { |
1938 return active_tree_->InnerViewportScrollLayer(); | 1943 return active_tree_->InnerViewportScrollLayer(); |
1939 } | 1944 } |
1940 | 1945 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2122 if (recycle_tree_) | 2127 if (recycle_tree_) |
2123 recycle_tree_->RecreateResources(); | 2128 recycle_tree_->RecreateResources(); |
2124 } | 2129 } |
2125 | 2130 |
2126 void LayerTreeHostImpl::CreateTileManagerResources() { | 2131 void LayerTreeHostImpl::CreateTileManagerResources() { |
2127 CreateResourceAndRasterBufferProvider(&raster_buffer_provider_, | 2132 CreateResourceAndRasterBufferProvider(&raster_buffer_provider_, |
2128 &resource_pool_); | 2133 &resource_pool_); |
2129 | 2134 |
2130 if (use_gpu_rasterization_) { | 2135 if (use_gpu_rasterization_) { |
2131 image_decode_controller_ = base::MakeUnique<GpuImageDecodeController>( | 2136 image_decode_controller_ = base::MakeUnique<GpuImageDecodeController>( |
2132 output_surface_->worker_context_provider(), | 2137 compositor_frame_sink_->worker_context_provider(), |
2133 settings_.renderer_settings.preferred_tile_format, | 2138 settings_.renderer_settings.preferred_tile_format, |
2134 settings_.gpu_decoded_image_budget_bytes); | 2139 settings_.gpu_decoded_image_budget_bytes); |
2135 } else { | 2140 } else { |
2136 image_decode_controller_ = base::MakeUnique<SoftwareImageDecodeController>( | 2141 image_decode_controller_ = base::MakeUnique<SoftwareImageDecodeController>( |
2137 settings_.renderer_settings.preferred_tile_format, | 2142 settings_.renderer_settings.preferred_tile_format, |
2138 settings_.software_decoded_image_budget_bytes); | 2143 settings_.software_decoded_image_budget_bytes); |
2139 } | 2144 } |
2140 | 2145 |
2141 // Pass the single-threaded synchronous task graph runner to the worker pool | 2146 // Pass the single-threaded synchronous task graph runner to the worker pool |
2142 // if we're in synchronous single-threaded mode. | 2147 // if we're in synchronous single-threaded mode. |
(...skipping 19 matching lines...) Expand all Loading... | |
2162 | 2167 |
2163 void LayerTreeHostImpl::CreateResourceAndRasterBufferProvider( | 2168 void LayerTreeHostImpl::CreateResourceAndRasterBufferProvider( |
2164 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, | 2169 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, |
2165 std::unique_ptr<ResourcePool>* resource_pool) { | 2170 std::unique_ptr<ResourcePool>* resource_pool) { |
2166 DCHECK(GetTaskRunner()); | 2171 DCHECK(GetTaskRunner()); |
2167 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is | 2172 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is |
2168 // resolved. | 2173 // resolved. |
2169 CHECK(resource_provider_); | 2174 CHECK(resource_provider_); |
2170 | 2175 |
2171 ContextProvider* compositor_context_provider = | 2176 ContextProvider* compositor_context_provider = |
2172 output_surface_->context_provider(); | 2177 compositor_frame_sink_->context_provider(); |
2173 if (!compositor_context_provider) { | 2178 if (!compositor_context_provider) { |
2174 *resource_pool = | 2179 *resource_pool = |
2175 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), | 2180 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), |
2176 ResourcePool::kDefaultExpirationDelay); | 2181 ResourcePool::kDefaultExpirationDelay); |
2177 | 2182 |
2178 *raster_buffer_provider = | 2183 *raster_buffer_provider = |
2179 BitmapRasterBufferProvider::Create(resource_provider_.get()); | 2184 BitmapRasterBufferProvider::Create(resource_provider_.get()); |
2180 return; | 2185 return; |
2181 } | 2186 } |
2182 | 2187 |
2183 ContextProvider* worker_context_provider = | 2188 ContextProvider* worker_context_provider = |
2184 output_surface_->worker_context_provider(); | 2189 compositor_frame_sink_->worker_context_provider(); |
2185 if (use_gpu_rasterization_) { | 2190 if (use_gpu_rasterization_) { |
2186 DCHECK(worker_context_provider); | 2191 DCHECK(worker_context_provider); |
2187 | 2192 |
2188 *resource_pool = | 2193 *resource_pool = |
2189 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), | 2194 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), |
2190 ResourcePool::kDefaultExpirationDelay); | 2195 ResourcePool::kDefaultExpirationDelay); |
2191 | 2196 |
2192 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; | 2197 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; |
2193 | 2198 |
2194 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( | 2199 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2249 | 2254 |
2250 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2255 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2251 ClearUIResources(); | 2256 ClearUIResources(); |
2252 tile_manager_.FinishTasksAndCleanUp(); | 2257 tile_manager_.FinishTasksAndCleanUp(); |
2253 resource_pool_ = nullptr; | 2258 resource_pool_ = nullptr; |
2254 tile_task_manager_ = nullptr; | 2259 tile_task_manager_ = nullptr; |
2255 single_thread_synchronous_task_graph_runner_ = nullptr; | 2260 single_thread_synchronous_task_graph_runner_ = nullptr; |
2256 image_decode_controller_ = nullptr; | 2261 image_decode_controller_ = nullptr; |
2257 } | 2262 } |
2258 | 2263 |
2259 void LayerTreeHostImpl::ReleaseOutputSurface() { | 2264 void LayerTreeHostImpl::ReleaseCompositorFrameSink() { |
2260 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseOutputSurface"); | 2265 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseCompositorFrameSink"); |
2261 | 2266 |
2262 if (!output_surface_) | 2267 if (!compositor_frame_sink_) |
2263 return; | 2268 return; |
2264 | 2269 |
2265 // Since we will create a new resource provider, we cannot continue to use | 2270 // 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 | 2271 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
2267 // before we destroy the old resource provider. | 2272 // before we destroy the old resource provider. |
2268 ReleaseTreeResources(); | 2273 ReleaseTreeResources(); |
2269 | 2274 |
2270 // Note: ui resource cleanup uses the |resource_provider_|. | 2275 // Note: ui resource cleanup uses the |resource_provider_|. |
2271 CleanUpTileManagerAndUIResources(); | 2276 CleanUpTileManagerAndUIResources(); |
2272 resource_provider_ = nullptr; | 2277 resource_provider_ = nullptr; |
2273 | 2278 |
2274 // Release any context visibility before we destroy the OutputSurface. | 2279 // Release any context visibility before we destroy the CompositorFrameSink. |
2275 if (visible_) | 2280 if (visible_) |
2276 SetCompositorContextVisibility(false); | 2281 SetCompositorContextVisibility(false); |
2277 // Worker context visibility is based on both LTHI visibility as well as | 2282 // Worker context visibility is based on both LTHI visibility as well as |
2278 // memory policy, so we directly check |worker_context_visibility_| here, | 2283 // memory policy, so we directly check |worker_context_visibility_| here, |
2279 // rather than just relying on |visibility_|. | 2284 // rather than just relying on |visibility_|. |
2280 if (worker_context_visibility_) | 2285 if (worker_context_visibility_) |
2281 SetWorkerContextVisibility(false); | 2286 SetWorkerContextVisibility(false); |
2282 | 2287 |
2283 // Detach from the old output surface and reset |output_surface_| pointer | 2288 // Detach from the old CompositorFrameSink and reset |compositor_frame_sink_| |
2289 // pointer | |
enne (OOO)
2016/09/14 00:35:45
@_@
| |
2284 // as this surface is going to be destroyed independent of if binding the | 2290 // as this surface is going to be destroyed independent of if binding the |
2285 // new output surface succeeds or not. | 2291 // new CompositorFrameSink succeeds or not. |
2286 output_surface_->DetachFromClient(); | 2292 compositor_frame_sink_->DetachFromClient(); |
2287 output_surface_ = nullptr; | 2293 compositor_frame_sink_ = nullptr; |
2288 | 2294 |
2289 // We don't know if the next OutputSurface will support GPU rasterization. | 2295 // We don't know if the next CompositorFrameSink will support GPU |
2296 // rasterization. | |
enne (OOO)
2016/09/14 00:35:45
@_@
| |
2290 // Make sure to clear the flag so that we force a re-computation. | 2297 // Make sure to clear the flag so that we force a re-computation. |
2291 use_gpu_rasterization_ = false; | 2298 use_gpu_rasterization_ = false; |
2292 } | 2299 } |
2293 | 2300 |
2294 bool LayerTreeHostImpl::InitializeRenderer(OutputSurface* output_surface) { | 2301 bool LayerTreeHostImpl::InitializeRenderer( |
2295 DCHECK(output_surface->capabilities().delegated_rendering); | 2302 CompositorFrameSink* compositor_frame_sink) { |
2303 DCHECK(compositor_frame_sink->capabilities().delegated_rendering); | |
2296 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); | 2304 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); |
2297 | 2305 |
2298 ReleaseOutputSurface(); | 2306 ReleaseCompositorFrameSink(); |
2299 if (!output_surface->BindToClient(this)) { | 2307 if (!compositor_frame_sink->BindToClient(this)) { |
2300 // Avoid recreating tree resources because we might not have enough | 2308 // 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 | 2309 // information to do this yet (eg. we don't have a TileManager at this |
2302 // point). | 2310 // point). |
2303 return false; | 2311 return false; |
2304 } | 2312 } |
2305 | 2313 |
2306 // When using software compositing, change to the limits specified for it. | 2314 // 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 | 2315 // Since this is a one way trip, we don't need to worry about going back to |
2308 // GPU compositing. | 2316 // GPU compositing. |
2309 if (!output_surface->context_provider()) | 2317 if (!compositor_frame_sink->context_provider()) |
2310 SetMemoryPolicy(settings_.software_memory_policy); | 2318 SetMemoryPolicy(settings_.software_memory_policy); |
2311 | 2319 |
2312 output_surface_ = output_surface; | 2320 compositor_frame_sink_ = compositor_frame_sink; |
2313 resource_provider_ = base::MakeUnique<ResourceProvider>( | 2321 resource_provider_ = base::MakeUnique<ResourceProvider>( |
2314 output_surface_->context_provider(), shared_bitmap_manager_, | 2322 compositor_frame_sink_->context_provider(), shared_bitmap_manager_, |
2315 gpu_memory_buffer_manager_, | 2323 gpu_memory_buffer_manager_, |
2316 task_runner_provider_->blocking_main_thread_task_runner(), | 2324 task_runner_provider_->blocking_main_thread_task_runner(), |
2317 settings_.renderer_settings.highp_threshold_min, | 2325 settings_.renderer_settings.highp_threshold_min, |
2318 settings_.renderer_settings.texture_id_allocation_chunk_size, | 2326 settings_.renderer_settings.texture_id_allocation_chunk_size, |
2319 output_surface_->capabilities().delegated_sync_points_required, | 2327 compositor_frame_sink_->capabilities().delegated_sync_points_required, |
2320 settings_.renderer_settings.use_gpu_memory_buffer_resources, false, | 2328 settings_.renderer_settings.use_gpu_memory_buffer_resources, false, |
2321 settings_.renderer_settings.buffer_to_texture_target_map); | 2329 settings_.renderer_settings.buffer_to_texture_target_map); |
2322 | 2330 |
2323 // Make sure the main context visibility is restored. Worker context | 2331 // Make sure the main context visibility is restored. Worker context |
2324 // visibility will be set via the memory policy update in | 2332 // visibility will be set via the memory policy update in |
2325 // CreateTileManagerResources below. | 2333 // CreateTileManagerResources below. |
2326 if (visible_) | 2334 if (visible_) |
2327 SetCompositorContextVisibility(true); | 2335 SetCompositorContextVisibility(true); |
2328 | 2336 |
2329 // Since the new context may be capable of MSAA, update status here. We don't | 2337 // 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 | 2338 // need to check the return value since we are recreating all resources |
2331 // already. | 2339 // already. |
2332 UpdateGpuRasterizationStatus(); | 2340 UpdateGpuRasterizationStatus(); |
2333 | 2341 |
2334 // See note in LayerTreeImpl::UpdateDrawProperties, new OutputSurface means a | 2342 // See note in LayerTreeImpl::UpdateDrawProperties, new CompositorFrameSink |
2343 // means a | |
enne (OOO)
2016/09/14 00:35:45
@_@
| |
2335 // new max texture size which affects draw properties. Also, if the draw | 2344 // new max texture size which affects draw properties. Also, if the draw |
2336 // properties were up to date, layers still lost resources and we need to | 2345 // properties were up to date, layers still lost resources and we need to |
2337 // UpdateDrawProperties() after calling RecreateTreeResources(). | 2346 // UpdateDrawProperties() after calling RecreateTreeResources(). |
2338 active_tree_->set_needs_update_draw_properties(); | 2347 active_tree_->set_needs_update_draw_properties(); |
2339 if (pending_tree_) | 2348 if (pending_tree_) |
2340 pending_tree_->set_needs_update_draw_properties(); | 2349 pending_tree_->set_needs_update_draw_properties(); |
2341 | 2350 |
2342 CreateTileManagerResources(); | 2351 CreateTileManagerResources(); |
2343 RecreateTreeResources(); | 2352 RecreateTreeResources(); |
2344 | 2353 |
2345 // TODO(brianderson): Don't use a hard-coded parent draw time. | 2354 // TODO(brianderson): Don't use a hard-coded parent draw time. |
2346 base::TimeDelta parent_draw_time = | 2355 base::TimeDelta parent_draw_time = |
2347 (!settings_.use_external_begin_frame_source && | 2356 (!settings_.use_external_begin_frame_source && |
2348 output_surface_->capabilities().adjust_deadline_for_parent) | 2357 compositor_frame_sink_->capabilities().adjust_deadline_for_parent) |
2349 ? BeginFrameArgs::DefaultEstimatedParentDrawTime() | 2358 ? BeginFrameArgs::DefaultEstimatedParentDrawTime() |
2350 : base::TimeDelta(); | 2359 : base::TimeDelta(); |
2351 client_->SetEstimatedParentDrawTime(parent_draw_time); | 2360 client_->SetEstimatedParentDrawTime(parent_draw_time); |
2352 | 2361 |
2353 DCHECK_EQ(1, output_surface_->capabilities().max_frames_pending); | 2362 DCHECK_EQ(1, compositor_frame_sink_->capabilities().max_frames_pending); |
2354 client_->OnCanDrawStateChanged(CanDraw()); | 2363 client_->OnCanDrawStateChanged(CanDraw()); |
2355 | 2364 |
2356 SetFullViewportDamage(); | 2365 SetFullViewportDamage(); |
2357 // There will not be anything to draw here, so set high res | 2366 // There will not be anything to draw here, so set high res |
2358 // to avoid checkerboards, typically when we are recovering | 2367 // to avoid checkerboards, typically when we are recovering |
2359 // from lost context. | 2368 // from lost context. |
2360 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. | 2369 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. |
2361 SetRequiresHighResToDraw(); | 2370 SetRequiresHighResToDraw(); |
2362 | 2371 |
2363 return true; | 2372 return true; |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4136 return task_runner_provider_->HasImplThread(); | 4145 return task_runner_provider_->HasImplThread(); |
4137 } | 4146 } |
4138 | 4147 |
4139 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4148 bool LayerTreeHostImpl::CommitToActiveTree() const { |
4140 // In single threaded mode we skip the pending tree and commit directly to the | 4149 // In single threaded mode we skip the pending tree and commit directly to the |
4141 // active tree. | 4150 // active tree. |
4142 return !task_runner_provider_->HasImplThread(); | 4151 return !task_runner_provider_->HasImplThread(); |
4143 } | 4152 } |
4144 | 4153 |
4145 void LayerTreeHostImpl::SetCompositorContextVisibility(bool is_visible) { | 4154 void LayerTreeHostImpl::SetCompositorContextVisibility(bool is_visible) { |
4146 if (!output_surface_) | 4155 if (!compositor_frame_sink_) |
4147 return; | 4156 return; |
4148 | 4157 |
4149 auto* compositor_context = output_surface_->context_provider(); | 4158 auto* compositor_context = compositor_frame_sink_->context_provider(); |
4150 if (!compositor_context) | 4159 if (!compositor_context) |
4151 return; | 4160 return; |
4152 | 4161 |
4153 DCHECK_NE(is_visible, !!compositor_context_visibility_); | 4162 DCHECK_NE(is_visible, !!compositor_context_visibility_); |
4154 | 4163 |
4155 if (is_visible) { | 4164 if (is_visible) { |
4156 compositor_context_visibility_ = | 4165 compositor_context_visibility_ = |
4157 compositor_context->CacheController()->ClientBecameVisible(); | 4166 compositor_context->CacheController()->ClientBecameVisible(); |
4158 } else { | 4167 } else { |
4159 compositor_context->CacheController()->ClientBecameNotVisible( | 4168 compositor_context->CacheController()->ClientBecameNotVisible( |
4160 std::move(compositor_context_visibility_)); | 4169 std::move(compositor_context_visibility_)); |
4161 } | 4170 } |
4162 } | 4171 } |
4163 | 4172 |
4164 void LayerTreeHostImpl::SetWorkerContextVisibility(bool is_visible) { | 4173 void LayerTreeHostImpl::SetWorkerContextVisibility(bool is_visible) { |
4165 if (!output_surface_) | 4174 if (!compositor_frame_sink_) |
4166 return; | 4175 return; |
4167 | 4176 |
4168 auto* worker_context = output_surface_->worker_context_provider(); | 4177 auto* worker_context = compositor_frame_sink_->worker_context_provider(); |
4169 if (!worker_context) | 4178 if (!worker_context) |
4170 return; | 4179 return; |
4171 | 4180 |
4172 // TODO(ericrk): This check is here because worker context visibility is a | 4181 // TODO(ericrk): This check is here because worker context visibility is a |
4173 // bit less controlled, being settable both by memory policy changes as well | 4182 // bit less controlled, being settable both by memory policy changes as well |
4174 // as direct visibility changes. We should simplify this. crbug.com/642154 | 4183 // as direct visibility changes. We should simplify this. crbug.com/642154 |
4175 if (is_visible == !!worker_context_visibility_) | 4184 if (is_visible == !!worker_context_visibility_) |
4176 return; | 4185 return; |
4177 | 4186 |
4178 ContextProvider::ScopedContextLock hold(worker_context); | 4187 ContextProvider::ScopedContextLock hold(worker_context); |
4179 if (is_visible) { | 4188 if (is_visible) { |
4180 worker_context_visibility_ = | 4189 worker_context_visibility_ = |
4181 worker_context->CacheController()->ClientBecameVisible(); | 4190 worker_context->CacheController()->ClientBecameVisible(); |
4182 } else { | 4191 } else { |
4183 worker_context->CacheController()->ClientBecameNotVisible( | 4192 worker_context->CacheController()->ClientBecameNotVisible( |
4184 std::move(worker_context_visibility_)); | 4193 std::move(worker_context_visibility_)); |
4185 } | 4194 } |
4186 } | 4195 } |
4187 | 4196 |
4188 } // namespace cc | 4197 } // namespace cc |
OLD | NEW |