Chromium Code Reviews| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 should_bubble_scrolls_(false), | 277 should_bubble_scrolls_(false), |
| 278 wheel_scrolling_(false), | 278 wheel_scrolling_(false), |
| 279 scroll_affects_scroll_handler_(false), | 279 scroll_affects_scroll_handler_(false), |
| 280 scroll_layer_id_when_mouse_over_scrollbar_(0), | 280 scroll_layer_id_when_mouse_over_scrollbar_(0), |
| 281 tile_priorities_dirty_(false), | 281 tile_priorities_dirty_(false), |
| 282 root_layer_scroll_offset_delegate_(NULL), | 282 root_layer_scroll_offset_delegate_(NULL), |
| 283 settings_(settings), | 283 settings_(settings), |
| 284 visible_(true), | 284 visible_(true), |
| 285 cached_managed_memory_policy_( | 285 cached_managed_memory_policy_( |
| 286 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 286 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
| 287 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 287 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING), |
| 288 ManagedMemoryPolicy::kDefaultNumResourcesLimit), | |
| 289 pinch_gesture_active_(false), | 288 pinch_gesture_active_(false), |
| 290 pinch_gesture_end_should_clear_scrolling_layer_(false), | 289 pinch_gesture_end_should_clear_scrolling_layer_(false), |
| 291 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), | 290 fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())), |
| 292 paint_time_counter_(PaintTimeCounter::Create()), | 291 paint_time_counter_(PaintTimeCounter::Create()), |
| 293 memory_history_(MemoryHistory::Create()), | 292 memory_history_(MemoryHistory::Create()), |
| 294 debug_rect_history_(DebugRectHistory::Create()), | 293 debug_rect_history_(DebugRectHistory::Create()), |
| 295 texture_mailbox_deleter_(new TextureMailboxDeleter( | 294 texture_mailbox_deleter_(new TextureMailboxDeleter( |
| 296 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 295 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
| 297 : proxy_->MainThreadTaskRunner())), | 296 : proxy_->MainThreadTaskRunner())), |
| 298 max_memory_needed_bytes_(0), | 297 max_memory_needed_bytes_(0), |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1216 global_tile_state_.soft_memory_limit_in_bytes = | 1215 global_tile_state_.soft_memory_limit_in_bytes = |
| 1217 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) * | 1216 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) * |
| 1218 settings_.max_memory_for_prepaint_percentage) / | 1217 settings_.max_memory_for_prepaint_percentage) / |
| 1219 100; | 1218 100; |
| 1220 } | 1219 } |
| 1221 global_tile_state_.memory_limit_policy = | 1220 global_tile_state_.memory_limit_policy = |
| 1222 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( | 1221 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( |
| 1223 visible_ ? | 1222 visible_ ? |
| 1224 policy.priority_cutoff_when_visible : | 1223 policy.priority_cutoff_when_visible : |
| 1225 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); | 1224 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); |
| 1226 global_tile_state_.num_resources_limit = policy.num_resources_limit; | |
| 1227 | 1225 |
| 1228 // TODO(reveman): We should avoid keeping around unused resources if | 1226 // TODO(reveman): We should avoid keeping around unused resources if |
| 1229 // possible. crbug.com/224475 | 1227 // possible. crbug.com/224475 |
| 1230 // Unused limit is calculated from soft-limit, as hard-limit may | 1228 // Unused limit is calculated from soft-limit, as hard-limit may |
| 1231 // be very high and shouldn't typically be exceeded. | 1229 // be very high and shouldn't typically be exceeded. |
| 1232 size_t unused_memory_limit_in_bytes = static_cast<size_t>( | 1230 size_t unused_memory_limit_in_bytes = static_cast<size_t>( |
| 1233 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) * | 1231 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) * |
| 1234 settings_.max_unused_resource_memory_percentage) / | 1232 settings_.max_unused_resource_memory_percentage) / |
| 1235 100); | 1233 100); |
| 1236 | 1234 |
| 1237 DCHECK(resource_pool_); | 1235 DCHECK(resource_pool_); |
| 1238 resource_pool_->CheckBusyResources(); | 1236 resource_pool_->CheckBusyResources(); |
| 1239 // Soft limit is used for resource pool such that memory returns to soft | 1237 // Soft limit is used for resource pool such that memory returns to soft |
| 1240 // limit after going over. | 1238 // limit after going over. |
| 1241 resource_pool_->SetResourceUsageLimits( | 1239 resource_pool_->SetResourceUsageLimits( |
| 1242 global_tile_state_.soft_memory_limit_in_bytes, | 1240 global_tile_state_.soft_memory_limit_in_bytes, |
| 1243 unused_memory_limit_in_bytes, | 1241 unused_memory_limit_in_bytes); |
| 1244 global_tile_state_.num_resources_limit); | |
| 1245 | 1242 |
| 1246 // Release all staging resources when invisible. | 1243 // Release all staging resources when invisible. |
| 1247 if (staging_resource_pool_) { | 1244 if (staging_resource_pool_) { |
| 1248 staging_resource_pool_->CheckBusyResources(); | 1245 staging_resource_pool_->CheckBusyResources(); |
| 1249 staging_resource_pool_->SetResourceUsageLimits( | 1246 size_t bytes_per_tile = settings_.default_tile_size.width() * |
| 1250 std::numeric_limits<size_t>::max(), | 1247 settings_.default_tile_size.height() * |
| 1251 std::numeric_limits<size_t>::max(), | 1248 4; // Conservative 4 bytes per pixel. |
| 1252 visible_ ? GetMaxStagingResourceCount() : 0); | 1249 size_t staging_bytes_limit = bytes_per_tile * GetMaxStagingResourceCount(); |
| 1250 staging_resource_pool_->SetResourceUsageLimits(staging_bytes_limit, | |
| 1251 staging_bytes_limit); | |
|
reveman
2014/10/27 13:39:00
Where did the visible_ check go?
The actual limit
boliu
2014/10/27 15:35:58
Oops my bad! Added back now.
| |
| 1253 } | 1252 } |
| 1254 | 1253 |
| 1255 DidModifyTilePriorities(); | 1254 DidModifyTilePriorities(); |
| 1256 } | 1255 } |
| 1257 | 1256 |
| 1258 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1257 void LayerTreeHostImpl::DidModifyTilePriorities() { |
| 1259 DCHECK(settings_.impl_side_painting); | 1258 DCHECK(settings_.impl_side_painting); |
| 1260 // Mark priorities as dirty and schedule a ManageTiles(). | 1259 // Mark priorities as dirty and schedule a ManageTiles(). |
| 1261 tile_priorities_dirty_ = true; | 1260 tile_priorities_dirty_ = true; |
| 1262 client_->SetNeedsManageTilesOnImplThread(); | 1261 client_->SetNeedsManageTilesOnImplThread(); |
| (...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3472 } | 3471 } |
| 3473 | 3472 |
| 3474 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3473 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3475 std::vector<PictureLayerImpl*>::iterator it = | 3474 std::vector<PictureLayerImpl*>::iterator it = |
| 3476 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3475 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3477 DCHECK(it != picture_layers_.end()); | 3476 DCHECK(it != picture_layers_.end()); |
| 3478 picture_layers_.erase(it); | 3477 picture_layers_.erase(it); |
| 3479 } | 3478 } |
| 3480 | 3479 |
| 3481 } // namespace cc | 3480 } // namespace cc |
| OLD | NEW |