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

Unified Diff: cc/tile_manager.cc

Issue 12185024: cc: Upload cheap tiles synchronously (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebased. 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
« no previous file with comments | « cc/tile_manager.h ('k') | no next file » | 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 b8ff58ba5078b49ee3abaf0bbf439a0176f351ad..ceb909038ea80e29ef72f165e4e62bcf4496b5a4 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -123,7 +123,7 @@ TileManager::TileManager(
raster_worker_pool_(RasterWorkerPool::Create(num_raster_threads, record_rendering_stats)),
manage_tiles_pending_(false),
manage_tiles_call_count_(0),
- bytes_pending_set_pixels_(0),
+ bytes_pending_upload_(0),
ever_exceeded_memory_budget_(false),
record_rendering_stats_(record_rendering_stats),
use_cheapness_estimator_(use_cheapness_estimator) {
@@ -144,7 +144,7 @@ TileManager::~TileManager() {
// resources.
raster_worker_pool_.reset();
CheckForCompletedTileUploads();
- DCHECK(tiles_with_pending_set_pixels_.size() == 0);
+ DCHECK(tiles_with_pending_upload_.size() == 0);
DCHECK(tiles_.size() == 0);
}
@@ -314,8 +314,8 @@ void TileManager::ManageTiles() {
}
void TileManager::CheckForCompletedTileUploads() {
- while (!tiles_with_pending_set_pixels_.empty()) {
- Tile* tile = tiles_with_pending_set_pixels_.front();
+ while (!tiles_with_pending_upload_.empty()) {
+ Tile* tile = tiles_with_pending_upload_.front();
DCHECK(tile->managed_state().resource);
// Set pixel tasks complete in the order they are posted.
@@ -324,24 +324,28 @@ void TileManager::CheckForCompletedTileUploads() {
break;
}
- if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0 &&
- tile->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION)
- client_->DidUploadVisibleHighResolutionTile();
-
// It's now safe to release the pixel buffer.
resource_pool_->resource_provider()->releasePixelBuffer(
tile->managed_state().resource->id());
- DidFinishTileInitialization(tile);
+ DidCompleteTileUpload(tile);
- bytes_pending_set_pixels_ -= tile->bytes_consumed_if_allocated();
- DidTileRasterStateChange(tile, IDLE_STATE);
- tiles_with_pending_set_pixels_.pop();
+ bytes_pending_upload_ -= tile->bytes_consumed_if_allocated();
+ tiles_with_pending_upload_.pop();
}
DispatchMoreTasks();
}
+void TileManager::DidCompleteTileUpload(Tile* tile) {
+ if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0 &&
+ tile->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION)
+ client_->DidUploadVisibleHighResolutionTile();
+
+ DidFinishTileInitialization(tile);
+ DidTileRasterStateChange(tile, IDLE_STATE);
+}
+
void TileManager::GetMemoryStats(
size_t* memoryRequiredBytes,
size_t* memoryNiceToHaveBytes,
@@ -407,7 +411,7 @@ bool TileManager::HasPendingWorkScheduled(WhichTree tree) const {
switch (i) {
case WAITING_FOR_RASTER_STATE:
case RASTER_STATE:
- case SET_PIXELS_STATE:
+ case UPLOAD_STATE:
for (int j = 0; j < NEVER_BIN; ++j) {
if (raster_state_count_[i][tree][j])
return true;
@@ -514,7 +518,7 @@ void TileManager::FreeResourcesForTile(Tile* tile) {
bool TileManager::CanDispatchRasterTask(Tile* tile) const {
if (raster_worker_pool_->IsBusy())
return false;
- size_t new_bytes_pending = bytes_pending_set_pixels_;
+ size_t new_bytes_pending = bytes_pending_upload_;
new_bytes_pending += tile->bytes_consumed_if_allocated();
return new_bytes_pending <= kMaxPendingUploadBytes;
}
@@ -524,10 +528,6 @@ bool TileManager::CanPerformCheapRaster(Tile* tile) const {
return false;
ManagedTileState& managed_state = tile->managed_state();
DCHECK(managed_state.pending_pixel_refs.empty());
- size_t new_bytes_pending = bytes_pending_set_pixels_;
- new_bytes_pending += tile->bytes_consumed_if_allocated();
- if (new_bytes_pending > kMaxPendingUploadBytes)
- return false;
return tile->picture_pile()->IsCheapInRect(tile->content_rect_,
tile->contents_scale());
}
@@ -701,14 +701,16 @@ void TileManager::PerformOneCheapRaster(Tile* tile) {
use_cheapness_estimator_,
tile->picture_pile(),
&rendering_stats_);
- OnRasterCompleted(tile, resource.Pass(), manage_tiles_call_count_);
+ OnRasterCompleted(tile, resource.Pass(), manage_tiles_call_count_,
+ TILE_UPLOAD_SYNC);
client_->DidPerformCheapRaster();
}
void TileManager::OnRasterCompleted(
scoped_refptr<Tile> tile,
scoped_ptr<ResourcePool::Resource> resource,
- int manage_tiles_call_count_when_dispatched) {
+ int manage_tiles_call_count_when_dispatched,
+ TileUploadMethod upload_method) {
TRACE_EVENT0("cc", "TileManager::OnRasterCompleted");
// Release raster resources.
@@ -734,16 +736,24 @@ void TileManager::OnRasterCompleted(
managed_tile_state.contents_swizzled =
!PlatformColor::sameComponentOrder(tile->format_);
- // Tile resources can't be freed until upload has completed.
- managed_tile_state.can_be_freed = false;
+ if (upload_method == TILE_UPLOAD_ASYNC) {
+ // Tile resources can't be freed until upload has completed.
+ managed_tile_state.can_be_freed = false;
- resource_pool_->resource_provider()->beginSetPixels(resource->id());
- resource_pool_->resource_provider()->shallowFlushIfSupported();
- managed_tile_state.resource = resource.Pass();
+ resource_pool_->resource_provider()->beginSetPixels(resource->id());
+ resource_pool_->resource_provider()->shallowFlushIfSupported();
+ managed_tile_state.resource = resource.Pass();
- bytes_pending_set_pixels_ += tile->bytes_consumed_if_allocated();
- DidTileRasterStateChange(tile, SET_PIXELS_STATE);
- tiles_with_pending_set_pixels_.push(tile);
+ bytes_pending_upload_ += tile->bytes_consumed_if_allocated();
+ DidTileRasterStateChange(tile, UPLOAD_STATE);
+ tiles_with_pending_upload_.push(tile);
+ } else {
+ DCHECK(upload_method == TILE_UPLOAD_SYNC);
+ resource_pool_->resource_provider()->setPixelsFromBuffer(resource->id());
+ resource_pool_->resource_provider()->releasePixelBuffer(resource->id());
+ managed_tile_state.resource = resource.Pass();
+ DidCompleteTileUpload(tile);
+ }
} else {
resource_pool_->resource_provider()->releasePixelBuffer(resource->id());
resource_pool_->ReleaseResource(resource.Pass());
@@ -757,7 +767,8 @@ void TileManager::OnRasterTaskCompleted(
scoped_ptr<ResourcePool::Resource> resource,
int manage_tiles_call_count_when_dispatched) {
OnRasterCompleted(tile, resource.Pass(),
- manage_tiles_call_count_when_dispatched);
+ manage_tiles_call_count_when_dispatched,
+ TILE_UPLOAD_ASYNC);
DispatchMoreTasks();
}
« no previous file with comments | « cc/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698