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

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

Issue 1832573004: Gpu Image Decode Controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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.cc ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 settings_.max_memory_for_prepaint_percentage) / 1232 settings_.max_memory_for_prepaint_percentage) /
1233 100; 1233 100;
1234 } 1234 }
1235 global_tile_state_.memory_limit_policy = 1235 global_tile_state_.memory_limit_policy =
1236 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( 1236 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
1237 visible_ ? 1237 visible_ ?
1238 policy.priority_cutoff_when_visible : 1238 policy.priority_cutoff_when_visible :
1239 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); 1239 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
1240 global_tile_state_.num_resources_limit = policy.num_resources_limit; 1240 global_tile_state_.num_resources_limit = policy.num_resources_limit;
1241 1241
1242 if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes > 0) { 1242 if (global_tile_state_.hard_memory_limit_in_bytes > 0) {
1243 // If |global_tile_state_.hard_memory_limit_in_bytes| is greater than 0, we 1243 // If |global_tile_state_.hard_memory_limit_in_bytes| is greater than 0, we
1244 // allow the worker context to retain allocated resources. Notify the worker 1244 // allow the worker context and image decode controller to retain allocated
1245 // context. If the memory policy has become zero, we'll handle the 1245 // resources. Notify them here. If the memory policy has become zero, we'll
1246 // notification in NotifyAllTileTasksCompleted, after in-progress work 1246 // handle the notification in NotifyAllTileTasksCompleted, after
1247 // finishes. 1247 // in-progress work finishes.
1248 output_surface_->SetWorkerContextShouldAggressivelyFreeResources( 1248 if (output_surface_) {
1249 false /* aggressively_free_resources */); 1249 output_surface_->SetWorkerContextShouldAggressivelyFreeResources(
1250 false /* aggressively_free_resources */);
1251 }
1252
1253 if (image_decode_controller_) {
1254 image_decode_controller_->SetShouldAggressivelyFreeResources(
1255 false /* aggressively_free_resources */);
1256 }
1250 } 1257 }
1251 1258
1252 DCHECK(resource_pool_); 1259 DCHECK(resource_pool_);
1253 resource_pool_->CheckBusyResources(); 1260 resource_pool_->CheckBusyResources();
1254 // Soft limit is used for resource pool such that memory returns to soft 1261 // Soft limit is used for resource pool such that memory returns to soft
1255 // limit after going over. 1262 // limit after going over.
1256 resource_pool_->SetResourceUsageLimits( 1263 resource_pool_->SetResourceUsageLimits(
1257 global_tile_state_.soft_memory_limit_in_bytes, 1264 global_tile_state_.soft_memory_limit_in_bytes,
1258 global_tile_state_.num_resources_limit); 1265 global_tile_state_.num_resources_limit);
1259 1266
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from 1318 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from
1312 // causing optimistic requests to draw a frame. 1319 // causing optimistic requests to draw a frame.
1313 is_likely_to_require_a_draw_ = false; 1320 is_likely_to_require_a_draw_ = false;
1314 1321
1315 client_->NotifyReadyToDraw(); 1322 client_->NotifyReadyToDraw();
1316 } 1323 }
1317 1324
1318 void LayerTreeHostImpl::NotifyAllTileTasksCompleted() { 1325 void LayerTreeHostImpl::NotifyAllTileTasksCompleted() {
1319 // The tile tasks started by the most recent call to PrepareTiles have 1326 // The tile tasks started by the most recent call to PrepareTiles have
1320 // completed. Now is a good time to free resources if necessary. 1327 // completed. Now is a good time to free resources if necessary.
1321 if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes == 0) { 1328 if (global_tile_state_.hard_memory_limit_in_bytes == 0) {
1322 output_surface_->SetWorkerContextShouldAggressivelyFreeResources( 1329 if (output_surface_) {
1323 true /* aggressively_free_resources */); 1330 output_surface_->SetWorkerContextShouldAggressivelyFreeResources(
1331 true /* aggressively_free_resources */);
1332 }
1333 if (image_decode_controller_) {
1334 image_decode_controller_->SetShouldAggressivelyFreeResources(
1335 true /* aggressively_free_resources */);
1336 }
1324 } 1337 }
1325 } 1338 }
1326 1339
1327 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { 1340 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) {
1328 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); 1341 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged");
1329 1342
1330 if (active_tree_) { 1343 if (active_tree_) {
1331 LayerImpl* layer_impl = 1344 LayerImpl* layer_impl =
1332 active_tree_->FindActiveTreeLayerById(tile->layer_id()); 1345 active_tree_->FindActiveTreeLayerById(tile->layer_id());
1333 if (layer_impl) 1346 if (layer_impl)
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 active_tree_->set_needs_update_draw_properties(); 2145 active_tree_->set_needs_update_draw_properties();
2133 if (pending_tree_) 2146 if (pending_tree_)
2134 pending_tree_->set_needs_update_draw_properties(); 2147 pending_tree_->set_needs_update_draw_properties();
2135 client_->UpdateRendererCapabilitiesOnImplThread(); 2148 client_->UpdateRendererCapabilitiesOnImplThread();
2136 } 2149 }
2137 2150
2138 void LayerTreeHostImpl::CreateTileManagerResources() { 2151 void LayerTreeHostImpl::CreateTileManagerResources() {
2139 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); 2152 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_);
2140 2153
2141 if (use_gpu_rasterization_) { 2154 if (use_gpu_rasterization_) {
2142 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController); 2155 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController(
2156 output_surface_->worker_context_provider(),
2157 settings_.renderer_settings.preferred_tile_format));
2143 } else { 2158 } else {
2144 image_decode_controller_ = 2159 image_decode_controller_ =
2145 base::WrapUnique(new SoftwareImageDecodeController( 2160 base::WrapUnique(new SoftwareImageDecodeController(
2146 settings_.renderer_settings.preferred_tile_format)); 2161 settings_.renderer_settings.preferred_tile_format));
2147 } 2162 }
2148 2163
2149 // TODO(vmpstr): Initialize tile task limit at ctor time. 2164 // TODO(vmpstr): Initialize tile task limit at ctor time.
2150 tile_manager_->SetResources( 2165 tile_manager_->SetResources(
2151 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(), 2166 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(),
2152 image_decode_controller_.get(), 2167 image_decode_controller_.get(),
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
3942 return task_runner_provider_->HasImplThread(); 3957 return task_runner_provider_->HasImplThread();
3943 } 3958 }
3944 3959
3945 bool LayerTreeHostImpl::CommitToActiveTree() const { 3960 bool LayerTreeHostImpl::CommitToActiveTree() const {
3946 // In single threaded mode we skip the pending tree and commit directly to the 3961 // In single threaded mode we skip the pending tree and commit directly to the
3947 // active tree. 3962 // active tree.
3948 return !task_runner_provider_->HasImplThread(); 3963 return !task_runner_provider_->HasImplThread();
3949 } 3964 }
3950 3965
3951 } // namespace cc 3966 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.cc ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698