OLD | NEW |
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/rendering_stats.h" |
15 #include "cc/resource_pool.h" | 16 #include "cc/resource_pool.h" |
16 #include "cc/tile_priority.h" | 17 #include "cc/tile_priority.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 | 20 class RasterWorkerPool; |
20 class RasterThread; | |
21 class ResourceProvider; | 21 class ResourceProvider; |
22 class Tile; | 22 class Tile; |
23 class TileVersion; | 23 class TileVersion; |
24 struct RenderingStats; | |
25 | 24 |
26 class CC_EXPORT TileManagerClient { | 25 class CC_EXPORT TileManagerClient { |
27 public: | 26 public: |
28 virtual void ScheduleManageTiles() = 0; | 27 virtual void ScheduleManageTiles() = 0; |
29 virtual void ScheduleCheckForCompletedSetPixels() = 0; | 28 virtual void ScheduleCheckForCompletedSetPixels() = 0; |
30 | 29 |
31 protected: | 30 protected: |
32 virtual ~TileManagerClient() {} | 31 virtual ~TileManagerClient() {} |
33 }; | 32 }; |
34 | 33 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // should no longer have any memory assigned to them. Tile objects are "owned" | 72 // should no longer have any memory assigned to them. Tile objects are "owned" |
74 // by layers; they automatically register with the manager when they are | 73 // by layers; they automatically register with the manager when they are |
75 // created, and unregister from the manager when they are deleted. | 74 // created, and unregister from the manager when they are deleted. |
76 class CC_EXPORT TileManager { | 75 class CC_EXPORT TileManager { |
77 public: | 76 public: |
78 TileManager(TileManagerClient* client, | 77 TileManager(TileManagerClient* client, |
79 ResourceProvider *resource_provider, | 78 ResourceProvider *resource_provider, |
80 size_t num_raster_threads); | 79 size_t num_raster_threads); |
81 virtual ~TileManager(); | 80 virtual ~TileManager(); |
82 | 81 |
83 const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_
state_; } | 82 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
| 83 return global_state_; |
| 84 } |
84 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 85 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
85 | 86 |
86 void ManageTiles(); | 87 void ManageTiles(); |
87 void CheckForCompletedSetPixels(); | 88 void CheckForCompletedSetPixels(); |
88 void GetMemoryStats(size_t* memoryRequiredBytes, | 89 void GetMemoryStats(size_t* memoryRequiredBytes, |
89 size_t* memoryNiceToHaveBytes, | 90 size_t* memoryNiceToHaveBytes, |
90 size_t* memoryUsedBytes); | 91 size_t* memoryUsedBytes); |
91 | 92 |
92 void GetRenderingStats(RenderingStats* stats); | 93 void GetRenderingStats(RenderingStats* stats); |
93 | 94 |
94 int GetTilesInBinCount(TileManagerBin bin, WhichTree tree); | 95 int GetTilesInBinCount(TileManagerBin bin, WhichTree tree); |
95 int GetDrawableTilesInBinCount(TileManagerBin bin, WhichTree tree); | 96 int GetDrawableTilesInBinCount(TileManagerBin bin, WhichTree tree); |
96 | 97 |
97 protected: | 98 protected: |
98 // Methods called by Tile | 99 // Methods called by Tile |
99 friend class Tile; | 100 friend class Tile; |
100 void RegisterTile(Tile*); | 101 void RegisterTile(Tile* tile); |
101 void UnregisterTile(Tile*); | 102 void UnregisterTile(Tile* tile); |
102 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); | 103 void WillModifyTilePriority( |
| 104 Tile* tile, WhichTree tree, const TilePriority& new_priority); |
103 | 105 |
104 private: | 106 private: |
105 void ResetBinCounts(); | 107 void ResetBinCounts(); |
106 void AssignGpuMemoryToTiles(); | 108 void AssignGpuMemoryToTiles(); |
107 void FreeResourcesForTile(Tile*); | 109 void FreeResourcesForTile(Tile* tile); |
108 void ScheduleManageTiles(); | 110 void ScheduleManageTiles(); |
109 void ScheduleCheckForCompletedSetPixels(); | 111 void ScheduleCheckForCompletedSetPixels(); |
110 void DispatchMoreTasks(); | 112 void DispatchMoreTasks(); |
111 void DispatchOneRasterTask(RasterThread*, scoped_refptr<Tile>); | 113 void GatherPixelRefsForTile(Tile* tile); |
| 114 void DispatchImageDecodeTasksForTile(Tile* tile); |
| 115 void DispatchOneImageDecodeTask( |
| 116 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); |
| 117 void OnImageDecodeTaskCompleted( |
| 118 scoped_refptr<Tile> tile, uint32_t pixel_ref_id); |
| 119 void DispatchOneRasterTask(scoped_refptr<Tile> tile); |
112 void OnRasterTaskCompleted( | 120 void OnRasterTaskCompleted( |
113 scoped_refptr<Tile>, | 121 scoped_refptr<Tile> tile, |
114 scoped_ptr<ResourcePool::Resource>, | 122 scoped_ptr<ResourcePool::Resource> resource, |
115 scoped_refptr<PicturePileImpl>, | 123 int manage_tiles_call_count_when_dispatched); |
116 int manage_tiles_call_count_when_dispatched, | 124 void DidFinishTileInitialization(Tile* tile); |
117 RenderingStats*); | |
118 void DidFinishTileInitialization(Tile*); | |
119 void DispatchImageDecodingTasksForTile(Tile*); | |
120 void OnImageDecodingTaskCompleted(scoped_refptr<Tile>, | |
121 uint32_t, | |
122 RenderingStats*); | |
123 void DispatchOneImageDecodingTask( | |
124 RasterThread*, scoped_refptr<Tile>, skia::LazyPixelRef*); | |
125 void GatherPixelRefsForTile(Tile*); | |
126 RasterThread* GetFreeRasterThread(); | |
127 | 125 |
128 TileManagerClient* client_; | 126 TileManagerClient* client_; |
129 scoped_ptr<ResourcePool> resource_pool_; | 127 scoped_ptr<ResourcePool> resource_pool_; |
| 128 scoped_ptr<RasterWorkerPool> raster_worker_; |
130 bool manage_tiles_pending_; | 129 bool manage_tiles_pending_; |
131 int manage_tiles_call_count_; | 130 int manage_tiles_call_count_; |
132 bool check_for_completed_set_pixels_pending_; | 131 bool check_for_completed_set_pixels_pending_; |
133 | 132 |
134 GlobalStateThatImpactsTilePriority global_state_; | 133 GlobalStateThatImpactsTilePriority global_state_; |
135 | 134 |
136 int tiles_in_bin_count_[NUM_BINS][NUM_TREES]; | 135 int tiles_in_bin_count_[NUM_BINS][NUM_TREES]; |
137 int drawable_tiles_in_bin_count_[NUM_BINS][NUM_TREES]; | 136 int drawable_tiles_in_bin_count_[NUM_BINS][NUM_TREES]; |
138 | 137 |
139 typedef std::vector<Tile*> TileVector; | 138 typedef std::vector<Tile*> TileVector; |
140 TileVector tiles_; | 139 TileVector tiles_; |
141 TileVector tiles_that_need_to_be_rasterized_; | 140 TileVector tiles_that_need_to_be_rasterized_; |
142 | 141 |
143 typedef std::list<Tile*> TileList; | 142 typedef std::list<Tile*> TileList; |
144 // Tiles with image decoding tasks. These tiles need to be rasterized | 143 // Tiles with image decoding tasks. These tiles need to be rasterized |
145 // when all the image decoding tasks finish. | 144 // when all the image decoding tasks finish. |
146 TileList tiles_with_image_decoding_tasks_; | 145 TileList tiles_with_image_decoding_tasks_; |
147 | 146 |
148 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; | 147 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; |
149 PixelRefMap pending_decode_tasks_; | 148 PixelRefMap pending_decode_tasks_; |
150 | 149 |
151 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 150 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
152 TileQueue tiles_with_pending_set_pixels_; | 151 TileQueue tiles_with_pending_set_pixels_; |
153 | 152 |
154 typedef ScopedPtrVector<RasterThread> RasterThreadVector; | |
155 RasterThreadVector raster_threads_; | |
156 | |
157 RenderingStats rendering_stats_; | 153 RenderingStats rendering_stats_; |
158 | 154 |
159 DISALLOW_COPY_AND_ASSIGN(TileManager); | 155 DISALLOW_COPY_AND_ASSIGN(TileManager); |
160 }; | 156 }; |
161 | 157 |
162 } // namespace cc | 158 } // namespace cc |
163 | 159 |
164 #endif // CC_TILE_MANAGER_H_ | 160 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |