Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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
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
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
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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 if (active_tree_->hud_layer()) { 1649 if (active_tree_->hud_layer()) {
1648 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); 1650 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture");
1649 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, 1651 active_tree_->hud_layer()->UpdateHudTexture(draw_mode,
1650 resource_provider_.get()); 1652 resource_provider_.get());
1651 } 1653 }
1652 1654
1653 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { 1655 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) {
1654 bool disable_picture_quad_image_filtering = 1656 bool disable_picture_quad_image_filtering =
1655 IsActivelyScrolling() || animation_host_->NeedsAnimateLayers(); 1657 IsActivelyScrolling() || animation_host_->NeedsAnimateLayers();
1656 1658
1657 scoped_ptr<SoftwareRenderer> temp_software_renderer = 1659 std::unique_ptr<SoftwareRenderer> temp_software_renderer =
1658 SoftwareRenderer::Create(this, &settings_.renderer_settings, 1660 SoftwareRenderer::Create(this, &settings_.renderer_settings,
1659 output_surface_, NULL); 1661 output_surface_, NULL);
1660 temp_software_renderer->DrawFrame( 1662 temp_software_renderer->DrawFrame(
1661 &frame->render_passes, active_tree_->device_scale_factor(), 1663 &frame->render_passes, active_tree_->device_scale_factor(),
1662 DeviceViewport(), DeviceClip(), disable_picture_quad_image_filtering); 1664 DeviceViewport(), DeviceClip(), disable_picture_quad_image_filtering);
1663 } else { 1665 } else {
1664 renderer_->DrawFrame(&frame->render_passes, 1666 renderer_->DrawFrame(&frame->render_passes,
1665 active_tree_->device_scale_factor(), DeviceViewport(), 1667 active_tree_->device_scale_factor(), DeviceViewport(),
1666 DeviceClip(), false); 1668 DeviceClip(), false);
1667 } 1669 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 // If we have any picture layers, then by activating we also modified tile 2004 // If we have any picture layers, then by activating we also modified tile
2003 // priorities. 2005 // priorities.
2004 if (!active_tree_->picture_layers().empty()) 2006 if (!active_tree_->picture_layers().empty())
2005 DidModifyTilePriorities(); 2007 DidModifyTilePriorities();
2006 2008
2007 client_->OnCanDrawStateChanged(CanDraw()); 2009 client_->OnCanDrawStateChanged(CanDraw());
2008 client_->DidActivateSyncTree(); 2010 client_->DidActivateSyncTree();
2009 if (!tree_activation_callback_.is_null()) 2011 if (!tree_activation_callback_.is_null())
2010 tree_activation_callback_.Run(); 2012 tree_activation_callback_.Run();
2011 2013
2012 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation = 2014 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation =
2013 active_tree_->TakePendingPageScaleAnimation(); 2015 active_tree_->TakePendingPageScaleAnimation();
2014 if (pending_page_scale_animation) { 2016 if (pending_page_scale_animation) {
2015 StartPageScaleAnimation( 2017 StartPageScaleAnimation(
2016 pending_page_scale_animation->target_offset, 2018 pending_page_scale_animation->target_offset,
2017 pending_page_scale_animation->use_anchor, 2019 pending_page_scale_animation->use_anchor,
2018 pending_page_scale_animation->scale, 2020 pending_page_scale_animation->scale,
2019 pending_page_scale_animation->duration); 2021 pending_page_scale_animation->duration);
2020 } 2022 }
2021 // Activation can change the root scroll offset, so inform the synchronous 2023 // Activation can change the root scroll offset, so inform the synchronous
2022 // input handler. 2024 // input handler.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 active_tree_->set_needs_update_draw_properties(); 2130 active_tree_->set_needs_update_draw_properties();
2129 if (pending_tree_) 2131 if (pending_tree_)
2130 pending_tree_->set_needs_update_draw_properties(); 2132 pending_tree_->set_needs_update_draw_properties();
2131 client_->UpdateRendererCapabilitiesOnImplThread(); 2133 client_->UpdateRendererCapabilitiesOnImplThread();
2132 } 2134 }
2133 2135
2134 void LayerTreeHostImpl::CreateTileManagerResources() { 2136 void LayerTreeHostImpl::CreateTileManagerResources() {
2135 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); 2137 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_);
2136 2138
2137 if (use_gpu_rasterization_) { 2139 if (use_gpu_rasterization_) {
2138 image_decode_controller_ = make_scoped_ptr(new GpuImageDecodeController); 2140 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController);
2139 } else { 2141 } else {
2140 image_decode_controller_ = 2142 image_decode_controller_ =
2141 make_scoped_ptr(new SoftwareImageDecodeController( 2143 base::WrapUnique(new SoftwareImageDecodeController(
2142 settings_.renderer_settings.preferred_tile_format)); 2144 settings_.renderer_settings.preferred_tile_format));
2143 } 2145 }
2144 2146
2145 // TODO(vmpstr): Initialize tile task limit at ctor time. 2147 // TODO(vmpstr): Initialize tile task limit at ctor time.
2146 tile_manager_->SetResources( 2148 tile_manager_->SetResources(
2147 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(), 2149 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(),
2148 image_decode_controller_.get(), 2150 image_decode_controller_.get(),
2149 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max() 2151 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max()
2150 : settings_.scheduled_raster_task_limit, 2152 : settings_.scheduled_raster_task_limit,
2151 use_gpu_rasterization_); 2153 use_gpu_rasterization_);
2152 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); 2154 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
2153 } 2155 }
2154 2156
2155 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( 2157 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
2156 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, 2158 std::unique_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
2157 scoped_ptr<ResourcePool>* resource_pool) { 2159 std::unique_ptr<ResourcePool>* resource_pool) {
2158 DCHECK(GetTaskRunner()); 2160 DCHECK(GetTaskRunner());
2159 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is 2161 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is
2160 // resolved. 2162 // resolved.
2161 CHECK(resource_provider_); 2163 CHECK(resource_provider_);
2162 2164
2163 // Pass the single-threaded synchronous task graph runner to the worker pool 2165 // Pass the single-threaded synchronous task graph runner to the worker pool
2164 // if we're in synchronous single-threaded mode. 2166 // if we're in synchronous single-threaded mode.
2165 TaskGraphRunner* task_graph_runner = task_graph_runner_; 2167 TaskGraphRunner* task_graph_runner = task_graph_runner_;
2166 if (is_synchronous_single_threaded_) { 2168 if (is_synchronous_single_threaded_) {
2167 DCHECK(!single_thread_synchronous_task_graph_runner_); 2169 DCHECK(!single_thread_synchronous_task_graph_runner_);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 if (request_ids.empty()) 2239 if (request_ids.empty())
2238 return; 2240 return;
2239 2241
2240 base::TimeTicks start_time = start_of_main_frame_args.frame_time; 2242 base::TimeTicks start_time = start_of_main_frame_args.frame_time;
2241 base::TimeTicks end_time = expected_next_main_frame_args.frame_time; 2243 base::TimeTicks end_time = expected_next_main_frame_args.frame_time;
2242 frame_timing_tracker_->SaveMainFrameTimeStamps( 2244 frame_timing_tracker_->SaveMainFrameTimeStamps(
2243 request_ids, start_time, end_time, active_tree_->source_frame_number()); 2245 request_ids, start_time, end_time, active_tree_->source_frame_number());
2244 } 2246 }
2245 2247
2246 void LayerTreeHostImpl::PostFrameTimingEvents( 2248 void LayerTreeHostImpl::PostFrameTimingEvents(
2247 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 2249 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
2248 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 2250 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
2249 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), 2251 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events),
2250 std::move(main_frame_events)); 2252 std::move(main_frame_events));
2251 } 2253 }
2252 2254
2253 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { 2255 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() {
2254 ClearUIResources(); 2256 ClearUIResources();
2255 tile_manager_->FinishTasksAndCleanUp(); 2257 tile_manager_->FinishTasksAndCleanUp();
2256 resource_pool_ = nullptr; 2258 resource_pool_ = nullptr;
2257 tile_task_worker_pool_ = nullptr; 2259 tile_task_worker_pool_ = nullptr;
2258 single_thread_synchronous_task_graph_runner_ = nullptr; 2260 single_thread_synchronous_task_graph_runner_ = nullptr;
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, 3311 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
3310 LayerImpl* root_layer) { 3312 LayerImpl* root_layer) {
3311 if (!root_layer) 3313 if (!root_layer)
3312 return; 3314 return;
3313 3315
3314 return root_layer->layer_tree_impl() 3316 return root_layer->layer_tree_impl()
3315 ->property_trees() 3317 ->property_trees()
3316 ->scroll_tree.CollectScrollDeltas(scroll_info); 3318 ->scroll_tree.CollectScrollDeltas(scroll_info);
3317 } 3319 }
3318 3320
3319 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { 3321 std::unique_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() {
3320 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); 3322 std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet());
3321 3323
3322 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); 3324 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer());
3323 scroll_info->page_scale_delta = 3325 scroll_info->page_scale_delta =
3324 active_tree_->page_scale_factor()->PullDeltaForMainThread(); 3326 active_tree_->page_scale_factor()->PullDeltaForMainThread();
3325 scroll_info->top_controls_delta = 3327 scroll_info->top_controls_delta =
3326 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread(); 3328 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread();
3327 scroll_info->elastic_overscroll_delta = 3329 scroll_info->elastic_overscroll_delta =
3328 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); 3330 active_tree_->elastic_overscroll()->PullDeltaForMainThread();
3329 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); 3331 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_);
3330 3332
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3423 // still request an extra SetNeedsAnimate here. 3425 // still request an extra SetNeedsAnimate here.
3424 if (animated) 3426 if (animated)
3425 SetNeedsOneBeginImplFrame(); 3427 SetNeedsOneBeginImplFrame();
3426 // TODO(crbug.com/551138): We could return true only if the animations are on 3428 // TODO(crbug.com/551138): We could return true only if the animations are on
3427 // the active tree. There's no need to cause a draw to take place from 3429 // the active tree. There's no need to cause a draw to take place from
3428 // animations starting/ticking on the pending tree. 3430 // animations starting/ticking on the pending tree.
3429 return animated; 3431 return animated;
3430 } 3432 }
3431 3433
3432 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { 3434 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
3433 scoped_ptr<AnimationEvents> events = animation_host_->CreateEvents(); 3435 std::unique_ptr<AnimationEvents> events = animation_host_->CreateEvents();
3434 3436
3435 const bool has_active_animations = animation_host_->UpdateAnimationState( 3437 const bool has_active_animations = animation_host_->UpdateAnimationState(
3436 start_ready_animations, events.get()); 3438 start_ready_animations, events.get());
3437 3439
3438 if (!events->events_.empty()) 3440 if (!events->events_.empty())
3439 client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events)); 3441 client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events));
3440 3442
3441 if (has_active_animations) 3443 if (has_active_animations)
3442 SetNeedsOneBeginImplFrame(); 3444 SetNeedsOneBeginImplFrame();
3443 } 3445 }
3444 3446
3445 void LayerTreeHostImpl::ActivateAnimations() { 3447 void LayerTreeHostImpl::ActivateAnimations() {
3446 const bool activated = animation_host_->ActivateAnimations(); 3448 const bool activated = animation_host_->ActivateAnimations();
3447 if (activated) { 3449 if (activated) {
3448 // Activating an animation changes layer draw properties, such as 3450 // Activating an animation changes layer draw properties, such as
3449 // screen_space_transform_is_animating. So when we see a new animation get 3451 // screen_space_transform_is_animating. So when we see a new animation get
3450 // activated, we need to update the draw properties on the active tree. 3452 // activated, we need to update the draw properties on the active tree.
3451 active_tree()->set_needs_update_draw_properties(); 3453 active_tree()->set_needs_update_draw_properties();
3452 // Request another frame to run the next tick of the animation. 3454 // Request another frame to run the next tick of the animation.
3453 SetNeedsOneBeginImplFrame(); 3455 SetNeedsOneBeginImplFrame();
3454 } 3456 }
3455 } 3457 }
3456 3458
3457 std::string LayerTreeHostImpl::LayerTreeAsJson() const { 3459 std::string LayerTreeHostImpl::LayerTreeAsJson() const {
3458 std::string str; 3460 std::string str;
3459 if (active_tree_->root_layer()) { 3461 if (active_tree_->root_layer()) {
3460 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson()); 3462 std::unique_ptr<base::Value> json(
3463 active_tree_->root_layer()->LayerTreeAsJson());
3461 base::JSONWriter::WriteWithOptions( 3464 base::JSONWriter::WriteWithOptions(
3462 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); 3465 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str);
3463 } 3466 }
3464 return str; 3467 return str;
3465 } 3468 }
3466 3469
3467 void LayerTreeHostImpl::RegisterScrollbarAnimationController( 3470 void LayerTreeHostImpl::RegisterScrollbarAnimationController(
3468 int scroll_layer_id) { 3471 int scroll_layer_id) {
3469 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) 3472 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR)
3470 return; 3473 return;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { 3552 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const {
3550 // TODO(mithro): Replace call with current_begin_frame_tracker_.Current() 3553 // TODO(mithro): Replace call with current_begin_frame_tracker_.Current()
3551 // once all calls which happens outside impl frames are fixed. 3554 // once all calls which happens outside impl frames are fixed.
3552 return current_begin_frame_tracker_.DangerousMethodCurrentOrLast(); 3555 return current_begin_frame_tracker_.DangerousMethodCurrentOrLast();
3553 } 3556 }
3554 3557
3555 base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const { 3558 base::TimeDelta LayerTreeHostImpl::CurrentBeginFrameInterval() const {
3556 return current_begin_frame_tracker_.Interval(); 3559 return current_begin_frame_tracker_.Interval();
3557 } 3560 }
3558 3561
3559 scoped_ptr<base::trace_event::ConvertableToTraceFormat> 3562 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
3560 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { 3563 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const {
3561 scoped_ptr<base::trace_event::TracedValue> state( 3564 std::unique_ptr<base::trace_event::TracedValue> state(
3562 new base::trace_event::TracedValue()); 3565 new base::trace_event::TracedValue());
3563 AsValueWithFrameInto(frame, state.get()); 3566 AsValueWithFrameInto(frame, state.get());
3564 return std::move(state); 3567 return std::move(state);
3565 } 3568 }
3566 3569
3567 void LayerTreeHostImpl::AsValueWithFrameInto( 3570 void LayerTreeHostImpl::AsValueWithFrameInto(
3568 FrameData* frame, 3571 FrameData* frame,
3569 base::trace_event::TracedValue* state) const { 3572 base::trace_event::TracedValue* state) const {
3570 if (this->pending_tree_) { 3573 if (this->pending_tree_) {
3571 state->BeginDictionary("activation_state"); 3574 state->BeginDictionary("activation_state");
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3717 std::set<UIResourceId>::iterator found_in_evicted = 3720 std::set<UIResourceId>::iterator found_in_evicted =
3718 evicted_ui_resources_.find(uid); 3721 evicted_ui_resources_.find(uid);
3719 if (found_in_evicted == evicted_ui_resources_.end()) 3722 if (found_in_evicted == evicted_ui_resources_.end())
3720 return; 3723 return;
3721 evicted_ui_resources_.erase(found_in_evicted); 3724 evicted_ui_resources_.erase(found_in_evicted);
3722 if (evicted_ui_resources_.empty()) 3725 if (evicted_ui_resources_.empty())
3723 client_->OnCanDrawStateChanged(CanDraw()); 3726 client_->OnCanDrawStateChanged(CanDraw());
3724 } 3727 }
3725 3728
3726 void LayerTreeHostImpl::ScheduleMicroBenchmark( 3729 void LayerTreeHostImpl::ScheduleMicroBenchmark(
3727 scoped_ptr<MicroBenchmarkImpl> benchmark) { 3730 std::unique_ptr<MicroBenchmarkImpl> benchmark) {
3728 micro_benchmark_controller_.ScheduleRun(std::move(benchmark)); 3731 micro_benchmark_controller_.ScheduleRun(std::move(benchmark));
3729 } 3732 }
3730 3733
3731 void LayerTreeHostImpl::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) { 3734 void LayerTreeHostImpl::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) {
3732 swap_promise_monitor_.insert(monitor); 3735 swap_promise_monitor_.insert(monitor);
3733 } 3736 }
3734 3737
3735 void LayerTreeHostImpl::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { 3738 void LayerTreeHostImpl::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) {
3736 swap_promise_monitor_.erase(monitor); 3739 swap_promise_monitor_.erase(monitor);
3737 } 3740 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 return task_runner_provider_->HasImplThread(); 3940 return task_runner_provider_->HasImplThread();
3938 } 3941 }
3939 3942
3940 bool LayerTreeHostImpl::CommitToActiveTree() const { 3943 bool LayerTreeHostImpl::CommitToActiveTree() const {
3941 // In single threaded mode we skip the pending tree and commit directly to the 3944 // In single threaded mode we skip the pending tree and commit directly to the
3942 // active tree. 3945 // active tree.
3943 return !task_runner_provider_->HasImplThread(); 3946 return !task_runner_provider_->HasImplThread();
3944 } 3947 }
3945 3948
3946 } // namespace cc 3949 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698