Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: ericrk's review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "cc/output/delegating_renderer.h" 55 #include "cc/output/delegating_renderer.h"
56 #include "cc/output/gl_renderer.h" 56 #include "cc/output/gl_renderer.h"
57 #include "cc/output/software_renderer.h" 57 #include "cc/output/software_renderer.h"
58 #include "cc/output/texture_mailbox_deleter.h" 58 #include "cc/output/texture_mailbox_deleter.h"
59 #include "cc/quads/render_pass_draw_quad.h" 59 #include "cc/quads/render_pass_draw_quad.h"
60 #include "cc/quads/shared_quad_state.h" 60 #include "cc/quads/shared_quad_state.h"
61 #include "cc/quads/solid_color_draw_quad.h" 61 #include "cc/quads/solid_color_draw_quad.h"
62 #include "cc/quads/texture_draw_quad.h" 62 #include "cc/quads/texture_draw_quad.h"
63 #include "cc/raster/bitmap_raster_buffer_provider.h" 63 #include "cc/raster/bitmap_raster_buffer_provider.h"
64 #include "cc/raster/gpu_raster_buffer_provider.h" 64 #include "cc/raster/gpu_raster_buffer_provider.h"
65 #include "cc/raster/gpu_rasterizer.h"
66 #include "cc/raster/one_copy_raster_buffer_provider.h" 65 #include "cc/raster/one_copy_raster_buffer_provider.h"
67 #include "cc/raster/raster_buffer_provider.h" 66 #include "cc/raster/raster_buffer_provider.h"
68 #include "cc/raster/synchronous_task_graph_runner.h" 67 #include "cc/raster/synchronous_task_graph_runner.h"
69 #include "cc/raster/zero_copy_raster_buffer_provider.h" 68 #include "cc/raster/zero_copy_raster_buffer_provider.h"
70 #include "cc/resources/memory_history.h" 69 #include "cc/resources/memory_history.h"
71 #include "cc/resources/resource_pool.h" 70 #include "cc/resources/resource_pool.h"
72 #include "cc/resources/ui_resource_bitmap.h" 71 #include "cc/resources/ui_resource_bitmap.h"
73 #include "cc/scheduler/delay_based_time_source.h" 72 #include "cc/scheduler/delay_based_time_source.h"
74 #include "cc/tiles/eviction_tile_priority_queue.h" 73 #include "cc/tiles/eviction_tile_priority_queue.h"
75 #include "cc/tiles/gpu_image_decode_controller.h" 74 #include "cc/tiles/gpu_image_decode_controller.h"
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be 2168 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be
2170 // initialized to get max texture size. Also, after releasing resources, 2169 // initialized to get max texture size. Also, after releasing resources,
2171 // trees need another update to generate new ones. 2170 // trees need another update to generate new ones.
2172 active_tree_->set_needs_update_draw_properties(); 2171 active_tree_->set_needs_update_draw_properties();
2173 if (pending_tree_) 2172 if (pending_tree_)
2174 pending_tree_->set_needs_update_draw_properties(); 2173 pending_tree_->set_needs_update_draw_properties();
2175 client_->UpdateRendererCapabilitiesOnImplThread(); 2174 client_->UpdateRendererCapabilitiesOnImplThread();
2176 } 2175 }
2177 2176
2178 void LayerTreeHostImpl::CreateTileManagerResources() { 2177 void LayerTreeHostImpl::CreateTileManagerResources() {
2179 std::unique_ptr<RasterBufferProvider> raster_buffer_provider; 2178 CreateResourceAndRasterBufferProvider(&raster_buffer_provider_,
2180 CreateResourceAndRasterBufferProvider(&raster_buffer_provider,
2181 &resource_pool_); 2179 &resource_pool_);
2182 2180
2183 if (use_gpu_rasterization_) { 2181 if (use_gpu_rasterization_) {
2184 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController( 2182 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController(
2185 output_surface_->worker_context_provider(), 2183 output_surface_->worker_context_provider(),
2186 settings_.renderer_settings.preferred_tile_format, 2184 settings_.renderer_settings.preferred_tile_format,
2187 settings_.gpu_decoded_image_budget_bytes)); 2185 settings_.gpu_decoded_image_budget_bytes));
2188 } else { 2186 } else {
2189 image_decode_controller_ = 2187 image_decode_controller_ =
2190 base::WrapUnique(new SoftwareImageDecodeController( 2188 base::WrapUnique(new SoftwareImageDecodeController(
2191 settings_.renderer_settings.preferred_tile_format, 2189 settings_.renderer_settings.preferred_tile_format,
2192 settings_.software_decoded_image_budget_bytes)); 2190 settings_.software_decoded_image_budget_bytes));
2193 } 2191 }
2194 2192
2195 // Pass the single-threaded synchronous task graph runner to the worker pool 2193 // Pass the single-threaded synchronous task graph runner to the worker pool
2196 // if we're in synchronous single-threaded mode. 2194 // if we're in synchronous single-threaded mode.
2197 TaskGraphRunner* task_graph_runner = task_graph_runner_; 2195 TaskGraphRunner* task_graph_runner = task_graph_runner_;
2198 if (is_synchronous_single_threaded_) { 2196 if (is_synchronous_single_threaded_) {
2199 DCHECK(!single_thread_synchronous_task_graph_runner_); 2197 DCHECK(!single_thread_synchronous_task_graph_runner_);
2200 single_thread_synchronous_task_graph_runner_.reset( 2198 single_thread_synchronous_task_graph_runner_.reset(
2201 new SynchronousTaskGraphRunner); 2199 new SynchronousTaskGraphRunner);
2202 task_graph_runner = single_thread_synchronous_task_graph_runner_.get(); 2200 task_graph_runner = single_thread_synchronous_task_graph_runner_.get();
2203 } 2201 }
2204 2202
2205 tile_task_manager_ = TileTaskManagerImpl::Create( 2203 tile_task_manager_ = TileTaskManagerImpl::Create(task_graph_runner);
2206 std::move(raster_buffer_provider), task_graph_runner);
2207 2204
2208 // TODO(vmpstr): Initialize tile task limit at ctor time. 2205 // TODO(vmpstr): Initialize tile task limit at ctor time.
2209 tile_manager_.SetResources( 2206 tile_manager_.SetResources(
2210 resource_pool_.get(), image_decode_controller_.get(), 2207 resource_pool_.get(), image_decode_controller_.get(),
2211 tile_task_manager_.get(), 2208 tile_task_manager_.get(), raster_buffer_provider_.get(),
2212 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max() 2209 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max()
2213 : settings_.scheduled_raster_task_limit, 2210 : settings_.scheduled_raster_task_limit,
2214 use_gpu_rasterization_); 2211 use_gpu_rasterization_);
2215 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); 2212 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
2216 } 2213 }
2217 2214
2218 void LayerTreeHostImpl::CreateResourceAndRasterBufferProvider( 2215 void LayerTreeHostImpl::CreateResourceAndRasterBufferProvider(
2219 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, 2216 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider,
2220 std::unique_ptr<ResourcePool>* resource_pool) { 2217 std::unique_ptr<ResourcePool>* resource_pool) {
2221 DCHECK(GetTaskRunner()); 2218 DCHECK(GetTaskRunner());
(...skipping 18 matching lines...) Expand all
2240 DCHECK(worker_context_provider); 2237 DCHECK(worker_context_provider);
2241 2238
2242 *resource_pool = 2239 *resource_pool =
2243 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); 2240 ResourcePool::Create(resource_provider_.get(), GetTaskRunner());
2244 2241
2245 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; 2242 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0;
2246 2243
2247 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( 2244 *raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>(
2248 compositor_context_provider, worker_context_provider, 2245 compositor_context_provider, worker_context_provider,
2249 resource_provider_.get(), settings_.use_distance_field_text, 2246 resource_provider_.get(), settings_.use_distance_field_text,
2250 msaa_sample_count); 2247 msaa_sample_count, settings_.async_worker_context_enabled);
2251 return; 2248 return;
2252 } 2249 }
2253 2250
2254 DCHECK(GetRendererCapabilities().using_image); 2251 DCHECK(GetRendererCapabilities().using_image);
2255 2252
2256 bool use_zero_copy = settings_.use_zero_copy; 2253 bool use_zero_copy = settings_.use_zero_copy;
2257 // TODO(reveman): Remove this when mojo supports worker contexts. 2254 // TODO(reveman): Remove this when mojo supports worker contexts.
2258 // crbug.com/522440 2255 // crbug.com/522440
2259 if (!use_zero_copy && !worker_context_provider) { 2256 if (!use_zero_copy && !worker_context_provider) {
2260 LOG(ERROR) 2257 LOG(ERROR)
(...skipping 15 matching lines...) Expand all
2276 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); 2273 ResourcePool::Create(resource_provider_.get(), GetTaskRunner());
2277 2274
2278 const int max_copy_texture_chromium_size = 2275 const int max_copy_texture_chromium_size =
2279 compositor_context_provider->ContextCapabilities() 2276 compositor_context_provider->ContextCapabilities()
2280 .max_copy_texture_chromium_size; 2277 .max_copy_texture_chromium_size;
2281 2278
2282 *raster_buffer_provider = base::MakeUnique<OneCopyRasterBufferProvider>( 2279 *raster_buffer_provider = base::MakeUnique<OneCopyRasterBufferProvider>(
2283 GetTaskRunner(), compositor_context_provider, worker_context_provider, 2280 GetTaskRunner(), compositor_context_provider, worker_context_provider,
2284 resource_provider_.get(), max_copy_texture_chromium_size, 2281 resource_provider_.get(), max_copy_texture_chromium_size,
2285 settings_.use_partial_raster, settings_.max_staging_buffer_usage_in_bytes, 2282 settings_.use_partial_raster, settings_.max_staging_buffer_usage_in_bytes,
2286 settings_.renderer_settings.preferred_tile_format); 2283 settings_.renderer_settings.preferred_tile_format,
2284 settings_.async_worker_context_enabled);
2287 } 2285 }
2288 2286
2289 void LayerTreeHostImpl::SetLayerTreeMutator( 2287 void LayerTreeHostImpl::SetLayerTreeMutator(
2290 std::unique_ptr<LayerTreeMutator> mutator) { 2288 std::unique_ptr<LayerTreeMutator> mutator) {
2291 if (mutator == mutator_) 2289 if (mutator == mutator_)
2292 return; 2290 return;
2293 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 2291 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
2294 "LayerTreeHostImpl::SetLayerTreeMutator"); 2292 "LayerTreeHostImpl::SetLayerTreeMutator");
2295 mutator_ = std::move(mutator); 2293 mutator_ = std::move(mutator);
2296 mutator_->SetClient(this); 2294 mutator_->SetClient(this);
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
4029 const { 4027 const {
4030 return fixed_raster_scale_attempted_scale_change_history_.count() >= 4028 return fixed_raster_scale_attempted_scale_change_history_.count() >=
4031 kFixedRasterScaleAttemptedScaleChangeThreshold; 4029 kFixedRasterScaleAttemptedScaleChangeThreshold;
4032 } 4030 }
4033 4031
4034 void LayerTreeHostImpl::SetFixedRasterScaleAttemptedToChangeScale() { 4032 void LayerTreeHostImpl::SetFixedRasterScaleAttemptedToChangeScale() {
4035 fixed_raster_scale_attempted_scale_change_history_.set(0); 4033 fixed_raster_scale_attempted_scale_change_history_.set(0);
4036 } 4034 }
4037 4035
4038 } // namespace cc 4036 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698