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

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
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 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 settings_.max_memory_for_prepaint_percentage) / 1231 settings_.max_memory_for_prepaint_percentage) /
1232 100; 1232 100;
1233 } 1233 }
1234 global_tile_state_.memory_limit_policy = 1234 global_tile_state_.memory_limit_policy =
1235 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( 1235 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
1236 visible_ ? 1236 visible_ ?
1237 policy.priority_cutoff_when_visible : 1237 policy.priority_cutoff_when_visible :
1238 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); 1238 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
1239 global_tile_state_.num_resources_limit = policy.num_resources_limit; 1239 global_tile_state_.num_resources_limit = policy.num_resources_limit;
1240 1240
1241 if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes > 0) { 1241 if (global_tile_state_.hard_memory_limit_in_bytes > 0) {
1242 // If |global_tile_state_.hard_memory_limit_in_bytes| is greater than 0, we 1242 // If |global_tile_state_.hard_memory_limit_in_bytes| is greater than 0, we
1243 // allow the worker context to retain allocated resources. Notify the worker 1243 // allow the worker context and image decode controller to retain allocated
1244 // context. If the memory policy has become zero, we'll handle the 1244 // resources. Notify them here. If the memory policy has become zero, we'll
1245 // notification in NotifyAllTileTasksCompleted, after in-progress work 1245 // handle the notification in NotifyAllTileTasksCompleted, after
1246 // finishes. 1246 // in-progress work finishes.
1247 output_surface_->SetWorkerContextShouldAggressivelyFreeResources( 1247 if (output_surface_) {
1248 false /* aggressively_free_resources */); 1248 output_surface_->SetWorkerContextShouldAggressivelyFreeResources(
1249 false /* aggressively_free_resources */);
1250 }
1251
1252 if (image_decode_controller_) {
1253 image_decode_controller_->SetShouldAggressivelyFreeResources(
1254 false /* aggressively_free_resources */);
1255 }
1249 } 1256 }
1250 1257
1251 DCHECK(resource_pool_); 1258 DCHECK(resource_pool_);
1252 resource_pool_->CheckBusyResources(); 1259 resource_pool_->CheckBusyResources();
1253 // Soft limit is used for resource pool such that memory returns to soft 1260 // Soft limit is used for resource pool such that memory returns to soft
1254 // limit after going over. 1261 // limit after going over.
1255 resource_pool_->SetResourceUsageLimits( 1262 resource_pool_->SetResourceUsageLimits(
1256 global_tile_state_.soft_memory_limit_in_bytes, 1263 global_tile_state_.soft_memory_limit_in_bytes,
1257 global_tile_state_.num_resources_limit); 1264 global_tile_state_.num_resources_limit);
1258 1265
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from 1316 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from
1310 // causing optimistic requests to draw a frame. 1317 // causing optimistic requests to draw a frame.
1311 is_likely_to_require_a_draw_ = false; 1318 is_likely_to_require_a_draw_ = false;
1312 1319
1313 client_->NotifyReadyToDraw(); 1320 client_->NotifyReadyToDraw();
1314 } 1321 }
1315 1322
1316 void LayerTreeHostImpl::NotifyAllTileTasksCompleted() { 1323 void LayerTreeHostImpl::NotifyAllTileTasksCompleted() {
1317 // The tile tasks started by the most recent call to PrepareTiles have 1324 // The tile tasks started by the most recent call to PrepareTiles have
1318 // completed. Now is a good time to free resources if necessary. 1325 // completed. Now is a good time to free resources if necessary.
1319 if (output_surface_ && global_tile_state_.hard_memory_limit_in_bytes == 0) { 1326 if (global_tile_state_.hard_memory_limit_in_bytes == 0) {
1320 output_surface_->SetWorkerContextShouldAggressivelyFreeResources( 1327 if (output_surface_) {
1321 true /* aggressively_free_resources */); 1328 output_surface_->SetWorkerContextShouldAggressivelyFreeResources(
1329 true /* aggressively_free_resources */);
1330 }
1331 if (image_decode_controller_) {
1332 image_decode_controller_->SetShouldAggressivelyFreeResources(
1333 true /* aggressively_free_resources */);
1334 }
1322 } 1335 }
1323 } 1336 }
1324 1337
1325 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { 1338 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) {
1326 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); 1339 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged");
1327 1340
1328 if (active_tree_) { 1341 if (active_tree_) {
1329 LayerImpl* layer_impl = 1342 LayerImpl* layer_impl =
1330 active_tree_->FindActiveTreeLayerById(tile->layer_id()); 1343 active_tree_->FindActiveTreeLayerById(tile->layer_id());
1331 if (layer_impl) 1344 if (layer_impl)
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 active_tree_->set_needs_update_draw_properties(); 2143 active_tree_->set_needs_update_draw_properties();
2131 if (pending_tree_) 2144 if (pending_tree_)
2132 pending_tree_->set_needs_update_draw_properties(); 2145 pending_tree_->set_needs_update_draw_properties();
2133 client_->UpdateRendererCapabilitiesOnImplThread(); 2146 client_->UpdateRendererCapabilitiesOnImplThread();
2134 } 2147 }
2135 2148
2136 void LayerTreeHostImpl::CreateTileManagerResources() { 2149 void LayerTreeHostImpl::CreateTileManagerResources() {
2137 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); 2150 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_);
2138 2151
2139 if (use_gpu_rasterization_) { 2152 if (use_gpu_rasterization_) {
2140 image_decode_controller_ = make_scoped_ptr(new GpuImageDecodeController); 2153 image_decode_controller_ = make_scoped_ptr(new GpuImageDecodeController(
2154 output_surface_->worker_context_provider(),
2155 settings_.renderer_settings.preferred_tile_format));
2141 } else { 2156 } else {
2142 image_decode_controller_ = 2157 image_decode_controller_ =
2143 make_scoped_ptr(new SoftwareImageDecodeController( 2158 make_scoped_ptr(new SoftwareImageDecodeController(
2144 settings_.renderer_settings.preferred_tile_format)); 2159 settings_.renderer_settings.preferred_tile_format));
2145 } 2160 }
2146 2161
2147 // TODO(vmpstr): Initialize tile task limit at ctor time. 2162 // TODO(vmpstr): Initialize tile task limit at ctor time.
2148 tile_manager_->SetResources( 2163 tile_manager_->SetResources(
2149 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(), 2164 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(),
2150 image_decode_controller_.get(), 2165 image_decode_controller_.get(),
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 return task_runner_provider_->HasImplThread(); 3954 return task_runner_provider_->HasImplThread();
3940 } 3955 }
3941 3956
3942 bool LayerTreeHostImpl::CommitToActiveTree() const { 3957 bool LayerTreeHostImpl::CommitToActiveTree() const {
3943 // In single threaded mode we skip the pending tree and commit directly to the 3958 // In single threaded mode we skip the pending tree and commit directly to the
3944 // active tree. 3959 // active tree.
3945 return !task_runner_provider_->HasImplThread(); 3960 return !task_runner_provider_->HasImplThread();
3946 } 3961 }
3947 3962
3948 } // namespace cc 3963 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698