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

Side by Side Diff: cc/tile_manager.h

Issue 12217105: cc: Check for completed raster tasks at interval. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch back to kNumPendingTasksPerWorker, seems good enough for now Created 7 years, 10 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 | Annotate | Revision Log
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_TILE_MANAGER_H_ 5 #ifndef CC_TILE_MANAGER_H_
6 #define CC_TILE_MANAGER_H_ 6 #define CC_TILE_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <queue> 9 #include <queue>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "cc/memory_history.h" 15 #include "cc/memory_history.h"
16 #include "cc/rendering_stats.h" 16 #include "cc/rendering_stats.h"
17 #include "cc/resource_pool.h" 17 #include "cc/resource_pool.h"
18 #include "cc/tile_priority.h" 18 #include "cc/tile_priority.h"
19 #include "cc/worker_pool.h"
19 20
20 namespace cc { 21 namespace cc {
21 class RasterWorkerPool; 22 class RasterWorkerPool;
22 class ResourceProvider; 23 class ResourceProvider;
23 class Tile; 24 class Tile;
24 class TileVersion; 25 class TileVersion;
25 26
26 class CC_EXPORT TileManagerClient { 27 class CC_EXPORT TileManagerClient {
27 public: 28 public:
28 virtual void ScheduleManageTiles() = 0; 29 virtual void ScheduleManageTiles() = 0;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // send to the GPU memory manager to determine policy. 95 // send to the GPU memory manager to determine policy.
95 TileManagerBin gpu_memmgr_stats_bin; 96 TileManagerBin gpu_memmgr_stats_bin;
96 TileResolution resolution; 97 TileResolution resolution;
97 float time_to_needed_in_seconds; 98 float time_to_needed_in_seconds;
98 }; 99 };
99 100
100 // This class manages tiles, deciding which should get rasterized and which 101 // This class manages tiles, deciding which should get rasterized and which
101 // should no longer have any memory assigned to them. Tile objects are "owned" 102 // should no longer have any memory assigned to them. Tile objects are "owned"
102 // by layers; they automatically register with the manager when they are 103 // by layers; they automatically register with the manager when they are
103 // created, and unregister from the manager when they are deleted. 104 // created, and unregister from the manager when they are deleted.
104 class CC_EXPORT TileManager { 105 class CC_EXPORT TileManager : public WorkerPoolClient {
105 public: 106 public:
106 TileManager(TileManagerClient* client, 107 TileManager(TileManagerClient* client,
107 ResourceProvider *resource_provider, 108 ResourceProvider *resource_provider,
108 size_t num_raster_threads, 109 size_t num_raster_threads,
109 bool use_cheapess_estimator); 110 bool use_cheapess_estimator);
110 virtual ~TileManager(); 111 virtual ~TileManager();
111 112
112 const GlobalStateThatImpactsTilePriority& GlobalState() const { 113 const GlobalStateThatImpactsTilePriority& GlobalState() const {
113 return global_state_; 114 return global_state_;
114 } 115 }
115 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); 116 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state);
116 117
117 void ManageTiles(); 118 void ManageTiles();
118 void CheckForCompletedTileUploads(); 119 void CheckForCompletedTileUploads();
119 void AbortPendingTileUploads(); 120 void AbortPendingTileUploads();
120 121
121 scoped_ptr<base::Value> BasicStateAsValue() const; 122 scoped_ptr<base::Value> BasicStateAsValue() const;
122 scoped_ptr<base::Value> AllTilesAsValue() const; 123 scoped_ptr<base::Value> AllTilesAsValue() const;
123 void GetMemoryStats(size_t* memoryRequiredBytes, 124 void GetMemoryStats(size_t* memoryRequiredBytes,
124 size_t* memoryNiceToHaveBytes, 125 size_t* memoryNiceToHaveBytes,
125 size_t* memoryUsedBytes) const; 126 size_t* memoryUsedBytes) const;
126 void SetRecordRenderingStats(bool record_rendering_stats); 127 void SetRecordRenderingStats(bool record_rendering_stats);
127 void GetRenderingStats(RenderingStats* stats); 128 void GetRenderingStats(RenderingStats* stats);
128 bool HasPendingWorkScheduled(WhichTree tree) const; 129 bool HasPendingWorkScheduled(WhichTree tree) const;
129 130
130 const MemoryHistory::Entry& memory_stats_from_last_assign() const { return mem ory_stats_from_last_assign_; } 131 const MemoryHistory::Entry& memory_stats_from_last_assign() const {
132 return memory_stats_from_last_assign_;
133 }
134
135 // Overridden from WorkerPoolClient:
136 virtual void DidFinishDispatchingWorkerPoolCompletionCallbacks() OVERRIDE;
131 137
132 protected: 138 protected:
133 // Methods called by Tile 139 // Methods called by Tile
134 friend class Tile; 140 friend class Tile;
135 void RegisterTile(Tile* tile); 141 void RegisterTile(Tile* tile);
136 void UnregisterTile(Tile* tile); 142 void UnregisterTile(Tile* tile);
137 void WillModifyTilePriority( 143 void WillModifyTilePriority(
138 Tile* tile, WhichTree tree, const TilePriority& new_priority) { 144 Tile* tile, WhichTree tree, const TilePriority& new_priority) {
139 // TODO(nduca): Do something smarter if reprioritization turns out to be 145 // TODO(nduca): Do something smarter if reprioritization turns out to be
140 // costly. 146 // costly.
141 ScheduleManageTiles(); 147 ScheduleManageTiles();
142 } 148 }
143 149
144 private: 150 private:
145 void SortTiles(); 151 void SortTiles();
146 void AssignGpuMemoryToTiles(); 152 void AssignGpuMemoryToTiles();
147 void FreeResourcesForTile(Tile* tile); 153 void FreeResourcesForTile(Tile* tile);
148 void ScheduleManageTiles() { 154 void ScheduleManageTiles() {
149 if (manage_tiles_pending_) 155 if (manage_tiles_pending_)
150 return; 156 return;
151 client_->ScheduleManageTiles(); 157 client_->ScheduleManageTiles();
152 manage_tiles_pending_ = true; 158 manage_tiles_pending_ = true;
153 } 159 }
154 void DispatchMoreTasks(); 160 void DispatchMoreTasks();
155 void GatherPixelRefsForTile(Tile* tile); 161 void GatherPixelRefsForTile(Tile* tile);
156 void DispatchImageDecodeTasksForTile(Tile* tile); 162 void DispatchImageDecodeTasksForTile(Tile* tile);
157 void DispatchOneImageDecodeTask( 163 void DispatchOneImageDecodeTask(
158 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); 164 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref);
159 void OnImageDecodeTaskCompleted( 165 void OnImageDecodeTaskCompleted(
160 scoped_refptr<Tile> tile, uint32_t pixel_ref_id); 166 scoped_refptr<Tile> tile,
167 uint32_t pixel_ref_id);
161 bool CanDispatchRasterTask(Tile* tile); 168 bool CanDispatchRasterTask(Tile* tile);
162 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); 169 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile);
163 void DispatchOneRasterTask(scoped_refptr<Tile> tile); 170 void DispatchOneRasterTask(scoped_refptr<Tile> tile);
164 void PerformOneRaster(Tile* tile); 171 void PerformOneRaster(Tile* tile);
165 void OnRasterCompleted( 172 void OnRasterCompleted(
166 scoped_refptr<Tile> tile, 173 scoped_refptr<Tile> tile,
167 scoped_ptr<ResourcePool::Resource> resource, 174 scoped_ptr<ResourcePool::Resource> resource,
168 int manage_tiles_call_count_when_dispatched); 175 int manage_tiles_call_count_when_dispatched);
169 void OnRasterTaskCompleted( 176 void OnRasterTaskCompleted(
170 scoped_refptr<Tile> tile, 177 scoped_refptr<Tile> tile,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Tiles with image decoding tasks. These tiles need to be rasterized 214 // Tiles with image decoding tasks. These tiles need to be rasterized
208 // when all the image decoding tasks finish. 215 // when all the image decoding tasks finish.
209 TileList tiles_with_image_decoding_tasks_; 216 TileList tiles_with_image_decoding_tasks_;
210 217
211 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; 218 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap;
212 PixelRefMap pending_decode_tasks_; 219 PixelRefMap pending_decode_tasks_;
213 220
214 typedef std::queue<scoped_refptr<Tile> > TileQueue; 221 typedef std::queue<scoped_refptr<Tile> > TileQueue;
215 TileQueue tiles_with_pending_set_pixels_; 222 TileQueue tiles_with_pending_set_pixels_;
216 size_t bytes_pending_set_pixels_; 223 size_t bytes_pending_set_pixels_;
224 bool has_performed_uploads_since_last_flush_;
217 bool ever_exceeded_memory_budget_; 225 bool ever_exceeded_memory_budget_;
218 MemoryHistory::Entry memory_stats_from_last_assign_; 226 MemoryHistory::Entry memory_stats_from_last_assign_;
219 227
220 bool record_rendering_stats_; 228 bool record_rendering_stats_;
221 RenderingStats rendering_stats_; 229 RenderingStats rendering_stats_;
222 230
223 bool use_cheapness_estimator_; 231 bool use_cheapness_estimator_;
224 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; 232 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS];
225 233
226 DISALLOW_COPY_AND_ASSIGN(TileManager); 234 DISALLOW_COPY_AND_ASSIGN(TileManager);
227 }; 235 };
228 236
229 } // namespace cc 237 } // namespace cc
230 238
231 #endif // CC_TILE_MANAGER_H_ 239 #endif // CC_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/raster_worker_pool.cc ('k') | cc/tile_manager.cc » ('j') | cc/worker_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698