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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 1229223003: Revert of Reland: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index abe2e84f10ed85fcea75f88277495e1a49b210f9..a9fbff52bfa10f2dfb3f7ae7439c358c6710a133 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -200,12 +200,6 @@
: client_(client),
proxy_(proxy),
current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
- tile_manager_(
- TileManager::Create(this,
- GetTaskRunner(),
- IsSynchronousSingleThreaded()
- ? std::numeric_limits<size_t>::max()
- : settings.scheduled_raster_task_limit)),
content_is_suitable_for_gpu_rasterization_(true),
has_gpu_rasterization_trigger_(false),
use_gpu_rasterization_(false),
@@ -312,7 +306,7 @@
animation_host_->SetMutatorHostClient(nullptr);
}
- CleanUpTileManager();
+ DestroyTileManager();
}
void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) {
@@ -354,10 +348,9 @@
bool update_lcd_text = true;
sync_tree()->UpdateDrawProperties(update_lcd_text);
// Start working on newly created tiles immediately if needed.
- // TODO(vmpstr): Investigate always having PrepareTiles issue
- // NotifyReadyToActivate, instead of handling it here.
- bool did_prepare_tiles = PrepareTiles();
- if (!did_prepare_tiles) {
+ if (tile_manager_ && tile_priorities_dirty_) {
+ PrepareTiles();
+ } else {
NotifyReadyToActivate();
// Ensure we get ReadyToDraw signal even when PrepareTiles not run. This
@@ -433,16 +426,16 @@
AnimateTopControls(monotonic_time);
}
-bool LayerTreeHostImpl::PrepareTiles() {
+void LayerTreeHostImpl::PrepareTiles() {
+ if (!tile_manager_)
+ return;
if (!tile_priorities_dirty_)
- return false;
+ return;
client_->WillPrepareTiles();
- bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_);
- if (did_prepare_tiles)
- tile_priorities_dirty_ = false;
+ tile_priorities_dirty_ = false;
+ tile_manager_->PrepareTiles(global_tile_state_);
client_->DidPrepareTiles();
- return did_prepare_tiles;
}
void LayerTreeHostImpl::StartPageScaleAnimation(
@@ -1192,7 +1185,7 @@
void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
const ManagedMemoryPolicy& policy) {
- if (!resource_pool_)
+ if (!tile_manager_)
return;
global_tile_state_.hard_memory_limit_in_bytes = 0;
@@ -1344,11 +1337,14 @@
// This is short term solution to synchronously drop tile resources when
// using synchronous compositing to avoid memory usage regression.
// TODO(boliu): crbug.com/499004 to track removing this.
- if (!policy.bytes_limit_when_visible && resource_pool_ &&
+ if (!policy.bytes_limit_when_visible && tile_manager_ &&
settings_.using_synchronous_renderer_compositor) {
ReleaseTreeResources();
- CleanUpTileManager();
- CreateTileManagerResources();
+ // TileManager destruction will synchronoulsy wait for all tile workers to
+ // be cancelled or completed. This allows all resources to be freed
+ // synchronously.
+ DestroyTileManager();
+ CreateAndSetTileManager();
RecreateTreeResources();
}
}
@@ -1455,7 +1451,9 @@
// In OOM, we now might be able to release more resources that were held
// because they were exported.
- if (resource_pool_) {
+ if (tile_manager_) {
+ DCHECK(resource_pool_);
+
resource_pool_->CheckBusyResources(false);
resource_pool_->ReduceResourceUsage();
}
@@ -1700,13 +1698,11 @@
return;
// Clean up and replace existing tile manager with another one that uses
- // appropriate rasterizer. Only do this however if we already have a
- // resource pool, since otherwise we might not be able to create a new
- // one.
+ // appropriate rasterizer.
ReleaseTreeResources();
- if (resource_pool_) {
- CleanUpTileManager();
- CreateTileManagerResources();
+ if (tile_manager_) {
+ DestroyTileManager();
+ CreateAndSetTileManager();
}
RecreateTreeResources();
@@ -2070,13 +2066,24 @@
client_->UpdateRendererCapabilitiesOnImplThread();
}
-void LayerTreeHostImpl::CreateTileManagerResources() {
+void LayerTreeHostImpl::CreateAndSetTileManager() {
+ DCHECK(!tile_manager_);
+ DCHECK(output_surface_);
+ DCHECK(resource_provider_);
+
CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_,
&staging_resource_pool_);
- tile_manager_->SetResources(
- resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(),
+ DCHECK(tile_task_worker_pool_);
+ DCHECK(resource_pool_);
+
+ DCHECK(GetTaskRunner());
+ size_t scheduled_raster_task_limit =
IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max()
- : settings_.scheduled_raster_task_limit);
+ : settings_.scheduled_raster_task_limit;
+ tile_manager_ = TileManager::Create(
+ this, GetTaskRunner(), resource_pool_.get(),
+ tile_task_worker_pool_->AsTileTaskRunner(), scheduled_raster_task_limit);
+
UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
}
@@ -2196,8 +2203,8 @@
main_frame_events.Pass());
}
-void LayerTreeHostImpl::CleanUpTileManager() {
- tile_manager_->FinishTasksAndCleanUp();
+void LayerTreeHostImpl::DestroyTileManager() {
+ tile_manager_ = nullptr;
resource_pool_ = nullptr;
staging_resource_pool_ = nullptr;
tile_task_worker_pool_ = nullptr;
@@ -2219,7 +2226,7 @@
// Note: order is important here.
renderer_ = nullptr;
- CleanUpTileManager();
+ DestroyTileManager();
resource_provider_ = nullptr;
output_surface_ = nullptr;
@@ -2244,7 +2251,7 @@
// Since the new renderer may be capable of MSAA, update status here.
UpdateGpuRasterizationStatus();
- CreateTileManagerResources();
+ CreateAndSetTileManager();
RecreateTreeResources();
// Initialize vsync parameters to sane values.
« no previous file with comments | « 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