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

Side by Side Diff: cc/tiles/tile_manager.h

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase 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
« no previous file with comments | « cc/tiles/tile_draw_info.h ('k') | cc/tiles/tile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CC_TILES_TILE_MANAGER_H_ 5 #ifndef CC_TILES_TILE_MANAGER_H_
6 #define CC_TILES_TILE_MANAGER_H_ 6 #define CC_TILES_TILE_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory>
11 #include <set> 12 #include <set>
12 #include <unordered_map> 13 #include <unordered_map>
13 #include <utility> 14 #include <utility>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "cc/base/unique_notifier.h" 19 #include "cc/base/unique_notifier.h"
20 #include "cc/playback/raster_source.h" 20 #include "cc/playback/raster_source.h"
21 #include "cc/raster/tile_task_runner.h" 21 #include "cc/raster/tile_task_runner.h"
22 #include "cc/resources/memory_history.h" 22 #include "cc/resources/memory_history.h"
23 #include "cc/resources/resource_pool.h" 23 #include "cc/resources/resource_pool.h"
24 #include "cc/tiles/eviction_tile_priority_queue.h" 24 #include "cc/tiles/eviction_tile_priority_queue.h"
25 #include "cc/tiles/image_decode_controller.h" 25 #include "cc/tiles/image_decode_controller.h"
26 #include "cc/tiles/raster_tile_priority_queue.h" 26 #include "cc/tiles/raster_tile_priority_queue.h"
27 #include "cc/tiles/tile.h" 27 #include "cc/tiles/tile.h"
(...skipping 25 matching lines...) Expand all
53 // Called when the visible representation of a tile might have changed. Some 53 // Called when the visible representation of a tile might have changed. Some
54 // examples are: 54 // examples are:
55 // - Tile version initialized. 55 // - Tile version initialized.
56 // - Tile resources freed. 56 // - Tile resources freed.
57 // - Tile marked for on-demand raster. 57 // - Tile marked for on-demand raster.
58 virtual void NotifyTileStateChanged(const Tile* tile) = 0; 58 virtual void NotifyTileStateChanged(const Tile* tile) = 0;
59 59
60 // Given an empty raster tile priority queue, this will build a priority queue 60 // Given an empty raster tile priority queue, this will build a priority queue
61 // that will return tiles in order in which they should be rasterized. 61 // that will return tiles in order in which they should be rasterized.
62 // Note if the queue was previous built, Reset must be called on it. 62 // Note if the queue was previous built, Reset must be called on it.
63 virtual scoped_ptr<RasterTilePriorityQueue> BuildRasterQueue( 63 virtual std::unique_ptr<RasterTilePriorityQueue> BuildRasterQueue(
64 TreePriority tree_priority, 64 TreePriority tree_priority,
65 RasterTilePriorityQueue::Type type) = 0; 65 RasterTilePriorityQueue::Type type) = 0;
66 66
67 // Given an empty eviction tile priority queue, this will build a priority 67 // Given an empty eviction tile priority queue, this will build a priority
68 // queue that will return tiles in order in which they should be evicted. 68 // queue that will return tiles in order in which they should be evicted.
69 // Note if the queue was previous built, Reset must be called on it. 69 // Note if the queue was previous built, Reset must be called on it.
70 virtual scoped_ptr<EvictionTilePriorityQueue> BuildEvictionQueue( 70 virtual std::unique_ptr<EvictionTilePriorityQueue> BuildEvictionQueue(
71 TreePriority tree_priority) = 0; 71 TreePriority tree_priority) = 0;
72 72
73 // Informs the client that due to the currently rasterizing (or scheduled to 73 // Informs the client that due to the currently rasterizing (or scheduled to
74 // be rasterized) tiles, we will be in a position that will likely require a 74 // be rasterized) tiles, we will be in a position that will likely require a
75 // draw. This can be used to preemptively start a frame. 75 // draw. This can be used to preemptively start a frame.
76 virtual void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) = 0; 76 virtual void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) = 0;
77 77
78 protected: 78 protected:
79 virtual ~TileManagerClient() {} 79 virtual ~TileManagerClient() {}
80 }; 80 };
81 81
82 struct RasterTaskCompletionStats { 82 struct RasterTaskCompletionStats {
83 RasterTaskCompletionStats(); 83 RasterTaskCompletionStats();
84 84
85 size_t completed_count; 85 size_t completed_count;
86 size_t canceled_count; 86 size_t canceled_count;
87 }; 87 };
88 scoped_ptr<base::trace_event::ConvertableToTraceFormat> 88 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
89 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); 89 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats);
90 90
91 // This class manages tiles, deciding which should get rasterized and which 91 // This class manages tiles, deciding which should get rasterized and which
92 // should no longer have any memory assigned to them. Tile objects are "owned" 92 // should no longer have any memory assigned to them. Tile objects are "owned"
93 // by layers; they automatically register with the manager when they are 93 // by layers; they automatically register with the manager when they are
94 // created, and unregister from the manager when they are deleted. 94 // created, and unregister from the manager when they are deleted.
95 class CC_EXPORT TileManager { 95 class CC_EXPORT TileManager {
96 public: 96 public:
97 static scoped_ptr<TileManager> Create(TileManagerClient* client, 97 static std::unique_ptr<TileManager> Create(
98 base::SequencedTaskRunner* task_runner, 98 TileManagerClient* client,
99 size_t scheduled_raster_task_limit, 99 base::SequencedTaskRunner* task_runner,
100 bool use_partial_raster); 100 size_t scheduled_raster_task_limit,
101 bool use_partial_raster);
101 virtual ~TileManager(); 102 virtual ~TileManager();
102 103
103 // Assigns tile memory and schedules work to prepare tiles for drawing. 104 // Assigns tile memory and schedules work to prepare tiles for drawing.
104 // - Runs client_->NotifyReadyToActivate() when all tiles required for 105 // - Runs client_->NotifyReadyToActivate() when all tiles required for
105 // activation are prepared, or failed to prepare due to OOM. 106 // activation are prepared, or failed to prepare due to OOM.
106 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are 107 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are
107 // prepared, or failed to prepare due to OOM. 108 // prepared, or failed to prepare due to OOM.
108 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); 109 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state);
109 110
110 // Synchronously finish any in progress work, cancel the rest, and clean up as 111 // Synchronously finish any in progress work, cancel the rest, and clean up as
(...skipping 15 matching lines...) Expand all
126 void Flush(); 127 void Flush();
127 128
128 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, 129 ScopedTilePtr CreateTile(const Tile::CreateInfo& info,
129 int layer_id, 130 int layer_id,
130 int source_frame_number, 131 int source_frame_number,
131 int flags); 132 int flags);
132 133
133 bool IsReadyToActivate() const; 134 bool IsReadyToActivate() const;
134 bool IsReadyToDraw() const; 135 bool IsReadyToDraw() const;
135 136
136 scoped_ptr<base::trace_event::ConvertableToTraceFormat> BasicStateAsValue() 137 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
137 const; 138 BasicStateAsValue() const;
138 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; 139 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const;
139 const MemoryHistory::Entry& memory_stats_from_last_assign() const { 140 const MemoryHistory::Entry& memory_stats_from_last_assign() const {
140 return memory_stats_from_last_assign_; 141 return memory_stats_from_last_assign_;
141 } 142 }
142 143
143 // Public methods for testing. 144 // Public methods for testing.
144 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { 145 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) {
145 for (size_t i = 0; i < tiles.size(); ++i) { 146 for (size_t i = 0; i < tiles.size(); ++i) {
146 TileDrawInfo& draw_info = tiles[i]->draw_info(); 147 TileDrawInfo& draw_info = tiles[i]->draw_info();
147 draw_info.resource_ = resource_pool_->AcquireResource( 148 draw_info.resource_ = resource_pool_->AcquireResource(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void OnRasterTaskCompleted( 245 void OnRasterTaskCompleted(
245 Tile::Id tile, 246 Tile::Id tile,
246 Resource* resource, 247 Resource* resource,
247 bool was_canceled); 248 bool was_canceled);
248 249
249 void FreeResourcesForTile(Tile* tile); 250 void FreeResourcesForTile(Tile* tile);
250 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); 251 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile);
251 scoped_refptr<RasterTask> CreateRasterTask( 252 scoped_refptr<RasterTask> CreateRasterTask(
252 const PrioritizedTile& prioritized_tile); 253 const PrioritizedTile& prioritized_tile);
253 254
254 scoped_ptr<EvictionTilePriorityQueue> 255 std::unique_ptr<EvictionTilePriorityQueue>
255 FreeTileResourcesUntilUsageIsWithinLimit( 256 FreeTileResourcesUntilUsageIsWithinLimit(
256 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue, 257 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue,
257 const MemoryUsage& limit, 258 const MemoryUsage& limit,
258 MemoryUsage* usage); 259 MemoryUsage* usage);
259 scoped_ptr<EvictionTilePriorityQueue> 260 std::unique_ptr<EvictionTilePriorityQueue>
260 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( 261 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit(
261 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue, 262 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue,
262 const MemoryUsage& limit, 263 const MemoryUsage& limit,
263 const TilePriority& oother_priority, 264 const TilePriority& oother_priority,
264 MemoryUsage* usage); 265 MemoryUsage* usage);
265 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); 266 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority);
266 bool AreRequiredTilesReadyToDraw(RasterTilePriorityQueue::Type type) const; 267 bool AreRequiredTilesReadyToDraw(RasterTilePriorityQueue::Type type) const;
267 void CheckIfMoreTilesNeedToBePrepared(); 268 void CheckIfMoreTilesNeedToBePrepared();
268 void CheckAndIssueSignals(); 269 void CheckAndIssueSignals();
269 bool MarkTilesOutOfMemory(scoped_ptr<RasterTilePriorityQueue> queue) const; 270 bool MarkTilesOutOfMemory(
271 std::unique_ptr<RasterTilePriorityQueue> queue) const;
270 272
271 ResourceFormat DetermineResourceFormat(const Tile* tile) const; 273 ResourceFormat DetermineResourceFormat(const Tile* tile) const;
272 bool DetermineResourceRequiresSwizzle(const Tile* tile) const; 274 bool DetermineResourceRequiresSwizzle(const Tile* tile) const;
273 275
274 void DidFinishRunningTileTasksRequiredForActivation(); 276 void DidFinishRunningTileTasksRequiredForActivation();
275 void DidFinishRunningTileTasksRequiredForDraw(); 277 void DidFinishRunningTileTasksRequiredForDraw();
276 void DidFinishRunningAllTileTasks(); 278 void DidFinishRunningAllTileTasks();
277 279
278 scoped_refptr<TileTask> CreateTaskSetFinishedTask( 280 scoped_refptr<TileTask> CreateTaskSetFinishedTask(
279 void (TileManager::*callback)()); 281 void (TileManager::*callback)());
280 282
281 scoped_ptr<base::trace_event::ConvertableToTraceFormat> 283 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
282 ScheduledTasksStateAsValue() const; 284 ScheduledTasksStateAsValue() const;
283 285
284 TileManagerClient* client_; 286 TileManagerClient* client_;
285 scoped_refptr<base::SequencedTaskRunner> task_runner_; 287 scoped_refptr<base::SequencedTaskRunner> task_runner_;
286 ResourcePool* resource_pool_; 288 ResourcePool* resource_pool_;
287 TileTaskRunner* tile_task_runner_; 289 TileTaskRunner* tile_task_runner_;
288 GlobalStateThatImpactsTilePriority global_state_; 290 GlobalStateThatImpactsTilePriority global_state_;
289 size_t scheduled_raster_task_limit_; 291 size_t scheduled_raster_task_limit_;
290 const bool use_partial_raster_; 292 const bool use_partial_raster_;
291 bool use_gpu_rasterization_; 293 bool use_gpu_rasterization_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; 339 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_;
338 340
339 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; 341 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_;
340 342
341 DISALLOW_COPY_AND_ASSIGN(TileManager); 343 DISALLOW_COPY_AND_ASSIGN(TileManager);
342 }; 344 };
343 345
344 } // namespace cc 346 } // namespace cc
345 347
346 #endif // CC_TILES_TILE_MANAGER_H_ 348 #endif // CC_TILES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/tiles/tile_draw_info.h ('k') | cc/tiles/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698