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

Side by Side Diff: cc/resources/tile_manager.h

Issue 18581004: cc: Remove tile ref counting in tile manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed small helper functions Created 7 years, 5 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
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_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/debug/rendering_stats_instrumentation.h" 15 #include "cc/debug/rendering_stats_instrumentation.h"
16 #include "cc/resources/managed_tile_state.h" 16 #include "cc/resources/managed_tile_state.h"
17 #include "cc/resources/memory_history.h" 17 #include "cc/resources/memory_history.h"
18 #include "cc/resources/picture_pile_impl.h" 18 #include "cc/resources/picture_pile_impl.h"
19 #include "cc/resources/raster_worker_pool.h" 19 #include "cc/resources/raster_worker_pool.h"
20 #include "cc/resources/resource_pool.h" 20 #include "cc/resources/resource_pool.h"
21 #include "cc/resources/tile.h"
21 22
22 namespace cc { 23 namespace cc {
23 class ResourceProvider; 24 class ResourceProvider;
24 class Tile;
25 class TileVersion;
26 25
27 class CC_EXPORT TileManagerClient { 26 class CC_EXPORT TileManagerClient {
28 public: 27 public:
29 virtual void DidInitializeVisibleTile() = 0; 28 virtual void DidInitializeVisibleTile() = 0;
30 virtual void NotifyReadyToActivate() = 0; 29 virtual void NotifyReadyToActivate() = 0;
31 30
32 protected: 31 protected:
33 virtual ~TileManagerClient() {} 32 virtual ~TileManagerClient() {}
34 }; 33 };
35 34
(...skipping 23 matching lines...) Expand all
59 scoped_ptr<base::Value> AllTilesAsValue() const; 58 scoped_ptr<base::Value> AllTilesAsValue() const;
60 void GetMemoryStats(size_t* memory_required_bytes, 59 void GetMemoryStats(size_t* memory_required_bytes,
61 size_t* memory_nice_to_have_bytes, 60 size_t* memory_nice_to_have_bytes,
62 size_t* memory_used_bytes) const; 61 size_t* memory_used_bytes) const;
63 62
64 const MemoryHistory::Entry& memory_stats_from_last_assign() const { 63 const MemoryHistory::Entry& memory_stats_from_last_assign() const {
65 return memory_stats_from_last_assign_; 64 return memory_stats_from_last_assign_;
66 } 65 }
67 66
68 bool AreTilesRequiredForActivationReady() const { 67 bool AreTilesRequiredForActivationReady() const {
69 return tiles_that_need_to_be_initialized_for_activation_.empty() && 68 return all_tiles_required_for_activation_have_been_initialized_ &&
70 oom_tiles_that_need_to_be_initialized_for_activation_.empty(); 69 all_tiles_required_for_activation_have_memory_;
71 } 70 }
72 71
73 protected: 72 protected:
74 TileManager(TileManagerClient* client, 73 TileManager(TileManagerClient* client,
75 ResourceProvider* resource_provider, 74 ResourceProvider* resource_provider,
76 scoped_ptr<RasterWorkerPool> raster_worker_pool, 75 scoped_ptr<RasterWorkerPool> raster_worker_pool,
77 size_t num_raster_threads, 76 size_t num_raster_threads,
78 RenderingStatsInstrumentation* rendering_stats_instrumentation, 77 RenderingStatsInstrumentation* rendering_stats_instrumentation,
79 GLenum texture_format); 78 GLenum texture_format);
80 79
81 // Methods called by Tile 80 // Methods called by Tile
82 friend class Tile; 81 friend class Tile;
83 void RegisterTile(Tile* tile); 82 void RegisterTile(Tile* tile);
84 void UnregisterTile(Tile* tile); 83 void UnregisterTile(Tile* tile);
85 84
86 // Overriden from RasterWorkerPoolClient: 85 // Overriden from RasterWorkerPoolClient:
87 virtual bool ShouldForceTasksRequiredForActivationToComplete() const 86 virtual bool ShouldForceTasksRequiredForActivationToComplete() const
88 OVERRIDE; 87 OVERRIDE;
89 virtual void DidFinishedRunningTasks() OVERRIDE; 88 virtual void DidFinishedRunningTasks() OVERRIDE;
90 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE; 89 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE;
91 90
91 typedef std::vector<Tile*> TileVector;
92 typedef std::vector<scoped_refptr<Tile> > TileRefVector;
93 typedef std::set<Tile*> TileSet;
94
92 // Virtual for test 95 // Virtual for test
93 virtual void ScheduleTasks(); 96 virtual void ScheduleTasks(
97 const TileVector& tiles_that_need_to_be_rasterized);
94 98
95 const std::vector<Tile*>& tiles_that_need_to_be_rasterized() const { 99 void ReassignGpuMemoryToOOMTilesRequiredForActivation(
96 return tiles_that_need_to_be_rasterized_; 100 const TileRefVector& sorted_tiles,
101 TileVector* tiles_that_need_to_be_rasterized,
102 TileSet* oom_tiles_required_for_activation);
103 void AssignGpuMemoryToTiles(
104 const TileRefVector& sorted_tiles,
105 TileVector* tiles_that_need_to_be_rasterized,
106 TileSet* oom_tiles_required_for_activation);
107 void AssignBinsToTiles(TileRefVector* tiles);
108 void SortTiles(TileRefVector* tiles);
109 void UpdateSortedTiles();
110
111 // Test functions
112 void GetSortedTilesForTest(TileRefVector* tiles) {
113 *tiles = sorted_tiles_;
97 } 114 }
98 115
99 void ReassignGpuMemoryToOOMTilesRequiredForActivation();
100
101 private: 116 private:
102 void OnImageDecodeTaskCompleted( 117 void OnImageDecodeTaskCompleted(
103 int layer_id, 118 int layer_id,
104 skia::LazyPixelRef* pixel_ref, 119 skia::LazyPixelRef* pixel_ref,
105 bool was_canceled); 120 bool was_canceled);
106 void OnRasterTaskCompleted( 121 void OnRasterTaskCompleted(
107 scoped_refptr<Tile> tile, 122 Tile::Id tile,
108 scoped_ptr<ResourcePool::Resource> resource, 123 scoped_ptr<ResourcePool::Resource> resource,
109 RasterMode raster_mode, 124 RasterMode raster_mode,
110 const PicturePileImpl::Analysis& analysis, 125 const PicturePileImpl::Analysis& analysis,
111 bool was_canceled); 126 bool was_canceled);
112 127
113 void AssignBinsToTiles();
114 void SortTiles();
115 RasterMode DetermineRasterMode(const Tile* tile) const; 128 RasterMode DetermineRasterMode(const Tile* tile) const;
116 void CleanUpUnusedImageDecodeTasks(); 129 void CleanUpUnusedImageDecodeTasks();
117 void AssignGpuMemoryToTiles();
118 void FreeResourceForTile(Tile* tile, RasterMode mode); 130 void FreeResourceForTile(Tile* tile, RasterMode mode);
119 void FreeResourcesForTile(Tile* tile); 131 void FreeResourcesForTile(Tile* tile);
120 void FreeUnusedResourcesForTile(Tile* tile); 132 void FreeUnusedResourcesForTile(Tile* tile);
121 RasterWorkerPool::Task CreateImageDecodeTask( 133 RasterWorkerPool::Task CreateImageDecodeTask(
122 Tile* tile, skia::LazyPixelRef* pixel_ref); 134 Tile* tile, skia::LazyPixelRef* pixel_ref);
123 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); 135 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile);
124 void DidFinishTileInitialization(Tile* tile);
125 void DidTileTreeBinChange(Tile* tile,
126 ManagedTileBin new_tree_bin,
127 WhichTree tree);
128 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; 136 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const;
129 void AddRequiredTileForActivation(Tile* tile);
130 137
131 TileManagerClient* client_; 138 TileManagerClient* client_;
132 scoped_ptr<ResourcePool> resource_pool_; 139 scoped_ptr<ResourcePool> resource_pool_;
133 scoped_ptr<RasterWorkerPool> raster_worker_pool_; 140 scoped_ptr<RasterWorkerPool> raster_worker_pool_;
134 GlobalStateThatImpactsTilePriority global_state_; 141 GlobalStateThatImpactsTilePriority global_state_;
135 142
136 typedef std::vector<Tile*> TileVector; 143 typedef base::hash_map<Tile::Id, Tile*> TileMap;
137 TileVector tiles_; 144 TileMap tiles_;
138 TileVector tiles_that_need_to_be_rasterized_; 145
139 typedef std::set<Tile*> TileSet; 146 TileRefVector sorted_tiles_;
140 TileSet tiles_that_need_to_be_initialized_for_activation_; 147
141 TileSet oom_tiles_that_need_to_be_initialized_for_activation_; 148 bool all_tiles_required_for_activation_have_been_initialized_;
149 bool all_tiles_required_for_activation_have_memory_;
142 150
143 bool ever_exceeded_memory_budget_; 151 bool ever_exceeded_memory_budget_;
144 MemoryHistory::Entry memory_stats_from_last_assign_; 152 MemoryHistory::Entry memory_stats_from_last_assign_;
145 153
146 RenderingStatsInstrumentation* rendering_stats_instrumentation_; 154 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
147 155
148 bool did_initialize_visible_tile_; 156 bool did_initialize_visible_tile_;
149 157
150 GLenum texture_format_; 158 GLenum texture_format_;
151 159
152 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; 160 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap;
153 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; 161 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap;
154 LayerPixelRefTaskMap image_decode_tasks_; 162 LayerPixelRefTaskMap image_decode_tasks_;
155 163
156 DISALLOW_COPY_AND_ASSIGN(TileManager); 164 DISALLOW_COPY_AND_ASSIGN(TileManager);
157 }; 165 };
158 166
159 } // namespace cc 167 } // namespace cc
160 168
161 #endif // CC_RESOURCES_TILE_MANAGER_H_ 169 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/resources/tile.cc ('k') | cc/resources/tile_manager.cc » ('j') | cc/resources/tile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698