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 <deque> | 8 #include <deque> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Called when all tiles marked as required for draw are ready to draw. | 52 // Called when all tiles marked as required for draw are ready to draw. |
53 virtual void NotifyReadyToDraw() = 0; | 53 virtual void NotifyReadyToDraw() = 0; |
54 | 54 |
55 // Called when the visible representation of a tile might have changed. Some | 55 // Called when the visible representation of a tile might have changed. Some |
56 // examples are: | 56 // examples are: |
57 // - Tile version initialized. | 57 // - Tile version initialized. |
58 // - Tile resources freed. | 58 // - Tile resources freed. |
59 // - Tile marked for on-demand raster. | 59 // - Tile marked for on-demand raster. |
60 virtual void NotifyTileStateChanged(const Tile* tile) = 0; | 60 virtual void NotifyTileStateChanged(const Tile* tile) = 0; |
61 | 61 |
62 // Given an empty raster tile priority queue, this will build a priority queue | |
63 // that will return tiles in order in which they should be rasterized. | |
64 // Note if the queue was previous built, Reset must be called on it. | |
65 virtual scoped_ptr<RasterTilePriorityQueue> BuildRasterQueue( | |
66 TreePriority tree_priority, | |
67 RasterTilePriorityQueue::Type type) = 0; | |
68 | |
69 // Given an empty eviction tile priority queue, this will build a priority | |
70 // queue that will return tiles in order in which they should be evicted. | |
71 // Note if the queue was previous built, Reset must be called on it. | |
72 virtual scoped_ptr<EvictionTilePriorityQueue> BuildEvictionQueue( | |
73 TreePriority tree_priority) = 0; | |
74 | |
75 // Informs the client that due to the currently rasterizing (or scheduled to | 62 // Informs the client that due to the currently rasterizing (or scheduled to |
76 // be rasterized) tiles, we will be in a position that will likely require a | 63 // be rasterized) tiles, we will be in a position that will likely require a |
77 // draw. This can be used to preemptively start a frame. | 64 // draw. This can be used to preemptively start a frame. |
78 virtual void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) = 0; | 65 virtual void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) = 0; |
79 | 66 |
| 67 // Returns true iff we have a pending tree. |
| 68 virtual bool PendingTreeExists() = 0; |
| 69 |
80 protected: | 70 protected: |
81 virtual ~TileManagerClient() {} | 71 virtual ~TileManagerClient() {} |
82 }; | 72 }; |
83 | 73 |
84 struct RasterTaskCompletionStats { | 74 struct RasterTaskCompletionStats { |
85 RasterTaskCompletionStats(); | 75 RasterTaskCompletionStats(); |
86 | 76 |
87 size_t completed_count; | 77 size_t completed_count; |
88 size_t canceled_count; | 78 size_t canceled_count; |
89 }; | 79 }; |
(...skipping 21 matching lines...) Expand all Loading... |
111 "minus 1"); | 101 "minus 1"); |
112 | 102 |
113 static scoped_ptr<TileManager> Create(TileManagerClient* client, | 103 static scoped_ptr<TileManager> Create(TileManagerClient* client, |
114 base::SequencedTaskRunner* task_runner, | 104 base::SequencedTaskRunner* task_runner, |
115 ResourcePool* resource_pool, | 105 ResourcePool* resource_pool, |
116 TileTaskRunner* tile_task_runner, | 106 TileTaskRunner* tile_task_runner, |
117 Rasterizer* rasterizer, | 107 Rasterizer* rasterizer, |
118 size_t scheduled_raster_task_limit); | 108 size_t scheduled_raster_task_limit); |
119 ~TileManager() override; | 109 ~TileManager() override; |
120 | 110 |
| 111 void RegisterPictureLayerTilingSet(int layer_id, |
| 112 WhichTree tree, |
| 113 PictureLayerTilingSet* tiling_set); |
| 114 void UnregisterPictureLayerTilingSet(int layer_id, WhichTree tree); |
| 115 |
121 // Assigns tile memory and schedules work to prepare tiles for drawing. | 116 // Assigns tile memory and schedules work to prepare tiles for drawing. |
122 // - Runs client_->NotifyReadyToActivate() when all tiles required for | 117 // - Runs client_->NotifyReadyToActivate() when all tiles required for |
123 // activation are prepared, or failed to prepare due to OOM. | 118 // activation are prepared, or failed to prepare due to OOM. |
124 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are | 119 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are |
125 // prepared, or failed to prepare due to OOM. | 120 // prepared, or failed to prepare due to OOM. |
126 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); | 121 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); |
127 | 122 |
128 void UpdateVisibleTiles(const GlobalStateThatImpactsTilePriority& state); | 123 void UpdateVisibleTiles(const GlobalStateThatImpactsTilePriority& state); |
129 | 124 |
| 125 bool HasPictureLayerTilingSets() const { |
| 126 return !paired_picture_layer_tiling_sets_.empty(); |
| 127 } |
| 128 |
130 scoped_refptr<Tile> CreateTile(RasterSource* raster_source, | 129 scoped_refptr<Tile> CreateTile(RasterSource* raster_source, |
131 const gfx::Size& desired_texture_size, | 130 const gfx::Size& desired_texture_size, |
132 const gfx::Rect& content_rect, | 131 const gfx::Rect& content_rect, |
133 float contents_scale, | 132 float contents_scale, |
134 int layer_id, | 133 int layer_id, |
135 int source_frame_number, | 134 int source_frame_number, |
136 int flags); | 135 int flags); |
137 | 136 |
138 scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() | 137 scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() |
139 const; | 138 const; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return tiles; | 178 return tiles; |
180 } | 179 } |
181 | 180 |
182 void SetScheduledRasterTaskLimitForTesting(size_t limit) { | 181 void SetScheduledRasterTaskLimitForTesting(size_t limit) { |
183 scheduled_raster_task_limit_ = limit; | 182 scheduled_raster_task_limit_ = limit; |
184 } | 183 } |
185 | 184 |
186 bool IsReadyToActivate() const; | 185 bool IsReadyToActivate() const; |
187 bool IsReadyToDraw() const; | 186 bool IsReadyToDraw() const; |
188 | 187 |
| 188 scoped_ptr<RasterTilePriorityQueue> BuildRasterQueue( |
| 189 RasterTilePriorityQueue::Type type) const; |
| 190 scoped_ptr<EvictionTilePriorityQueue> BuildEvictionQueue() const; |
| 191 |
189 protected: | 192 protected: |
190 TileManager(TileManagerClient* client, | 193 TileManager(TileManagerClient* client, |
191 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 194 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
192 ResourcePool* resource_pool, | 195 ResourcePool* resource_pool, |
193 TileTaskRunner* tile_task_runner, | 196 TileTaskRunner* tile_task_runner, |
194 Rasterizer* rasterizer, | 197 Rasterizer* rasterizer, |
195 size_t scheduled_raster_task_limit); | 198 size_t scheduled_raster_task_limit); |
196 | 199 |
197 void FreeResourcesForReleasedTiles(); | 200 void FreeResourcesForReleasedTiles(); |
198 void CleanUpReleasedTiles(); | 201 void CleanUpReleasedTiles(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 315 |
313 UniqueNotifier ready_to_activate_notifier_; | 316 UniqueNotifier ready_to_activate_notifier_; |
314 UniqueNotifier ready_to_draw_notifier_; | 317 UniqueNotifier ready_to_draw_notifier_; |
315 UniqueNotifier ready_to_activate_check_notifier_; | 318 UniqueNotifier ready_to_activate_check_notifier_; |
316 UniqueNotifier ready_to_draw_check_notifier_; | 319 UniqueNotifier ready_to_draw_check_notifier_; |
317 UniqueNotifier more_tiles_need_prepare_check_notifier_; | 320 UniqueNotifier more_tiles_need_prepare_check_notifier_; |
318 | 321 |
319 bool did_notify_ready_to_activate_; | 322 bool did_notify_ready_to_activate_; |
320 bool did_notify_ready_to_draw_; | 323 bool did_notify_ready_to_draw_; |
321 | 324 |
| 325 base::hash_map<int, PictureLayerTilingSet::Pair> |
| 326 paired_picture_layer_tiling_sets_; |
| 327 |
322 DISALLOW_COPY_AND_ASSIGN(TileManager); | 328 DISALLOW_COPY_AND_ASSIGN(TileManager); |
323 }; | 329 }; |
324 | 330 |
325 } // namespace cc | 331 } // namespace cc |
326 | 332 |
327 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 333 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |