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

Unified Diff: cc/tile_manager.cc

Issue 12217105: cc: Check for completed raster tasks at interval. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DidFinishDispatchingCompletionCallbacks Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« cc/tile_manager.h ('K') | « cc/tile_manager.h ('k') | cc/worker_pool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tile_manager.cc
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index be8e1d91e3e66a94401a6fff47f0c65212ca12b5..7300ff7af9636b5d8c4aaf2da7e073613a3d16d4 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -30,8 +30,10 @@ namespace {
// For reference, the Nexus10 can upload 1MB in about 2.5ms.
// Assuming a three frame deep pipeline this implies ~20MB.
const int kMaxPendingUploadBytes = 20 * 1024 * 1024;
+const int kMaxPendingRasterBytes = 2 * 1024 * 1024;
#else
const int kMaxPendingUploadBytes = 100 * 1024 * 1024;
+const int kMaxPendingRasterBytes = 10 * 1024 * 1024;
#endif
// Determine bin based on three categories of tiles: things we need now,
@@ -169,10 +171,12 @@ TileManager::TileManager(
bool use_cheapness_estimator)
: client_(client),
resource_pool_(ResourcePool::Create(resource_provider)),
- raster_worker_pool_(RasterWorkerPool::Create(num_raster_threads)),
+ raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)),
manage_tiles_pending_(false),
manage_tiles_call_count_(0),
+ bytes_pending_raster_(0),
bytes_pending_set_pixels_(0),
+ need_shallow_flush_(false),
ever_exceeded_memory_budget_(false),
record_rendering_stats_(false),
use_cheapness_estimator_(use_cheapness_estimator) {
@@ -541,6 +545,16 @@ bool TileManager::HasPendingWorkScheduled(WhichTree tree) const {
return false;
}
+void TileManager::DidFinishDispatchingCompletionCallbacks() {
+ // If a flush is needed, do it now before starting to dispatch more tasks.
+ if (need_shallow_flush_) {
nduca 2013/02/13 10:53:37 has_performed_uploads_since_last_shallow_flush_?
reveman 2013/02/13 15:32:58 ok, I changed to has_performed_uploads_since_last_
+ resource_pool_->resource_provider()->shallowFlushIfSupported();
+ need_shallow_flush_ = false;
+ }
+
+ DispatchMoreTasks();
+}
+
void TileManager::AssignGpuMemoryToTiles() {
TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
// Some memory cannot be released. Figure out which.
@@ -632,11 +646,18 @@ void TileManager::FreeResourcesForTile(Tile* tile) {
}
bool TileManager::CanDispatchRasterTask(Tile* tile) {
- if (raster_worker_pool_->IsBusy())
+ size_t new_raster_bytes_pending = bytes_pending_raster_;
+ new_raster_bytes_pending += tile->bytes_consumed_if_allocated();
+ if (new_raster_bytes_pending > kMaxPendingRasterBytes)
+ return false;
+
+ size_t new_upload_bytes_pending = bytes_pending_raster_ +
+ bytes_pending_set_pixels_;
+ new_upload_bytes_pending += tile->bytes_consumed_if_allocated();
+ if (new_upload_bytes_pending > kMaxPendingUploadBytes)
return false;
- size_t new_bytes_pending = bytes_pending_set_pixels_;
- new_bytes_pending += tile->bytes_consumed_if_allocated();
- return new_bytes_pending <= kMaxPendingUploadBytes;
+
+ return true;
}
void TileManager::DispatchMoreTasks() {
@@ -710,7 +731,7 @@ void TileManager::DispatchImageDecodeTasksForTile(Tile* tile) {
rendering_stats_.totalDeferredImageCacheHitCount++;
pending_pixel_refs.erase(it++);
} else {
- if (raster_worker_pool_->IsBusy())
+ if (!CanDispatchRasterTask(tile))
return;
DispatchOneImageDecodeTask(tile, *it);
++it;
@@ -751,8 +772,6 @@ void TileManager::OnImageDecodeTaskCompleted(
}
}
}
-
- DispatchMoreTasks();
}
scoped_ptr<ResourcePool::Resource> TileManager::PrepareTileForRaster(
@@ -788,6 +807,8 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) {
tile,
base::Passed(&resource),
manage_tiles_call_count_));
+
+ bytes_pending_raster_ += tile->bytes_consumed_if_allocated();
}
void TileManager::PerformOneRaster(Tile* tile) {
@@ -838,7 +859,8 @@ void TileManager::OnRasterCompleted(
managed_tile_state.can_be_freed = false;
resource_pool_->resource_provider()->beginSetPixels(resource->id());
- resource_pool_->resource_provider()->shallowFlushIfSupported();
+ need_shallow_flush_ = true;
+
managed_tile_state.resource = resource.Pass();
bytes_pending_set_pixels_ += tile->bytes_consumed_if_allocated();
@@ -856,9 +878,9 @@ void TileManager::OnRasterTaskCompleted(
scoped_refptr<Tile> tile,
scoped_ptr<ResourcePool::Resource> resource,
int manage_tiles_call_count_when_dispatched) {
+ bytes_pending_raster_ -= tile->bytes_consumed_if_allocated();
OnRasterCompleted(tile, resource.Pass(),
manage_tiles_call_count_when_dispatched);
- DispatchMoreTasks();
}
void TileManager::DidFinishTileInitialization(Tile* tile) {
« cc/tile_manager.h ('K') | « cc/tile_manager.h ('k') | cc/worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698