| 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> |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <unordered_map> | 14 #include <unordered_map> |
| 15 #include <utility> | 15 #include <utility> |
| 16 | 16 |
| 17 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 18 #include "base/containers/small_map.h" | 18 #include "base/containers/small_map.h" |
| 19 #include "base/json/json_writer.h" | 19 #include "base/json/json_writer.h" |
| 20 #include "base/memory/ptr_util.h" |
| 20 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
| 21 #include "base/numerics/safe_conversions.h" | 22 #include "base/numerics/safe_conversions.h" |
| 22 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 24 #include "base/trace_event/trace_event_argument.h" | 25 #include "base/trace_event/trace_event_argument.h" |
| 25 #include "cc/animation/animation_events.h" | 26 #include "cc/animation/animation_events.h" |
| 26 #include "cc/animation/animation_host.h" | 27 #include "cc/animation/animation_host.h" |
| 27 #include "cc/animation/timing_function.h" | 28 #include "cc/animation/timing_function.h" |
| 28 #include "cc/base/histograms.h" | 29 #include "cc/base/histograms.h" |
| 29 #include "cc/base/math_util.h" | 30 #include "cc/base/math_util.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 | 160 |
| 160 } // namespace | 161 } // namespace |
| 161 | 162 |
| 162 LayerTreeHostImpl::FrameData::FrameData() | 163 LayerTreeHostImpl::FrameData::FrameData() |
| 163 : render_surface_layer_list(nullptr), has_no_damage(false) {} | 164 : render_surface_layer_list(nullptr), has_no_damage(false) {} |
| 164 | 165 |
| 165 LayerTreeHostImpl::FrameData::~FrameData() {} | 166 LayerTreeHostImpl::FrameData::~FrameData() {} |
| 166 | 167 |
| 167 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( | 168 std::unique_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( |
| 168 const LayerTreeSettings& settings, | 169 const LayerTreeSettings& settings, |
| 169 LayerTreeHostImplClient* client, | 170 LayerTreeHostImplClient* client, |
| 170 TaskRunnerProvider* task_runner_provider, | 171 TaskRunnerProvider* task_runner_provider, |
| 171 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 172 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 172 SharedBitmapManager* shared_bitmap_manager, | 173 SharedBitmapManager* shared_bitmap_manager, |
| 173 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 174 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 174 TaskGraphRunner* task_graph_runner, | 175 TaskGraphRunner* task_graph_runner, |
| 175 int id) { | 176 int id) { |
| 176 return make_scoped_ptr(new LayerTreeHostImpl( | 177 return base::WrapUnique(new LayerTreeHostImpl( |
| 177 settings, client, task_runner_provider, rendering_stats_instrumentation, | 178 settings, client, task_runner_provider, rendering_stats_instrumentation, |
| 178 shared_bitmap_manager, gpu_memory_buffer_manager, task_graph_runner, id)); | 179 shared_bitmap_manager, gpu_memory_buffer_manager, task_graph_runner, id)); |
| 179 } | 180 } |
| 180 | 181 |
| 181 LayerTreeHostImpl::LayerTreeHostImpl( | 182 LayerTreeHostImpl::LayerTreeHostImpl( |
| 182 const LayerTreeSettings& settings, | 183 const LayerTreeSettings& settings, |
| 183 LayerTreeHostImplClient* client, | 184 LayerTreeHostImplClient* client, |
| 184 TaskRunnerProvider* task_runner_provider, | 185 TaskRunnerProvider* task_runner_provider, |
| 185 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 186 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 186 SharedBitmapManager* shared_bitmap_manager, | 187 SharedBitmapManager* shared_bitmap_manager, |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 base::TimeDelta duration) { | 488 base::TimeDelta duration) { |
| 488 if (!InnerViewportScrollLayer()) | 489 if (!InnerViewportScrollLayer()) |
| 489 return; | 490 return; |
| 490 | 491 |
| 491 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 492 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
| 492 gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize(); | 493 gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize(); |
| 493 gfx::SizeF viewport_size = | 494 gfx::SizeF viewport_size = |
| 494 gfx::SizeF(active_tree_->InnerViewportContainerLayer()->bounds()); | 495 gfx::SizeF(active_tree_->InnerViewportContainerLayer()->bounds()); |
| 495 | 496 |
| 496 // Easing constants experimentally determined. | 497 // Easing constants experimentally determined. |
| 497 scoped_ptr<TimingFunction> timing_function = | 498 std::unique_ptr<TimingFunction> timing_function = |
| 498 CubicBezierTimingFunction::Create(.8, 0, .3, .9); | 499 CubicBezierTimingFunction::Create(.8, 0, .3, .9); |
| 499 | 500 |
| 500 // TODO(miletus) : Pass in ScrollOffset. | 501 // TODO(miletus) : Pass in ScrollOffset. |
| 501 page_scale_animation_ = PageScaleAnimation::Create( | 502 page_scale_animation_ = PageScaleAnimation::Create( |
| 502 ScrollOffsetToVector2dF(scroll_total), | 503 ScrollOffsetToVector2dF(scroll_total), |
| 503 active_tree_->current_page_scale_factor(), viewport_size, | 504 active_tree_->current_page_scale_factor(), viewport_size, |
| 504 scaled_scrollable_size, std::move(timing_function)); | 505 scaled_scrollable_size, std::move(timing_function)); |
| 505 | 506 |
| 506 if (anchor_point) { | 507 if (anchor_point) { |
| 507 gfx::Vector2dF anchor(target_offset); | 508 gfx::Vector2dF anchor(target_offset); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 581 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 581 | 582 |
| 582 // Now determine if there are actually any handlers at that point. | 583 // Now determine if there are actually any handlers at that point. |
| 583 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 584 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 584 LayerImpl* layer_impl = | 585 LayerImpl* layer_impl = |
| 585 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 586 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 586 device_viewport_point); | 587 device_viewport_point); |
| 587 return layer_impl != NULL; | 588 return layer_impl != NULL; |
| 588 } | 589 } |
| 589 | 590 |
| 590 scoped_ptr<SwapPromiseMonitor> | 591 std::unique_ptr<SwapPromiseMonitor> |
| 591 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 592 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 592 ui::LatencyInfo* latency) { | 593 ui::LatencyInfo* latency) { |
| 593 return make_scoped_ptr( | 594 return base::WrapUnique( |
| 594 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 595 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 595 } | 596 } |
| 596 | 597 |
| 597 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { | 598 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { |
| 598 DCHECK(!scroll_elasticity_helper_); | 599 DCHECK(!scroll_elasticity_helper_); |
| 599 if (settings_.enable_elastic_overscroll) { | 600 if (settings_.enable_elastic_overscroll) { |
| 600 scroll_elasticity_helper_.reset( | 601 scroll_elasticity_helper_.reset( |
| 601 ScrollElasticityHelper::CreateForLayerTreeHostImpl(this)); | 602 ScrollElasticityHelper::CreateForLayerTreeHostImpl(this)); |
| 602 } | 603 } |
| 603 return scroll_elasticity_helper_.get(); | 604 return scroll_elasticity_helper_.get(); |
| 604 } | 605 } |
| 605 | 606 |
| 606 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( | 607 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( |
| 607 scoped_ptr<SwapPromise> swap_promise) { | 608 std::unique_ptr<SwapPromise> swap_promise) { |
| 608 swap_promises_for_main_thread_scroll_update_.push_back( | 609 swap_promises_for_main_thread_scroll_update_.push_back( |
| 609 std::move(swap_promise)); | 610 std::move(swap_promise)); |
| 610 } | 611 } |
| 611 | 612 |
| 612 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 613 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
| 613 LayerImpl* root_draw_layer, | 614 LayerImpl* root_draw_layer, |
| 614 const LayerImplList& render_surface_layer_list) { | 615 const LayerImplList& render_surface_layer_list) { |
| 615 // For now, we use damage tracking to compute a global scissor. To do this, we | 616 // For now, we use damage tracking to compute a global scissor. To do this, we |
| 616 // must compute all damage tracking before drawing anything, so that we know | 617 // must compute all damage tracking before drawing anything, so that we know |
| 617 // the root damage rect. The root damage rect is then used to scissor each | 618 // the root damage rect. The root damage rect is then used to scissor each |
| (...skipping 28 matching lines...) Expand all Loading... |
| 646 for (size_t i = 0; i < render_passes.size(); ++i) { | 647 for (size_t i = 0; i < render_passes.size(); ++i) { |
| 647 value->BeginDictionary(); | 648 value->BeginDictionary(); |
| 648 render_passes[i]->AsValueInto(value); | 649 render_passes[i]->AsValueInto(value); |
| 649 value->EndDictionary(); | 650 value->EndDictionary(); |
| 650 } | 651 } |
| 651 value->EndArray(); | 652 value->EndArray(); |
| 652 } | 653 } |
| 653 } | 654 } |
| 654 | 655 |
| 655 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 656 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
| 656 scoped_ptr<RenderPass> render_pass) { | 657 std::unique_ptr<RenderPass> render_pass) { |
| 657 render_passes.push_back(std::move(render_pass)); | 658 render_passes.push_back(std::move(render_pass)); |
| 658 } | 659 } |
| 659 | 660 |
| 660 DrawMode LayerTreeHostImpl::GetDrawMode() const { | 661 DrawMode LayerTreeHostImpl::GetDrawMode() const { |
| 661 if (resourceless_software_draw_) { | 662 if (resourceless_software_draw_) { |
| 662 return DRAW_MODE_RESOURCELESS_SOFTWARE; | 663 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
| 663 } else if (output_surface_->context_provider()) { | 664 } else if (output_surface_->context_provider()) { |
| 664 return DRAW_MODE_HARDWARE; | 665 return DRAW_MODE_HARDWARE; |
| 665 } else { | 666 } else { |
| 666 return DRAW_MODE_SOFTWARE; | 667 return DRAW_MODE_SOFTWARE; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 visible_screen_space_rect, | 751 visible_screen_space_rect, |
| 751 screen_background_color, | 752 screen_background_color, |
| 752 false); | 753 false); |
| 753 } | 754 } |
| 754 } | 755 } |
| 755 | 756 |
| 756 static RenderPass* FindRenderPassById(const RenderPassList& list, | 757 static RenderPass* FindRenderPassById(const RenderPassList& list, |
| 757 RenderPassId id) { | 758 RenderPassId id) { |
| 758 auto it = std::find_if( | 759 auto it = std::find_if( |
| 759 list.begin(), list.end(), | 760 list.begin(), list.end(), |
| 760 [id](const scoped_ptr<RenderPass>& p) { return p->id == id; }); | 761 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); |
| 761 return it == list.end() ? nullptr : it->get(); | 762 return it == list.end() ? nullptr : it->get(); |
| 762 } | 763 } |
| 763 | 764 |
| 764 DrawResult LayerTreeHostImpl::CalculateRenderPasses( | 765 DrawResult LayerTreeHostImpl::CalculateRenderPasses( |
| 765 FrameData* frame) { | 766 FrameData* frame) { |
| 766 DCHECK(frame->render_passes.empty()); | 767 DCHECK(frame->render_passes.empty()); |
| 767 DCHECK(CanDraw()); | 768 DCHECK(CanDraw()); |
| 768 DCHECK(active_tree_->root_layer()); | 769 DCHECK(active_tree_->root_layer()); |
| 769 | 770 |
| 770 TrackDamageForAllSurfaces(active_tree_->root_layer(), | 771 TrackDamageForAllSurfaces(active_tree_->root_layer(), |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 active_tree_->RootScrollLayerDeviceViewportBounds(), | 976 active_tree_->RootScrollLayerDeviceViewportBounds(), |
| 976 frame->render_passes.back().get(), active_tree_->root_layer(), | 977 frame->render_passes.back().get(), active_tree_->root_layer(), |
| 977 active_tree_->background_color(), unoccluded_screen_space_region); | 978 active_tree_->background_color(), unoccluded_screen_space_region); |
| 978 } | 979 } |
| 979 | 980 |
| 980 RemoveRenderPasses(frame); | 981 RemoveRenderPasses(frame); |
| 981 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); | 982 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); |
| 982 | 983 |
| 983 // Any copy requests left in the tree are not going to get serviced, and | 984 // Any copy requests left in the tree are not going to get serviced, and |
| 984 // should be aborted. | 985 // should be aborted. |
| 985 std::vector<scoped_ptr<CopyOutputRequest>> requests_to_abort; | 986 std::vector<std::unique_ptr<CopyOutputRequest>> requests_to_abort; |
| 986 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { | 987 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { |
| 987 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); | 988 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); |
| 988 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); | 989 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); |
| 989 } | 990 } |
| 990 for (size_t i = 0; i < requests_to_abort.size(); ++i) | 991 for (size_t i = 0; i < requests_to_abort.size(); ++i) |
| 991 requests_to_abort[i]->SendEmptyResult(); | 992 requests_to_abort[i]->SendEmptyResult(); |
| 992 | 993 |
| 993 // If we're making a frame to draw, it better have at least one render pass. | 994 // If we're making a frame to draw, it better have at least one render pass. |
| 994 DCHECK(!frame->render_passes.empty()); | 995 DCHECK(!frame->render_passes.empty()); |
| 995 | 996 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 | 1259 |
| 1259 DidModifyTilePriorities(); | 1260 DidModifyTilePriorities(); |
| 1260 } | 1261 } |
| 1261 | 1262 |
| 1262 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1263 void LayerTreeHostImpl::DidModifyTilePriorities() { |
| 1263 // Mark priorities as dirty and schedule a PrepareTiles(). | 1264 // Mark priorities as dirty and schedule a PrepareTiles(). |
| 1264 tile_priorities_dirty_ = true; | 1265 tile_priorities_dirty_ = true; |
| 1265 client_->SetNeedsPrepareTilesOnImplThread(); | 1266 client_->SetNeedsPrepareTilesOnImplThread(); |
| 1266 } | 1267 } |
| 1267 | 1268 |
| 1268 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( | 1269 std::unique_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( |
| 1269 TreePriority tree_priority, | 1270 TreePriority tree_priority, |
| 1270 RasterTilePriorityQueue::Type type) { | 1271 RasterTilePriorityQueue::Type type) { |
| 1271 TRACE_EVENT0("disabled-by-default-cc.debug", | 1272 TRACE_EVENT0("disabled-by-default-cc.debug", |
| 1272 "LayerTreeHostImpl::BuildRasterQueue"); | 1273 "LayerTreeHostImpl::BuildRasterQueue"); |
| 1273 | 1274 |
| 1274 return RasterTilePriorityQueue::Create(active_tree_->picture_layers(), | 1275 return RasterTilePriorityQueue::Create(active_tree_->picture_layers(), |
| 1275 pending_tree_ | 1276 pending_tree_ |
| 1276 ? pending_tree_->picture_layers() | 1277 ? pending_tree_->picture_layers() |
| 1277 : std::vector<PictureLayerImpl*>(), | 1278 : std::vector<PictureLayerImpl*>(), |
| 1278 tree_priority, type); | 1279 tree_priority, type); |
| 1279 } | 1280 } |
| 1280 | 1281 |
| 1281 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( | 1282 std::unique_ptr<EvictionTilePriorityQueue> |
| 1282 TreePriority tree_priority) { | 1283 LayerTreeHostImpl::BuildEvictionQueue(TreePriority tree_priority) { |
| 1283 TRACE_EVENT0("disabled-by-default-cc.debug", | 1284 TRACE_EVENT0("disabled-by-default-cc.debug", |
| 1284 "LayerTreeHostImpl::BuildEvictionQueue"); | 1285 "LayerTreeHostImpl::BuildEvictionQueue"); |
| 1285 | 1286 |
| 1286 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); | 1287 std::unique_ptr<EvictionTilePriorityQueue> queue( |
| 1288 new EvictionTilePriorityQueue); |
| 1287 queue->Build(active_tree_->picture_layers(), | 1289 queue->Build(active_tree_->picture_layers(), |
| 1288 pending_tree_ ? pending_tree_->picture_layers() | 1290 pending_tree_ ? pending_tree_->picture_layers() |
| 1289 : std::vector<PictureLayerImpl*>(), | 1291 : std::vector<PictureLayerImpl*>(), |
| 1290 tree_priority); | 1292 tree_priority); |
| 1291 return queue; | 1293 return queue; |
| 1292 } | 1294 } |
| 1293 | 1295 |
| 1294 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( | 1296 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( |
| 1295 bool is_likely_to_require_a_draw) { | 1297 bool is_likely_to_require_a_draw) { |
| 1296 // Proactively tell the scheduler that we expect to draw within each vsync | 1298 // Proactively tell the scheduler that we expect to draw within each vsync |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 if (active_tree_->hud_layer()) { | 1651 if (active_tree_->hud_layer()) { |
| 1650 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1652 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
| 1651 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1653 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
| 1652 resource_provider_.get()); | 1654 resource_provider_.get()); |
| 1653 } | 1655 } |
| 1654 | 1656 |
| 1655 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 1657 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 1656 bool disable_picture_quad_image_filtering = | 1658 bool disable_picture_quad_image_filtering = |
| 1657 IsActivelyScrolling() || animation_host_->NeedsAnimateLayers(); | 1659 IsActivelyScrolling() || animation_host_->NeedsAnimateLayers(); |
| 1658 | 1660 |
| 1659 scoped_ptr<SoftwareRenderer> temp_software_renderer = | 1661 std::unique_ptr<SoftwareRenderer> temp_software_renderer = |
| 1660 SoftwareRenderer::Create(this, &settings_.renderer_settings, | 1662 SoftwareRenderer::Create(this, &settings_.renderer_settings, |
| 1661 output_surface_, NULL); | 1663 output_surface_, NULL); |
| 1662 temp_software_renderer->DrawFrame( | 1664 temp_software_renderer->DrawFrame( |
| 1663 &frame->render_passes, active_tree_->device_scale_factor(), | 1665 &frame->render_passes, active_tree_->device_scale_factor(), |
| 1664 DeviceViewport(), DeviceClip(), disable_picture_quad_image_filtering); | 1666 DeviceViewport(), DeviceClip(), disable_picture_quad_image_filtering); |
| 1665 } else { | 1667 } else { |
| 1666 renderer_->DrawFrame(&frame->render_passes, | 1668 renderer_->DrawFrame(&frame->render_passes, |
| 1667 active_tree_->device_scale_factor(), DeviceViewport(), | 1669 active_tree_->device_scale_factor(), DeviceViewport(), |
| 1668 DeviceClip(), false); | 1670 DeviceClip(), false); |
| 1669 } | 1671 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 // If we have any picture layers, then by activating we also modified tile | 2006 // If we have any picture layers, then by activating we also modified tile |
| 2005 // priorities. | 2007 // priorities. |
| 2006 if (!active_tree_->picture_layers().empty()) | 2008 if (!active_tree_->picture_layers().empty()) |
| 2007 DidModifyTilePriorities(); | 2009 DidModifyTilePriorities(); |
| 2008 | 2010 |
| 2009 client_->OnCanDrawStateChanged(CanDraw()); | 2011 client_->OnCanDrawStateChanged(CanDraw()); |
| 2010 client_->DidActivateSyncTree(); | 2012 client_->DidActivateSyncTree(); |
| 2011 if (!tree_activation_callback_.is_null()) | 2013 if (!tree_activation_callback_.is_null()) |
| 2012 tree_activation_callback_.Run(); | 2014 tree_activation_callback_.Run(); |
| 2013 | 2015 |
| 2014 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation = | 2016 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation = |
| 2015 active_tree_->TakePendingPageScaleAnimation(); | 2017 active_tree_->TakePendingPageScaleAnimation(); |
| 2016 if (pending_page_scale_animation) { | 2018 if (pending_page_scale_animation) { |
| 2017 StartPageScaleAnimation( | 2019 StartPageScaleAnimation( |
| 2018 pending_page_scale_animation->target_offset, | 2020 pending_page_scale_animation->target_offset, |
| 2019 pending_page_scale_animation->use_anchor, | 2021 pending_page_scale_animation->use_anchor, |
| 2020 pending_page_scale_animation->scale, | 2022 pending_page_scale_animation->scale, |
| 2021 pending_page_scale_animation->duration); | 2023 pending_page_scale_animation->duration); |
| 2022 } | 2024 } |
| 2023 // Activation can change the root scroll offset, so inform the synchronous | 2025 // Activation can change the root scroll offset, so inform the synchronous |
| 2024 // input handler. | 2026 // input handler. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2130 active_tree_->set_needs_update_draw_properties(); | 2132 active_tree_->set_needs_update_draw_properties(); |
| 2131 if (pending_tree_) | 2133 if (pending_tree_) |
| 2132 pending_tree_->set_needs_update_draw_properties(); | 2134 pending_tree_->set_needs_update_draw_properties(); |
| 2133 client_->UpdateRendererCapabilitiesOnImplThread(); | 2135 client_->UpdateRendererCapabilitiesOnImplThread(); |
| 2134 } | 2136 } |
| 2135 | 2137 |
| 2136 void LayerTreeHostImpl::CreateTileManagerResources() { | 2138 void LayerTreeHostImpl::CreateTileManagerResources() { |
| 2137 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); | 2139 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); |
| 2138 | 2140 |
| 2139 if (use_gpu_rasterization_) { | 2141 if (use_gpu_rasterization_) { |
| 2140 image_decode_controller_ = make_scoped_ptr(new GpuImageDecodeController); | 2142 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController); |
| 2141 } else { | 2143 } else { |
| 2142 image_decode_controller_ = | 2144 image_decode_controller_ = |
| 2143 make_scoped_ptr(new SoftwareImageDecodeController( | 2145 base::WrapUnique(new SoftwareImageDecodeController( |
| 2144 settings_.renderer_settings.preferred_tile_format)); | 2146 settings_.renderer_settings.preferred_tile_format)); |
| 2145 } | 2147 } |
| 2146 | 2148 |
| 2147 // TODO(vmpstr): Initialize tile task limit at ctor time. | 2149 // TODO(vmpstr): Initialize tile task limit at ctor time. |
| 2148 tile_manager_->SetResources( | 2150 tile_manager_->SetResources( |
| 2149 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(), | 2151 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(), |
| 2150 image_decode_controller_.get(), | 2152 image_decode_controller_.get(), |
| 2151 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max() | 2153 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max() |
| 2152 : settings_.scheduled_raster_task_limit, | 2154 : settings_.scheduled_raster_task_limit, |
| 2153 use_gpu_rasterization_); | 2155 use_gpu_rasterization_); |
| 2154 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 2156 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
| 2155 } | 2157 } |
| 2156 | 2158 |
| 2157 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( | 2159 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( |
| 2158 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 2160 std::unique_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
| 2159 scoped_ptr<ResourcePool>* resource_pool) { | 2161 std::unique_ptr<ResourcePool>* resource_pool) { |
| 2160 DCHECK(GetTaskRunner()); | 2162 DCHECK(GetTaskRunner()); |
| 2161 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is | 2163 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is |
| 2162 // resolved. | 2164 // resolved. |
| 2163 CHECK(resource_provider_); | 2165 CHECK(resource_provider_); |
| 2164 | 2166 |
| 2165 // Pass the single-threaded synchronous task graph runner to the worker pool | 2167 // Pass the single-threaded synchronous task graph runner to the worker pool |
| 2166 // if we're in synchronous single-threaded mode. | 2168 // if we're in synchronous single-threaded mode. |
| 2167 TaskGraphRunner* task_graph_runner = task_graph_runner_; | 2169 TaskGraphRunner* task_graph_runner = task_graph_runner_; |
| 2168 if (is_synchronous_single_threaded_) { | 2170 if (is_synchronous_single_threaded_) { |
| 2169 DCHECK(!single_thread_synchronous_task_graph_runner_); | 2171 DCHECK(!single_thread_synchronous_task_graph_runner_); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 if (request_ids.empty()) | 2241 if (request_ids.empty()) |
| 2240 return; | 2242 return; |
| 2241 | 2243 |
| 2242 base::TimeTicks start_time = start_of_main_frame_args.frame_time; | 2244 base::TimeTicks start_time = start_of_main_frame_args.frame_time; |
| 2243 base::TimeTicks end_time = expected_next_main_frame_args.frame_time; | 2245 base::TimeTicks end_time = expected_next_main_frame_args.frame_time; |
| 2244 frame_timing_tracker_->SaveMainFrameTimeStamps( | 2246 frame_timing_tracker_->SaveMainFrameTimeStamps( |
| 2245 request_ids, start_time, end_time, active_tree_->source_frame_number()); | 2247 request_ids, start_time, end_time, active_tree_->source_frame_number()); |
| 2246 } | 2248 } |
| 2247 | 2249 |
| 2248 void LayerTreeHostImpl::PostFrameTimingEvents( | 2250 void LayerTreeHostImpl::PostFrameTimingEvents( |
| 2249 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 2251 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 2250 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 2252 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 2251 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), | 2253 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), |
| 2252 std::move(main_frame_events)); | 2254 std::move(main_frame_events)); |
| 2253 } | 2255 } |
| 2254 | 2256 |
| 2255 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2257 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
| 2256 ClearUIResources(); | 2258 ClearUIResources(); |
| 2257 tile_manager_->FinishTasksAndCleanUp(); | 2259 tile_manager_->FinishTasksAndCleanUp(); |
| 2258 resource_pool_ = nullptr; | 2260 resource_pool_ = nullptr; |
| 2259 tile_task_worker_pool_ = nullptr; | 2261 tile_task_worker_pool_ = nullptr; |
| 2260 single_thread_synchronous_task_graph_runner_ = nullptr; | 2262 single_thread_synchronous_task_graph_runner_ = nullptr; |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3311 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 3313 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
| 3312 LayerImpl* root_layer) { | 3314 LayerImpl* root_layer) { |
| 3313 if (!root_layer) | 3315 if (!root_layer) |
| 3314 return; | 3316 return; |
| 3315 | 3317 |
| 3316 return root_layer->layer_tree_impl() | 3318 return root_layer->layer_tree_impl() |
| 3317 ->property_trees() | 3319 ->property_trees() |
| 3318 ->scroll_tree.CollectScrollDeltas(scroll_info); | 3320 ->scroll_tree.CollectScrollDeltas(scroll_info); |
| 3319 } | 3321 } |
| 3320 | 3322 |
| 3321 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 3323 std::unique_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
| 3322 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 3324 std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
| 3323 | 3325 |
| 3324 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 3326 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
| 3325 scroll_info->page_scale_delta = | 3327 scroll_info->page_scale_delta = |
| 3326 active_tree_->page_scale_factor()->PullDeltaForMainThread(); | 3328 active_tree_->page_scale_factor()->PullDeltaForMainThread(); |
| 3327 scroll_info->top_controls_delta = | 3329 scroll_info->top_controls_delta = |
| 3328 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread(); | 3330 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread(); |
| 3329 scroll_info->elastic_overscroll_delta = | 3331 scroll_info->elastic_overscroll_delta = |
| 3330 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); | 3332 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); |
| 3331 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); | 3333 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); |
| 3332 | 3334 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3425 // still request an extra SetNeedsAnimate here. | 3427 // still request an extra SetNeedsAnimate here. |
| 3426 if (animated) | 3428 if (animated) |
| 3427 SetNeedsOneBeginImplFrame(); | 3429 SetNeedsOneBeginImplFrame(); |
| 3428 // TODO(crbug.com/551138): We could return true only if the animations are on | 3430 // TODO(crbug.com/551138): We could return true only if the animations are on |
| 3429 // the active tree. There's no need to cause a draw to take place from | 3431 // the active tree. There's no need to cause a draw to take place from |
| 3430 // animations starting/ticking on the pending tree. | 3432 // animations starting/ticking on the pending tree. |
| 3431 return animated; | 3433 return animated; |
| 3432 } | 3434 } |
| 3433 | 3435 |
| 3434 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 3436 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
| 3435 scoped_ptr<AnimationEvents> events = animation_host_->CreateEvents(); | 3437 std::unique_ptr<AnimationEvents> events = animation_host_->CreateEvents(); |
| 3436 | 3438 |
| 3437 const bool has_active_animations = animation_host_->UpdateAnimationState( | 3439 const bool has_active_animations = animation_host_->UpdateAnimationState( |
| 3438 start_ready_animations, events.get()); | 3440 start_ready_animations, events.get()); |
| 3439 | 3441 |
| 3440 if (!events->events_.empty()) | 3442 if (!events->events_.empty()) |
| 3441 client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events)); | 3443 client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events)); |
| 3442 | 3444 |
| 3443 if (has_active_animations) | 3445 if (has_active_animations) |
| 3444 SetNeedsOneBeginImplFrame(); | 3446 SetNeedsOneBeginImplFrame(); |
| 3445 } | 3447 } |
| 3446 | 3448 |
| 3447 void LayerTreeHostImpl::ActivateAnimations() { | 3449 void LayerTreeHostImpl::ActivateAnimations() { |
| 3448 const bool activated = animation_host_->ActivateAnimations(); | 3450 const bool activated = animation_host_->ActivateAnimations(); |
| 3449 if (activated) { | 3451 if (activated) { |
| 3450 // Activating an animation changes layer draw properties, such as | 3452 // Activating an animation changes layer draw properties, such as |
| 3451 // screen_space_transform_is_animating. So when we see a new animation get | 3453 // screen_space_transform_is_animating. So when we see a new animation get |
| 3452 // activated, we need to update the draw properties on the active tree. | 3454 // activated, we need to update the draw properties on the active tree. |
| 3453 active_tree()->set_needs_update_draw_properties(); | 3455 active_tree()->set_needs_update_draw_properties(); |
| 3454 // Request another frame to run the next tick of the animation. | 3456 // Request another frame to run the next tick of the animation. |
| 3455 SetNeedsOneBeginImplFrame(); | 3457 SetNeedsOneBeginImplFrame(); |
| 3456 } | 3458 } |
| 3457 } | 3459 } |
| 3458 | 3460 |
| 3459 std::string LayerTreeHostImpl::LayerTreeAsJson() const { | 3461 std::string LayerTreeHostImpl::LayerTreeAsJson() const { |
| 3460 std::string str; | 3462 std::string str; |
| 3461 if (active_tree_->root_layer()) { | 3463 if (active_tree_->root_layer()) { |
| 3462 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson()); | 3464 std::unique_ptr<base::Value> json( |
| 3465 active_tree_->root_layer()->LayerTreeAsJson()); |
| 3463 base::JSONWriter::WriteWithOptions( | 3466 base::JSONWriter::WriteWithOptions( |
| 3464 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); | 3467 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); |
| 3465 } | 3468 } |
| 3466 return str; | 3469 return str; |
| 3467 } | 3470 } |
| 3468 | 3471 |
| 3469 void LayerTreeHostImpl::RegisterScrollbarAnimationController( | 3472 void LayerTreeHostImpl::RegisterScrollbarAnimationController( |
| 3470 int scroll_layer_id) { | 3473 int scroll_layer_id) { |
| 3471 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) | 3474 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) |
| 3472 return; | 3475 return; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3551 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { | 3554 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { |
| 3552 // TODO(mithro): Replace call with current_begin_frame_tracker_.Current() | 3555 // TODO(mithro): Replace call with current_begin_frame_tracker_.Current() |
| 3553 // once all calls which happens outside impl frames are fixed. | 3556 // once all calls which happens outside impl frames are fixed. |
| 3554 return current_begin_frame_tracker_.DangerousMethodCurrentOrLast(); | 3557 return current_begin_frame_tracker_.DangerousMethodCurrentOrLast(); |
| 3555 } | 3558 } |
| 3556 | 3559 |
| 3557 base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const { | 3560 base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const { |
| 3558 return current_begin_frame_tracker_.Interval(); | 3561 return current_begin_frame_tracker_.Interval(); |
| 3559 } | 3562 } |
| 3560 | 3563 |
| 3561 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 3564 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 3562 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { | 3565 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
| 3563 scoped_ptr<base::trace_event::TracedValue> state( | 3566 std::unique_ptr<base::trace_event::TracedValue> state( |
| 3564 new base::trace_event::TracedValue()); | 3567 new base::trace_event::TracedValue()); |
| 3565 AsValueWithFrameInto(frame, state.get()); | 3568 AsValueWithFrameInto(frame, state.get()); |
| 3566 return std::move(state); | 3569 return std::move(state); |
| 3567 } | 3570 } |
| 3568 | 3571 |
| 3569 void LayerTreeHostImpl::AsValueWithFrameInto( | 3572 void LayerTreeHostImpl::AsValueWithFrameInto( |
| 3570 FrameData* frame, | 3573 FrameData* frame, |
| 3571 base::trace_event::TracedValue* state) const { | 3574 base::trace_event::TracedValue* state) const { |
| 3572 if (this->pending_tree_) { | 3575 if (this->pending_tree_) { |
| 3573 state->BeginDictionary("activation_state"); | 3576 state->BeginDictionary("activation_state"); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3719 std::set<UIResourceId>::iterator found_in_evicted = | 3722 std::set<UIResourceId>::iterator found_in_evicted = |
| 3720 evicted_ui_resources_.find(uid); | 3723 evicted_ui_resources_.find(uid); |
| 3721 if (found_in_evicted == evicted_ui_resources_.end()) | 3724 if (found_in_evicted == evicted_ui_resources_.end()) |
| 3722 return; | 3725 return; |
| 3723 evicted_ui_resources_.erase(found_in_evicted); | 3726 evicted_ui_resources_.erase(found_in_evicted); |
| 3724 if (evicted_ui_resources_.empty()) | 3727 if (evicted_ui_resources_.empty()) |
| 3725 client_->OnCanDrawStateChanged(CanDraw()); | 3728 client_->OnCanDrawStateChanged(CanDraw()); |
| 3726 } | 3729 } |
| 3727 | 3730 |
| 3728 void LayerTreeHostImpl::ScheduleMicroBenchmark( | 3731 void LayerTreeHostImpl::ScheduleMicroBenchmark( |
| 3729 scoped_ptr<MicroBenchmarkImpl> benchmark) { | 3732 std::unique_ptr<MicroBenchmarkImpl> benchmark) { |
| 3730 micro_benchmark_controller_.ScheduleRun(std::move(benchmark)); | 3733 micro_benchmark_controller_.ScheduleRun(std::move(benchmark)); |
| 3731 } | 3734 } |
| 3732 | 3735 |
| 3733 void LayerTreeHostImpl::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) { | 3736 void LayerTreeHostImpl::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) { |
| 3734 swap_promise_monitor_.insert(monitor); | 3737 swap_promise_monitor_.insert(monitor); |
| 3735 } | 3738 } |
| 3736 | 3739 |
| 3737 void LayerTreeHostImpl::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { | 3740 void LayerTreeHostImpl::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { |
| 3738 swap_promise_monitor_.erase(monitor); | 3741 swap_promise_monitor_.erase(monitor); |
| 3739 } | 3742 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3939 return task_runner_provider_->HasImplThread(); | 3942 return task_runner_provider_->HasImplThread(); |
| 3940 } | 3943 } |
| 3941 | 3944 |
| 3942 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3945 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3943 // In single threaded mode we skip the pending tree and commit directly to the | 3946 // In single threaded mode we skip the pending tree and commit directly to the |
| 3944 // active tree. | 3947 // active tree. |
| 3945 return !task_runner_provider_->HasImplThread(); | 3948 return !task_runner_provider_->HasImplThread(); |
| 3946 } | 3949 } |
| 3947 | 3950 |
| 3948 } // namespace cc | 3951 } // namespace cc |
| OLD | NEW |