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

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: Post task to impl thread when worker pool becomes idle. 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;
30 virtual void ScheduleCheckForCompletedRasterTasks() = 0;
29 virtual void DidUploadVisibleHighResolutionTile() = 0; 31 virtual void DidUploadVisibleHighResolutionTile() = 0;
32 virtual void DidDetectIdleRaster() = 0;
30 33
31 protected: 34 protected:
32 virtual ~TileManagerClient() {} 35 virtual ~TileManagerClient() {}
33 }; 36 };
34 37
35 // Tile manager classifying tiles into a few basic 38 // Tile manager classifying tiles into a few basic
36 // bins: 39 // bins:
37 enum TileManagerBin { 40 enum TileManagerBin {
38 NOW_BIN = 0, // Needed ASAP. 41 NOW_BIN = 0, // Needed ASAP.
39 SOON_BIN = 1, // Impl-side version of prepainting. 42 SOON_BIN = 1, // Impl-side version of prepainting.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // send to the GPU memory manager to determine policy. 91 // send to the GPU memory manager to determine policy.
89 TileManagerBin gpu_memmgr_stats_bin; 92 TileManagerBin gpu_memmgr_stats_bin;
90 TileResolution resolution; 93 TileResolution resolution;
91 float time_to_needed_in_seconds; 94 float time_to_needed_in_seconds;
92 }; 95 };
93 96
94 // This class manages tiles, deciding which should get rasterized and which 97 // This class manages tiles, deciding which should get rasterized and which
95 // should no longer have any memory assigned to them. Tile objects are "owned" 98 // should no longer have any memory assigned to them. Tile objects are "owned"
96 // by layers; they automatically register with the manager when they are 99 // by layers; they automatically register with the manager when they are
97 // created, and unregister from the manager when they are deleted. 100 // created, and unregister from the manager when they are deleted.
98 class CC_EXPORT TileManager { 101 class CC_EXPORT TileManager : public WorkerPoolClient {
99 public: 102 public:
100 TileManager(TileManagerClient* client, 103 TileManager(TileManagerClient* client,
101 ResourceProvider *resource_provider, 104 ResourceProvider *resource_provider,
102 size_t num_raster_threads, 105 size_t num_raster_threads,
103 bool use_cheapess_estimator); 106 bool use_cheapess_estimator);
104 virtual ~TileManager(); 107 virtual ~TileManager();
105 108
106 const GlobalStateThatImpactsTilePriority& GlobalState() const { 109 const GlobalStateThatImpactsTilePriority& GlobalState() const {
107 return global_state_; 110 return global_state_;
108 } 111 }
109 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); 112 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state);
110 113
111 void ManageTiles(); 114 void ManageTiles();
115 void CheckForCompletedRasterTasks();
112 void CheckForCompletedTileUploads(); 116 void CheckForCompletedTileUploads();
113 void AbortPendingTileUploads(); 117 void AbortPendingTileUploads();
114 118
115 scoped_ptr<base::Value> BasicStateAsValue() const; 119 scoped_ptr<base::Value> BasicStateAsValue() const;
116 scoped_ptr<base::Value> AllTilesAsValue() const; 120 scoped_ptr<base::Value> AllTilesAsValue() const;
117 void GetMemoryStats(size_t* memoryRequiredBytes, 121 void GetMemoryStats(size_t* memoryRequiredBytes,
118 size_t* memoryNiceToHaveBytes, 122 size_t* memoryNiceToHaveBytes,
119 size_t* memoryUsedBytes) const; 123 size_t* memoryUsedBytes) const;
120 void SetRecordRenderingStats(bool record_rendering_stats); 124 void SetRecordRenderingStats(bool record_rendering_stats);
121 void GetRenderingStats(RenderingStats* stats); 125 void GetRenderingStats(RenderingStats* stats);
122 bool HasPendingWorkScheduled(WhichTree tree) const; 126 bool HasPendingWorkScheduled(WhichTree tree) const;
123 127
124 const MemoryHistory::Entry& memory_stats_from_last_assign() const { return mem ory_stats_from_last_assign_; } 128 const MemoryHistory::Entry& memory_stats_from_last_assign() const { return mem ory_stats_from_last_assign_; }
125 129
130 // Overridden from WorkerPoolClient:
131 virtual void OnIdle() OVERRIDE;
132
126 protected: 133 protected:
127 // Methods called by Tile 134 // Methods called by Tile
128 friend class Tile; 135 friend class Tile;
129 void RegisterTile(Tile* tile); 136 void RegisterTile(Tile* tile);
130 void UnregisterTile(Tile* tile); 137 void UnregisterTile(Tile* tile);
131 void WillModifyTilePriority( 138 void WillModifyTilePriority(
132 Tile* tile, WhichTree tree, const TilePriority& new_priority) { 139 Tile* tile, WhichTree tree, const TilePriority& new_priority) {
133 // TODO(nduca): Do something smarter if reprioritization turns out to be 140 // TODO(nduca): Do something smarter if reprioritization turns out to be
134 // costly. 141 // costly.
135 ScheduleManageTiles(); 142 ScheduleManageTiles();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 typedef std::list<Tile*> TileList; 205 typedef std::list<Tile*> TileList;
199 // Tiles with image decoding tasks. These tiles need to be rasterized 206 // Tiles with image decoding tasks. These tiles need to be rasterized
200 // when all the image decoding tasks finish. 207 // when all the image decoding tasks finish.
201 TileList tiles_with_image_decoding_tasks_; 208 TileList tiles_with_image_decoding_tasks_;
202 209
203 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; 210 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap;
204 PixelRefMap pending_decode_tasks_; 211 PixelRefMap pending_decode_tasks_;
205 212
206 typedef std::queue<scoped_refptr<Tile> > TileQueue; 213 typedef std::queue<scoped_refptr<Tile> > TileQueue;
207 TileQueue tiles_with_pending_set_pixels_; 214 TileQueue tiles_with_pending_set_pixels_;
208 size_t bytes_pending_set_pixels_;
209 bool ever_exceeded_memory_budget_; 215 bool ever_exceeded_memory_budget_;
210 MemoryHistory::Entry memory_stats_from_last_assign_; 216 MemoryHistory::Entry memory_stats_from_last_assign_;
211 217
218 size_t bytes_pending_raster_;
219 size_t bytes_pending_set_pixels_;
220
212 bool record_rendering_stats_; 221 bool record_rendering_stats_;
213 RenderingStats rendering_stats_; 222 RenderingStats rendering_stats_;
214 223
215 bool use_cheapness_estimator_; 224 bool use_cheapness_estimator_;
216 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; 225 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS];
217 226
218 DISALLOW_COPY_AND_ASSIGN(TileManager); 227 DISALLOW_COPY_AND_ASSIGN(TileManager);
219 }; 228 };
220 229
221 } // namespace cc 230 } // namespace cc
222 231
223 #endif // CC_TILE_MANAGER_H_ 232 #endif // CC_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/thread_proxy.cc ('k') | cc/tile_manager.cc » ('j') | cc/worker_pool.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698