| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 std::unique_ptr<ResourcePool>* resource_pool) { | 2218 std::unique_ptr<ResourcePool>* resource_pool) { |
| 2219 DCHECK(GetTaskRunner()); | 2219 DCHECK(GetTaskRunner()); |
| 2220 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is | 2220 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is |
| 2221 // resolved. | 2221 // resolved. |
| 2222 CHECK(resource_provider_); | 2222 CHECK(resource_provider_); |
| 2223 | 2223 |
| 2224 ContextProvider* compositor_context_provider = | 2224 ContextProvider* compositor_context_provider = |
| 2225 output_surface_->context_provider(); | 2225 output_surface_->context_provider(); |
| 2226 if (!compositor_context_provider) { | 2226 if (!compositor_context_provider) { |
| 2227 *resource_pool = | 2227 *resource_pool = |
| 2228 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); | 2228 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), |
| 2229 ResourcePool::kDefaultExpirationDelay); |
| 2229 | 2230 |
| 2230 *raster_buffer_provider = | 2231 *raster_buffer_provider = |
| 2231 BitmapRasterBufferProvider::Create(resource_provider_.get()); | 2232 BitmapRasterBufferProvider::Create(resource_provider_.get()); |
| 2232 return; | 2233 return; |
| 2233 } | 2234 } |
| 2234 | 2235 |
| 2235 ContextProvider* worker_context_provider = | 2236 ContextProvider* worker_context_provider = |
| 2236 output_surface_->worker_context_provider(); | 2237 output_surface_->worker_context_provider(); |
| 2237 if (use_gpu_rasterization_) { | 2238 if (use_gpu_rasterization_) { |
| 2238 DCHECK(worker_context_provider); | 2239 DCHECK(worker_context_provider); |
| 2239 | 2240 |
| 2240 *resource_pool = | 2241 *resource_pool = |
| 2241 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); | 2242 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), |
| 2243 ResourcePool::kDefaultExpirationDelay); |
| 2242 | 2244 |
| 2243 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; | 2245 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; |
| 2244 | 2246 |
| 2245 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( | 2247 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( |
| 2246 compositor_context_provider, worker_context_provider, | 2248 compositor_context_provider, worker_context_provider, |
| 2247 resource_provider_.get(), settings_.use_distance_field_text, | 2249 resource_provider_.get(), settings_.use_distance_field_text, |
| 2248 msaa_sample_count, settings_.async_worker_context_enabled); | 2250 msaa_sample_count, settings_.async_worker_context_enabled); |
| 2249 return; | 2251 return; |
| 2250 } | 2252 } |
| 2251 | 2253 |
| 2252 DCHECK(GetRendererCapabilities().using_image); | 2254 DCHECK(GetRendererCapabilities().using_image); |
| 2253 | 2255 |
| 2254 bool use_zero_copy = settings_.use_zero_copy; | 2256 bool use_zero_copy = settings_.use_zero_copy; |
| 2255 // TODO(reveman): Remove this when mojo supports worker contexts. | 2257 // TODO(reveman): Remove this when mojo supports worker contexts. |
| 2256 // crbug.com/522440 | 2258 // crbug.com/522440 |
| 2257 if (!use_zero_copy && !worker_context_provider) { | 2259 if (!use_zero_copy && !worker_context_provider) { |
| 2258 LOG(ERROR) | 2260 LOG(ERROR) |
| 2259 << "Forcing zero-copy tile initialization as worker context is missing"; | 2261 << "Forcing zero-copy tile initialization as worker context is missing"; |
| 2260 use_zero_copy = true; | 2262 use_zero_copy = true; |
| 2261 } | 2263 } |
| 2262 | 2264 |
| 2263 if (use_zero_copy) { | 2265 if (use_zero_copy) { |
| 2264 *resource_pool = ResourcePool::CreateForGpuMemoryBufferResources( | 2266 *resource_pool = ResourcePool::CreateForGpuMemoryBufferResources( |
| 2265 resource_provider_.get(), GetTaskRunner(), | 2267 resource_provider_.get(), GetTaskRunner(), |
| 2266 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE); | 2268 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
| 2269 ResourcePool::kDefaultExpirationDelay); |
| 2267 | 2270 |
| 2268 *raster_buffer_provider = ZeroCopyRasterBufferProvider::Create( | 2271 *raster_buffer_provider = ZeroCopyRasterBufferProvider::Create( |
| 2269 resource_provider_.get(), | 2272 resource_provider_.get(), |
| 2270 settings_.renderer_settings.preferred_tile_format); | 2273 settings_.renderer_settings.preferred_tile_format); |
| 2271 return; | 2274 return; |
| 2272 } | 2275 } |
| 2273 | 2276 |
| 2274 *resource_pool = | 2277 *resource_pool = |
| 2275 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); | 2278 ResourcePool::Create(resource_provider_.get(), GetTaskRunner(), |
| 2279 ResourcePool::kDefaultExpirationDelay); |
| 2276 | 2280 |
| 2277 const int max_copy_texture_chromium_size = | 2281 const int max_copy_texture_chromium_size = |
| 2278 compositor_context_provider->ContextCapabilities() | 2282 compositor_context_provider->ContextCapabilities() |
| 2279 .max_copy_texture_chromium_size; | 2283 .max_copy_texture_chromium_size; |
| 2280 | 2284 |
| 2281 *raster_buffer_provider = base::MakeUnique<OneCopyRasterBufferProvider>( | 2285 *raster_buffer_provider = base::MakeUnique<OneCopyRasterBufferProvider>( |
| 2282 GetTaskRunner(), compositor_context_provider, worker_context_provider, | 2286 GetTaskRunner(), compositor_context_provider, worker_context_provider, |
| 2283 resource_provider_.get(), max_copy_texture_chromium_size, | 2287 resource_provider_.get(), max_copy_texture_chromium_size, |
| 2284 settings_.use_partial_raster, settings_.max_staging_buffer_usage_in_bytes, | 2288 settings_.use_partial_raster, settings_.max_staging_buffer_usage_in_bytes, |
| 2285 settings_.renderer_settings.preferred_tile_format, | 2289 settings_.renderer_settings.preferred_tile_format, |
| (...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4066 return task_runner_provider_->HasImplThread(); | 4070 return task_runner_provider_->HasImplThread(); |
| 4067 } | 4071 } |
| 4068 | 4072 |
| 4069 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4073 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 4070 // In single threaded mode we skip the pending tree and commit directly to the | 4074 // In single threaded mode we skip the pending tree and commit directly to the |
| 4071 // active tree. | 4075 // active tree. |
| 4072 return !task_runner_provider_->HasImplThread(); | 4076 return !task_runner_provider_->HasImplThread(); |
| 4073 } | 4077 } |
| 4074 | 4078 |
| 4075 } // namespace cc | 4079 } // namespace cc |
| OLD | NEW |