Index: cc/trees/layer_tree_host_impl.cc |
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc |
index a3a9b2cc3f19c36783e007d71f4d11a23e3f7e9b..926964120880ee030d4644e1491bd22c9b26616d 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -153,6 +153,11 @@ |
max_transfer_buffer_usage_bytes); |
} |
+size_t GetMaxStagingResourceCount() { |
+ // Upper bound for number of staging resource to allow. |
+ return 32; |
+} |
+ |
size_t GetDefaultMemoryAllocationLimit() { |
// TODO(ccameron): (http://crbug.com/137094) This 64MB default is a straggler |
// from the old texture manager and is just to give us a default memory |
@@ -1231,13 +1236,22 @@ |
100); |
DCHECK(resource_pool_); |
- resource_pool_->CheckBusyResources(); |
+ resource_pool_->CheckBusyResources(false); |
// Soft limit is used for resource pool such that memory returns to soft |
// limit after going over. |
resource_pool_->SetResourceUsageLimits( |
global_tile_state_.soft_memory_limit_in_bytes, |
unused_memory_limit_in_bytes, |
global_tile_state_.num_resources_limit); |
+ |
+ // Release all staging resources when invisible. |
+ if (staging_resource_pool_) { |
+ staging_resource_pool_->CheckBusyResources(false); |
+ staging_resource_pool_->SetResourceUsageLimits( |
+ std::numeric_limits<size_t>::max(), |
+ std::numeric_limits<size_t>::max(), |
+ visible_ ? GetMaxStagingResourceCount() : 0); |
+ } |
DidModifyTilePriorities(); |
} |
@@ -1452,7 +1466,7 @@ |
// In OOM, we now might be able to release more resources that were held |
// because they were exported. |
if (resource_pool_) { |
- resource_pool_->CheckBusyResources(); |
+ resource_pool_->CheckBusyResources(false); |
resource_pool_->ReduceResourceUsage(); |
} |
// If we're not visible, we likely released resources, so we want to |
@@ -2063,7 +2077,8 @@ |
} |
void LayerTreeHostImpl::CreateTileManagerResources() { |
- CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); |
+ CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_, |
+ &staging_resource_pool_); |
// TODO(vmpstr): Initialize tile task limit at ctor time. |
tile_manager_->SetResources( |
resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(), |
@@ -2074,7 +2089,8 @@ |
void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( |
scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
- scoped_ptr<ResourcePool>* resource_pool) { |
+ scoped_ptr<ResourcePool>* resource_pool, |
+ scoped_ptr<ResourcePool>* staging_resource_pool) { |
DCHECK(GetTaskRunner()); |
// TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is |
// resolved. |
@@ -2100,8 +2116,6 @@ |
} |
if (use_gpu_rasterization_) { |
- DCHECK(resource_provider_->output_surface()->worker_context_provider()); |
- |
*resource_pool = |
ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); |
@@ -2116,16 +2130,7 @@ |
DCHECK(GetRendererCapabilities().using_image); |
- bool use_zero_copy = settings_.use_zero_copy; |
- // TODO(reveman): Remove this when mojo supports worker contexts. |
- // crbug.com/522440 |
- if (!resource_provider_->output_surface()->worker_context_provider()) { |
- LOG(ERROR) |
- << "Forcing zero-copy tile initialization as worker context is missing"; |
- use_zero_copy = true; |
- } |
- |
- if (use_zero_copy) { |
+ if (settings_.use_zero_copy) { |
*resource_pool = ResourcePool::Create(resource_provider_.get()); |
*tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( |
@@ -2134,6 +2139,13 @@ |
} |
if (settings_.use_one_copy) { |
+ // Synchronous single-threaded mode depends on tiles being ready to |
+ // draw when raster is complete. Therefore, it must use one of zero |
+ // copy, software raster, or GPU raster. |
+ DCHECK(!is_synchronous_single_threaded_); |
+ |
+ // We need to create a staging resource pool when using copy rasterizer. |
+ *staging_resource_pool = ResourcePool::Create(resource_provider_.get()); |
*resource_pool = |
ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); |
@@ -2143,9 +2155,9 @@ |
*tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
GetTaskRunner(), task_graph_runner, context_provider, |
- resource_provider_.get(), max_copy_texture_chromium_size, |
- settings_.use_persistent_map_for_gpu_memory_buffers, |
- settings_.max_staging_buffers); |
+ resource_provider_.get(), staging_resource_pool_.get(), |
+ max_copy_texture_chromium_size, |
+ settings_.use_persistent_map_for_gpu_memory_buffers); |
return; |
} |
@@ -2188,6 +2200,7 @@ |
void LayerTreeHostImpl::CleanUpTileManager() { |
tile_manager_->FinishTasksAndCleanUp(); |
resource_pool_ = nullptr; |
+ staging_resource_pool_ = nullptr; |
tile_task_worker_pool_ = nullptr; |
single_thread_synchronous_task_graph_runner_ = nullptr; |
} |
@@ -2221,6 +2234,7 @@ |
settings_.renderer_settings.highp_threshold_min, |
settings_.renderer_settings.use_rgba_4444_textures, |
settings_.renderer_settings.texture_id_allocation_chunk_size, |
+ settings_.use_persistent_map_for_gpu_memory_buffers, |
settings_.use_image_texture_targets); |
CreateAndSetRenderer(); |