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_RESOURCES_TILE_MANAGER_H_ | 5 #ifndef CC_RESOURCES_TILE_MANAGER_H_ |
6 #define CC_RESOURCES_TILE_MANAGER_H_ | 6 #define CC_RESOURCES_TILE_MANAGER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/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/base/ref_counted_managed.h" | 15 #include "cc/base/ref_counted_managed.h" |
16 #include "cc/debug/rendering_stats_instrumentation.h" | 16 #include "cc/debug/rendering_stats_instrumentation.h" |
| 17 #include "cc/resources/gpu_rasterizer.h" |
17 #include "cc/resources/managed_tile_state.h" | 18 #include "cc/resources/managed_tile_state.h" |
18 #include "cc/resources/memory_history.h" | 19 #include "cc/resources/memory_history.h" |
19 #include "cc/resources/picture_pile_impl.h" | 20 #include "cc/resources/picture_pile_impl.h" |
20 #include "cc/resources/prioritized_tile_set.h" | 21 #include "cc/resources/prioritized_tile_set.h" |
21 #include "cc/resources/raster_worker_pool.h" | 22 #include "cc/resources/raster_worker_pool.h" |
22 #include "cc/resources/resource_pool.h" | 23 #include "cc/resources/resource_pool.h" |
23 #include "cc/resources/tile.h" | 24 #include "cc/resources/tile.h" |
24 | 25 |
25 namespace cc { | 26 namespace cc { |
26 class ResourceProvider; | 27 class ResourceProvider; |
(...skipping 13 matching lines...) Expand all Loading... |
40 size_t canceled_count; | 41 size_t canceled_count; |
41 }; | 42 }; |
42 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( | 43 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( |
43 const RasterTaskCompletionStats& stats); | 44 const RasterTaskCompletionStats& stats); |
44 | 45 |
45 // This class manages tiles, deciding which should get rasterized and which | 46 // This class manages tiles, deciding which should get rasterized and which |
46 // should no longer have any memory assigned to them. Tile objects are "owned" | 47 // should no longer have any memory assigned to them. Tile objects are "owned" |
47 // by layers; they automatically register with the manager when they are | 48 // by layers; they automatically register with the manager when they are |
48 // created, and unregister from the manager when they are deleted. | 49 // created, and unregister from the manager when they are deleted. |
49 class CC_EXPORT TileManager : public RasterWorkerPoolClient, | 50 class CC_EXPORT TileManager : public RasterWorkerPoolClient, |
| 51 public GpuRasterizerClient, |
50 public RefCountedManager<Tile> { | 52 public RefCountedManager<Tile> { |
51 public: | 53 public: |
52 static scoped_ptr<TileManager> Create( | 54 static scoped_ptr<TileManager> Create( |
53 TileManagerClient* client, | 55 TileManagerClient* client, |
54 ResourceProvider* resource_provider, | 56 ResourceProvider* resource_provider, |
| 57 ContextProvider* context_provider, |
55 size_t num_raster_threads, | 58 size_t num_raster_threads, |
56 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 59 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
57 bool use_map_image, | 60 bool use_map_image, |
58 size_t max_transfer_buffer_usage_bytes, | 61 size_t max_transfer_buffer_usage_bytes, |
59 size_t max_raster_usage_bytes, | 62 size_t max_raster_usage_bytes, |
60 GLenum map_image_texture_target); | 63 GLenum map_image_texture_target); |
61 virtual ~TileManager(); | 64 virtual ~TileManager(); |
62 | 65 |
63 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); | 66 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); |
64 | 67 |
65 // Returns true when visible tiles have been initialized. | 68 // Returns true when visible tiles have been initialized. |
66 bool UpdateVisibleTiles(); | 69 bool UpdateVisibleTiles(); |
67 | 70 |
68 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, | 71 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, |
69 gfx::Size tile_size, | 72 gfx::Size tile_size, |
70 gfx::Rect content_rect, | 73 gfx::Rect content_rect, |
71 gfx::Rect opaque_rect, | 74 gfx::Rect opaque_rect, |
72 float contents_scale, | 75 float contents_scale, |
73 int layer_id, | 76 int layer_id, |
74 int source_frame_number, | 77 int source_frame_number, |
75 bool can_use_lcd_text); | 78 bool can_use_lcd_text, |
| 79 bool use_gpu_rasterizer); |
76 | 80 |
77 scoped_ptr<base::Value> BasicStateAsValue() const; | 81 scoped_ptr<base::Value> BasicStateAsValue() const; |
78 scoped_ptr<base::Value> AllTilesAsValue() const; | 82 scoped_ptr<base::Value> AllTilesAsValue() const; |
79 void GetMemoryStats(size_t* memory_required_bytes, | 83 void GetMemoryStats(size_t* memory_required_bytes, |
80 size_t* memory_nice_to_have_bytes, | 84 size_t* memory_nice_to_have_bytes, |
81 size_t* memory_allocated_bytes, | 85 size_t* memory_allocated_bytes, |
82 size_t* memory_used_bytes) const; | 86 size_t* memory_used_bytes) const; |
83 | 87 |
84 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 88 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
85 return memory_stats_from_last_assign_; | 89 return memory_stats_from_last_assign_; |
(...skipping 23 matching lines...) Expand all Loading... |
109 if (state != global_state_) { | 113 if (state != global_state_) { |
110 global_state_ = state; | 114 global_state_ = state; |
111 prioritized_tiles_dirty_ = true; | 115 prioritized_tiles_dirty_ = true; |
112 resource_pool_->SetResourceUsageLimits( | 116 resource_pool_->SetResourceUsageLimits( |
113 global_state_.memory_limit_in_bytes, | 117 global_state_.memory_limit_in_bytes, |
114 global_state_.unused_memory_limit_in_bytes, | 118 global_state_.unused_memory_limit_in_bytes, |
115 global_state_.num_resources_limit); | 119 global_state_.num_resources_limit); |
116 } | 120 } |
117 } | 121 } |
118 | 122 |
| 123 // GpuRasterizerClient interface |
| 124 virtual void OnGpuRasterTaskCompleted( |
| 125 Tile* tile, scoped_ptr<ResourcePool::Resource> resource) OVERRIDE; |
| 126 |
119 protected: | 127 protected: |
120 TileManager(TileManagerClient* client, | 128 TileManager(TileManagerClient* client, |
121 ResourceProvider* resource_provider, | 129 ResourceProvider* resource_provider, |
| 130 ContextProvider* context_provider, |
122 scoped_ptr<RasterWorkerPool> raster_worker_pool, | 131 scoped_ptr<RasterWorkerPool> raster_worker_pool, |
123 size_t num_raster_threads, | 132 size_t num_raster_threads, |
124 size_t max_raster_usage_bytes, | 133 size_t max_raster_usage_bytes, |
125 RenderingStatsInstrumentation* rendering_stats_instrumentation); | 134 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
126 | 135 |
127 // Methods called by Tile | 136 // Methods called by Tile |
128 friend class Tile; | 137 friend class Tile; |
129 void DidChangeTilePriority(Tile* tile); | 138 void DidChangeTilePriority(Tile* tile); |
130 | 139 |
131 void CleanUpReleasedTiles(); | 140 void CleanUpReleasedTiles(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 void FreeUnusedResourcesForTile(Tile* tile); | 183 void FreeUnusedResourcesForTile(Tile* tile); |
175 RasterWorkerPool::Task CreateImageDecodeTask( | 184 RasterWorkerPool::Task CreateImageDecodeTask( |
176 Tile* tile, skia::LazyPixelRef* pixel_ref); | 185 Tile* tile, skia::LazyPixelRef* pixel_ref); |
177 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); | 186 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); |
178 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; | 187 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; |
179 void UpdatePrioritizedTileSetIfNeeded(); | 188 void UpdatePrioritizedTileSetIfNeeded(); |
180 | 189 |
181 TileManagerClient* client_; | 190 TileManagerClient* client_; |
182 scoped_ptr<ResourcePool> resource_pool_; | 191 scoped_ptr<ResourcePool> resource_pool_; |
183 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 192 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
| 193 scoped_ptr<GpuRasterizer> gpu_rasterizer_; |
184 GlobalStateThatImpactsTilePriority global_state_; | 194 GlobalStateThatImpactsTilePriority global_state_; |
185 | 195 |
186 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 196 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
187 TileMap tiles_; | 197 TileMap tiles_; |
188 | 198 |
189 PrioritizedTileSet prioritized_tiles_; | 199 PrioritizedTileSet prioritized_tiles_; |
190 bool prioritized_tiles_dirty_; | 200 bool prioritized_tiles_dirty_; |
191 | 201 |
192 bool all_tiles_that_need_to_be_rasterized_have_memory_; | 202 bool all_tiles_that_need_to_be_rasterized_have_memory_; |
193 bool all_tiles_required_for_activation_have_memory_; | 203 bool all_tiles_required_for_activation_have_memory_; |
(...skipping 23 matching lines...) Expand all Loading... |
217 RasterTaskCompletionStats update_visible_tiles_stats_; | 227 RasterTaskCompletionStats update_visible_tiles_stats_; |
218 | 228 |
219 std::vector<Tile*> released_tiles_; | 229 std::vector<Tile*> released_tiles_; |
220 | 230 |
221 DISALLOW_COPY_AND_ASSIGN(TileManager); | 231 DISALLOW_COPY_AND_ASSIGN(TileManager); |
222 }; | 232 }; |
223 | 233 |
224 } // namespace cc | 234 } // namespace cc |
225 | 235 |
226 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 236 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |