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

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

Issue 1910213005: cc: Refactor TileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_states
Patch Set: feedback Created 4 years, 7 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/test/test_hooks.cc ('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 <memory>
12 #include <set> 12 #include <set>
13 #include <unordered_map> 13 #include <unordered_map>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/macros.h" 17 #include "base/macros.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_worker_pool.h" 21 #include "cc/raster/raster_buffer_provider.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"
28 #include "cc/tiles/tile_draw_info.h" 28 #include "cc/tiles/tile_draw_info.h"
29 #include "cc/tiles/tile_task_manager.h"
29 30
30 namespace base { 31 namespace base {
31 namespace trace_event { 32 namespace trace_event {
32 class ConvertableToTraceFormat; 33 class ConvertableToTraceFormat;
33 class TracedValue; 34 class TracedValue;
34 } 35 }
35 } 36 }
36 37
37 namespace cc { 38 namespace cc {
38 class PictureLayerImpl; 39 class PictureLayerImpl;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 // Synchronously finish any in progress work, cancel the rest, and clean up as 112 // Synchronously finish any in progress work, cancel the rest, and clean up as
112 // much resources as possible. Also, prevents any future work until a 113 // much resources as possible. Also, prevents any future work until a
113 // SetResources call. 114 // SetResources call.
114 void FinishTasksAndCleanUp(); 115 void FinishTasksAndCleanUp();
115 116
116 // Set the new given resource pool and tile task runner. Note that 117 // Set the new given resource pool and tile task runner. Note that
117 // FinishTasksAndCleanUp must be called in between consecutive calls to 118 // FinishTasksAndCleanUp must be called in between consecutive calls to
118 // SetResources. 119 // SetResources.
119 void SetResources(ResourcePool* resource_pool, 120 void SetResources(ResourcePool* resource_pool,
120 TileTaskWorkerPool* tile_task_worker_pool,
121 ImageDecodeController* image_decode_controller, 121 ImageDecodeController* image_decode_controller,
122 TileTaskManager* tile_task_manager,
122 size_t scheduled_raster_task_limit, 123 size_t scheduled_raster_task_limit,
123 bool use_gpu_rasterization); 124 bool use_gpu_rasterization);
124 125
125 // This causes any completed raster work to finalize, so that tiles get up to 126 // This causes any completed raster work to finalize, so that tiles get up to
126 // date draw information. 127 // date draw information.
127 void Flush(); 128 void Flush();
128 129
129 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, 130 ScopedTilePtr CreateTile(const Tile::CreateInfo& info,
130 int layer_id, 131 int layer_id,
131 int source_frame_number, 132 int source_frame_number,
132 int flags); 133 int flags);
133 134
134 bool IsReadyToActivate() const; 135 bool IsReadyToActivate() const;
135 bool IsReadyToDraw() const; 136 bool IsReadyToDraw() const;
136 137
137 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 138 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
138 BasicStateAsValue() const; 139 BasicStateAsValue() const;
139 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; 140 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const;
140 const MemoryHistory::Entry& memory_stats_from_last_assign() const { 141 const MemoryHistory::Entry& memory_stats_from_last_assign() const {
141 return memory_stats_from_last_assign_; 142 return memory_stats_from_last_assign_;
142 } 143 }
143 144
144 // Public methods for testing. 145 // Public methods for testing.
145 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { 146 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) {
146 for (size_t i = 0; i < tiles.size(); ++i) { 147 for (size_t i = 0; i < tiles.size(); ++i) {
147 TileDrawInfo& draw_info = tiles[i]->draw_info(); 148 TileDrawInfo& draw_info = tiles[i]->draw_info();
148 draw_info.resource_ = resource_pool_->AcquireResource( 149 draw_info.resource_ = resource_pool_->AcquireResource(
149 tiles[i]->desired_texture_size(), 150 tiles[i]->desired_texture_size(),
150 tile_task_worker_pool_->GetResourceFormat(false)); 151 tile_task_manager_->GetRasterBufferProvider()->GetResourceFormat(
152 false));
151 } 153 }
152 } 154 }
153 155
154 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { 156 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) {
155 for (size_t i = 0; i < tiles.size(); ++i) { 157 for (size_t i = 0; i < tiles.size(); ++i) {
156 Tile* tile = tiles[i]; 158 Tile* tile = tiles[i];
157 FreeResourcesForTile(tile); 159 FreeResourcesForTile(tile);
158 } 160 }
159 } 161 }
160 162
161 void SetGlobalStateForTesting( 163 void SetGlobalStateForTesting(
162 const GlobalStateThatImpactsTilePriority& state) { 164 const GlobalStateThatImpactsTilePriority& state) {
163 global_state_ = state; 165 global_state_ = state;
164 } 166 }
165 167
166 void SetTileTaskWorkerPoolForTesting( 168 void SetTileTaskManagerForTesting(TileTaskManager* tile_task_manager);
167 TileTaskWorkerPool* tile_task_worker_pool);
168 169
169 void FreeResourcesAndCleanUpReleasedTilesForTesting() { 170 void FreeResourcesAndCleanUpReleasedTilesForTesting() {
170 FreeResourcesForReleasedTiles(); 171 FreeResourcesForReleasedTiles();
171 CleanUpReleasedTiles(); 172 CleanUpReleasedTiles();
172 } 173 }
173 174
174 std::vector<Tile*> AllTilesForTesting() const { 175 std::vector<Tile*> AllTilesForTesting() const {
175 std::vector<Tile*> tiles; 176 std::vector<Tile*> tiles;
176 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); 177 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end();
177 ++it) { 178 ++it) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 281
281 scoped_refptr<TileTask> CreateTaskSetFinishedTask( 282 scoped_refptr<TileTask> CreateTaskSetFinishedTask(
282 void (TileManager::*callback)()); 283 void (TileManager::*callback)());
283 284
284 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 285 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
285 ScheduledTasksStateAsValue() const; 286 ScheduledTasksStateAsValue() const;
286 287
287 TileManagerClient* client_; 288 TileManagerClient* client_;
288 scoped_refptr<base::SequencedTaskRunner> task_runner_; 289 scoped_refptr<base::SequencedTaskRunner> task_runner_;
289 ResourcePool* resource_pool_; 290 ResourcePool* resource_pool_;
290 TileTaskWorkerPool* tile_task_worker_pool_; 291 TileTaskManager* tile_task_manager_;
291 GlobalStateThatImpactsTilePriority global_state_; 292 GlobalStateThatImpactsTilePriority global_state_;
292 size_t scheduled_raster_task_limit_; 293 size_t scheduled_raster_task_limit_;
293 const bool use_partial_raster_; 294 const bool use_partial_raster_;
294 bool use_gpu_rasterization_; 295 bool use_gpu_rasterization_;
295 296
296 using TileMap = std::unordered_map<Tile::Id, Tile*>; 297 using TileMap = std::unordered_map<Tile::Id, Tile*>;
297 TileMap tiles_; 298 TileMap tiles_;
298 299
299 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; 300 bool all_tiles_that_need_to_be_rasterized_are_scheduled_;
300 MemoryHistory::Entry memory_stats_from_last_assign_; 301 MemoryHistory::Entry memory_stats_from_last_assign_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; 341 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_;
341 342
342 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; 343 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_;
343 344
344 DISALLOW_COPY_AND_ASSIGN(TileManager); 345 DISALLOW_COPY_AND_ASSIGN(TileManager);
345 }; 346 };
346 347
347 } // namespace cc 348 } // namespace cc
348 349
349 #endif // CC_TILES_TILE_MANAGER_H_ 350 #endif // CC_TILES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/test/test_hooks.cc ('k') | cc/tiles/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698