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 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 LayerTreeHostImplClient* client, | 193 LayerTreeHostImplClient* client, |
194 Proxy* proxy, | 194 Proxy* proxy, |
195 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 195 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
196 SharedBitmapManager* shared_bitmap_manager, | 196 SharedBitmapManager* shared_bitmap_manager, |
197 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 197 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
198 TaskGraphRunner* task_graph_runner, | 198 TaskGraphRunner* task_graph_runner, |
199 int id) | 199 int id) |
200 : client_(client), | 200 : client_(client), |
201 proxy_(proxy), | 201 proxy_(proxy), |
202 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | 202 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
203 tile_manager_( | |
204 TileManager::Create(this, | |
205 GetTaskRunner(), | |
206 IsSynchronousSingleThreaded() | |
207 ? std::numeric_limits<size_t>::max() | |
208 : settings.scheduled_raster_task_limit)), | |
209 content_is_suitable_for_gpu_rasterization_(true), | 203 content_is_suitable_for_gpu_rasterization_(true), |
210 has_gpu_rasterization_trigger_(false), | 204 has_gpu_rasterization_trigger_(false), |
211 use_gpu_rasterization_(false), | 205 use_gpu_rasterization_(false), |
212 use_msaa_(false), | 206 use_msaa_(false), |
213 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), | 207 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), |
214 tree_resources_for_gpu_rasterization_dirty_(false), | 208 tree_resources_for_gpu_rasterization_dirty_(false), |
215 input_handler_client_(NULL), | 209 input_handler_client_(NULL), |
216 did_lock_scrolling_layer_(false), | 210 did_lock_scrolling_layer_(false), |
217 should_bubble_scrolls_(false), | 211 should_bubble_scrolls_(false), |
218 wheel_scrolling_(false), | 212 wheel_scrolling_(false), |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 active_tree_->Shutdown(); | 299 active_tree_->Shutdown(); |
306 recycle_tree_ = nullptr; | 300 recycle_tree_ = nullptr; |
307 pending_tree_ = nullptr; | 301 pending_tree_ = nullptr; |
308 active_tree_ = nullptr; | 302 active_tree_ = nullptr; |
309 | 303 |
310 if (animation_host_) { | 304 if (animation_host_) { |
311 animation_host_->ClearTimelines(); | 305 animation_host_->ClearTimelines(); |
312 animation_host_->SetMutatorHostClient(nullptr); | 306 animation_host_->SetMutatorHostClient(nullptr); |
313 } | 307 } |
314 | 308 |
315 CleanUpTileManager(); | 309 DestroyTileManager(); |
316 } | 310 } |
317 | 311 |
318 void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) { | 312 void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) { |
319 // If the begin frame data was handled, then scroll and scale set was applied | 313 // If the begin frame data was handled, then scroll and scale set was applied |
320 // by the main thread, so the active tree needs to be updated as if these sent | 314 // by the main thread, so the active tree needs to be updated as if these sent |
321 // values were applied and committed. | 315 // values were applied and committed. |
322 if (CommitEarlyOutHandledCommit(reason)) | 316 if (CommitEarlyOutHandledCommit(reason)) |
323 active_tree_->ApplySentScrollAndScaleDeltasFromAbortedCommit(); | 317 active_tree_->ApplySentScrollAndScaleDeltasFromAbortedCommit(); |
324 } | 318 } |
325 | 319 |
(...skipping 21 matching lines...) Expand all Loading... |
347 UpdateTreeResourcesForGpuRasterizationIfNeeded(); | 341 UpdateTreeResourcesForGpuRasterizationIfNeeded(); |
348 sync_tree()->set_needs_update_draw_properties(); | 342 sync_tree()->set_needs_update_draw_properties(); |
349 | 343 |
350 // We need an update immediately post-commit to have the opportunity to create | 344 // We need an update immediately post-commit to have the opportunity to create |
351 // tilings. Because invalidations may be coming from the main thread, it's | 345 // tilings. Because invalidations may be coming from the main thread, it's |
352 // safe to do an update for lcd text at this point and see if lcd text needs | 346 // safe to do an update for lcd text at this point and see if lcd text needs |
353 // to be disabled on any layers. | 347 // to be disabled on any layers. |
354 bool update_lcd_text = true; | 348 bool update_lcd_text = true; |
355 sync_tree()->UpdateDrawProperties(update_lcd_text); | 349 sync_tree()->UpdateDrawProperties(update_lcd_text); |
356 // Start working on newly created tiles immediately if needed. | 350 // Start working on newly created tiles immediately if needed. |
357 // TODO(vmpstr): Investigate always having PrepareTiles issue | 351 if (tile_manager_ && tile_priorities_dirty_) { |
358 // NotifyReadyToActivate, instead of handling it here. | 352 PrepareTiles(); |
359 bool did_prepare_tiles = PrepareTiles(); | 353 } else { |
360 if (!did_prepare_tiles) { | |
361 NotifyReadyToActivate(); | 354 NotifyReadyToActivate(); |
362 | 355 |
363 // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This | 356 // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This |
364 // is important for SingleThreadProxy and impl-side painting case. For | 357 // is important for SingleThreadProxy and impl-side painting case. For |
365 // STP, we commit to active tree and RequiresHighResToDraw, and set | 358 // STP, we commit to active tree and RequiresHighResToDraw, and set |
366 // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard. | 359 // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard. |
367 if (proxy_->CommitToActiveTree()) | 360 if (proxy_->CommitToActiveTree()) |
368 NotifyReadyToDraw(); | 361 NotifyReadyToDraw(); |
369 } | 362 } |
370 | 363 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && | 419 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && |
427 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) { | 420 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) { |
428 AnimateInput(monotonic_time); | 421 AnimateInput(monotonic_time); |
429 } | 422 } |
430 AnimatePageScale(monotonic_time); | 423 AnimatePageScale(monotonic_time); |
431 AnimateLayers(monotonic_time); | 424 AnimateLayers(monotonic_time); |
432 AnimateScrollbars(monotonic_time); | 425 AnimateScrollbars(monotonic_time); |
433 AnimateTopControls(monotonic_time); | 426 AnimateTopControls(monotonic_time); |
434 } | 427 } |
435 | 428 |
436 bool LayerTreeHostImpl::PrepareTiles() { | 429 void LayerTreeHostImpl::PrepareTiles() { |
| 430 if (!tile_manager_) |
| 431 return; |
437 if (!tile_priorities_dirty_) | 432 if (!tile_priorities_dirty_) |
438 return false; | 433 return; |
439 | 434 |
440 client_->WillPrepareTiles(); | 435 client_->WillPrepareTiles(); |
441 bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_); | 436 tile_priorities_dirty_ = false; |
442 if (did_prepare_tiles) | 437 tile_manager_->PrepareTiles(global_tile_state_); |
443 tile_priorities_dirty_ = false; | |
444 client_->DidPrepareTiles(); | 438 client_->DidPrepareTiles(); |
445 return did_prepare_tiles; | |
446 } | 439 } |
447 | 440 |
448 void LayerTreeHostImpl::StartPageScaleAnimation( | 441 void LayerTreeHostImpl::StartPageScaleAnimation( |
449 const gfx::Vector2d& target_offset, | 442 const gfx::Vector2d& target_offset, |
450 bool anchor_point, | 443 bool anchor_point, |
451 float page_scale, | 444 float page_scale, |
452 base::TimeDelta duration) { | 445 base::TimeDelta duration) { |
453 if (!InnerViewportScrollLayer()) | 446 if (!InnerViewportScrollLayer()) |
454 return; | 447 return; |
455 | 448 |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 recycle_tree_->DetachLayerTree(); | 1178 recycle_tree_->DetachLayerTree(); |
1186 recycle_tree_ = nullptr; | 1179 recycle_tree_ = nullptr; |
1187 } | 1180 } |
1188 | 1181 |
1189 size_t LayerTreeHostImpl::SourceAnimationFrameNumberForTesting() const { | 1182 size_t LayerTreeHostImpl::SourceAnimationFrameNumberForTesting() const { |
1190 return fps_counter_->current_frame_number(); | 1183 return fps_counter_->current_frame_number(); |
1191 } | 1184 } |
1192 | 1185 |
1193 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy( | 1186 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy( |
1194 const ManagedMemoryPolicy& policy) { | 1187 const ManagedMemoryPolicy& policy) { |
1195 if (!resource_pool_) | 1188 if (!tile_manager_) |
1196 return; | 1189 return; |
1197 | 1190 |
1198 global_tile_state_.hard_memory_limit_in_bytes = 0; | 1191 global_tile_state_.hard_memory_limit_in_bytes = 0; |
1199 global_tile_state_.soft_memory_limit_in_bytes = 0; | 1192 global_tile_state_.soft_memory_limit_in_bytes = 0; |
1200 if (visible_ && policy.bytes_limit_when_visible > 0) { | 1193 if (visible_ && policy.bytes_limit_when_visible > 0) { |
1201 global_tile_state_.hard_memory_limit_in_bytes = | 1194 global_tile_state_.hard_memory_limit_in_bytes = |
1202 policy.bytes_limit_when_visible; | 1195 policy.bytes_limit_when_visible; |
1203 global_tile_state_.soft_memory_limit_in_bytes = | 1196 global_tile_state_.soft_memory_limit_in_bytes = |
1204 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) * | 1197 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) * |
1205 settings_.max_memory_for_prepaint_percentage) / | 1198 settings_.max_memory_for_prepaint_percentage) / |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 SetNeedsRedraw(); | 1330 SetNeedsRedraw(); |
1338 } | 1331 } |
1339 } | 1332 } |
1340 | 1333 |
1341 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 1334 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
1342 SetManagedMemoryPolicy(policy); | 1335 SetManagedMemoryPolicy(policy); |
1343 | 1336 |
1344 // This is short term solution to synchronously drop tile resources when | 1337 // This is short term solution to synchronously drop tile resources when |
1345 // using synchronous compositing to avoid memory usage regression. | 1338 // using synchronous compositing to avoid memory usage regression. |
1346 // TODO(boliu): crbug.com/499004 to track removing this. | 1339 // TODO(boliu): crbug.com/499004 to track removing this. |
1347 if (!policy.bytes_limit_when_visible && resource_pool_ && | 1340 if (!policy.bytes_limit_when_visible && tile_manager_ && |
1348 settings_.using_synchronous_renderer_compositor) { | 1341 settings_.using_synchronous_renderer_compositor) { |
1349 ReleaseTreeResources(); | 1342 ReleaseTreeResources(); |
1350 CleanUpTileManager(); | 1343 // TileManager destruction will synchronoulsy wait for all tile workers to |
1351 CreateTileManagerResources(); | 1344 // be cancelled or completed. This allows all resources to be freed |
| 1345 // synchronously. |
| 1346 DestroyTileManager(); |
| 1347 CreateAndSetTileManager(); |
1352 RecreateTreeResources(); | 1348 RecreateTreeResources(); |
1353 } | 1349 } |
1354 } | 1350 } |
1355 | 1351 |
1356 void LayerTreeHostImpl::SetTreeActivationCallback( | 1352 void LayerTreeHostImpl::SetTreeActivationCallback( |
1357 const base::Closure& callback) { | 1353 const base::Closure& callback) { |
1358 DCHECK(proxy_->IsImplThread()); | 1354 DCHECK(proxy_->IsImplThread()); |
1359 tree_activation_callback_ = callback; | 1355 tree_activation_callback_ = callback; |
1360 } | 1356 } |
1361 | 1357 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 } | 1444 } |
1449 | 1445 |
1450 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { | 1446 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { |
1451 // TODO(piman): We may need to do some validation on this ack before | 1447 // TODO(piman): We may need to do some validation on this ack before |
1452 // processing it. | 1448 // processing it. |
1453 if (renderer_) | 1449 if (renderer_) |
1454 renderer_->ReceiveSwapBuffersAck(*ack); | 1450 renderer_->ReceiveSwapBuffersAck(*ack); |
1455 | 1451 |
1456 // In OOM, we now might be able to release more resources that were held | 1452 // In OOM, we now might be able to release more resources that were held |
1457 // because they were exported. | 1453 // because they were exported. |
1458 if (resource_pool_) { | 1454 if (tile_manager_) { |
| 1455 DCHECK(resource_pool_); |
| 1456 |
1459 resource_pool_->CheckBusyResources(false); | 1457 resource_pool_->CheckBusyResources(false); |
1460 resource_pool_->ReduceResourceUsage(); | 1458 resource_pool_->ReduceResourceUsage(); |
1461 } | 1459 } |
1462 // If we're not visible, we likely released resources, so we want to | 1460 // If we're not visible, we likely released resources, so we want to |
1463 // aggressively flush here to make sure those DeleteTextures make it to the | 1461 // aggressively flush here to make sure those DeleteTextures make it to the |
1464 // GPU process to free up the memory. | 1462 // GPU process to free up the memory. |
1465 if (output_surface_->context_provider() && !visible_) { | 1463 if (output_surface_->context_provider() && !visible_) { |
1466 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); | 1464 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); |
1467 } | 1465 } |
1468 } | 1466 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 use_msaa_ = use_msaa; | 1691 use_msaa_ = use_msaa; |
1694 | 1692 |
1695 tree_resources_for_gpu_rasterization_dirty_ = true; | 1693 tree_resources_for_gpu_rasterization_dirty_ = true; |
1696 } | 1694 } |
1697 | 1695 |
1698 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() { | 1696 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() { |
1699 if (!tree_resources_for_gpu_rasterization_dirty_) | 1697 if (!tree_resources_for_gpu_rasterization_dirty_) |
1700 return; | 1698 return; |
1701 | 1699 |
1702 // Clean up and replace existing tile manager with another one that uses | 1700 // Clean up and replace existing tile manager with another one that uses |
1703 // appropriate rasterizer. Only do this however if we already have a | 1701 // appropriate rasterizer. |
1704 // resource pool, since otherwise we might not be able to create a new | |
1705 // one. | |
1706 ReleaseTreeResources(); | 1702 ReleaseTreeResources(); |
1707 if (resource_pool_) { | 1703 if (tile_manager_) { |
1708 CleanUpTileManager(); | 1704 DestroyTileManager(); |
1709 CreateTileManagerResources(); | 1705 CreateAndSetTileManager(); |
1710 } | 1706 } |
1711 RecreateTreeResources(); | 1707 RecreateTreeResources(); |
1712 | 1708 |
1713 // We have released tilings for both active and pending tree. | 1709 // We have released tilings for both active and pending tree. |
1714 // We would not have any content to draw until the pending tree is activated. | 1710 // We would not have any content to draw until the pending tree is activated. |
1715 // Prevent the active tree from drawing until activation. | 1711 // Prevent the active tree from drawing until activation. |
1716 SetRequiresHighResToDraw(); | 1712 SetRequiresHighResToDraw(); |
1717 | 1713 |
1718 tree_resources_for_gpu_rasterization_dirty_ = false; | 1714 tree_resources_for_gpu_rasterization_dirty_ = false; |
1719 } | 1715 } |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2063 | 2059 |
2064 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be | 2060 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be |
2065 // initialized to get max texture size. Also, after releasing resources, | 2061 // initialized to get max texture size. Also, after releasing resources, |
2066 // trees need another update to generate new ones. | 2062 // trees need another update to generate new ones. |
2067 active_tree_->set_needs_update_draw_properties(); | 2063 active_tree_->set_needs_update_draw_properties(); |
2068 if (pending_tree_) | 2064 if (pending_tree_) |
2069 pending_tree_->set_needs_update_draw_properties(); | 2065 pending_tree_->set_needs_update_draw_properties(); |
2070 client_->UpdateRendererCapabilitiesOnImplThread(); | 2066 client_->UpdateRendererCapabilitiesOnImplThread(); |
2071 } | 2067 } |
2072 | 2068 |
2073 void LayerTreeHostImpl::CreateTileManagerResources() { | 2069 void LayerTreeHostImpl::CreateAndSetTileManager() { |
| 2070 DCHECK(!tile_manager_); |
| 2071 DCHECK(output_surface_); |
| 2072 DCHECK(resource_provider_); |
| 2073 |
2074 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_, | 2074 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_, |
2075 &staging_resource_pool_); | 2075 &staging_resource_pool_); |
2076 tile_manager_->SetResources(resource_pool_.get(), | 2076 DCHECK(tile_task_worker_pool_); |
2077 tile_task_worker_pool_->AsTileTaskRunner()); | 2077 DCHECK(resource_pool_); |
| 2078 |
| 2079 DCHECK(GetTaskRunner()); |
| 2080 size_t scheduled_raster_task_limit = |
| 2081 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() |
| 2082 : settings_.scheduled_raster_task_limit; |
| 2083 tile_manager_ = TileManager::Create( |
| 2084 this, GetTaskRunner(), resource_pool_.get(), |
| 2085 tile_task_worker_pool_->AsTileTaskRunner(), scheduled_raster_task_limit); |
| 2086 |
2078 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 2087 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
2079 } | 2088 } |
2080 | 2089 |
2081 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( | 2090 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( |
2082 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 2091 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
2083 scoped_ptr<ResourcePool>* resource_pool, | 2092 scoped_ptr<ResourcePool>* resource_pool, |
2084 scoped_ptr<ResourcePool>* staging_resource_pool) { | 2093 scoped_ptr<ResourcePool>* staging_resource_pool) { |
2085 DCHECK(GetTaskRunner()); | 2094 DCHECK(GetTaskRunner()); |
2086 | 2095 |
2087 // Pass the single-threaded synchronous task graph runner to the worker pool | 2096 // Pass the single-threaded synchronous task graph runner to the worker pool |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 request_ids, start_time, end_time, active_tree_->source_frame_number()); | 2196 request_ids, start_time, end_time, active_tree_->source_frame_number()); |
2188 } | 2197 } |
2189 | 2198 |
2190 void LayerTreeHostImpl::PostFrameTimingEvents( | 2199 void LayerTreeHostImpl::PostFrameTimingEvents( |
2191 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 2200 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
2192 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 2201 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
2193 client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(), | 2202 client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(), |
2194 main_frame_events.Pass()); | 2203 main_frame_events.Pass()); |
2195 } | 2204 } |
2196 | 2205 |
2197 void LayerTreeHostImpl::CleanUpTileManager() { | 2206 void LayerTreeHostImpl::DestroyTileManager() { |
2198 tile_manager_->FinishTasksAndCleanUp(); | 2207 tile_manager_ = nullptr; |
2199 resource_pool_ = nullptr; | 2208 resource_pool_ = nullptr; |
2200 staging_resource_pool_ = nullptr; | 2209 staging_resource_pool_ = nullptr; |
2201 tile_task_worker_pool_ = nullptr; | 2210 tile_task_worker_pool_ = nullptr; |
2202 single_thread_synchronous_task_graph_runner_ = nullptr; | 2211 single_thread_synchronous_task_graph_runner_ = nullptr; |
2203 } | 2212 } |
2204 | 2213 |
2205 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const { | 2214 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const { |
2206 return !proxy_->HasImplThread() && !settings_.single_thread_proxy_scheduler; | 2215 return !proxy_->HasImplThread() && !settings_.single_thread_proxy_scheduler; |
2207 } | 2216 } |
2208 | 2217 |
2209 bool LayerTreeHostImpl::InitializeRenderer( | 2218 bool LayerTreeHostImpl::InitializeRenderer( |
2210 scoped_ptr<OutputSurface> output_surface) { | 2219 scoped_ptr<OutputSurface> output_surface) { |
2211 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); | 2220 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); |
2212 | 2221 |
2213 // Since we will create a new resource provider, we cannot continue to use | 2222 // Since we will create a new resource provider, we cannot continue to use |
2214 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 2223 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
2215 // before we destroy the old resource provider. | 2224 // before we destroy the old resource provider. |
2216 ReleaseTreeResources(); | 2225 ReleaseTreeResources(); |
2217 | 2226 |
2218 // Note: order is important here. | 2227 // Note: order is important here. |
2219 renderer_ = nullptr; | 2228 renderer_ = nullptr; |
2220 CleanUpTileManager(); | 2229 DestroyTileManager(); |
2221 resource_provider_ = nullptr; | 2230 resource_provider_ = nullptr; |
2222 output_surface_ = nullptr; | 2231 output_surface_ = nullptr; |
2223 | 2232 |
2224 if (!output_surface->BindToClient(this)) { | 2233 if (!output_surface->BindToClient(this)) { |
2225 // Avoid recreating tree resources because we might not have enough | 2234 // Avoid recreating tree resources because we might not have enough |
2226 // information to do this yet (eg. we don't have a TileManager at this | 2235 // information to do this yet (eg. we don't have a TileManager at this |
2227 // point). | 2236 // point). |
2228 return false; | 2237 return false; |
2229 } | 2238 } |
2230 | 2239 |
2231 output_surface_ = output_surface.Pass(); | 2240 output_surface_ = output_surface.Pass(); |
2232 resource_provider_ = ResourceProvider::Create( | 2241 resource_provider_ = ResourceProvider::Create( |
2233 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_, | 2242 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_, |
2234 proxy_->blocking_main_thread_task_runner(), | 2243 proxy_->blocking_main_thread_task_runner(), |
2235 settings_.renderer_settings.highp_threshold_min, | 2244 settings_.renderer_settings.highp_threshold_min, |
2236 settings_.renderer_settings.use_rgba_4444_textures, | 2245 settings_.renderer_settings.use_rgba_4444_textures, |
2237 settings_.renderer_settings.texture_id_allocation_chunk_size, | 2246 settings_.renderer_settings.texture_id_allocation_chunk_size, |
2238 settings_.use_persistent_map_for_gpu_memory_buffers); | 2247 settings_.use_persistent_map_for_gpu_memory_buffers); |
2239 | 2248 |
2240 CreateAndSetRenderer(); | 2249 CreateAndSetRenderer(); |
2241 | 2250 |
2242 // Since the new renderer may be capable of MSAA, update status here. | 2251 // Since the new renderer may be capable of MSAA, update status here. |
2243 UpdateGpuRasterizationStatus(); | 2252 UpdateGpuRasterizationStatus(); |
2244 | 2253 |
2245 CreateTileManagerResources(); | 2254 CreateAndSetTileManager(); |
2246 RecreateTreeResources(); | 2255 RecreateTreeResources(); |
2247 | 2256 |
2248 // Initialize vsync parameters to sane values. | 2257 // Initialize vsync parameters to sane values. |
2249 const base::TimeDelta display_refresh_interval = | 2258 const base::TimeDelta display_refresh_interval = |
2250 base::TimeDelta::FromMicroseconds( | 2259 base::TimeDelta::FromMicroseconds( |
2251 base::Time::kMicrosecondsPerSecond / | 2260 base::Time::kMicrosecondsPerSecond / |
2252 settings_.renderer_settings.refresh_rate); | 2261 settings_.renderer_settings.refresh_rate); |
2253 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); | 2262 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); |
2254 | 2263 |
2255 // TODO(brianderson): Don't use a hard-coded parent draw time. | 2264 // TODO(brianderson): Don't use a hard-coded parent draw time. |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3595 if (active_tree()) { | 3604 if (active_tree()) { |
3596 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); | 3605 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); |
3597 if (layer) | 3606 if (layer) |
3598 return layer->ScrollOffsetForAnimation(); | 3607 return layer->ScrollOffsetForAnimation(); |
3599 } | 3608 } |
3600 | 3609 |
3601 return gfx::ScrollOffset(); | 3610 return gfx::ScrollOffset(); |
3602 } | 3611 } |
3603 | 3612 |
3604 } // namespace cc | 3613 } // namespace cc |
OLD | NEW |