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

Side by Side Diff: cc/tile_manager.cc

Issue 11348384: cc: Use asynchronous set pixels API for impl-side painting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and removed unused CheckForPendingSetPixelsCompletion(). Created 8 years 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
« cc/layer_tree_host_impl.cc ('K') | « cc/tile_manager.h ('k') | no next file » | 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/tile_manager.h" 5 #include "cc/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 int num_pending_tasks_; 95 int num_pending_tasks_;
96 96
97 DISALLOW_COPY_AND_ASSIGN(RasterThread); 97 DISALLOW_COPY_AND_ASSIGN(RasterThread);
98 }; 98 };
99 99
100 ManagedTileState::ManagedTileState() 100 ManagedTileState::ManagedTileState()
101 : can_use_gpu_memory(false), 101 : can_use_gpu_memory(false),
102 can_be_freed(true), 102 can_be_freed(true),
103 resource_id(0),
103 resource_is_being_initialized(false), 104 resource_is_being_initialized(false),
104 contents_swizzled(false) { 105 contents_swizzled(false) {
105 } 106 }
106 107
107 ManagedTileState::~ManagedTileState() { 108 ManagedTileState::~ManagedTileState() {
108 DCHECK(!resource); 109 DCHECK(!resource);
109 DCHECK(!resource_is_being_initialized); 110 DCHECK(!resource_is_being_initialized);
110 } 111 }
111 112
112 TileManager::TileManager( 113 TileManager::TileManager(
113 TileManagerClient* client, 114 TileManagerClient* client,
114 ResourceProvider* resource_provider, 115 ResourceProvider* resource_provider,
115 size_t num_raster_threads) 116 size_t num_raster_threads)
116 : client_(client), 117 : client_(client),
117 resource_pool_(ResourcePool::Create(resource_provider, 118 resource_pool_(ResourcePool::Create(resource_provider,
118 Renderer::ImplPool)), 119 Renderer::ImplPool)),
119 manage_tiles_pending_(false) { 120 manage_tiles_pending_(false),
121 check_for_completed_set_pixels_pending_(false) {
120 // Initialize all threads. 122 // Initialize all threads.
121 const std::string thread_name_prefix = kRasterThreadNamePrefix; 123 const std::string thread_name_prefix = kRasterThreadNamePrefix;
122 while (raster_threads_.size() < num_raster_threads) { 124 while (raster_threads_.size() < num_raster_threads) {
123 int thread_number = raster_threads_.size() + 1; 125 int thread_number = raster_threads_.size() + 1;
124 scoped_ptr<RasterThread> thread = make_scoped_ptr( 126 scoped_ptr<RasterThread> thread = make_scoped_ptr(
125 new RasterThread(thread_name_prefix + 127 new RasterThread(thread_name_prefix +
126 StringPrintf("Worker%d", thread_number).c_str())); 128 StringPrintf("Worker%d", thread_number).c_str()));
127 raster_threads_.append(thread.Pass()); 129 raster_threads_.append(thread.Pass());
128 } 130 }
129 } 131 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ScheduleManageTiles(); 170 ScheduleManageTiles();
169 } 171 }
170 172
171 void TileManager::ScheduleManageTiles() { 173 void TileManager::ScheduleManageTiles() {
172 if (manage_tiles_pending_) 174 if (manage_tiles_pending_)
173 return; 175 return;
174 client_->ScheduleManageTiles(); 176 client_->ScheduleManageTiles();
175 manage_tiles_pending_ = true; 177 manage_tiles_pending_ = true;
176 } 178 }
177 179
180 void TileManager::ScheduleCheckForCompletedSetPixels() {
181 if (check_for_completed_set_pixels_pending_)
182 return;
183 client_->ScheduleCheckForCompletedSetPixels();
184 check_for_completed_set_pixels_pending_ = true;
185 }
186
178 class BinComparator { 187 class BinComparator {
179 public: 188 public:
180 bool operator() (const Tile* a, const Tile* b) const { 189 bool operator() (const Tile* a, const Tile* b) const {
181 const ManagedTileState& ams = a->managed_state(); 190 const ManagedTileState& ams = a->managed_state();
182 const ManagedTileState& bms = b->managed_state(); 191 const ManagedTileState& bms = b->managed_state();
183 if (ams.bin != bms.bin) 192 if (ams.bin != bms.bin)
184 return ams.bin < bms.bin; 193 return ams.bin < bms.bin;
185 194
186 if (ams.resolution != bms.resolution) 195 if (ams.resolution != bms.resolution)
187 return ams.resolution < ams.resolution; 196 return ams.resolution < ams.resolution;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 280
272 // Sort by bin. 281 // Sort by bin.
273 std::sort(tiles_.begin(), tiles_.end(), BinComparator()); 282 std::sort(tiles_.begin(), tiles_.end(), BinComparator());
274 283
275 // Assign gpu memory and determine what tiles need to be rasterized. 284 // Assign gpu memory and determine what tiles need to be rasterized.
276 AssignGpuMemoryToTiles(); 285 AssignGpuMemoryToTiles();
277 286
278 // Finally, kick the rasterizer. 287 // Finally, kick the rasterizer.
279 DispatchMoreRasterTasks(); 288 DispatchMoreRasterTasks();
280 } 289 }
281 290
epennerAtGoogle 2012/12/06 00:33:17 Could this possibly just be called at the beginnin
reveman 2012/12/06 15:28:20 For minimal latency I think we want to call this j
291 void TileManager::CheckForCompletedSetPixels() {
nduca 2012/12/06 03:21:30 I had asked for this before, and I'll ask again.
reveman 2012/12/06 15:28:20 We've moved away from using the "upload" term in r
292 check_for_completed_set_pixels_pending_ = false;
293
294 while (!tiles_with_pending_set_pixels_.empty()) {
295 Tile* tile = tiles_with_pending_set_pixels_.front();
296 DCHECK(tile->managed_state().resource);
297
298 // Set pixel tasks complete in the order they are posted.
nduca 2012/12/06 16:37:09 does async upload extension guarantee completion o
reveman 2012/12/06 20:40:35 Yes and it's advantages not to relax this requirem
299 if (!resource_pool_->resource_provider()->didSetPixelsComplete(
300 tile->managed_state().resource->id())) {
301 ScheduleCheckForCompletedSetPixels();
302 break;
303 }
304
305 // It's now safe to release the pixel buffer.
306 resource_pool_->resource_provider()->releasePixelBuffer(
307 tile->managed_state().resource->id());
308
309 DidFinishTileInitialization(tile);
310 tiles_with_pending_set_pixels_.pop();
311 }
312 }
313
282 void TileManager::renderingStats(RenderingStats* stats) { 314 void TileManager::renderingStats(RenderingStats* stats) {
283 stats->totalRasterizeTimeInSeconds = 315 stats->totalRasterizeTimeInSeconds =
284 rendering_stats_.totalRasterizeTimeInSeconds; 316 rendering_stats_.totalRasterizeTimeInSeconds;
285 stats->totalPixelsRasterized = rendering_stats_.totalPixelsRasterized; 317 stats->totalPixelsRasterized = rendering_stats_.totalPixelsRasterized;
286 } 318 }
287 319
288 void TileManager::AssignGpuMemoryToTiles() { 320 void TileManager::AssignGpuMemoryToTiles() {
289 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); 321 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
290 // Some memory cannot be released. Figure out which. 322 // Some memory cannot be released. Figure out which.
291 size_t unreleasable_bytes = 0; 323 size_t unreleasable_bytes = 0;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 // Tile can be freed after the completion of the raster task. Call 445 // Tile can be freed after the completion of the raster task. Call
414 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority 446 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority
415 // tiles. The result of this could be that this tile is no longer 447 // tiles. The result of this could be that this tile is no longer
416 // allowed to use gpu memory and in that case we need to abort 448 // allowed to use gpu memory and in that case we need to abort
417 // initialization and free all associated resources before calling 449 // initialization and free all associated resources before calling
418 // DispatchMoreRasterTasks(). 450 // DispatchMoreRasterTasks().
419 AssignGpuMemoryToTiles(); 451 AssignGpuMemoryToTiles();
420 452
421 // Finish resource initialization if |can_use_gpu_memory| is true. 453 // Finish resource initialization if |can_use_gpu_memory| is true.
422 if (managed_tile_state.can_use_gpu_memory) { 454 if (managed_tile_state.can_use_gpu_memory) {
423 resource_pool_->resource_provider()->setPixelsFromBuffer(resource->id()); 455 // The component order may be bgra if we're uploading bgra pixels to rgba
424 resource_pool_->resource_provider()->releasePixelBuffer(resource->id());
425
426 // The component order may be bgra if we uploaded bgra pixels to rgba
427 // texture. Mark contents as swizzled if image component order is 456 // texture. Mark contents as swizzled if image component order is
428 // different than texture format. 457 // different than texture format.
429 managed_tile_state.contents_swizzled = 458 managed_tile_state.contents_swizzled =
430 !PlatformColor::sameComponentOrder(tile->format_); 459 !PlatformColor::sameComponentOrder(tile->format_);
431 460
432 DidFinishTileInitialization(tile, resource.Pass()); 461 // Tile resources can't be freed until upload has completed.
462 managed_tile_state.can_be_freed = false;
463
464 resource_pool_->resource_provider()->beginSetPixels(resource->id());
465 managed_tile_state.resource = resource.Pass();
nduca 2012/12/06 16:37:09 this is getting really insane to me that you have
reveman 2012/12/06 20:40:35 I got rid of ManagedTileState::resource_id by just
466 tiles_with_pending_set_pixels_.push(tile);
467
468 ScheduleCheckForCompletedSetPixels();
433 } else { 469 } else {
434 resource_pool_->resource_provider()->releasePixelBuffer(resource->id()); 470 resource_pool_->resource_provider()->releasePixelBuffer(resource->id());
435 resource_pool_->ReleaseResource(resource.Pass()); 471 resource_pool_->ReleaseResource(resource.Pass());
436 managed_tile_state.resource_is_being_initialized = false; 472 managed_tile_state.resource_is_being_initialized = false;
437 } 473 }
438 474
439 DispatchMoreRasterTasks(); 475 DispatchMoreRasterTasks();
440 } 476 }
441 477
442 void TileManager::DidFinishTileInitialization( 478 void TileManager::DidFinishTileInitialization(Tile* tile) {
443 Tile* tile, scoped_ptr<ResourcePool::Resource> resource) {
444 ManagedTileState& managed_tile_state = tile->managed_state(); 479 ManagedTileState& managed_tile_state = tile->managed_state();
445 DCHECK(!managed_tile_state.resource); 480 DCHECK(managed_tile_state.resource);
446 managed_tile_state.resource = resource.Pass(); 481 managed_tile_state.resource_id = managed_tile_state.resource->id();
447 managed_tile_state.resource_is_being_initialized = false; 482 managed_tile_state.resource_is_being_initialized = false;
448 // TODO(qinmin): Make this conditional on managed_tile_state.bin == NOW_BIN. 483 managed_tile_state.can_be_freed = true;
449 client_->ScheduleRedraw();
450 } 484 }
451 485
452 } 486 }
OLDNEW
« cc/layer_tree_host_impl.cc ('K') | « cc/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698