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

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

Issue 19308003: Merge 210713 "cc: Remove tile ref counting in tile manager." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1547/src/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile.cc ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24 matching lines...) Expand all
60 scoped_ptr<base::Value> AllTilesAsValue() const; 59 scoped_ptr<base::Value> AllTilesAsValue() const;
61 void GetMemoryStats(size_t* memory_required_bytes, 60 void GetMemoryStats(size_t* memory_required_bytes,
62 size_t* memory_nice_to_have_bytes, 61 size_t* memory_nice_to_have_bytes,
63 size_t* memory_used_bytes) const; 62 size_t* memory_used_bytes) const;
64 63
65 const MemoryHistory::Entry& memory_stats_from_last_assign() const { 64 const MemoryHistory::Entry& memory_stats_from_last_assign() const {
66 return memory_stats_from_last_assign_; 65 return memory_stats_from_last_assign_;
67 } 66 }
68 67
69 bool AreTilesRequiredForActivationReady() const { 68 bool AreTilesRequiredForActivationReady() const {
70 return tiles_that_need_to_be_initialized_for_activation_.empty() && 69 return all_tiles_required_for_activation_have_been_initialized_ &&
71 oom_tiles_that_need_to_be_initialized_for_activation_.empty(); 70 all_tiles_required_for_activation_have_memory_;
72 } 71 }
73 72
74 protected: 73 protected:
75 TileManager(TileManagerClient* client, 74 TileManager(TileManagerClient* client,
76 ResourceProvider* resource_provider, 75 ResourceProvider* resource_provider,
77 scoped_ptr<RasterWorkerPool> raster_worker_pool, 76 scoped_ptr<RasterWorkerPool> raster_worker_pool,
78 size_t num_raster_threads, 77 size_t num_raster_threads,
79 bool use_color_estimator, 78 bool use_color_estimator,
80 RenderingStatsInstrumentation* rendering_stats_instrumentation, 79 RenderingStatsInstrumentation* rendering_stats_instrumentation,
81 GLenum texture_format); 80 GLenum texture_format);
82 81
83 // Methods called by Tile 82 // Methods called by Tile
84 friend class Tile; 83 friend class Tile;
85 void RegisterTile(Tile* tile); 84 void RegisterTile(Tile* tile);
86 void UnregisterTile(Tile* tile); 85 void UnregisterTile(Tile* tile);
87 86
88 // Overriden from RasterWorkerPoolClient: 87 // Overriden from RasterWorkerPoolClient:
89 virtual bool ShouldForceTasksRequiredForActivationToComplete() const 88 virtual bool ShouldForceTasksRequiredForActivationToComplete() const
90 OVERRIDE; 89 OVERRIDE;
91 virtual void DidFinishedRunningTasks() OVERRIDE; 90 virtual void DidFinishedRunningTasks() OVERRIDE;
92 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE; 91 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE;
93 92
93 typedef std::vector<Tile*> TileVector;
94 typedef std::vector<scoped_refptr<Tile> > TileRefVector;
95 typedef std::set<Tile*> TileSet;
96
94 // Virtual for test 97 // Virtual for test
95 virtual void ScheduleTasks(); 98 virtual void ScheduleTasks(
99 const TileVector& tiles_that_need_to_be_rasterized);
96 100
97 const std::vector<Tile*>& tiles_that_need_to_be_rasterized() const { 101 void ReassignGpuMemoryToOOMTilesRequiredForActivation(
98 return tiles_that_need_to_be_rasterized_; 102 const TileRefVector& sorted_tiles,
99 } 103 TileVector* tiles_that_need_to_be_rasterized,
100 104 TileSet* oom_tiles_required_for_activation);
101 void ReassignGpuMemoryToOOMTilesRequiredForActivation(); 105 void AssignGpuMemoryToTiles(
106 const TileRefVector& sorted_tiles,
107 TileVector* tiles_that_need_to_be_rasterized,
108 TileSet* oom_tiles_required_for_activation);
109 void AssignBinsToTiles(TileRefVector* tiles);
110 void SortTiles(TileRefVector* tiles);
111 void GetSortedTiles(TileRefVector* tiles);
102 112
103 private: 113 private:
104 void OnImageDecodeTaskCompleted( 114 void OnImageDecodeTaskCompleted(
105 int layer_id, 115 int layer_id,
106 skia::LazyPixelRef* pixel_ref, 116 skia::LazyPixelRef* pixel_ref,
107 bool was_canceled); 117 bool was_canceled);
108 void OnRasterTaskCompleted( 118 void OnRasterTaskCompleted(
109 scoped_refptr<Tile> tile, 119 Tile::Id tile,
110 scoped_ptr<ResourcePool::Resource> resource, 120 scoped_ptr<ResourcePool::Resource> resource,
111 RasterMode raster_mode, 121 RasterMode raster_mode,
112 const PicturePileImpl::Analysis& analysis, 122 const PicturePileImpl::Analysis& analysis,
113 bool was_canceled); 123 bool was_canceled);
114 124
115 void AssignBinsToTiles();
116 void SortTiles();
117 RasterMode DetermineRasterMode(const Tile* tile) const; 125 RasterMode DetermineRasterMode(const Tile* tile) const;
118 void CleanUpUnusedImageDecodeTasks(); 126 void CleanUpUnusedImageDecodeTasks();
119 void AssignGpuMemoryToTiles();
120 void FreeResourceForTile(Tile* tile, RasterMode mode); 127 void FreeResourceForTile(Tile* tile, RasterMode mode);
121 void FreeResourcesForTile(Tile* tile); 128 void FreeResourcesForTile(Tile* tile);
122 void FreeUnusedResourcesForTile(Tile* tile); 129 void FreeUnusedResourcesForTile(Tile* tile);
123 RasterWorkerPool::Task CreateImageDecodeTask( 130 RasterWorkerPool::Task CreateImageDecodeTask(
124 Tile* tile, skia::LazyPixelRef* pixel_ref); 131 Tile* tile, skia::LazyPixelRef* pixel_ref);
125 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); 132 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile);
126 void DidFinishTileInitialization(Tile* tile);
127 void DidTileTreeBinChange(Tile* tile,
128 ManagedTileBin new_tree_bin,
129 WhichTree tree);
130 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; 133 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const;
131 void AddRequiredTileForActivation(Tile* tile);
132 134
133 TileManagerClient* client_; 135 TileManagerClient* client_;
134 scoped_ptr<ResourcePool> resource_pool_; 136 scoped_ptr<ResourcePool> resource_pool_;
135 scoped_ptr<RasterWorkerPool> raster_worker_pool_; 137 scoped_ptr<RasterWorkerPool> raster_worker_pool_;
136 GlobalStateThatImpactsTilePriority global_state_; 138 GlobalStateThatImpactsTilePriority global_state_;
137 139
138 typedef std::vector<Tile*> TileVector; 140 typedef base::hash_map<Tile::Id, Tile*> TileMap;
139 TileVector tiles_; 141 TileMap tiles_;
140 TileVector tiles_that_need_to_be_rasterized_; 142
141 typedef std::set<Tile*> TileSet; 143 TileRefVector sorted_tiles_;
142 TileSet tiles_that_need_to_be_initialized_for_activation_; 144
143 TileSet oom_tiles_that_need_to_be_initialized_for_activation_; 145 bool all_tiles_required_for_activation_have_been_initialized_;
146 bool all_tiles_required_for_activation_have_memory_;
144 147
145 bool ever_exceeded_memory_budget_; 148 bool ever_exceeded_memory_budget_;
146 MemoryHistory::Entry memory_stats_from_last_assign_; 149 MemoryHistory::Entry memory_stats_from_last_assign_;
147 150
148 RenderingStatsInstrumentation* rendering_stats_instrumentation_; 151 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
149 152
150 bool use_color_estimator_; 153 bool use_color_estimator_;
151 bool did_initialize_visible_tile_; 154 bool did_initialize_visible_tile_;
152 155
153 GLenum texture_format_; 156 GLenum texture_format_;
154 157
155 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; 158 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap;
156 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; 159 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap;
157 LayerPixelRefTaskMap image_decode_tasks_; 160 LayerPixelRefTaskMap image_decode_tasks_;
158 161
159 DISALLOW_COPY_AND_ASSIGN(TileManager); 162 DISALLOW_COPY_AND_ASSIGN(TileManager);
160 }; 163 };
161 164
162 } // namespace cc 165 } // namespace cc
163 166
164 #endif // CC_RESOURCES_TILE_MANAGER_H_ 167 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/resources/tile.cc ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698