| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "cc/raster/zero_copy_tile_task_worker_pool.h" | 72 #include "cc/raster/zero_copy_tile_task_worker_pool.h" |
| 73 #include "cc/resources/memory_history.h" | 73 #include "cc/resources/memory_history.h" |
| 74 #include "cc/resources/resource_pool.h" | 74 #include "cc/resources/resource_pool.h" |
| 75 #include "cc/resources/ui_resource_bitmap.h" | 75 #include "cc/resources/ui_resource_bitmap.h" |
| 76 #include "cc/scheduler/delay_based_time_source.h" | 76 #include "cc/scheduler/delay_based_time_source.h" |
| 77 #include "cc/tiles/eviction_tile_priority_queue.h" | 77 #include "cc/tiles/eviction_tile_priority_queue.h" |
| 78 #include "cc/tiles/gpu_image_decode_controller.h" | 78 #include "cc/tiles/gpu_image_decode_controller.h" |
| 79 #include "cc/tiles/picture_layer_tiling.h" | 79 #include "cc/tiles/picture_layer_tiling.h" |
| 80 #include "cc/tiles/raster_tile_priority_queue.h" | 80 #include "cc/tiles/raster_tile_priority_queue.h" |
| 81 #include "cc/tiles/software_image_decode_controller.h" | 81 #include "cc/tiles/software_image_decode_controller.h" |
| 82 #include "cc/tiles/tile_task_manager.h" |
| 82 #include "cc/trees/damage_tracker.h" | 83 #include "cc/trees/damage_tracker.h" |
| 83 #include "cc/trees/draw_property_utils.h" | 84 #include "cc/trees/draw_property_utils.h" |
| 84 #include "cc/trees/latency_info_swap_promise_monitor.h" | 85 #include "cc/trees/latency_info_swap_promise_monitor.h" |
| 85 #include "cc/trees/layer_tree_host.h" | 86 #include "cc/trees/layer_tree_host.h" |
| 86 #include "cc/trees/layer_tree_host_common.h" | 87 #include "cc/trees/layer_tree_host_common.h" |
| 87 #include "cc/trees/layer_tree_impl.h" | 88 #include "cc/trees/layer_tree_impl.h" |
| 88 #include "cc/trees/single_thread_proxy.h" | 89 #include "cc/trees/single_thread_proxy.h" |
| 89 #include "cc/trees/tree_synchronizer.h" | 90 #include "cc/trees/tree_synchronizer.h" |
| 90 #include "gpu/GLES2/gl2extchromium.h" | 91 #include "gpu/GLES2/gl2extchromium.h" |
| 91 #include "gpu/command_buffer/client/gles2_interface.h" | 92 #include "gpu/command_buffer/client/gles2_interface.h" |
| (...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be | 2145 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be |
| 2145 // initialized to get max texture size. Also, after releasing resources, | 2146 // initialized to get max texture size. Also, after releasing resources, |
| 2146 // trees need another update to generate new ones. | 2147 // trees need another update to generate new ones. |
| 2147 active_tree_->set_needs_update_draw_properties(); | 2148 active_tree_->set_needs_update_draw_properties(); |
| 2148 if (pending_tree_) | 2149 if (pending_tree_) |
| 2149 pending_tree_->set_needs_update_draw_properties(); | 2150 pending_tree_->set_needs_update_draw_properties(); |
| 2150 client_->UpdateRendererCapabilitiesOnImplThread(); | 2151 client_->UpdateRendererCapabilitiesOnImplThread(); |
| 2151 } | 2152 } |
| 2152 | 2153 |
| 2153 void LayerTreeHostImpl::CreateTileManagerResources() { | 2154 void LayerTreeHostImpl::CreateTileManagerResources() { |
| 2154 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); | 2155 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool; |
| 2156 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool, &resource_pool_); |
| 2155 | 2157 |
| 2156 if (use_gpu_rasterization_) { | 2158 if (use_gpu_rasterization_) { |
| 2157 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController( | 2159 image_decode_controller_ = base::WrapUnique(new GpuImageDecodeController( |
| 2158 output_surface_->worker_context_provider(), | 2160 output_surface_->worker_context_provider(), |
| 2159 settings_.renderer_settings.preferred_tile_format)); | 2161 settings_.renderer_settings.preferred_tile_format)); |
| 2160 } else { | 2162 } else { |
| 2161 image_decode_controller_ = | 2163 image_decode_controller_ = |
| 2162 base::WrapUnique(new SoftwareImageDecodeController( | 2164 base::WrapUnique(new SoftwareImageDecodeController( |
| 2163 settings_.renderer_settings.preferred_tile_format)); | 2165 settings_.renderer_settings.preferred_tile_format)); |
| 2164 } | 2166 } |
| 2165 | 2167 |
| 2168 // Pass the single-threaded synchronous task graph runner to the worker pool |
| 2169 // if we're in synchronous single-threaded mode. |
| 2170 TaskGraphRunner* task_graph_runner = task_graph_runner_; |
| 2171 if (is_synchronous_single_threaded_) { |
| 2172 DCHECK(!single_thread_synchronous_task_graph_runner_); |
| 2173 single_thread_synchronous_task_graph_runner_.reset( |
| 2174 new SynchronousTaskGraphRunner); |
| 2175 task_graph_runner = single_thread_synchronous_task_graph_runner_.get(); |
| 2176 } |
| 2177 |
| 2178 tile_task_manager_ = TileTaskManager::Create(std::move(tile_task_worker_pool), |
| 2179 task_graph_runner); |
| 2180 |
| 2166 // TODO(vmpstr): Initialize tile task limit at ctor time. | 2181 // TODO(vmpstr): Initialize tile task limit at ctor time. |
| 2167 tile_manager_->SetResources( | 2182 tile_manager_->SetResources( |
| 2168 resource_pool_.get(), tile_task_worker_pool_.get(), | 2183 resource_pool_.get(), image_decode_controller_.get(), |
| 2169 image_decode_controller_.get(), | 2184 tile_task_manager_.get(), |
| 2170 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max() | 2185 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max() |
| 2171 : settings_.scheduled_raster_task_limit, | 2186 : settings_.scheduled_raster_task_limit, |
| 2172 use_gpu_rasterization_); | 2187 use_gpu_rasterization_); |
| 2173 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 2188 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
| 2174 } | 2189 } |
| 2175 | 2190 |
| 2176 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( | 2191 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( |
| 2177 std::unique_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 2192 std::unique_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
| 2178 std::unique_ptr<ResourcePool>* resource_pool) { | 2193 std::unique_ptr<ResourcePool>* resource_pool) { |
| 2179 DCHECK(GetTaskRunner()); | 2194 DCHECK(GetTaskRunner()); |
| 2180 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is | 2195 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is |
| 2181 // resolved. | 2196 // resolved. |
| 2182 CHECK(resource_provider_); | 2197 CHECK(resource_provider_); |
| 2183 | 2198 |
| 2184 // Pass the single-threaded synchronous task graph runner to the worker pool | |
| 2185 // if we're in synchronous single-threaded mode. | |
| 2186 TaskGraphRunner* task_graph_runner = task_graph_runner_; | |
| 2187 if (is_synchronous_single_threaded_) { | |
| 2188 DCHECK(!single_thread_synchronous_task_graph_runner_); | |
| 2189 single_thread_synchronous_task_graph_runner_.reset( | |
| 2190 new SynchronousTaskGraphRunner); | |
| 2191 task_graph_runner = single_thread_synchronous_task_graph_runner_.get(); | |
| 2192 } | |
| 2193 | |
| 2194 ContextProvider* context_provider = output_surface_->context_provider(); | 2199 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2195 if (!context_provider) { | 2200 if (!context_provider) { |
| 2196 *resource_pool = | 2201 *resource_pool = |
| 2197 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); | 2202 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); |
| 2198 | 2203 |
| 2199 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( | 2204 *tile_task_worker_pool = |
| 2200 GetTaskRunner(), task_graph_runner, resource_provider_.get()); | 2205 BitmapTileTaskWorkerPool::Create(resource_provider_.get()); |
| 2201 return; | 2206 return; |
| 2202 } | 2207 } |
| 2203 | 2208 |
| 2204 if (use_gpu_rasterization_) { | 2209 if (use_gpu_rasterization_) { |
| 2205 DCHECK(resource_provider_->output_surface()->worker_context_provider()); | 2210 DCHECK(resource_provider_->output_surface()->worker_context_provider()); |
| 2206 | 2211 |
| 2207 *resource_pool = | 2212 *resource_pool = |
| 2208 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); | 2213 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); |
| 2209 | 2214 |
| 2210 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; | 2215 int msaa_sample_count = use_msaa_ ? RequestedMSAASampleCount() : 0; |
| 2211 | 2216 |
| 2212 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( | 2217 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( |
| 2213 GetTaskRunner(), task_graph_runner, context_provider, | 2218 context_provider, resource_provider_.get(), |
| 2214 resource_provider_.get(), settings_.use_distance_field_text, | 2219 settings_.use_distance_field_text, msaa_sample_count); |
| 2215 msaa_sample_count); | |
| 2216 return; | 2220 return; |
| 2217 } | 2221 } |
| 2218 | 2222 |
| 2219 DCHECK(GetRendererCapabilities().using_image); | 2223 DCHECK(GetRendererCapabilities().using_image); |
| 2220 | 2224 |
| 2221 bool use_zero_copy = settings_.use_zero_copy; | 2225 bool use_zero_copy = settings_.use_zero_copy; |
| 2222 // TODO(reveman): Remove this when mojo supports worker contexts. | 2226 // TODO(reveman): Remove this when mojo supports worker contexts. |
| 2223 // crbug.com/522440 | 2227 // crbug.com/522440 |
| 2224 if (!resource_provider_->output_surface()->worker_context_provider()) { | 2228 if (!resource_provider_->output_surface()->worker_context_provider()) { |
| 2225 LOG(ERROR) | 2229 LOG(ERROR) |
| 2226 << "Forcing zero-copy tile initialization as worker context is missing"; | 2230 << "Forcing zero-copy tile initialization as worker context is missing"; |
| 2227 use_zero_copy = true; | 2231 use_zero_copy = true; |
| 2228 } | 2232 } |
| 2229 | 2233 |
| 2230 if (use_zero_copy) { | 2234 if (use_zero_copy) { |
| 2231 *resource_pool = ResourcePool::CreateForGpuMemoryBufferResources( | 2235 *resource_pool = ResourcePool::CreateForGpuMemoryBufferResources( |
| 2232 resource_provider_.get(), GetTaskRunner()); | 2236 resource_provider_.get(), GetTaskRunner()); |
| 2233 | 2237 |
| 2234 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( | 2238 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( |
| 2235 GetTaskRunner(), task_graph_runner, resource_provider_.get(), | 2239 resource_provider_.get(), |
| 2236 settings_.renderer_settings.preferred_tile_format); | 2240 settings_.renderer_settings.preferred_tile_format); |
| 2237 return; | 2241 return; |
| 2238 } | 2242 } |
| 2239 | 2243 |
| 2240 *resource_pool = | 2244 *resource_pool = |
| 2241 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); | 2245 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); |
| 2242 | 2246 |
| 2243 int max_copy_texture_chromium_size = context_provider->ContextCapabilities() | 2247 int max_copy_texture_chromium_size = context_provider->ContextCapabilities() |
| 2244 .gpu.max_copy_texture_chromium_size; | 2248 .gpu.max_copy_texture_chromium_size; |
| 2245 | 2249 |
| 2246 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( | 2250 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
| 2247 GetTaskRunner(), task_graph_runner, context_provider, | 2251 GetTaskRunner(), context_provider, resource_provider_.get(), |
| 2248 resource_provider_.get(), max_copy_texture_chromium_size, | 2252 max_copy_texture_chromium_size, settings_.use_partial_raster, |
| 2249 settings_.use_partial_raster, settings_.max_staging_buffer_usage_in_bytes, | 2253 settings_.max_staging_buffer_usage_in_bytes, |
| 2250 settings_.renderer_settings.preferred_tile_format); | 2254 settings_.renderer_settings.preferred_tile_format); |
| 2251 } | 2255 } |
| 2252 | 2256 |
| 2253 void LayerTreeHostImpl::RecordMainFrameTiming( | 2257 void LayerTreeHostImpl::RecordMainFrameTiming( |
| 2254 const BeginFrameArgs& start_of_main_frame_args, | 2258 const BeginFrameArgs& start_of_main_frame_args, |
| 2255 const BeginFrameArgs& expected_next_main_frame_args) { | 2259 const BeginFrameArgs& expected_next_main_frame_args) { |
| 2256 std::vector<int64_t> request_ids; | 2260 std::vector<int64_t> request_ids; |
| 2257 active_tree_->GatherFrameTimingRequestIds(&request_ids); | 2261 active_tree_->GatherFrameTimingRequestIds(&request_ids); |
| 2258 if (request_ids.empty()) | 2262 if (request_ids.empty()) |
| 2259 return; | 2263 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2274 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { | 2278 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { |
| 2275 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 2279 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 2276 "LayerTreeHostImpl::SetLayerTreeMutator"); | 2280 "LayerTreeHostImpl::SetLayerTreeMutator"); |
| 2277 mutator_ = mutator; | 2281 mutator_ = mutator; |
| 2278 } | 2282 } |
| 2279 | 2283 |
| 2280 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2284 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
| 2281 ClearUIResources(); | 2285 ClearUIResources(); |
| 2282 tile_manager_->FinishTasksAndCleanUp(); | 2286 tile_manager_->FinishTasksAndCleanUp(); |
| 2283 resource_pool_ = nullptr; | 2287 resource_pool_ = nullptr; |
| 2284 tile_task_worker_pool_ = nullptr; | 2288 tile_task_manager_ = nullptr; |
| 2285 single_thread_synchronous_task_graph_runner_ = nullptr; | 2289 single_thread_synchronous_task_graph_runner_ = nullptr; |
| 2286 image_decode_controller_ = nullptr; | 2290 image_decode_controller_ = nullptr; |
| 2287 } | 2291 } |
| 2288 | 2292 |
| 2289 void LayerTreeHostImpl::ReleaseOutputSurface() { | 2293 void LayerTreeHostImpl::ReleaseOutputSurface() { |
| 2290 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseOutputSurface"); | 2294 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseOutputSurface"); |
| 2291 | 2295 |
| 2292 // Since we will create a new resource provider, we cannot continue to use | 2296 // Since we will create a new resource provider, we cannot continue to use |
| 2293 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 2297 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
| 2294 // before we destroy the old resource provider. | 2298 // before we destroy the old resource provider. |
| (...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 return task_runner_provider_->HasImplThread(); | 3984 return task_runner_provider_->HasImplThread(); |
| 3981 } | 3985 } |
| 3982 | 3986 |
| 3983 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3987 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3984 // In single threaded mode we skip the pending tree and commit directly to the | 3988 // In single threaded mode we skip the pending tree and commit directly to the |
| 3985 // active tree. | 3989 // active tree. |
| 3986 return !task_runner_provider_->HasImplThread(); | 3990 return !task_runner_provider_->HasImplThread(); |
| 3987 } | 3991 } |
| 3988 | 3992 |
| 3989 } // namespace cc | 3993 } // namespace cc |
| OLD | NEW |