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

Unified 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 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 a9fbff52bfa10f2dfb3f7ae7439c358c6710a133..89d2ef5b173b512dc7eaf3699d2900cca159c3e2 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -220,6 +220,13 @@ LayerTreeHostImpl::LayerTreeHostImpl(
GetDefaultMemoryAllocationLimit(),
gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
ManagedMemoryPolicy::kDefaultNumResourcesLimit),
+ // Must be initialized after settings_ and proxy_.
+ tile_manager_(
+ TileManager::Create(this,
+ GetTaskRunner(),
+ IsSynchronousSingleThreaded()
+ ? std::numeric_limits<size_t>::max()
+ : settings.scheduled_raster_task_limit)),
pinch_gesture_active_(false),
pinch_gesture_end_should_clear_scrolling_layer_(false),
fps_counter_(FrameRateCounter::Create(proxy_->HasImplThread())),
@@ -306,7 +313,7 @@ LayerTreeHostImpl::~LayerTreeHostImpl() {
animation_host_->SetMutatorHostClient(nullptr);
}
- DestroyTileManager();
+ CleanUpTileManager();
}
void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) {
@@ -348,9 +355,10 @@ void LayerTreeHostImpl::CommitComplete() {
bool update_lcd_text = true;
sync_tree()->UpdateDrawProperties(update_lcd_text);
// Start working on newly created tiles immediately if needed.
- if (tile_manager_ && tile_priorities_dirty_) {
- PrepareTiles();
- } else {
+ // TODO(vmpstr): Investigate always having PrepareTiles issue
+ // NotifyReadyToActivate, instead of handling it here.
+ bool did_prepare_tiles = PrepareTiles();
+ if (!did_prepare_tiles) {
NotifyReadyToActivate();
// Ensure we get ReadyToDraw signal even when PrepareTiles not run. This
@@ -426,16 +434,16 @@ void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
AnimateTopControls(monotonic_time);
}
-void LayerTreeHostImpl::PrepareTiles() {
- if (!tile_manager_)
- return;
+bool LayerTreeHostImpl::PrepareTiles() {
if (!tile_priorities_dirty_)
- return;
+ return false;
client_->WillPrepareTiles();
- tile_priorities_dirty_ = false;
- tile_manager_->PrepareTiles(global_tile_state_);
+ bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_);
+ if (did_prepare_tiles)
+ tile_priorities_dirty_ = false;
client_->DidPrepareTiles();
+ return did_prepare_tiles;
}
void LayerTreeHostImpl::StartPageScaleAnimation(
@@ -1185,7 +1193,7 @@ size_t LayerTreeHostImpl::SourceAnimationFrameNumberForTesting() const {
void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
const ManagedMemoryPolicy& policy) {
- if (!tile_manager_)
+ if (!resource_pool_)
return;
global_tile_state_.hard_memory_limit_in_bytes = 0;
@@ -1337,14 +1345,11 @@ void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
// 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 && tile_manager_ &&
+ if (!policy.bytes_limit_when_visible && resource_pool_ &&
settings_.using_synchronous_renderer_compositor) {
ReleaseTreeResources();
- // TileManager destruction will synchronoulsy wait for all tile workers to
- // be cancelled or completed. This allows all resources to be freed
- // synchronously.
- DestroyTileManager();
- CreateAndSetTileManager();
+ CleanUpTileManager();
+ CreateTileManagerResources();
RecreateTreeResources();
}
}
@@ -1451,9 +1456,7 @@ void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) {
// In OOM, we now might be able to release more resources that were held
// because they were exported.
- if (tile_manager_) {
- DCHECK(resource_pool_);
-
+ if (resource_pool_) {
resource_pool_->CheckBusyResources(false);
resource_pool_->ReduceResourceUsage();
}
@@ -1698,11 +1701,13 @@ void LayerTreeHostImpl::UpdateTreeResourcesForGpuRasterizationIfNeeded() {
return;
// Clean up and replace existing tile manager with another one that uses
- // appropriate rasterizer.
+ // 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.
ReleaseTreeResources();
- if (tile_manager_) {
- DestroyTileManager();
- CreateAndSetTileManager();
+ if (resource_pool_) {
+ CleanUpTileManager();
+ CreateTileManagerResources();
}
RecreateTreeResources();
@@ -2066,24 +2071,13 @@ void LayerTreeHostImpl::CreateAndSetRenderer() {
client_->UpdateRendererCapabilitiesOnImplThread();
}
-void LayerTreeHostImpl::CreateAndSetTileManager() {
- DCHECK(!tile_manager_);
- DCHECK(output_surface_);
- DCHECK(resource_provider_);
-
+void LayerTreeHostImpl::CreateTileManagerResources() {
CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_,
&staging_resource_pool_);
- DCHECK(tile_task_worker_pool_);
- DCHECK(resource_pool_);
-
- DCHECK(GetTaskRunner());
- size_t scheduled_raster_task_limit =
+ tile_manager_->SetResources(
+ resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(),
IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max()
- : settings_.scheduled_raster_task_limit;
- tile_manager_ = TileManager::Create(
- this, GetTaskRunner(), resource_pool_.get(),
- tile_task_worker_pool_->AsTileTaskRunner(), scheduled_raster_task_limit);
-
+ : settings_.scheduled_raster_task_limit);
UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
}
@@ -2203,8 +2197,8 @@ void LayerTreeHostImpl::PostFrameTimingEvents(
main_frame_events.Pass());
}
-void LayerTreeHostImpl::DestroyTileManager() {
- tile_manager_ = nullptr;
+void LayerTreeHostImpl::CleanUpTileManager() {
+ tile_manager_->FinishTasksAndCleanUp();
resource_pool_ = nullptr;
staging_resource_pool_ = nullptr;
tile_task_worker_pool_ = nullptr;
@@ -2226,7 +2220,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
// Note: order is important here.
renderer_ = nullptr;
- DestroyTileManager();
+ CleanUpTileManager();
resource_provider_ = nullptr;
output_surface_ = nullptr;
@@ -2251,7 +2245,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
// Since the new renderer may be capable of MSAA, update status here.
UpdateGpuRasterizationStatus();
- CreateAndSetTileManager();
+ CreateTileManagerResources();
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