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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 1293873005: Expire resources in ResourcePool after non-use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@re-use
Patch Set: Fix unit test Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « cc/tiles/tile_manager_unittest.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes > 0) { 1214 if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes > 0) {
1215 // If |global_tile_state_.hard_memory_limit_in_bytes| is greater than 0, we 1215 // If |global_tile_state_.hard_memory_limit_in_bytes| is greater than 0, we
1216 // allow the worker context to retain allocated resources. Notify the worker 1216 // allow the worker context to retain allocated resources. Notify the worker
1217 // context. If the memory policy has become zero, we'll handle the 1217 // context. If the memory policy has become zero, we'll handle the
1218 // notification in NotifyAllTileTasksCompleted, after in-progress work 1218 // notification in NotifyAllTileTasksCompleted, after in-progress work
1219 // finishes. 1219 // finishes.
1220 output_surface_->SetWorkerContextShouldAggressivelyFreeResources( 1220 output_surface_->SetWorkerContextShouldAggressivelyFreeResources(
1221 false /* aggressively_free_resources */); 1221 false /* aggressively_free_resources */);
1222 } 1222 }
1223 1223
1224 // TODO(reveman): We should avoid keeping around unused resources if
1225 // possible. crbug.com/224475
1226 // Unused limit is calculated from soft-limit, as hard-limit may
1227 // be very high and shouldn't typically be exceeded.
1228 size_t unused_memory_limit_in_bytes = static_cast<size_t>(
1229 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) *
1230 settings_.max_unused_resource_memory_percentage) /
1231 100);
1232
1233 DCHECK(resource_pool_); 1224 DCHECK(resource_pool_);
1234 resource_pool_->CheckBusyResources(); 1225 resource_pool_->CheckBusyResources();
1235 // Soft limit is used for resource pool such that memory returns to soft 1226 // Soft limit is used for resource pool such that memory returns to soft
1236 // limit after going over. 1227 // limit after going over.
1237 resource_pool_->SetResourceUsageLimits( 1228 resource_pool_->SetResourceUsageLimits(
1238 global_tile_state_.soft_memory_limit_in_bytes, 1229 global_tile_state_.soft_memory_limit_in_bytes,
1239 unused_memory_limit_in_bytes,
1240 global_tile_state_.num_resources_limit); 1230 global_tile_state_.num_resources_limit);
1241 1231
1242 DidModifyTilePriorities(); 1232 DidModifyTilePriorities();
1243 } 1233 }
1244 1234
1245 void LayerTreeHostImpl::DidModifyTilePriorities() { 1235 void LayerTreeHostImpl::DidModifyTilePriorities() {
1246 // Mark priorities as dirty and schedule a PrepareTiles(). 1236 // Mark priorities as dirty and schedule a PrepareTiles().
1247 tile_priorities_dirty_ = true; 1237 tile_priorities_dirty_ = true;
1248 client_->SetNeedsPrepareTilesOnImplThread(); 1238 client_->SetNeedsPrepareTilesOnImplThread();
1249 } 1239 }
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 // if we're in synchronous single-threaded mode. 2074 // if we're in synchronous single-threaded mode.
2085 TaskGraphRunner* task_graph_runner = task_graph_runner_; 2075 TaskGraphRunner* task_graph_runner = task_graph_runner_;
2086 if (is_synchronous_single_threaded_) { 2076 if (is_synchronous_single_threaded_) {
2087 DCHECK(!single_thread_synchronous_task_graph_runner_); 2077 DCHECK(!single_thread_synchronous_task_graph_runner_);
2088 single_thread_synchronous_task_graph_runner_.reset(new TaskGraphRunner); 2078 single_thread_synchronous_task_graph_runner_.reset(new TaskGraphRunner);
2089 task_graph_runner = single_thread_synchronous_task_graph_runner_.get(); 2079 task_graph_runner = single_thread_synchronous_task_graph_runner_.get();
2090 } 2080 }
2091 2081
2092 ContextProvider* context_provider = output_surface_->context_provider(); 2082 ContextProvider* context_provider = output_surface_->context_provider();
2093 if (!context_provider) { 2083 if (!context_provider) {
2094 *resource_pool = 2084 *resource_pool = ResourcePool::Create(resource_provider_.get(),
2095 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); 2085 GetTaskRunner(), GL_TEXTURE_2D);
2096 2086
2097 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( 2087 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create(
2098 GetTaskRunner(), task_graph_runner, resource_provider_.get()); 2088 GetTaskRunner(), task_graph_runner, resource_provider_.get());
2099 return; 2089 return;
2100 } 2090 }
2101 2091
2102 if (use_gpu_rasterization_) { 2092 if (use_gpu_rasterization_) {
2103 DCHECK(resource_provider_->output_surface()->worker_context_provider()); 2093 DCHECK(resource_provider_->output_surface()->worker_context_provider());
2104 2094
2105 *resource_pool = 2095 *resource_pool = ResourcePool::Create(resource_provider_.get(),
2106 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); 2096 GetTaskRunner(), GL_TEXTURE_2D);
2107 2097
2108 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; 2098 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0;
2109 2099
2110 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( 2100 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create(
2111 GetTaskRunner(), task_graph_runner, context_provider, 2101 GetTaskRunner(), task_graph_runner, context_provider,
2112 resource_provider_.get(), settings_.use_distance_field_text, 2102 resource_provider_.get(), settings_.use_distance_field_text,
2113 msaa_sample_count); 2103 msaa_sample_count);
2114 return; 2104 return;
2115 } 2105 }
2116 2106
2117 DCHECK(GetRendererCapabilities().using_image); 2107 DCHECK(GetRendererCapabilities().using_image);
2118 2108
2119 bool use_zero_copy = settings_.use_zero_copy; 2109 bool use_zero_copy = settings_.use_zero_copy;
2120 // TODO(reveman): Remove this when mojo supports worker contexts. 2110 // TODO(reveman): Remove this when mojo supports worker contexts.
2121 // crbug.com/522440 2111 // crbug.com/522440
2122 if (!resource_provider_->output_surface()->worker_context_provider()) { 2112 if (!resource_provider_->output_surface()->worker_context_provider()) {
2123 LOG(ERROR) 2113 LOG(ERROR)
2124 << "Forcing zero-copy tile initialization as worker context is missing"; 2114 << "Forcing zero-copy tile initialization as worker context is missing";
2125 use_zero_copy = true; 2115 use_zero_copy = true;
2126 } 2116 }
2127 2117
2128 if (use_zero_copy) { 2118 if (use_zero_copy) {
2129 *resource_pool = ResourcePool::Create(resource_provider_.get()); 2119 *resource_pool =
2120 ResourcePool::Create(resource_provider_.get(), GetTaskRunner());
2130 2121
2131 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( 2122 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create(
2132 GetTaskRunner(), task_graph_runner, resource_provider_.get()); 2123 GetTaskRunner(), task_graph_runner, resource_provider_.get());
2133 return; 2124 return;
2134 } 2125 }
2135 2126
2136 if (settings_.use_one_copy) { 2127 if (settings_.use_one_copy) {
2137 *resource_pool = 2128 *resource_pool = ResourcePool::Create(resource_provider_.get(),
2138 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); 2129 GetTaskRunner(), GL_TEXTURE_2D);
2139 2130
2140 int max_copy_texture_chromium_size = 2131 int max_copy_texture_chromium_size =
2141 context_provider->ContextCapabilities() 2132 context_provider->ContextCapabilities()
2142 .gpu.max_copy_texture_chromium_size; 2133 .gpu.max_copy_texture_chromium_size;
2143 2134
2144 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( 2135 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create(
2145 GetTaskRunner(), task_graph_runner, context_provider, 2136 GetTaskRunner(), task_graph_runner, context_provider,
2146 resource_provider_.get(), max_copy_texture_chromium_size, 2137 resource_provider_.get(), max_copy_texture_chromium_size,
2147 settings_.use_persistent_map_for_gpu_memory_buffers, 2138 settings_.use_persistent_map_for_gpu_memory_buffers,
2148 settings_.max_staging_buffers); 2139 settings_.max_staging_buffers);
2149 return; 2140 return;
2150 } 2141 }
2151 2142
2152 // Synchronous single-threaded mode depends on tiles being ready to 2143 // Synchronous single-threaded mode depends on tiles being ready to
2153 // draw when raster is complete. Therefore, it must use one of zero 2144 // draw when raster is complete. Therefore, it must use one of zero
2154 // copy, software raster, or GPU raster (in the branches above). 2145 // copy, software raster, or GPU raster (in the branches above).
2155 DCHECK(!is_synchronous_single_threaded_); 2146 DCHECK(!is_synchronous_single_threaded_);
2156 2147
2157 *resource_pool = ResourcePool::Create( 2148 *resource_pool = ResourcePool::Create(resource_provider_.get(),
2158 resource_provider_.get(), GL_TEXTURE_2D); 2149 GetTaskRunner(), GL_TEXTURE_2D);
2159 2150
2160 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( 2151 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create(
2161 GetTaskRunner(), task_graph_runner_, context_provider, 2152 GetTaskRunner(), task_graph_runner_, context_provider,
2162 resource_provider_.get(), 2153 resource_provider_.get(),
2163 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), 2154 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(),
2164 settings_.renderer_settings.refresh_rate)); 2155 settings_.renderer_settings.refresh_rate));
2165 } 2156 }
2166 2157
2167 void LayerTreeHostImpl::RecordMainFrameTiming( 2158 void LayerTreeHostImpl::RecordMainFrameTiming(
2168 const BeginFrameArgs& start_of_main_frame_args, 2159 const BeginFrameArgs& start_of_main_frame_args,
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
3631 if (active_tree()) { 3622 if (active_tree()) {
3632 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); 3623 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id);
3633 if (layer) 3624 if (layer)
3634 return layer->ScrollOffsetForAnimation(); 3625 return layer->ScrollOffsetForAnimation();
3635 } 3626 }
3636 3627
3637 return gfx::ScrollOffset(); 3628 return gfx::ScrollOffset();
3638 } 3629 }
3639 3630
3640 } // namespace cc 3631 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager_unittest.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698