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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "cc/resource_pool.h" | 12 #include "cc/resource_pool.h" |
| 13 #include "cc/scoped_ptr_deque.h" |
13 #include "cc/tile_priority.h" | 14 #include "cc/tile_priority.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class SequencedWorkerPool; | 17 class SequencedWorkerPool; |
17 } | 18 } |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
21 class Tile; | 22 class Tile; |
22 class TileVersion; | 23 class TileVersion; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 scoped_ptr<ResourcePool::Resource> resource; | 56 scoped_ptr<ResourcePool::Resource> resource; |
56 bool resource_is_being_initialized; | 57 bool resource_is_being_initialized; |
57 bool contents_swizzled; | 58 bool contents_swizzled; |
58 | 59 |
59 // Ephemeral state, valid only during Manage. | 60 // Ephemeral state, valid only during Manage. |
60 TileManagerBin bin; | 61 TileManagerBin bin; |
61 TileResolution resolution; | 62 TileResolution resolution; |
62 float time_to_needed_in_seconds; | 63 float time_to_needed_in_seconds; |
63 }; | 64 }; |
64 | 65 |
| 66 class PendingSetPixels { |
| 67 public: |
| 68 PendingSetPixels(Tile*, scoped_ptr<ResourcePool::Resource>); |
| 69 ~PendingSetPixels(); |
| 70 |
| 71 Tile* tile() { return tile_.get(); } |
| 72 ResourcePool::Resource* resource() { return resource_.get(); } |
| 73 scoped_ptr<ResourcePool::Resource> takeResource() { |
| 74 return resource_.Pass(); |
| 75 } |
| 76 |
| 77 private: |
| 78 scoped_refptr<Tile> tile_; |
| 79 scoped_ptr<ResourcePool::Resource> resource_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(PendingSetPixels); |
| 82 }; |
| 83 |
| 84 |
65 // This class manages tiles, deciding which should get rasterized and which | 85 // This class manages tiles, deciding which should get rasterized and which |
66 // should no longer have any memory assigned to them. Tile objects are "owned" | 86 // should no longer have any memory assigned to them. Tile objects are "owned" |
67 // by layers; they automatically register with the manager when they are | 87 // by layers; they automatically register with the manager when they are |
68 // created, and unregister from the manager when they are deleted. | 88 // created, and unregister from the manager when they are deleted. |
69 class CC_EXPORT TileManager { | 89 class CC_EXPORT TileManager { |
70 public: | 90 public: |
71 TileManager(TileManagerClient* client, | 91 TileManager(TileManagerClient* client, |
72 ResourceProvider *resource_provider, | 92 ResourceProvider *resource_provider, |
73 size_t num_raster_threads); | 93 size_t num_raster_threads); |
74 virtual ~TileManager(); | 94 virtual ~TileManager(); |
75 | 95 |
76 const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_
state_; } | 96 const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_
state_; } |
77 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 97 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
78 | 98 |
79 void ManageTiles(); | 99 void ManageTiles(); |
| 100 void PrepareToDraw(); |
80 | 101 |
81 void renderingStats(RenderingStats* stats); | 102 void renderingStats(RenderingStats* stats); |
82 | 103 |
83 protected: | 104 protected: |
84 // Methods called by Tile | 105 // Methods called by Tile |
85 friend class Tile; | 106 friend class Tile; |
86 void RegisterTile(Tile*); | 107 void RegisterTile(Tile*); |
87 void UnregisterTile(Tile*); | 108 void UnregisterTile(Tile*); |
88 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); | 109 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); |
89 | 110 |
90 private: | 111 private: |
91 void AssignGpuMemoryToTiles(); | 112 void AssignGpuMemoryToTiles(); |
92 void FreeResourcesForTile(Tile*); | 113 void FreeResourcesForTile(Tile*); |
93 void ScheduleManageTiles(); | 114 void ScheduleManageTiles(); |
94 void DispatchMoreRasterTasks(); | 115 void DispatchMoreRasterTasks(); |
95 void DispatchOneRasterTask(scoped_refptr<Tile>); | 116 void DispatchOneRasterTask(scoped_refptr<Tile>); |
96 void OnRasterTaskCompleted( | 117 void OnRasterTaskCompleted( |
97 scoped_refptr<Tile>, | 118 scoped_refptr<Tile>, |
98 scoped_ptr<ResourcePool::Resource>, | 119 scoped_ptr<ResourcePool::Resource>, |
99 scoped_refptr<PicturePileImpl>, | 120 scoped_refptr<PicturePileImpl>, |
100 RenderingStats*); | 121 RenderingStats*); |
| 122 void CheckForPendingSetPixelsCompletion(); |
101 void DidFinishTileInitialization(Tile*, scoped_ptr<ResourcePool::Resource>); | 123 void DidFinishTileInitialization(Tile*, scoped_ptr<ResourcePool::Resource>); |
102 | 124 |
103 TileManagerClient* client_; | 125 TileManagerClient* client_; |
104 scoped_ptr<ResourcePool> resource_pool_; | 126 scoped_ptr<ResourcePool> resource_pool_; |
105 bool manage_tiles_pending_; | 127 bool manage_tiles_pending_; |
106 int pending_raster_tasks_; | 128 int pending_raster_tasks_; |
107 size_t num_raster_threads_; | 129 size_t num_raster_threads_; |
108 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | 130 scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
| 131 bool in_prepare_to_draw_; |
109 | 132 |
110 GlobalStateThatImpactsTilePriority global_state_; | 133 GlobalStateThatImpactsTilePriority global_state_; |
111 | 134 |
112 typedef std::vector<Tile*> TileVector; | 135 typedef std::vector<Tile*> TileVector; |
113 TileVector tiles_; | 136 TileVector tiles_; |
114 TileVector tiles_that_need_to_be_rasterized_; | 137 TileVector tiles_that_need_to_be_rasterized_; |
115 | 138 |
| 139 typedef ScopedPtrDeque<PendingSetPixels> PendingSetPixelsDeque; |
| 140 PendingSetPixelsDeque pending_set_pixels_; |
| 141 |
116 RenderingStats rendering_stats_; | 142 RenderingStats rendering_stats_; |
| 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(TileManager); |
117 }; | 145 }; |
118 | 146 |
119 } // namespace cc | 147 } // namespace cc |
120 | 148 |
121 #endif // CC_TILE_MANAGER_H_ | 149 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |