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

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

Issue 1210073020: Reland (2): cc: Make tile manager object persist for the length of LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« cc/tiles/tile_manager.cc ('K') | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 LayerTreeHostImplClient* client, 192 LayerTreeHostImplClient* client,
193 Proxy* proxy, 193 Proxy* proxy,
194 RenderingStatsInstrumentation* rendering_stats_instrumentation, 194 RenderingStatsInstrumentation* rendering_stats_instrumentation,
195 SharedBitmapManager* shared_bitmap_manager, 195 SharedBitmapManager* shared_bitmap_manager,
196 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 196 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
197 TaskGraphRunner* task_graph_runner, 197 TaskGraphRunner* task_graph_runner,
198 int id) 198 int id)
199 : client_(client), 199 : client_(client),
200 proxy_(proxy), 200 proxy_(proxy),
201 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), 201 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
202 tile_manager_(
203 TileManager::Create(this,
204 GetTaskRunner(),
205 IsSynchronousSingleThreaded()
206 ? std::numeric_limits<size_t>::max()
207 : settings.scheduled_raster_task_limit)),
202 content_is_suitable_for_gpu_rasterization_(true), 208 content_is_suitable_for_gpu_rasterization_(true),
203 has_gpu_rasterization_trigger_(false), 209 has_gpu_rasterization_trigger_(false),
204 use_gpu_rasterization_(false), 210 use_gpu_rasterization_(false),
205 use_msaa_(false), 211 use_msaa_(false),
206 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), 212 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE),
207 tree_resources_for_gpu_rasterization_dirty_(false), 213 tree_resources_for_gpu_rasterization_dirty_(false),
208 input_handler_client_(NULL), 214 input_handler_client_(NULL),
209 did_lock_scrolling_layer_(false), 215 did_lock_scrolling_layer_(false),
210 should_bubble_scrolls_(false), 216 should_bubble_scrolls_(false),
211 wheel_scrolling_(false), 217 wheel_scrolling_(false),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // made a contract with our animation controllers that the registrar 287 // made a contract with our animation controllers that the registrar
282 // will outlive them, and we must make good. 288 // will outlive them, and we must make good.
283 if (recycle_tree_) 289 if (recycle_tree_)
284 recycle_tree_->Shutdown(); 290 recycle_tree_->Shutdown();
285 if (pending_tree_) 291 if (pending_tree_)
286 pending_tree_->Shutdown(); 292 pending_tree_->Shutdown();
287 active_tree_->Shutdown(); 293 active_tree_->Shutdown();
288 recycle_tree_ = nullptr; 294 recycle_tree_ = nullptr;
289 pending_tree_ = nullptr; 295 pending_tree_ = nullptr;
290 active_tree_ = nullptr; 296 active_tree_ = nullptr;
291 DestroyTileManager(); 297 CleanUpTileManager();
292 } 298 }
293 299
294 void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) { 300 void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) {
295 // If the begin frame data was handled, then scroll and scale set was applied 301 // If the begin frame data was handled, then scroll and scale set was applied
296 // by the main thread, so the active tree needs to be updated as if these sent 302 // by the main thread, so the active tree needs to be updated as if these sent
297 // values were applied and committed. 303 // values were applied and committed.
298 if (CommitEarlyOutHandledCommit(reason)) 304 if (CommitEarlyOutHandledCommit(reason))
299 active_tree_->ApplySentScrollAndScaleDeltasFromAbortedCommit(); 305 active_tree_->ApplySentScrollAndScaleDeltasFromAbortedCommit();
300 } 306 }
301 307
(...skipping 21 matching lines...) Expand all
323 UpdateTreeResourcesForGpuRasterizationIfNeeded(); 329 UpdateTreeResourcesForGpuRasterizationIfNeeded();
324 sync_tree()->set_needs_update_draw_properties(); 330 sync_tree()->set_needs_update_draw_properties();
325 331
326 // We need an update immediately post-commit to have the opportunity to create 332 // We need an update immediately post-commit to have the opportunity to create
327 // tilings. Because invalidations may be coming from the main thread, it's 333 // tilings. Because invalidations may be coming from the main thread, it's
328 // safe to do an update for lcd text at this point and see if lcd text needs 334 // safe to do an update for lcd text at this point and see if lcd text needs
329 // to be disabled on any layers. 335 // to be disabled on any layers.
330 bool update_lcd_text = true; 336 bool update_lcd_text = true;
331 sync_tree()->UpdateDrawProperties(update_lcd_text); 337 sync_tree()->UpdateDrawProperties(update_lcd_text);
332 // Start working on newly created tiles immediately if needed. 338 // Start working on newly created tiles immediately if needed.
333 if (tile_manager_ && tile_priorities_dirty_) { 339 bool did_prepare_tiles = PrepareTiles();
334 PrepareTiles(); 340 if (!did_prepare_tiles) {
enne (OOO) 2015/07/06 18:07:26 Would it be cleaner to just have PrepareTiles alwa
vmpstr 2015/07/06 18:41:35 Maybe. I've left a TODO here, because I think it's
335 } else {
336 NotifyReadyToActivate(); 341 NotifyReadyToActivate();
337 342
338 // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This 343 // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This
339 // is important for SingleThreadProxy and impl-side painting case. For 344 // is important for SingleThreadProxy and impl-side painting case. For
340 // STP, we commit to active tree and RequiresHighResToDraw, and set 345 // STP, we commit to active tree and RequiresHighResToDraw, and set
341 // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard. 346 // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard.
342 if (proxy_->CommitToActiveTree()) 347 if (proxy_->CommitToActiveTree())
343 NotifyReadyToDraw(); 348 NotifyReadyToDraw();
344 } 349 }
345 350
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && 406 (CurrentlyScrollingLayer() != InnerViewportScrollLayer() &&
402 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) { 407 CurrentlyScrollingLayer() != OuterViewportScrollLayer())) {
403 AnimateInput(monotonic_time); 408 AnimateInput(monotonic_time);
404 } 409 }
405 AnimatePageScale(monotonic_time); 410 AnimatePageScale(monotonic_time);
406 AnimateLayers(monotonic_time); 411 AnimateLayers(monotonic_time);
407 AnimateScrollbars(monotonic_time); 412 AnimateScrollbars(monotonic_time);
408 AnimateTopControls(monotonic_time); 413 AnimateTopControls(monotonic_time);
409 } 414 }
410 415
411 void LayerTreeHostImpl::PrepareTiles() { 416 bool LayerTreeHostImpl::PrepareTiles() {
412 if (!tile_manager_)
413 return;
414 if (!tile_priorities_dirty_) 417 if (!tile_priorities_dirty_)
415 return; 418 return false;
416 419
417 tile_priorities_dirty_ = false; 420 bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_);
418 tile_manager_->PrepareTiles(global_tile_state_); 421 if (did_prepare_tiles) {
419 422 tile_priorities_dirty_ = false;
420 client_->DidPrepareTiles(); 423 client_->DidPrepareTiles();
424 }
425 return did_prepare_tiles;
421 } 426 }
422 427
423 void LayerTreeHostImpl::StartPageScaleAnimation( 428 void LayerTreeHostImpl::StartPageScaleAnimation(
424 const gfx::Vector2d& target_offset, 429 const gfx::Vector2d& target_offset,
425 bool anchor_point, 430 bool anchor_point,
426 float page_scale, 431 float page_scale,
427 base::TimeDelta duration) { 432 base::TimeDelta duration) {
428 if (!InnerViewportScrollLayer()) 433 if (!InnerViewportScrollLayer())
429 return; 434 return;
430 435
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 recycle_tree_->DetachLayerTree(); 1165 recycle_tree_->DetachLayerTree();
1161 recycle_tree_ = nullptr; 1166 recycle_tree_ = nullptr;
1162 } 1167 }
1163 1168
1164 size_t LayerTreeHostImpl::SourceAnimationFrameNumberForTesting() const { 1169 size_t LayerTreeHostImpl::SourceAnimationFrameNumberForTesting() const {
1165 return fps_counter_->current_frame_number(); 1170 return fps_counter_->current_frame_number();
1166 } 1171 }
1167 1172
1168 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy( 1173 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
1169 const ManagedMemoryPolicy& policy) { 1174 const ManagedMemoryPolicy& policy) {
1170 if (!tile_manager_) 1175 if (!resource_pool_)
1171 return; 1176 return;
1172 1177
1173 global_tile_state_.hard_memory_limit_in_bytes = 0; 1178 global_tile_state_.hard_memory_limit_in_bytes = 0;
1174 global_tile_state_.soft_memory_limit_in_bytes = 0; 1179 global_tile_state_.soft_memory_limit_in_bytes = 0;
1175 if (visible_ && policy.bytes_limit_when_visible > 0) { 1180 if (visible_ && policy.bytes_limit_when_visible > 0) {
1176 global_tile_state_.hard_memory_limit_in_bytes = 1181 global_tile_state_.hard_memory_limit_in_bytes =
1177 policy.bytes_limit_when_visible; 1182 policy.bytes_limit_when_visible;
1178 global_tile_state_.soft_memory_limit_in_bytes = 1183 global_tile_state_.soft_memory_limit_in_bytes =
1179 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) * 1184 (static_cast<int64>(global_tile_state_.hard_memory_limit_in_bytes) *
1180 settings_.max_memory_for_prepaint_percentage) / 1185 settings_.max_memory_for_prepaint_percentage) /
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 SetNeedsRedraw(); 1317 SetNeedsRedraw();
1313 } 1318 }
1314 } 1319 }
1315 1320
1316 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 1321 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
1317 SetManagedMemoryPolicy(policy); 1322 SetManagedMemoryPolicy(policy);
1318 1323
1319 // This is short term solution to synchronously drop tile resources when 1324 // This is short term solution to synchronously drop tile resources when
1320 // using synchronous compositing to avoid memory usage regression. 1325 // using synchronous compositing to avoid memory usage regression.
1321 // TODO(boliu): crbug.com/499004 to track removing this. 1326 // TODO(boliu): crbug.com/499004 to track removing this.
1322 if (!policy.bytes_limit_when_visible && tile_manager_ && 1327 if (!policy.bytes_limit_when_visible && resource_pool_ &&
1323 settings_.using_synchronous_renderer_compositor) { 1328 settings_.using_synchronous_renderer_compositor) {
1324 ReleaseTreeResources(); 1329 ReleaseTreeResources();
1325 // TileManager destruction will synchronoulsy wait for all tile workers to 1330 // TileManager's reset will synchronoulsy wait for all tile workers to
1326 // be cancelled or completed. This allows all resources to be freed 1331 // be cancelled or completed. This allows all resources to be freed
1327 // synchronously. 1332 // synchronously. Note that we don't need to use LayerTreeHostImpl
1328 DestroyTileManager(); 1333 // since resource_pool and tile_task_worker_pool will be the same.
1329 CreateAndSetTileManager(); 1334 tile_manager_->FinishTasksAndCleanUp();
1335 tile_manager_->SetResources(resource_pool_.get(),
1336 tile_task_worker_pool_->AsTileTaskRunner());
1337 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
1330 RecreateTreeResources(); 1338 RecreateTreeResources();
1331 } 1339 }
1332 } 1340 }
1333 1341
1334 void LayerTreeHostImpl::SetTreeActivationCallback( 1342 void LayerTreeHostImpl::SetTreeActivationCallback(
1335 const base::Closure& callback) { 1343 const base::Closure& callback) {
1336 DCHECK(proxy_->IsImplThread()); 1344 DCHECK(proxy_->IsImplThread());
1337 tree_activation_callback_ = callback; 1345 tree_activation_callback_ = callback;
1338 } 1346 }
1339 1347
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 } 1434 }
1427 1435
1428 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { 1436 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) {
1429 // TODO(piman): We may need to do some validation on this ack before 1437 // TODO(piman): We may need to do some validation on this ack before
1430 // processing it. 1438 // processing it.
1431 if (renderer_) 1439 if (renderer_)
1432 renderer_->ReceiveSwapBuffersAck(*ack); 1440 renderer_->ReceiveSwapBuffersAck(*ack);
1433 1441
1434 // In OOM, we now might be able to release more resources that were held 1442 // In OOM, we now might be able to release more resources that were held
1435 // because they were exported. 1443 // because they were exported.
1436 if (tile_manager_) { 1444 if (resource_pool_) {
1437 DCHECK(resource_pool_);
1438
1439 resource_pool_->CheckBusyResources(false); 1445 resource_pool_->CheckBusyResources(false);
1440 resource_pool_->ReduceResourceUsage(); 1446 resource_pool_->ReduceResourceUsage();
1441 } 1447 }
1442 // If we're not visible, we likely released resources, so we want to 1448 // If we're not visible, we likely released resources, so we want to
1443 // aggressively flush here to make sure those DeleteTextures make it to the 1449 // aggressively flush here to make sure those DeleteTextures make it to the
1444 // GPU process to free up the memory. 1450 // GPU process to free up the memory.
1445 if (output_surface_->context_provider() && !visible_) { 1451 if (output_surface_->context_provider() && !visible_) {
1446 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); 1452 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM();
1447 } 1453 }
1448 } 1454 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 use_msaa_ = use_msaa; 1677 use_msaa_ = use_msaa;
1672 1678
1673 tree_resources_for_gpu_rasterization_dirty_ = true; 1679 tree_resources_for_gpu_rasterization_dirty_ = true;
1674 } 1680 }
1675 1681
1676 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() { 1682 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() {
1677 if (!tree_resources_for_gpu_rasterization_dirty_) 1683 if (!tree_resources_for_gpu_rasterization_dirty_)
1678 return; 1684 return;
1679 1685
1680 // Clean up and replace existing tile manager with another one that uses 1686 // Clean up and replace existing tile manager with another one that uses
1681 // appropriate rasterizer. 1687 // appropriate rasterizer. Only do this however if we already have a
1688 // resource pool, since otherwise we might not be able to create a new
1689 // one.
1682 ReleaseTreeResources(); 1690 ReleaseTreeResources();
1683 if (tile_manager_) { 1691 if (resource_pool_) {
1684 DestroyTileManager(); 1692 CleanUpTileManager();
1685 CreateAndSetTileManager(); 1693 RecreateTileManagerResources();
1686 } 1694 }
1687 RecreateTreeResources(); 1695 RecreateTreeResources();
1688 1696
1689 // We have released tilings for both active and pending tree. 1697 // We have released tilings for both active and pending tree.
1690 // We would not have any content to draw until the pending tree is activated. 1698 // We would not have any content to draw until the pending tree is activated.
1691 // Prevent the active tree from drawing until activation. 1699 // Prevent the active tree from drawing until activation.
1692 SetRequiresHighResToDraw(); 1700 SetRequiresHighResToDraw();
1693 1701
1694 tree_resources_for_gpu_rasterization_dirty_ = false; 1702 tree_resources_for_gpu_rasterization_dirty_ = false;
1695 } 1703 }
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 2047
2040 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be 2048 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be
2041 // initialized to get max texture size. Also, after releasing resources, 2049 // initialized to get max texture size. Also, after releasing resources,
2042 // trees need another update to generate new ones. 2050 // trees need another update to generate new ones.
2043 active_tree_->set_needs_update_draw_properties(); 2051 active_tree_->set_needs_update_draw_properties();
2044 if (pending_tree_) 2052 if (pending_tree_)
2045 pending_tree_->set_needs_update_draw_properties(); 2053 pending_tree_->set_needs_update_draw_properties();
2046 client_->UpdateRendererCapabilitiesOnImplThread(); 2054 client_->UpdateRendererCapabilitiesOnImplThread();
2047 } 2055 }
2048 2056
2049 void LayerTreeHostImpl::CreateAndSetTileManager() { 2057 void LayerTreeHostImpl::RecreateTileManagerResources() {
enne (OOO) 2015/07/06 18:07:26 bikeshedding: This seems less Recreate and more ju
vmpstr 2015/07/06 18:41:35 Done.
2050 DCHECK(!tile_manager_);
2051 DCHECK(output_surface_);
2052 DCHECK(resource_provider_);
2053
2054 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_, 2058 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_,
2055 &staging_resource_pool_); 2059 &staging_resource_pool_);
2056 DCHECK(tile_task_worker_pool_); 2060 tile_manager_->SetResources(resource_pool_.get(),
2057 DCHECK(resource_pool_); 2061 tile_task_worker_pool_->AsTileTaskRunner());
2058
2059 DCHECK(GetTaskRunner());
2060 size_t scheduled_raster_task_limit =
2061 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max()
2062 : settings_.scheduled_raster_task_limit;
2063 tile_manager_ = TileManager::Create(
2064 this, GetTaskRunner(), resource_pool_.get(),
2065 tile_task_worker_pool_->AsTileTaskRunner(), scheduled_raster_task_limit);
2066
2067 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); 2062 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
2068 } 2063 }
2069 2064
2070 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( 2065 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
2071 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, 2066 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
2072 scoped_ptr<ResourcePool>* resource_pool, 2067 scoped_ptr<ResourcePool>* resource_pool,
2073 scoped_ptr<ResourcePool>* staging_resource_pool) { 2068 scoped_ptr<ResourcePool>* staging_resource_pool) {
2074 DCHECK(GetTaskRunner()); 2069 DCHECK(GetTaskRunner());
2075 2070
2076 // Pass the single-threaded synchronous task graph runner to the worker pool 2071 // Pass the single-threaded synchronous task graph runner to the worker pool
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 request_ids, start_time, end_time, active_tree_->source_frame_number()); 2171 request_ids, start_time, end_time, active_tree_->source_frame_number());
2177 } 2172 }
2178 2173
2179 void LayerTreeHostImpl::PostFrameTimingEvents( 2174 void LayerTreeHostImpl::PostFrameTimingEvents(
2180 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 2175 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
2181 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 2176 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
2182 client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(), 2177 client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(),
2183 main_frame_events.Pass()); 2178 main_frame_events.Pass());
2184 } 2179 }
2185 2180
2186 void LayerTreeHostImpl::DestroyTileManager() { 2181 void LayerTreeHostImpl::CleanUpTileManager() {
2187 tile_manager_ = nullptr; 2182 tile_manager_->FinishTasksAndCleanUp();
2188 resource_pool_ = nullptr; 2183 resource_pool_ = nullptr;
2189 staging_resource_pool_ = nullptr; 2184 staging_resource_pool_ = nullptr;
2190 tile_task_worker_pool_ = nullptr; 2185 tile_task_worker_pool_ = nullptr;
2191 single_thread_synchronous_task_graph_runner_ = nullptr; 2186 single_thread_synchronous_task_graph_runner_ = nullptr;
2192 } 2187 }
2193 2188
2194 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const { 2189 bool LayerTreeHostImpl::IsSynchronousSingleThreaded() const {
2195 return !proxy_->HasImplThread() && !settings_.single_thread_proxy_scheduler; 2190 return !proxy_->HasImplThread() && !settings_.single_thread_proxy_scheduler;
2196 } 2191 }
2197 2192
2198 bool LayerTreeHostImpl::InitializeRenderer( 2193 bool LayerTreeHostImpl::InitializeRenderer(
2199 scoped_ptr<OutputSurface> output_surface) { 2194 scoped_ptr<OutputSurface> output_surface) {
2200 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); 2195 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer");
2201 2196
2202 // Since we will create a new resource provider, we cannot continue to use 2197 // Since we will create a new resource provider, we cannot continue to use
2203 // the old resources (i.e. render_surfaces and texture IDs). Clear them 2198 // the old resources (i.e. render_surfaces and texture IDs). Clear them
2204 // before we destroy the old resource provider. 2199 // before we destroy the old resource provider.
2205 ReleaseTreeResources(); 2200 ReleaseTreeResources();
2206 2201
2207 // Note: order is important here. 2202 // Note: order is important here.
2208 renderer_ = nullptr; 2203 renderer_ = nullptr;
2209 DestroyTileManager(); 2204 CleanUpTileManager();
2210 resource_provider_ = nullptr; 2205 resource_provider_ = nullptr;
2211 output_surface_ = nullptr; 2206 output_surface_ = nullptr;
2212 2207
2213 if (!output_surface->BindToClient(this)) { 2208 if (!output_surface->BindToClient(this)) {
2214 // Avoid recreating tree resources because we might not have enough 2209 // Avoid recreating tree resources because we might not have enough
2215 // information to do this yet (eg. we don't have a TileManager at this 2210 // information to do this yet (eg. we don't have a TileManager at this
2216 // point). 2211 // point).
2217 return false; 2212 return false;
2218 } 2213 }
2219 2214
2220 output_surface_ = output_surface.Pass(); 2215 output_surface_ = output_surface.Pass();
2221 resource_provider_ = ResourceProvider::Create( 2216 resource_provider_ = ResourceProvider::Create(
2222 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_, 2217 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_,
2223 proxy_->blocking_main_thread_task_runner(), 2218 proxy_->blocking_main_thread_task_runner(),
2224 settings_.renderer_settings.highp_threshold_min, 2219 settings_.renderer_settings.highp_threshold_min,
2225 settings_.renderer_settings.use_rgba_4444_textures, 2220 settings_.renderer_settings.use_rgba_4444_textures,
2226 settings_.renderer_settings.texture_id_allocation_chunk_size, 2221 settings_.renderer_settings.texture_id_allocation_chunk_size,
2227 settings_.use_persistent_map_for_gpu_memory_buffers); 2222 settings_.use_persistent_map_for_gpu_memory_buffers);
2228 2223
2229 CreateAndSetRenderer(); 2224 CreateAndSetRenderer();
2230 2225
2231 // Since the new renderer may be capable of MSAA, update status here. 2226 // Since the new renderer may be capable of MSAA, update status here.
2232 UpdateGpuRasterizationStatus(); 2227 UpdateGpuRasterizationStatus();
2233 2228
2234 CreateAndSetTileManager(); 2229 RecreateTileManagerResources();
2235 RecreateTreeResources(); 2230 RecreateTreeResources();
2236 2231
2237 // Initialize vsync parameters to sane values. 2232 // Initialize vsync parameters to sane values.
2238 const base::TimeDelta display_refresh_interval = 2233 const base::TimeDelta display_refresh_interval =
2239 base::TimeDelta::FromMicroseconds( 2234 base::TimeDelta::FromMicroseconds(
2240 base::Time::kMicrosecondsPerSecond / 2235 base::Time::kMicrosecondsPerSecond /
2241 settings_.renderer_settings.refresh_rate); 2236 settings_.renderer_settings.refresh_rate);
2242 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); 2237 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval);
2243 2238
2244 // TODO(brianderson): Don't use a hard-coded parent draw time. 2239 // TODO(brianderson): Don't use a hard-coded parent draw time.
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3435 new_target.SetToMin(layer_impl->MaxScrollOffset()); 3430 new_target.SetToMin(layer_impl->MaxScrollOffset());
3436 3431
3437 curve->UpdateTarget( 3432 curve->UpdateTarget(
3438 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) 3433 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time)
3439 .InSecondsF(), 3434 .InSecondsF(),
3440 new_target); 3435 new_target);
3441 3436
3442 return true; 3437 return true;
3443 } 3438 }
3444 } // namespace cc 3439 } // namespace cc
OLDNEW
« cc/tiles/tile_manager.cc ('K') | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698