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

Unified 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 side-by-side diff with in-line comments
Download patch
« cc/layer_tree_host_impl.cc ('K') | « 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 80c2c74069c2d06db44d0c03b6c4c04c924b04ae..fdeb9eb7eee72f30cd755e4907231b2c424c1f46 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -100,6 +100,7 @@ class RasterThread : public base::Thread {
ManagedTileState::ManagedTileState()
: can_use_gpu_memory(false),
can_be_freed(true),
+ resource_id(0),
resource_is_being_initialized(false),
contents_swizzled(false) {
}
@@ -116,7 +117,8 @@ TileManager::TileManager(
: client_(client),
resource_pool_(ResourcePool::Create(resource_provider,
Renderer::ImplPool)),
- manage_tiles_pending_(false) {
+ manage_tiles_pending_(false),
+ check_for_completed_set_pixels_pending_(false) {
// Initialize all threads.
const std::string thread_name_prefix = kRasterThreadNamePrefix;
while (raster_threads_.size() < num_raster_threads) {
@@ -175,6 +177,13 @@ void TileManager::ScheduleManageTiles() {
manage_tiles_pending_ = true;
}
+void TileManager::ScheduleCheckForCompletedSetPixels() {
+ if (check_for_completed_set_pixels_pending_)
+ return;
+ client_->ScheduleCheckForCompletedSetPixels();
+ check_for_completed_set_pixels_pending_ = true;
+}
+
class BinComparator {
public:
bool operator() (const Tile* a, const Tile* b) const {
@@ -279,6 +288,29 @@ void TileManager::ManageTiles() {
DispatchMoreRasterTasks();
}
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
+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
+ check_for_completed_set_pixels_pending_ = false;
+
+ while (!tiles_with_pending_set_pixels_.empty()) {
+ Tile* tile = tiles_with_pending_set_pixels_.front();
+ DCHECK(tile->managed_state().resource);
+
+ // 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
+ if (!resource_pool_->resource_provider()->didSetPixelsComplete(
+ tile->managed_state().resource->id())) {
+ ScheduleCheckForCompletedSetPixels();
+ break;
+ }
+
+ // It's now safe to release the pixel buffer.
+ resource_pool_->resource_provider()->releasePixelBuffer(
+ tile->managed_state().resource->id());
+
+ DidFinishTileInitialization(tile);
+ tiles_with_pending_set_pixels_.pop();
+ }
+}
+
void TileManager::renderingStats(RenderingStats* stats) {
stats->totalRasterizeTimeInSeconds =
rendering_stats_.totalRasterizeTimeInSeconds;
@@ -420,16 +452,20 @@ void TileManager::OnRasterTaskCompleted(
// Finish resource initialization if |can_use_gpu_memory| is true.
if (managed_tile_state.can_use_gpu_memory) {
- resource_pool_->resource_provider()->setPixelsFromBuffer(resource->id());
- resource_pool_->resource_provider()->releasePixelBuffer(resource->id());
-
- // The component order may be bgra if we uploaded bgra pixels to rgba
+ // The component order may be bgra if we're uploading bgra pixels to rgba
// texture. Mark contents as swizzled if image component order is
// different than texture format.
managed_tile_state.contents_swizzled =
!PlatformColor::sameComponentOrder(tile->format_);
- DidFinishTileInitialization(tile, resource.Pass());
+ // Tile resources can't be freed until upload has completed.
+ managed_tile_state.can_be_freed = false;
+
+ resource_pool_->resource_provider()->beginSetPixels(resource->id());
+ 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
+ tiles_with_pending_set_pixels_.push(tile);
+
+ ScheduleCheckForCompletedSetPixels();
} else {
resource_pool_->resource_provider()->releasePixelBuffer(resource->id());
resource_pool_->ReleaseResource(resource.Pass());
@@ -439,14 +475,12 @@ void TileManager::OnRasterTaskCompleted(
DispatchMoreRasterTasks();
}
-void TileManager::DidFinishTileInitialization(
- Tile* tile, scoped_ptr<ResourcePool::Resource> resource) {
+void TileManager::DidFinishTileInitialization(Tile* tile) {
ManagedTileState& managed_tile_state = tile->managed_state();
- DCHECK(!managed_tile_state.resource);
- managed_tile_state.resource = resource.Pass();
+ DCHECK(managed_tile_state.resource);
+ managed_tile_state.resource_id = managed_tile_state.resource->id();
managed_tile_state.resource_is_being_initialized = false;
- // TODO(qinmin): Make this conditional on managed_tile_state.bin == NOW_BIN.
- client_->ScheduleRedraw();
+ managed_tile_state.can_be_freed = true;
}
}
« 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