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

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

Issue 15855008: cc: Call ManageTiles explicitly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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_manager.h ('k') | cc/test/fake_layer_tree_host_impl_client.h » ('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 #include "cc/resources/tile_manager.h" 5 #include "cc/resources/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 TileManager::TileManager( 119 TileManager::TileManager(
120 TileManagerClient* client, 120 TileManagerClient* client,
121 ResourceProvider* resource_provider, 121 ResourceProvider* resource_provider,
122 scoped_ptr<RasterWorkerPool> raster_worker_pool, 122 scoped_ptr<RasterWorkerPool> raster_worker_pool,
123 size_t num_raster_threads, 123 size_t num_raster_threads,
124 bool use_color_estimator, 124 bool use_color_estimator,
125 RenderingStatsInstrumentation* rendering_stats_instrumentation) 125 RenderingStatsInstrumentation* rendering_stats_instrumentation)
126 : client_(client), 126 : client_(client),
127 resource_pool_(ResourcePool::Create(resource_provider)), 127 resource_pool_(ResourcePool::Create(resource_provider)),
128 raster_worker_pool_(raster_worker_pool.Pass()), 128 raster_worker_pool_(raster_worker_pool.Pass()),
129 manage_tiles_pending_(false),
130 ever_exceeded_memory_budget_(false), 129 ever_exceeded_memory_budget_(false),
131 rendering_stats_instrumentation_(rendering_stats_instrumentation), 130 rendering_stats_instrumentation_(rendering_stats_instrumentation),
132 use_color_estimator_(use_color_estimator), 131 use_color_estimator_(use_color_estimator),
133 did_initialize_visible_tile_(false) { 132 did_initialize_visible_tile_(false) {
134 } 133 }
135 134
136 TileManager::~TileManager() { 135 TileManager::~TileManager() {
137 // Reset global state and manage. This should cause 136 // Reset global state and manage. This should cause
138 // our memory usage to drop to zero. 137 // our memory usage to drop to zero.
139 global_state_ = GlobalStateThatImpactsTilePriority(); 138 global_state_ = GlobalStateThatImpactsTilePriority();
140 AssignGpuMemoryToTiles(); 139 AssignGpuMemoryToTiles();
141 // This should finish all pending tasks and release any uninitialized 140 // This should finish all pending tasks and release any uninitialized
142 // resources. 141 // resources.
143 raster_worker_pool_->Shutdown(); 142 raster_worker_pool_->Shutdown();
144 raster_worker_pool_->CheckForCompletedTasks(); 143 raster_worker_pool_->CheckForCompletedTasks();
145 DCHECK_EQ(0u, tiles_.size()); 144 DCHECK_EQ(0u, tiles_.size());
146 } 145 }
147 146
148 void TileManager::SetGlobalState( 147 void TileManager::SetGlobalState(
149 const GlobalStateThatImpactsTilePriority& global_state) { 148 const GlobalStateThatImpactsTilePriority& global_state) {
150 global_state_ = global_state; 149 global_state_ = global_state;
151 resource_pool_->SetMaxMemoryUsageBytes( 150 resource_pool_->SetMaxMemoryUsageBytes(
152 global_state_.memory_limit_in_bytes, 151 global_state_.memory_limit_in_bytes,
153 global_state_.unused_memory_limit_in_bytes); 152 global_state_.unused_memory_limit_in_bytes);
154 ScheduleManageTiles();
155 } 153 }
156 154
157 void TileManager::RegisterTile(Tile* tile) { 155 void TileManager::RegisterTile(Tile* tile) {
158 DCHECK(std::find(tiles_.begin(), tiles_.end(), tile) == tiles_.end()); 156 DCHECK(std::find(tiles_.begin(), tiles_.end(), tile) == tiles_.end());
159 DCHECK(!tile->required_for_activation()); 157 DCHECK(!tile->required_for_activation());
160 tiles_.push_back(tile); 158 tiles_.push_back(tile);
161 ScheduleManageTiles();
162 } 159 }
163 160
164 void TileManager::UnregisterTile(Tile* tile) { 161 void TileManager::UnregisterTile(Tile* tile) {
165 TileVector::iterator raster_iter = 162 TileVector::iterator raster_iter =
166 std::find(tiles_that_need_to_be_rasterized_.begin(), 163 std::find(tiles_that_need_to_be_rasterized_.begin(),
167 tiles_that_need_to_be_rasterized_.end(), 164 tiles_that_need_to_be_rasterized_.end(),
168 tile); 165 tile);
169 if (raster_iter != tiles_that_need_to_be_rasterized_.end()) 166 if (raster_iter != tiles_that_need_to_be_rasterized_.end())
170 tiles_that_need_to_be_rasterized_.erase(raster_iter); 167 tiles_that_need_to_be_rasterized_.erase(raster_iter);
171 168
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 282
286 void TileManager::SortTiles() { 283 void TileManager::SortTiles() {
287 TRACE_EVENT0("cc", "TileManager::SortTiles"); 284 TRACE_EVENT0("cc", "TileManager::SortTiles");
288 285
289 // Sort by bin, resolution and time until needed. 286 // Sort by bin, resolution and time until needed.
290 std::sort(tiles_.begin(), tiles_.end(), BinComparator()); 287 std::sort(tiles_.begin(), tiles_.end(), BinComparator());
291 } 288 }
292 289
293 void TileManager::ManageTiles() { 290 void TileManager::ManageTiles() {
294 TRACE_EVENT0("cc", "TileManager::ManageTiles"); 291 TRACE_EVENT0("cc", "TileManager::ManageTiles");
295
296 manage_tiles_pending_ = false;
297
298 AssignBinsToTiles(); 292 AssignBinsToTiles();
299 SortTiles(); 293 SortTiles();
300 AssignGpuMemoryToTiles(); 294 AssignGpuMemoryToTiles();
301 295
302 TRACE_EVENT_INSTANT1( 296 TRACE_EVENT_INSTANT1(
303 "cc", "DidManage", TRACE_EVENT_SCOPE_THREAD, 297 "cc", "DidManage", TRACE_EVENT_SCOPE_THREAD,
304 "state", TracedValue::FromValue(BasicStateAsValue().release())); 298 "state", TracedValue::FromValue(BasicStateAsValue().release()));
305 299
306 // Finally, schedule rasterizer tasks. 300 // Finally, schedule rasterizer tasks.
307 ScheduleTasks(); 301 ScheduleTasks();
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 100000, 947 100000,
954 100); 948 100);
955 } else { 949 } else {
956 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL); 950 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL);
957 } 951 }
958 952
959 return true; 953 return true;
960 } 954 }
961 955
962 } // namespace cc 956 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/test/fake_layer_tree_host_impl_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698