| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return GL_TEXTURE_2D; | 122 return GL_TEXTURE_2D; |
| 123 | 123 |
| 124 if (context_provider->ContextCapabilities().gpu.egl_image_external) | 124 if (context_provider->ContextCapabilities().gpu.egl_image_external) |
| 125 return GL_TEXTURE_EXTERNAL_OES; | 125 return GL_TEXTURE_EXTERNAL_OES; |
| 126 if (context_provider->ContextCapabilities().gpu.texture_rectangle) | 126 if (context_provider->ContextCapabilities().gpu.texture_rectangle) |
| 127 return GL_TEXTURE_RECTANGLE_ARB; | 127 return GL_TEXTURE_RECTANGLE_ARB; |
| 128 | 128 |
| 129 return GL_TEXTURE_2D; | 129 return GL_TEXTURE_2D; |
| 130 } | 130 } |
| 131 | 131 |
| 132 size_t GetMaxStagingResourceCount() { |
| 133 // Upper bound for number of staging resource to allow. |
| 134 return 32; |
| 135 } |
| 136 |
| 132 } // namespace | 137 } // namespace |
| 133 | 138 |
| 134 namespace cc { | 139 namespace cc { |
| 135 | 140 |
| 136 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { | 141 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { |
| 137 public: | 142 public: |
| 138 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( | 143 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( |
| 139 LayerTreeHostImpl* layer_tree_host_impl, | 144 LayerTreeHostImpl* layer_tree_host_impl, |
| 140 scoped_refptr<DelayBasedTimeSource> time_source) { | 145 scoped_refptr<DelayBasedTimeSource> time_source) { |
| 141 return make_scoped_ptr( | 146 return make_scoped_ptr( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 zero_budget_(false), | 262 zero_budget_(false), |
| 258 device_scale_factor_(1.f), | 263 device_scale_factor_(1.f), |
| 259 overhang_ui_resource_id_(0), | 264 overhang_ui_resource_id_(0), |
| 260 resourceless_software_draw_(false), | 265 resourceless_software_draw_(false), |
| 261 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 266 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 262 animation_registrar_(AnimationRegistrar::Create()), | 267 animation_registrar_(AnimationRegistrar::Create()), |
| 263 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 268 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 264 micro_benchmark_controller_(this), | 269 micro_benchmark_controller_(this), |
| 265 need_to_update_visible_tiles_before_draw_(false), | 270 need_to_update_visible_tiles_before_draw_(false), |
| 266 shared_bitmap_manager_(manager), | 271 shared_bitmap_manager_(manager), |
| 267 id_(id), | 272 id_(id) { |
| 268 transfer_buffer_memory_limit_(0u) { | |
| 269 DCHECK(proxy_->IsImplThread()); | 273 DCHECK(proxy_->IsImplThread()); |
| 270 DidVisibilityChange(this, visible_); | 274 DidVisibilityChange(this, visible_); |
| 271 animation_registrar_->set_supports_scroll_animations( | 275 animation_registrar_->set_supports_scroll_animations( |
| 272 proxy_->SupportsImplScrolling()); | 276 proxy_->SupportsImplScrolling()); |
| 273 | 277 |
| 274 SetDebugState(settings.initial_debug_state); | 278 SetDebugState(settings.initial_debug_state); |
| 275 | 279 |
| 276 // LTHI always has an active tree. | 280 // LTHI always has an active tree. |
| 277 active_tree_ = LayerTreeImpl::create(this); | 281 active_tree_ = LayerTreeImpl::create(this); |
| 278 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 282 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 | 1235 |
| 1232 DCHECK(resource_pool_); | 1236 DCHECK(resource_pool_); |
| 1233 resource_pool_->CheckBusyResources(); | 1237 resource_pool_->CheckBusyResources(); |
| 1234 // Soft limit is used for resource pool such that memory returns to soft | 1238 // Soft limit is used for resource pool such that memory returns to soft |
| 1235 // limit after going over. | 1239 // limit after going over. |
| 1236 resource_pool_->SetResourceUsageLimits( | 1240 resource_pool_->SetResourceUsageLimits( |
| 1237 global_tile_state_.soft_memory_limit_in_bytes, | 1241 global_tile_state_.soft_memory_limit_in_bytes, |
| 1238 unused_memory_limit_in_bytes, | 1242 unused_memory_limit_in_bytes, |
| 1239 global_tile_state_.num_resources_limit); | 1243 global_tile_state_.num_resources_limit); |
| 1240 | 1244 |
| 1241 // Staging pool resources are used as transfer buffers so we use | 1245 // Release all staging resources when invisible. |
| 1242 // |transfer_buffer_memory_limit_| as the memory limit for this resource pool. | |
| 1243 if (staging_resource_pool_) { | 1246 if (staging_resource_pool_) { |
| 1244 staging_resource_pool_->CheckBusyResources(); | 1247 staging_resource_pool_->CheckBusyResources(); |
| 1245 staging_resource_pool_->SetResourceUsageLimits( | 1248 staging_resource_pool_->SetResourceUsageLimits( |
| 1246 visible_ ? transfer_buffer_memory_limit_ : 0, | 1249 std::numeric_limits<size_t>::max(), |
| 1247 transfer_buffer_memory_limit_, | 1250 std::numeric_limits<size_t>::max(), |
| 1248 std::numeric_limits<size_t>::max()); | 1251 visible_ ? GetMaxStagingResourceCount() : 0); |
| 1249 } | 1252 } |
| 1250 | 1253 |
| 1251 DidModifyTilePriorities(); | 1254 DidModifyTilePriorities(); |
| 1252 } | 1255 } |
| 1253 | 1256 |
| 1254 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1257 void LayerTreeHostImpl::DidModifyTilePriorities() { |
| 1255 DCHECK(settings_.impl_side_painting); | 1258 DCHECK(settings_.impl_side_painting); |
| 1256 // Mark priorities as dirty and schedule a ManageTiles(). | 1259 // Mark priorities as dirty and schedule a ManageTiles(). |
| 1257 tile_priorities_dirty_ = true; | 1260 tile_priorities_dirty_ = true; |
| 1258 client_->SetNeedsManageTilesOnImplThread(); | 1261 client_->SetNeedsManageTilesOnImplThread(); |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 } | 1959 } |
| 1957 | 1960 |
| 1958 void LayerTreeHostImpl::CreateAndSetTileManager() { | 1961 void LayerTreeHostImpl::CreateAndSetTileManager() { |
| 1959 DCHECK(!tile_manager_); | 1962 DCHECK(!tile_manager_); |
| 1960 DCHECK(settings_.impl_side_painting); | 1963 DCHECK(settings_.impl_side_painting); |
| 1961 DCHECK(output_surface_); | 1964 DCHECK(output_surface_); |
| 1962 DCHECK(resource_provider_); | 1965 DCHECK(resource_provider_); |
| 1963 DCHECK(proxy_->ImplThreadTaskRunner()); | 1966 DCHECK(proxy_->ImplThreadTaskRunner()); |
| 1964 | 1967 |
| 1965 ContextProvider* context_provider = output_surface_->context_provider(); | 1968 ContextProvider* context_provider = output_surface_->context_provider(); |
| 1966 transfer_buffer_memory_limit_ = | |
| 1967 GetMaxTransferBufferUsageBytes(context_provider, settings_.refresh_rate); | |
| 1968 | |
| 1969 if (use_gpu_rasterization_ && context_provider) { | 1969 if (use_gpu_rasterization_ && context_provider) { |
| 1970 resource_pool_ = | 1970 resource_pool_ = |
| 1971 ResourcePool::Create(resource_provider_.get(), | 1971 ResourcePool::Create(resource_provider_.get(), |
| 1972 GL_TEXTURE_2D, | 1972 GL_TEXTURE_2D, |
| 1973 resource_provider_->best_texture_format()); | 1973 resource_provider_->best_texture_format()); |
| 1974 | 1974 |
| 1975 raster_worker_pool_ = | 1975 raster_worker_pool_ = |
| 1976 GpuRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), | 1976 GpuRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), |
| 1977 context_provider, | 1977 context_provider, |
| 1978 resource_provider_.get()); | 1978 resource_provider_.get()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1997 resource_pool_ = ResourcePool::Create( | 1997 resource_pool_ = ResourcePool::Create( |
| 1998 resource_provider_.get(), | 1998 resource_provider_.get(), |
| 1999 GL_TEXTURE_2D, | 1999 GL_TEXTURE_2D, |
| 2000 resource_provider_->memory_efficient_texture_format()); | 2000 resource_provider_->memory_efficient_texture_format()); |
| 2001 | 2001 |
| 2002 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( | 2002 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( |
| 2003 proxy_->ImplThreadTaskRunner(), | 2003 proxy_->ImplThreadTaskRunner(), |
| 2004 RasterWorkerPool::GetTaskGraphRunner(), | 2004 RasterWorkerPool::GetTaskGraphRunner(), |
| 2005 context_provider, | 2005 context_provider, |
| 2006 resource_provider_.get(), | 2006 resource_provider_.get(), |
| 2007 transfer_buffer_memory_limit_); | 2007 GetMaxTransferBufferUsageBytes(context_provider, |
| 2008 settings_.refresh_rate)); |
| 2008 } else { | 2009 } else { |
| 2009 resource_pool_ = | 2010 resource_pool_ = |
| 2010 ResourcePool::Create(resource_provider_.get(), | 2011 ResourcePool::Create(resource_provider_.get(), |
| 2011 GetMapImageTextureTarget(context_provider), | 2012 GetMapImageTextureTarget(context_provider), |
| 2012 resource_provider_->best_texture_format()); | 2013 resource_provider_->best_texture_format()); |
| 2013 | 2014 |
| 2014 raster_worker_pool_ = | 2015 raster_worker_pool_ = |
| 2015 ZeroCopyRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), | 2016 ZeroCopyRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), |
| 2016 RasterWorkerPool::GetTaskGraphRunner(), | 2017 RasterWorkerPool::GetTaskGraphRunner(), |
| 2017 resource_provider_.get()); | 2018 resource_provider_.get()); |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3383 } | 3384 } |
| 3384 | 3385 |
| 3385 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3386 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3386 std::vector<PictureLayerImpl*>::iterator it = | 3387 std::vector<PictureLayerImpl*>::iterator it = |
| 3387 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3388 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3388 DCHECK(it != picture_layers_.end()); | 3389 DCHECK(it != picture_layers_.end()); |
| 3389 picture_layers_.erase(it); | 3390 picture_layers_.erase(it); |
| 3390 } | 3391 } |
| 3391 | 3392 |
| 3392 } // namespace cc | 3393 } // namespace cc |
| OLD | NEW |