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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 if (context_capabilities.gpu.egl_image_external) | 155 if (context_capabilities.gpu.egl_image_external) |
156 return GL_TEXTURE_EXTERNAL_OES; | 156 return GL_TEXTURE_EXTERNAL_OES; |
157 if (context_capabilities.gpu.texture_rectangle) | 157 if (context_capabilities.gpu.texture_rectangle) |
158 return GL_TEXTURE_RECTANGLE_ARB; | 158 return GL_TEXTURE_RECTANGLE_ARB; |
159 | 159 |
160 return GL_TEXTURE_2D; | 160 return GL_TEXTURE_2D; |
161 } | 161 } |
162 | 162 |
163 size_t GetMaxStagingResourceCount() { | 163 size_t GetMaxStagingResourceCount() { |
164 // Upper bound for number of staging resource to allow. | 164 // Upper bound for number of staging resource to allow. |
165 return 32; | 165 return 32 * 512 * 512 * 4; |
166 } | 166 } |
167 | 167 |
168 } // namespace | 168 } // namespace |
169 | 169 |
170 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { | 170 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { |
171 public: | 171 public: |
172 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( | 172 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( |
173 LayerTreeHostImpl* layer_tree_host_impl, | 173 LayerTreeHostImpl* layer_tree_host_impl, |
174 scoped_refptr<DelayBasedTimeSource> time_source) { | 174 scoped_refptr<DelayBasedTimeSource> time_source) { |
175 return make_scoped_ptr( | 175 return make_scoped_ptr( |
(...skipping 101 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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 global_tile_state_.soft_memory_limit_in_bytes = | 1221 global_tile_state_.soft_memory_limit_in_bytes = |
1223 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) * | 1222 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) * |
1224 settings_.max_memory_for_prepaint_percentage) / | 1223 settings_.max_memory_for_prepaint_percentage) / |
1225 100; | 1224 100; |
1226 } | 1225 } |
1227 global_tile_state_.memory_limit_policy = | 1226 global_tile_state_.memory_limit_policy = |
1228 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( | 1227 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( |
1229 visible_ ? | 1228 visible_ ? |
1230 policy.priority_cutoff_when_visible : | 1229 policy.priority_cutoff_when_visible : |
1231 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); | 1230 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); |
1232 global_tile_state_.num_resources_limit = policy.num_resources_limit; | |
1233 | 1231 |
1234 // TODO(reveman): We should avoid keeping around unused resources if | 1232 // TODO(reveman): We should avoid keeping around unused resources if |
1235 // possible. crbug.com/224475 | 1233 // possible. crbug.com/224475 |
1236 // Unused limit is calculated from soft-limit, as hard-limit may | 1234 // Unused limit is calculated from soft-limit, as hard-limit may |
1237 // be very high and shouldn't typically be exceeded. | 1235 // be very high and shouldn't typically be exceeded. |
1238 size_t unused_memory_limit_in_bytes = static_cast<size_t>( | 1236 size_t unused_memory_limit_in_bytes = static_cast<size_t>( |
1239 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) * | 1237 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) * |
1240 settings_.max_unused_resource_memory_percentage) / | 1238 settings_.max_unused_resource_memory_percentage) / |
1241 100); | 1239 100); |
1242 | 1240 |
1243 DCHECK(resource_pool_); | 1241 DCHECK(resource_pool_); |
1244 resource_pool_->CheckBusyResources(); | 1242 resource_pool_->CheckBusyResources(); |
1245 // Soft limit is used for resource pool such that memory returns to soft | 1243 // Soft limit is used for resource pool such that memory returns to soft |
1246 // limit after going over. | 1244 // limit after going over. |
1247 resource_pool_->SetResourceUsageLimits( | 1245 resource_pool_->SetResourceUsageLimits( |
1248 global_tile_state_.soft_memory_limit_in_bytes, | 1246 global_tile_state_.soft_memory_limit_in_bytes, |
1249 unused_memory_limit_in_bytes, | 1247 unused_memory_limit_in_bytes); |
1250 global_tile_state_.num_resources_limit); | |
1251 | 1248 |
1252 // Release all staging resources when invisible. | 1249 // Release all staging resources when invisible. |
1253 if (staging_resource_pool_) { | 1250 if (staging_resource_pool_) { |
1254 staging_resource_pool_->CheckBusyResources(); | 1251 staging_resource_pool_->CheckBusyResources(); |
1255 staging_resource_pool_->SetResourceUsageLimits( | 1252 size_t staging_bytes_limit = visible_ ? GetMaxStagingResourceCount() : 0u; |
1256 std::numeric_limits<size_t>::max(), | 1253 staging_resource_pool_->SetResourceUsageLimits(staging_bytes_limit, |
1257 std::numeric_limits<size_t>::max(), | 1254 staging_bytes_limit); |
1258 visible_ ? GetMaxStagingResourceCount() : 0); | |
1259 } | 1255 } |
1260 | 1256 |
1261 DidModifyTilePriorities(); | 1257 DidModifyTilePriorities(); |
1262 } | 1258 } |
1263 | 1259 |
1264 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1260 void LayerTreeHostImpl::DidModifyTilePriorities() { |
1265 DCHECK(settings_.impl_side_painting); | 1261 DCHECK(settings_.impl_side_painting); |
1266 // Mark priorities as dirty and schedule a ManageTiles(). | 1262 // Mark priorities as dirty and schedule a ManageTiles(). |
1267 tile_priorities_dirty_ = true; | 1263 tile_priorities_dirty_ = true; |
1268 client_->SetNeedsManageTilesOnImplThread(); | 1264 client_->SetNeedsManageTilesOnImplThread(); |
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3478 } | 3474 } |
3479 | 3475 |
3480 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3476 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3481 std::vector<PictureLayerImpl*>::iterator it = | 3477 std::vector<PictureLayerImpl*>::iterator it = |
3482 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3478 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3483 DCHECK(it != picture_layers_.end()); | 3479 DCHECK(it != picture_layers_.end()); |
3484 picture_layers_.erase(it); | 3480 picture_layers_.erase(it); |
3485 } | 3481 } |
3486 | 3482 |
3487 } // namespace cc | 3483 } // namespace cc |
OLD | NEW |