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

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, 6 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
« cc/tiles/tile_manager.cc ('K') | « 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 ddb4dc951a8ea75b5a68c3fd9ad5dad38e24bd21..c7a1232b868e01b72b8b2b4522e0319c38992ea3 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -199,6 +199,12 @@ LayerTreeHostImpl::LayerTreeHostImpl(
: 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),
@@ -288,7 +294,7 @@ LayerTreeHostImpl::~LayerTreeHostImpl() {
recycle_tree_ = nullptr;
pending_tree_ = nullptr;
active_tree_ = nullptr;
- DestroyTileManager();
+ CleanUpTileManager();
}
void LayerTreeHostImpl::BeginMainFrameAborted(CommitEarlyOutReason reason) {
@@ -330,9 +336,8 @@ 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 {
+ bool did_prepare_tiles = PrepareTiles();
+ 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
NotifyReadyToActivate();
// Ensure we get ReadyToDraw signal even when PrepareTiles not run. This
@@ -408,16 +413,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;
-
- tile_priorities_dirty_ = false;
- tile_manager_->PrepareTiles(global_tile_state_);
+ return false;
- client_->DidPrepareTiles();
+ 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(
@@ -1167,7 +1172,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;
@@ -1319,14 +1324,17 @@ 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
+ // TileManager's reset will synchronoulsy wait for all tile workers to
// be cancelled or completed. This allows all resources to be freed
- // synchronously.
- DestroyTileManager();
- CreateAndSetTileManager();
+ // synchronously. Note that we don't need to use LayerTreeHostImpl
+ // since resource_pool and tile_task_worker_pool will be the same.
+ tile_manager_->FinishTasksAndCleanUp();
+ tile_manager_->SetResources(resource_pool_.get(),
+ tile_task_worker_pool_->AsTileTaskRunner());
+ UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
RecreateTreeResources();
}
}
@@ -1433,9 +1441,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();
}
@@ -1678,11 +1684,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();
+ RecreateTileManagerResources();
}
RecreateTreeResources();
@@ -2046,24 +2054,11 @@ void LayerTreeHostImpl::CreateAndSetRenderer() {
client_->UpdateRendererCapabilitiesOnImplThread();
}
-void LayerTreeHostImpl::CreateAndSetTileManager() {
- DCHECK(!tile_manager_);
- DCHECK(output_surface_);
- DCHECK(resource_provider_);
-
+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.
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 =
- 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);
-
+ tile_manager_->SetResources(resource_pool_.get(),
+ tile_task_worker_pool_->AsTileTaskRunner());
UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
}
@@ -2183,8 +2178,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;
@@ -2206,7 +2201,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
// Note: order is important here.
renderer_ = nullptr;
- DestroyTileManager();
+ CleanUpTileManager();
resource_provider_ = nullptr;
output_surface_ = nullptr;
@@ -2231,7 +2226,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
// Since the new renderer may be capable of MSAA, update status here.
UpdateGpuRasterizationStatus();
- CreateAndSetTileManager();
+ RecreateTileManagerResources();
RecreateTreeResources();
// Initialize vsync parameters to sane values.
« 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