OLD | NEW |
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 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 // TODO(reveman): We should avoid keeping around unused resources if | 1228 // TODO(reveman): We should avoid keeping around unused resources if |
1229 // possible. crbug.com/224475 | 1229 // possible. crbug.com/224475 |
1230 // Unused limit is calculated from soft-limit, as hard-limit may | 1230 // Unused limit is calculated from soft-limit, as hard-limit may |
1231 // be very high and shouldn't typically be exceeded. | 1231 // be very high and shouldn't typically be exceeded. |
1232 size_t unused_memory_limit_in_bytes = static_cast<size_t>( | 1232 size_t unused_memory_limit_in_bytes = static_cast<size_t>( |
1233 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) * | 1233 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) * |
1234 settings_.max_unused_resource_memory_percentage) / | 1234 settings_.max_unused_resource_memory_percentage) / |
1235 100); | 1235 100); |
1236 | 1236 |
1237 DCHECK(resource_pool_); | 1237 DCHECK(resource_pool_); |
1238 resource_pool_->CheckBusyResources(); | 1238 resource_pool_->CheckBusyResources(false); |
1239 // Soft limit is used for resource pool such that memory returns to soft | 1239 // Soft limit is used for resource pool such that memory returns to soft |
1240 // limit after going over. | 1240 // limit after going over. |
1241 resource_pool_->SetResourceUsageLimits( | 1241 resource_pool_->SetResourceUsageLimits( |
1242 global_tile_state_.soft_memory_limit_in_bytes, | 1242 global_tile_state_.soft_memory_limit_in_bytes, |
1243 unused_memory_limit_in_bytes, | 1243 unused_memory_limit_in_bytes, |
1244 global_tile_state_.num_resources_limit); | 1244 global_tile_state_.num_resources_limit); |
1245 | 1245 |
1246 // Release all staging resources when invisible. | 1246 // Release all staging resources when invisible. |
1247 if (staging_resource_pool_) { | 1247 if (staging_resource_pool_) { |
1248 staging_resource_pool_->CheckBusyResources(); | 1248 staging_resource_pool_->CheckBusyResources(false); |
1249 staging_resource_pool_->SetResourceUsageLimits( | 1249 staging_resource_pool_->SetResourceUsageLimits( |
1250 std::numeric_limits<size_t>::max(), | 1250 std::numeric_limits<size_t>::max(), |
1251 std::numeric_limits<size_t>::max(), | 1251 std::numeric_limits<size_t>::max(), |
1252 visible_ ? GetMaxStagingResourceCount() : 0); | 1252 visible_ ? GetMaxStagingResourceCount() : 0); |
1253 } | 1253 } |
1254 | 1254 |
1255 DidModifyTilePriorities(); | 1255 DidModifyTilePriorities(); |
1256 } | 1256 } |
1257 | 1257 |
1258 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1258 void LayerTreeHostImpl::DidModifyTilePriorities() { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 // TODO(piman): We may need to do some validation on this ack before | 1450 // TODO(piman): We may need to do some validation on this ack before |
1451 // processing it. | 1451 // processing it. |
1452 if (renderer_) | 1452 if (renderer_) |
1453 renderer_->ReceiveSwapBuffersAck(*ack); | 1453 renderer_->ReceiveSwapBuffersAck(*ack); |
1454 | 1454 |
1455 // In OOM, we now might be able to release more resources that were held | 1455 // In OOM, we now might be able to release more resources that were held |
1456 // because they were exported. | 1456 // because they were exported. |
1457 if (tile_manager_) { | 1457 if (tile_manager_) { |
1458 DCHECK(resource_pool_); | 1458 DCHECK(resource_pool_); |
1459 | 1459 |
1460 resource_pool_->CheckBusyResources(); | 1460 resource_pool_->CheckBusyResources(false); |
1461 resource_pool_->ReduceResourceUsage(); | 1461 resource_pool_->ReduceResourceUsage(); |
1462 } | 1462 } |
1463 // If we're not visible, we likely released resources, so we want to | 1463 // If we're not visible, we likely released resources, so we want to |
1464 // aggressively flush here to make sure those DeleteTextures make it to the | 1464 // aggressively flush here to make sure those DeleteTextures make it to the |
1465 // GPU process to free up the memory. | 1465 // GPU process to free up the memory. |
1466 if (output_surface_->context_provider() && !visible_) { | 1466 if (output_surface_->context_provider() && !visible_) { |
1467 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); | 1467 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); |
1468 } | 1468 } |
1469 } | 1469 } |
1470 | 1470 |
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3476 } | 3476 } |
3477 | 3477 |
3478 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3478 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3479 std::vector<PictureLayerImpl*>::iterator it = | 3479 std::vector<PictureLayerImpl*>::iterator it = |
3480 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3480 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3481 DCHECK(it != picture_layers_.end()); | 3481 DCHECK(it != picture_layers_.end()); |
3482 picture_layers_.erase(it); | 3482 picture_layers_.erase(it); |
3483 } | 3483 } |
3484 | 3484 |
3485 } // namespace cc | 3485 } // namespace cc |
OLD | NEW |