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

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

Issue 2468023002: Don't free non-tile resources on GPU rasterization toggle (Closed)
Patch Set: fix unittest Created 4 years, 1 month 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.h » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 1352 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
1353 DCHECK(task_runner_provider_->IsImplThread()); 1353 DCHECK(task_runner_provider_->IsImplThread());
1354 1354
1355 SetManagedMemoryPolicy(policy); 1355 SetManagedMemoryPolicy(policy);
1356 1356
1357 // This is short term solution to synchronously drop tile resources when 1357 // This is short term solution to synchronously drop tile resources when
1358 // using synchronous compositing to avoid memory usage regression. 1358 // using synchronous compositing to avoid memory usage regression.
1359 // TODO(boliu): crbug.com/499004 to track removing this. 1359 // TODO(boliu): crbug.com/499004 to track removing this.
1360 if (!policy.bytes_limit_when_visible && resource_pool_ && 1360 if (!policy.bytes_limit_when_visible && resource_pool_ &&
1361 settings_.using_synchronous_renderer_compositor) { 1361 settings_.using_synchronous_renderer_compositor) {
1362 ReleaseTreeResources(); 1362 ReleaseTileResources();
1363 CleanUpTileManagerAndUIResources(); 1363 CleanUpTileManagerAndUIResources();
1364 1364
1365 // Force a call to NotifyAllTileTasks completed - otherwise this logic may 1365 // Force a call to NotifyAllTileTasks completed - otherwise this logic may
1366 // be skipped if no work was enqueued at the time the tile manager was 1366 // be skipped if no work was enqueued at the time the tile manager was
1367 // destroyed. 1367 // destroyed.
1368 NotifyAllTileTasksCompleted(); 1368 NotifyAllTileTasksCompleted();
1369 1369
1370 CreateTileManagerResources(); 1370 CreateTileManagerResources();
1371 RecreateTreeResources(); 1371 RecreateTileResources();
1372 } 1372 }
1373 } 1373 }
1374 1374
1375 void LayerTreeHostImpl::SetTreeActivationCallback( 1375 void LayerTreeHostImpl::SetTreeActivationCallback(
1376 const base::Closure& callback) { 1376 const base::Closure& callback) {
1377 DCHECK(task_runner_provider_->IsImplThread()); 1377 DCHECK(task_runner_provider_->IsImplThread());
1378 tree_activation_callback_ = callback; 1378 tree_activation_callback_ = callback;
1379 } 1379 }
1380 1380
1381 void LayerTreeHostImpl::SetManagedMemoryPolicy( 1381 void LayerTreeHostImpl::SetManagedMemoryPolicy(
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() { 1800 void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() {
1801 if (!need_update_gpu_rasterization_status_) 1801 if (!need_update_gpu_rasterization_status_)
1802 return; 1802 return;
1803 if (!UpdateGpuRasterizationStatus()) 1803 if (!UpdateGpuRasterizationStatus())
1804 return; 1804 return;
1805 1805
1806 // Clean up and replace existing tile manager with another one that uses 1806 // Clean up and replace existing tile manager with another one that uses
1807 // appropriate rasterizer. Only do this however if we already have a 1807 // appropriate rasterizer. Only do this however if we already have a
1808 // resource pool, since otherwise we might not be able to create a new 1808 // resource pool, since otherwise we might not be able to create a new
1809 // one. 1809 // one.
1810 ReleaseTreeResources(); 1810 ReleaseTileResources();
1811 if (resource_pool_) { 1811 if (resource_pool_) {
1812 CleanUpTileManagerAndUIResources(); 1812 CleanUpTileManagerAndUIResources();
1813 CreateTileManagerResources(); 1813 CreateTileManagerResources();
1814 } 1814 }
1815 RecreateTreeResources(); 1815 RecreateTileResources();
1816 1816
1817 // We have released tilings for both active and pending tree. 1817 // We have released tilings for both active and pending tree.
1818 // We would not have any content to draw until the pending tree is activated. 1818 // We would not have any content to draw until the pending tree is activated.
1819 // Prevent the active tree from drawing until activation. 1819 // Prevent the active tree from drawing until activation.
1820 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. 1820 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw.
1821 SetRequiresHighResToDraw(); 1821 SetRequiresHighResToDraw();
1822 } 1822 }
1823 1823
1824 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { 1824 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
1825 current_begin_frame_tracker_.Start(args); 1825 current_begin_frame_tracker_.Start(args);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 void LayerTreeHostImpl::ReleaseTreeResources() { 2076 void LayerTreeHostImpl::ReleaseTreeResources() {
2077 active_tree_->ReleaseResources(); 2077 active_tree_->ReleaseResources();
2078 if (pending_tree_) 2078 if (pending_tree_)
2079 pending_tree_->ReleaseResources(); 2079 pending_tree_->ReleaseResources();
2080 if (recycle_tree_) 2080 if (recycle_tree_)
2081 recycle_tree_->ReleaseResources(); 2081 recycle_tree_->ReleaseResources();
2082 2082
2083 EvictAllUIResources(); 2083 EvictAllUIResources();
2084 } 2084 }
2085 2085
2086 void LayerTreeHostImpl::RecreateTreeResources() { 2086 void LayerTreeHostImpl::ReleaseTileResources() {
2087 active_tree_->RecreateResources(); 2087 active_tree_->ReleaseTileResources();
2088 if (pending_tree_) 2088 if (pending_tree_)
2089 pending_tree_->RecreateResources(); 2089 pending_tree_->ReleaseTileResources();
2090 if (recycle_tree_) 2090 if (recycle_tree_)
2091 recycle_tree_->RecreateResources(); 2091 recycle_tree_->ReleaseTileResources();
2092 }
2093
2094 void LayerTreeHostImpl::RecreateTileResources() {
2095 active_tree_->RecreateTileResources();
2096 if (pending_tree_)
2097 pending_tree_->RecreateTileResources();
2098 if (recycle_tree_)
2099 recycle_tree_->RecreateTileResources();
2092 } 2100 }
2093 2101
2094 void LayerTreeHostImpl::CreateTileManagerResources() { 2102 void LayerTreeHostImpl::CreateTileManagerResources() {
2095 CreateResourceAndRasterBufferProvider(&raster_buffer_provider_, 2103 CreateResourceAndRasterBufferProvider(&raster_buffer_provider_,
2096 &resource_pool_); 2104 &resource_pool_);
2097 2105
2098 if (use_gpu_rasterization_) { 2106 if (use_gpu_rasterization_) {
2099 image_decode_controller_ = base::MakeUnique<GpuImageDecodeController>( 2107 image_decode_controller_ = base::MakeUnique<GpuImageDecodeController>(
2100 compositor_frame_sink_->worker_context_provider(), 2108 compositor_frame_sink_->worker_context_provider(),
2101 settings_.renderer_settings.preferred_tile_format, 2109 settings_.renderer_settings.preferred_tile_format,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 2333
2326 // See note in LayerTreeImpl::UpdateDrawProperties, new CompositorFrameSink 2334 // See note in LayerTreeImpl::UpdateDrawProperties, new CompositorFrameSink
2327 // means a new max texture size which affects draw properties. Also, if the 2335 // means a new max texture size which affects draw properties. Also, if the
2328 // draw properties were up to date, layers still lost resources and we need to 2336 // draw properties were up to date, layers still lost resources and we need to
2329 // UpdateDrawProperties() after calling RecreateTreeResources(). 2337 // UpdateDrawProperties() after calling RecreateTreeResources().
2330 active_tree_->set_needs_update_draw_properties(); 2338 active_tree_->set_needs_update_draw_properties();
2331 if (pending_tree_) 2339 if (pending_tree_)
2332 pending_tree_->set_needs_update_draw_properties(); 2340 pending_tree_->set_needs_update_draw_properties();
2333 2341
2334 CreateTileManagerResources(); 2342 CreateTileManagerResources();
2335 RecreateTreeResources(); 2343 RecreateTileResources();
2336 2344
2337 client_->OnCanDrawStateChanged(CanDraw()); 2345 client_->OnCanDrawStateChanged(CanDraw());
2338 SetFullViewportDamage(); 2346 SetFullViewportDamage();
2339 // There will not be anything to draw here, so set high res 2347 // There will not be anything to draw here, so set high res
2340 // to avoid checkerboards, typically when we are recovering 2348 // to avoid checkerboards, typically when we are recovering
2341 // from lost context. 2349 // from lost context.
2342 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. 2350 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw.
2343 SetRequiresHighResToDraw(); 2351 SetRequiresHighResToDraw();
2344 2352
2345 return true; 2353 return true;
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
4097 if (is_visible) { 4105 if (is_visible) {
4098 worker_context_visibility_ = 4106 worker_context_visibility_ =
4099 worker_context->CacheController()->ClientBecameVisible(); 4107 worker_context->CacheController()->ClientBecameVisible();
4100 } else { 4108 } else {
4101 worker_context->CacheController()->ClientBecameNotVisible( 4109 worker_context->CacheController()->ClientBecameNotVisible(
4102 std::move(worker_context_visibility_)); 4110 std::move(worker_context_visibility_));
4103 } 4111 }
4104 } 4112 }
4105 4113
4106 } // namespace cc 4114 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698