summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/cc.gyp2
-rw-r--r--cc/resources/rasterizer_delegate.cc89
-rw-r--r--cc/resources/rasterizer_delegate.h46
-rw-r--r--cc/resources/tile_manager.cc45
-rw-r--r--cc/resources/tile_manager.h19
-rw-r--r--cc/resources/tile_manager_perftest.cc3
-rw-r--r--cc/test/fake_tile_manager.cc3
-rw-r--r--cc/trees/layer_tree_host_impl.cc181
-rw-r--r--cc/trees/layer_tree_host_impl.h14
9 files changed, 116 insertions, 286 deletions
diff --git a/cc/cc.gyp b/cc/cc.gyp
index a56fc90..d05de57 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -374,8 +374,6 @@
'resources/raster_worker_pool.h',
'resources/rasterizer.cc',
'resources/rasterizer.h',
- 'resources/rasterizer_delegate.cc',
- 'resources/rasterizer_delegate.h',
'resources/release_callback.h',
'resources/resource.cc',
'resources/resource.h',
diff --git a/cc/resources/rasterizer_delegate.cc b/cc/resources/rasterizer_delegate.cc
deleted file mode 100644
index dcceb1f..0000000
--- a/cc/resources/rasterizer_delegate.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/resources/rasterizer_delegate.h"
-
-#include "base/debug/trace_event.h"
-
-namespace cc {
-
-RasterizerDelegate::RasterizerDelegate(RasterizerClient* client,
- Rasterizer** rasterizers,
- size_t num_rasterizers)
- : client_(client),
- rasterizers_(rasterizers, rasterizers + num_rasterizers),
- did_finish_running_tasks_pending_count_(0u),
- did_finish_running_tasks_required_for_activation_pending_count_(0u) {
- DCHECK(client_);
- for (RasterizerVector::iterator it = rasterizers_.begin();
- it != rasterizers_.end();
- ++it)
- (*it)->SetClient(this);
-}
-
-RasterizerDelegate::~RasterizerDelegate() {}
-
-// static
-scoped_ptr<RasterizerDelegate> RasterizerDelegate::Create(
- RasterizerClient* client,
- Rasterizer** rasterizers,
- size_t num_rasterizers) {
- return make_scoped_ptr(
- new RasterizerDelegate(client, rasterizers, num_rasterizers));
-}
-
-void RasterizerDelegate::Shutdown() {
- for (RasterizerVector::iterator it = rasterizers_.begin();
- it != rasterizers_.end();
- ++it)
- (*it)->Shutdown();
-}
-
-void RasterizerDelegate::ScheduleTasks(RasterTaskQueue* queue) {
- for (size_t i = 0; i < rasterizers_.size(); ++i)
- rasterizers_[i]->ScheduleTasks(&queue[i]);
-
- did_finish_running_tasks_pending_count_ = rasterizers_.size();
- did_finish_running_tasks_required_for_activation_pending_count_ =
- rasterizers_.size();
-}
-
-void RasterizerDelegate::CheckForCompletedTasks() {
- for (RasterizerVector::iterator it = rasterizers_.begin();
- it != rasterizers_.end();
- ++it)
- (*it)->CheckForCompletedTasks();
-}
-
-bool RasterizerDelegate::ShouldForceTasksRequiredForActivationToComplete()
- const {
- return client_->ShouldForceTasksRequiredForActivationToComplete();
-}
-
-void RasterizerDelegate::DidFinishRunningTasks() {
- TRACE_EVENT1("cc",
- "RasterizerDelegate::DidFinishRunningTasks",
- "pending_count",
- did_finish_running_tasks_pending_count_);
-
- DCHECK_LT(0u, did_finish_running_tasks_pending_count_);
- if (--did_finish_running_tasks_pending_count_)
- return;
- client_->DidFinishRunningTasks();
-}
-
-void RasterizerDelegate::DidFinishRunningTasksRequiredForActivation() {
- TRACE_EVENT1("cc",
- "RasterizerDelegate::DidFinishRunningTasksRequiredForActivation",
- "pending_count",
- did_finish_running_tasks_required_for_activation_pending_count_);
-
- DCHECK_LT(0u,
- did_finish_running_tasks_required_for_activation_pending_count_);
- if (--did_finish_running_tasks_required_for_activation_pending_count_)
- return;
- client_->DidFinishRunningTasksRequiredForActivation();
-}
-
-} // namespace cc
diff --git a/cc/resources/rasterizer_delegate.h b/cc/resources/rasterizer_delegate.h
deleted file mode 100644
index f9209637..0000000
--- a/cc/resources/rasterizer_delegate.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_RESOURCES_RASTERIZER_DELEGATE_H_
-#define CC_RESOURCES_RASTERIZER_DELEGATE_H_
-
-#include <vector>
-
-#include "cc/resources/rasterizer.h"
-
-namespace cc {
-
-class RasterizerDelegate : public RasterizerClient {
- public:
- virtual ~RasterizerDelegate();
-
- static scoped_ptr<RasterizerDelegate> Create(RasterizerClient* client,
- Rasterizer** rasterizers,
- size_t num_rasterizers);
-
- void SetClient(RasterizerClient* client);
- void Shutdown();
- void ScheduleTasks(RasterTaskQueue* queue);
- void CheckForCompletedTasks();
-
- // Overriden from RasterizerClient:
- virtual bool ShouldForceTasksRequiredForActivationToComplete() const OVERRIDE;
- virtual void DidFinishRunningTasks() OVERRIDE;
- virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE;
-
- private:
- RasterizerDelegate(RasterizerClient* client,
- Rasterizer** rasterizers,
- size_t num_rasterizers);
-
- RasterizerClient* client_;
- typedef std::vector<Rasterizer*> RasterizerVector;
- RasterizerVector rasterizers_;
- size_t did_finish_running_tasks_pending_count_;
- size_t did_finish_running_tasks_required_for_activation_pending_count_;
-};
-
-} // namespace cc
-
-#endif // CC_RESOURCES_RASTERIZER_DELEGATE_H_
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index 82b6bf4..2b3e652 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -367,13 +367,11 @@ scoped_ptr<TileManager> TileManager::Create(
TileManagerClient* client,
ResourcePool* resource_pool,
Rasterizer* rasterizer,
- Rasterizer* gpu_rasterizer,
bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation) {
return make_scoped_ptr(new TileManager(client,
resource_pool,
rasterizer,
- gpu_rasterizer,
use_rasterize_on_demand,
rendering_stats_instrumentation));
}
@@ -382,11 +380,11 @@ TileManager::TileManager(
TileManagerClient* client,
ResourcePool* resource_pool,
Rasterizer* rasterizer,
- Rasterizer* gpu_rasterizer,
bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation)
: client_(client),
resource_pool_(resource_pool),
+ rasterizer_(rasterizer),
prioritized_tiles_dirty_(false),
all_tiles_that_need_to_be_rasterized_have_memory_(true),
all_tiles_required_for_activation_have_memory_(true),
@@ -399,12 +397,7 @@ TileManager::TileManager(
did_initialize_visible_tile_(false),
did_check_for_completed_tasks_since_last_schedule_tasks_(true),
use_rasterize_on_demand_(use_rasterize_on_demand) {
- Rasterizer* rasterizers[NUM_RASTERIZER_TYPES] = {
- rasterizer, // RASTERIZER_TYPE_DEFAULT
- gpu_rasterizer, // RASTERIZER_TYPE_GPU
- };
- rasterizer_delegate_ =
- RasterizerDelegate::Create(this, rasterizers, arraysize(rasterizers));
+ rasterizer_->SetClient(this);
}
TileManager::~TileManager() {
@@ -415,14 +408,14 @@ TileManager::~TileManager() {
CleanUpReleasedTiles();
DCHECK_EQ(0u, tiles_.size());
- RasterTaskQueue empty[NUM_RASTERIZER_TYPES];
- rasterizer_delegate_->ScheduleTasks(empty);
+ RasterTaskQueue empty;
+ rasterizer_->ScheduleTasks(&empty);
orphan_raster_tasks_.clear();
// This should finish all pending tasks and release any uninitialized
// resources.
- rasterizer_delegate_->Shutdown();
- rasterizer_delegate_->CheckForCompletedTasks();
+ rasterizer_->Shutdown();
+ rasterizer_->CheckForCompletedTasks();
DCHECK_EQ(0u, bytes_releasable_);
DCHECK_EQ(0u, resources_releasable_);
@@ -500,7 +493,7 @@ void TileManager::DidFinishRunningTasks() {
!memory_usage_above_limit)
return;
- rasterizer_delegate_->CheckForCompletedTasks();
+ rasterizer_->CheckForCompletedTasks();
did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
TileVector tiles_that_need_to_be_rasterized;
@@ -707,7 +700,7 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
// We need to call CheckForCompletedTasks() once in-between each call
// to ScheduleTasks() to prevent canceled tasks from being scheduled.
if (!did_check_for_completed_tasks_since_last_schedule_tasks_) {
- rasterizer_delegate_->CheckForCompletedTasks();
+ rasterizer_->CheckForCompletedTasks();
did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
}
@@ -736,7 +729,7 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
bool TileManager::UpdateVisibleTiles() {
TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles");
- rasterizer_delegate_->CheckForCompletedTasks();
+ rasterizer_->CheckForCompletedTasks();
did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
TRACE_EVENT_INSTANT1(
@@ -1013,8 +1006,7 @@ void TileManager::ScheduleTasks(
DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_);
- for (size_t i = 0; i < NUM_RASTERIZER_TYPES; ++i)
- raster_queue_[i].Reset();
+ raster_queue_.Reset();
// Build a new task queue containing all task currently needed. Tasks
// are added in order of priority, highest priority task first.
@@ -1032,12 +1024,9 @@ void TileManager::ScheduleTasks(
if (!tile_version.raster_task_)
tile_version.raster_task_ = CreateRasterTask(tile);
- size_t pool_type = tile->use_gpu_rasterization() ? RASTERIZER_TYPE_GPU
- : RASTERIZER_TYPE_DEFAULT;
-
- raster_queue_[pool_type].items.push_back(RasterTaskQueue::Item(
+ raster_queue_.items.push_back(RasterTaskQueue::Item(
tile_version.raster_task_.get(), tile->required_for_activation()));
- raster_queue_[pool_type].required_for_activation_count +=
+ raster_queue_.required_for_activation_count +=
tile->required_for_activation();
}
@@ -1048,7 +1037,7 @@ void TileManager::ScheduleTasks(
// Schedule running of |raster_tasks_|. This replaces any previously
// scheduled tasks and effectively cancels all tasks not present
// in |raster_tasks_|.
- rasterizer_delegate_->ScheduleTasks(raster_queue_);
+ rasterizer_->ScheduleTasks(&raster_queue_);
// It's now safe to clean up orphan tasks as raster worker pool is not
// allowed to keep around unreferenced raster tasks after ScheduleTasks() has
@@ -1633,11 +1622,9 @@ bool TileManager::EvictionTileIterator::EvictionOrderComparator::operator()(
return a_priority.IsHigherPriorityThan(b_priority);
}
-void TileManager::SetRasterizersForTesting(Rasterizer* rasterizer,
- Rasterizer* gpu_rasterizer) {
- Rasterizer* rasterizers[2] = {rasterizer, gpu_rasterizer};
- rasterizer_delegate_ =
- RasterizerDelegate::Create(this, rasterizers, arraysize(rasterizers));
+void TileManager::SetRasterizerForTesting(Rasterizer* rasterizer) {
+ rasterizer_ = rasterizer;
+ rasterizer_->SetClient(this);
}
} // namespace cc
diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h
index ea22fd8..cdc7d1e 100644
--- a/cc/resources/tile_manager.h
+++ b/cc/resources/tile_manager.h
@@ -22,12 +22,10 @@
#include "cc/resources/picture_pile_impl.h"
#include "cc/resources/prioritized_tile_set.h"
#include "cc/resources/rasterizer.h"
-#include "cc/resources/rasterizer_delegate.h"
#include "cc/resources/resource_pool.h"
#include "cc/resources/tile.h"
namespace cc {
-class RasterizerDelegate;
class ResourceProvider;
class CC_EXPORT TileManagerClient {
@@ -158,7 +156,6 @@ class CC_EXPORT TileManager : public RasterizerClient,
TileManagerClient* client,
ResourcePool* resource_pool,
Rasterizer* rasterizer,
- Rasterizer* gpu_rasterizer,
bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation);
virtual ~TileManager();
@@ -225,8 +222,7 @@ class CC_EXPORT TileManager : public RasterizerClient,
}
}
- void SetRasterizersForTesting(Rasterizer* rasterizer,
- Rasterizer* gpu_rasterizer);
+ void SetRasterizerForTesting(Rasterizer* rasterizer);
void CleanUpReleasedTilesForTesting() { CleanUpReleasedTiles(); }
@@ -234,7 +230,6 @@ class CC_EXPORT TileManager : public RasterizerClient,
TileManager(TileManagerClient* client,
ResourcePool* resource_pool,
Rasterizer* rasterizer,
- Rasterizer* gpu_rasterizer,
bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation);
@@ -264,12 +259,6 @@ class CC_EXPORT TileManager : public RasterizerClient,
void GetTilesWithAssignedBins(PrioritizedTileSet* tiles);
private:
- enum RasterizerType {
- RASTERIZER_TYPE_DEFAULT,
- RASTERIZER_TYPE_GPU,
- NUM_RASTERIZER_TYPES
- };
-
void OnImageDecodeTaskCompleted(int layer_id,
SkPixelRef* pixel_ref,
bool was_canceled);
@@ -296,7 +285,7 @@ class CC_EXPORT TileManager : public RasterizerClient,
TileManagerClient* client_;
ResourcePool* resource_pool_;
- scoped_ptr<RasterizerDelegate> rasterizer_delegate_;
+ Rasterizer* rasterizer_;
GlobalStateThatImpactsTilePriority global_state_;
typedef base::hash_map<Tile::Id, Tile*> TileMap;
@@ -338,8 +327,8 @@ class CC_EXPORT TileManager : public RasterizerClient,
ResourceFormat resource_format_;
- // Queues used when scheduling raster tasks.
- RasterTaskQueue raster_queue_[NUM_RASTERIZER_TYPES];
+ // Queue used when scheduling raster tasks.
+ RasterTaskQueue raster_queue_;
std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_;
diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc
index 7f427fb6..22e7c66 100644
--- a/cc/resources/tile_manager_perftest.cc
+++ b/cc/resources/tile_manager_perftest.cc
@@ -116,8 +116,7 @@ class TileManagerPerfTest : public testing::Test, public TileManagerClient {
virtual void InitializeRenderer() {
host_impl_.InitializeRenderer(
FakeOutputSurface::Create3d().PassAs<OutputSurface>());
- tile_manager()->SetRasterizersForTesting(g_fake_rasterizer.Pointer(),
- g_fake_rasterizer.Pointer());
+ tile_manager()->SetRasterizerForTesting(g_fake_rasterizer.Pointer());
}
void SetupDefaultTrees(const gfx::Size& layer_bounds) {
diff --git a/cc/test/fake_tile_manager.cc b/cc/test/fake_tile_manager.cc
index d197c3f..496baea 100644
--- a/cc/test/fake_tile_manager.cc
+++ b/cc/test/fake_tile_manager.cc
@@ -65,7 +65,6 @@ FakeTileManager::FakeTileManager(TileManagerClient* client)
: TileManager(client,
NULL,
g_fake_rasterizer.Pointer(),
- g_fake_rasterizer.Pointer(),
true,
NULL) {}
@@ -74,7 +73,6 @@ FakeTileManager::FakeTileManager(TileManagerClient* client,
: TileManager(client,
resource_pool,
g_fake_rasterizer.Pointer(),
- g_fake_rasterizer.Pointer(),
true,
NULL) {}
@@ -84,7 +82,6 @@ FakeTileManager::FakeTileManager(TileManagerClient* client,
: TileManager(client,
resource_pool,
g_fake_rasterizer.Pointer(),
- g_fake_rasterizer.Pointer(),
allow_on_demand_raster,
NULL) {}
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 44da104..219ea89 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -302,11 +302,7 @@ LayerTreeHostImpl::~LayerTreeHostImpl() {
recycle_tree_.reset();
pending_tree_.reset();
active_tree_.reset();
- tile_manager_.reset();
- resource_pool_.reset();
- raster_worker_pool_.reset();
- direct_raster_worker_pool_.reset();
- staging_resource_pool_.reset();
+ DestroyTileManager();
}
void LayerTreeHostImpl::BeginMainFrameAborted(bool did_handle) {
@@ -1531,6 +1527,13 @@ void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) {
use_gpu_rasterization_ = use_gpu;
ReleaseTreeResources();
+ // Replace existing tile manager with another one that uses appropriate
+ // rasterizer.
+ if (tile_manager_) {
+ DestroyTileManager();
+ CreateAndSetTileManager();
+ }
+
// We have released tilings for both active and pending tree.
// We would not have any content to draw until the pending tree is activated.
// Prevent the active tree from drawing until activation.
@@ -1824,23 +1827,24 @@ void LayerTreeHostImpl::ReleaseTreeResources() {
EvictAllUIResources();
}
-void LayerTreeHostImpl::CreateAndSetRenderer(
- OutputSurface* output_surface,
- ResourceProvider* resource_provider) {
+void LayerTreeHostImpl::CreateAndSetRenderer() {
DCHECK(!renderer_);
- if (output_surface->capabilities().delegated_rendering) {
+ DCHECK(output_surface_);
+ DCHECK(resource_provider_);
+
+ if (output_surface_->capabilities().delegated_rendering) {
renderer_ = DelegatingRenderer::Create(
- this, &settings_, output_surface, resource_provider);
- } else if (output_surface->context_provider()) {
+ this, &settings_, output_surface_.get(), resource_provider_.get());
+ } else if (output_surface_->context_provider()) {
renderer_ = GLRenderer::Create(this,
&settings_,
- output_surface,
- resource_provider,
+ output_surface_.get(),
+ resource_provider_.get(),
texture_mailbox_deleter_.get(),
settings_.highp_threshold_min);
- } else if (output_surface->software_device()) {
+ } else if (output_surface_->software_device()) {
renderer_ = SoftwareRenderer::Create(
- this, &settings_, output_surface, resource_provider);
+ this, &settings_, output_surface_.get(), resource_provider_.get());
}
DCHECK(renderer_);
@@ -1856,69 +1860,98 @@ void LayerTreeHostImpl::CreateAndSetRenderer(
client_->UpdateRendererCapabilitiesOnImplThread();
}
-void LayerTreeHostImpl::CreateAndSetTileManager(
- ResourceProvider* resource_provider,
- ContextProvider* context_provider,
- bool use_zero_copy,
- bool use_one_copy,
- bool allow_rasterize_on_demand) {
+void LayerTreeHostImpl::CreateAndSetTileManager() {
+ DCHECK(!tile_manager_);
DCHECK(settings_.impl_side_painting);
- DCHECK(resource_provider);
+ DCHECK(output_surface_);
+ DCHECK(resource_provider_);
DCHECK(proxy_->ImplThreadTaskRunner());
+ ContextProvider* context_provider = output_surface_->context_provider();
transfer_buffer_memory_limit_ =
GetMaxTransferBufferUsageBytes(context_provider);
- if (use_zero_copy) {
+ if (use_gpu_rasterization_ && context_provider) {
resource_pool_ =
- ResourcePool::Create(resource_provider,
+ ResourcePool::Create(resource_provider_.get(),
+ GL_TEXTURE_2D,
+ resource_provider_->best_texture_format());
+
+ raster_worker_pool_ =
+ DirectRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(),
+ resource_provider_.get(),
+ context_provider);
+ } else if (UseZeroCopyTextureUpload()) {
+ resource_pool_ =
+ ResourcePool::Create(resource_provider_.get(),
GetMapImageTextureTarget(context_provider),
- resource_provider->best_texture_format());
+ resource_provider_->best_texture_format());
+
raster_worker_pool_ =
ImageRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(),
RasterWorkerPool::GetTaskGraphRunner(),
- resource_provider);
- } else if (use_one_copy) {
+ resource_provider_.get());
+ } else if (UseOneCopyTextureUpload()) {
// We need to create a staging resource pool when using copy rasterizer.
staging_resource_pool_ =
- ResourcePool::Create(resource_provider,
+ ResourcePool::Create(resource_provider_.get(),
GetMapImageTextureTarget(context_provider),
- resource_provider->best_texture_format());
+ resource_provider_->best_texture_format());
resource_pool_ =
- ResourcePool::Create(resource_provider,
+ ResourcePool::Create(resource_provider_.get(),
GL_TEXTURE_2D,
- resource_provider->best_texture_format());
+ resource_provider_->best_texture_format());
raster_worker_pool_ = ImageCopyRasterWorkerPool::Create(
proxy_->ImplThreadTaskRunner(),
RasterWorkerPool::GetTaskGraphRunner(),
- resource_provider,
+ resource_provider_.get(),
staging_resource_pool_.get());
} else {
+ resource_pool_ = ResourcePool::Create(
+ resource_provider_.get(),
+ GL_TEXTURE_2D,
+ resource_provider_->memory_efficient_texture_format());
+
raster_worker_pool_ = PixelBufferRasterWorkerPool::Create(
proxy_->ImplThreadTaskRunner(),
RasterWorkerPool::GetTaskGraphRunner(),
- resource_provider,
+ resource_provider_.get(),
transfer_buffer_memory_limit_);
- resource_pool_ = ResourcePool::Create(
- resource_provider,
- GL_TEXTURE_2D,
- resource_provider->memory_efficient_texture_format());
}
- direct_raster_worker_pool_ = DirectRasterWorkerPool::Create(
- proxy_->ImplThreadTaskRunner(), resource_provider, context_provider);
+
tile_manager_ =
TileManager::Create(this,
resource_pool_.get(),
raster_worker_pool_->AsRasterizer(),
- direct_raster_worker_pool_->AsRasterizer(),
- allow_rasterize_on_demand,
+ GetRendererCapabilities().allow_rasterize_on_demand,
rendering_stats_instrumentation_);
UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
need_to_update_visible_tiles_before_draw_ = false;
}
+void LayerTreeHostImpl::DestroyTileManager() {
+ tile_manager_.reset();
+ resource_pool_.reset();
+ staging_resource_pool_.reset();
+ raster_worker_pool_.reset();
+}
+
+bool LayerTreeHostImpl::UseZeroCopyTextureUpload() const {
+ // Note: we use zero-copy by default when the renderer is using
+ // shared memory resources.
+ return (settings_.use_zero_copy ||
+ GetRendererCapabilities().using_shared_memory_resources) &&
+ GetRendererCapabilities().using_map_image;
+}
+
+bool LayerTreeHostImpl::UseOneCopyTextureUpload() const {
+ // Sync query support is required by one-copy rasterizer.
+ return settings_.use_one_copy && GetRendererCapabilities().using_map_image &&
+ resource_provider_->use_sync_query();
+}
+
void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) {
SetManagedMemoryPolicy(cached_managed_memory_policy_, zero_budget);
}
@@ -1936,53 +1969,32 @@ bool LayerTreeHostImpl::InitializeRenderer(
// Note: order is important here.
renderer_.reset();
- tile_manager_.reset();
- resource_pool_.reset();
- staging_resource_pool_.reset();
- raster_worker_pool_.reset();
- direct_raster_worker_pool_.reset();
+ DestroyTileManager();
resource_provider_.reset();
output_surface_.reset();
if (!output_surface->BindToClient(this))
return false;
- scoped_ptr<ResourceProvider> resource_provider =
- ResourceProvider::Create(output_surface.get(),
+ output_surface_ = output_surface.Pass();
+ resource_provider_ =
+ ResourceProvider::Create(output_surface_.get(),
shared_bitmap_manager_,
settings_.highp_threshold_min,
settings_.use_rgba_4444_textures,
settings_.texture_id_allocation_chunk_size,
settings_.use_distance_field_text);
- if (output_surface->capabilities().deferred_gl_initialization)
+ if (output_surface_->capabilities().deferred_gl_initialization)
EnforceZeroBudget(true);
- CreateAndSetRenderer(output_surface.get(), resource_provider.get());
+ CreateAndSetRenderer();
transfer_buffer_memory_limit_ =
- GetMaxTransferBufferUsageBytes(output_surface->context_provider().get());
+ GetMaxTransferBufferUsageBytes(output_surface_->context_provider());
- if (settings_.impl_side_painting) {
- // Note: we use zero-copy rasterizer by default when the renderer is using
- // shared memory resources.
- bool use_zero_copy =
- (settings_.use_zero_copy ||
- GetRendererCapabilities().using_shared_memory_resources) &&
- GetRendererCapabilities().using_map_image;
-
- // Sync query support is required by one-copy rasterizer.
- bool use_one_copy = settings_.use_one_copy &&
- GetRendererCapabilities().using_map_image &&
- resource_provider->use_sync_query();
-
- CreateAndSetTileManager(
- resource_provider.get(),
- output_surface->context_provider().get(),
- use_zero_copy,
- use_one_copy,
- GetRendererCapabilities().allow_rasterize_on_demand);
- }
+ if (settings_.impl_side_painting)
+ CreateAndSetTileManager();
// Initialize vsync parameters to sane values.
const base::TimeDelta display_refresh_interval =
@@ -1992,20 +2004,15 @@ bool LayerTreeHostImpl::InitializeRenderer(
// TODO(brianderson): Don't use a hard-coded parent draw time.
base::TimeDelta parent_draw_time =
- output_surface->capabilities().adjust_deadline_for_parent
+ output_surface_->capabilities().adjust_deadline_for_parent
? BeginFrameArgs::DefaultDeadlineAdjustment()
: base::TimeDelta();
client_->SetEstimatedParentDrawTime(parent_draw_time);
- int max_frames_pending =
- output_surface->capabilities().max_frames_pending;
+ int max_frames_pending = output_surface_->capabilities().max_frames_pending;
if (max_frames_pending <= 0)
max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING;
client_->SetMaxSwapsPendingOnImplThread(max_frames_pending);
-
- resource_provider_ = resource_provider.Pass();
- output_surface_ = output_surface.Pass();
-
client_->OnCanDrawStateChanged(CanDraw());
return true;
@@ -2026,7 +2033,7 @@ void LayerTreeHostImpl::DeferredInitialize() {
resource_provider_->InitializeGL();
- CreateAndSetRenderer(output_surface_.get(), resource_provider_.get());
+ CreateAndSetRenderer();
EnforceZeroBudget(false);
client_->SetNeedsCommitOnImplThread();
@@ -2039,24 +2046,14 @@ void LayerTreeHostImpl::ReleaseGL() {
ReleaseTreeResources();
renderer_.reset();
- tile_manager_.reset();
- resource_pool_.reset();
- raster_worker_pool_.reset();
- direct_raster_worker_pool_.reset();
- staging_resource_pool_.reset();
+ DestroyTileManager();
resource_provider_->InitializeSoftware();
output_surface_->ReleaseContextProvider();
- CreateAndSetRenderer(output_surface_.get(), resource_provider_.get());
+ CreateAndSetRenderer();
EnforceZeroBudget(true);
- DCHECK(GetRendererCapabilities().using_map_image);
- CreateAndSetTileManager(resource_provider_.get(),
- NULL,
- true,
- false,
- GetRendererCapabilities().allow_rasterize_on_demand);
- DCHECK(tile_manager_);
+ CreateAndSetTileManager();
client_->SetNeedsCommitOnImplThread();
}
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 05ddaab..494342e 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -486,16 +486,15 @@ class CC_EXPORT LayerTreeHostImpl
Proxy* proxy_;
private:
- void CreateAndSetRenderer(OutputSurface* output_surface,
- ResourceProvider* resource_provider);
- void CreateAndSetTileManager(ResourceProvider* resource_provider,
- ContextProvider* context_provider,
- bool use_zero_copy,
- bool use_one_copy,
- bool allow_rasterize_on_demand);
+ void CreateAndSetRenderer();
+ void CreateAndSetTileManager();
+ void DestroyTileManager();
void ReleaseTreeResources();
void EnforceZeroBudget(bool zero_budget);
+ bool UseZeroCopyTextureUpload() const;
+ bool UseOneCopyTextureUpload() const;
+
void ScrollViewportBy(gfx::Vector2dF scroll_delta);
void AnimatePageScale(base::TimeTicks monotonic_time);
void AnimateScrollbars(base::TimeTicks monotonic_time);
@@ -564,7 +563,6 @@ class CC_EXPORT LayerTreeHostImpl
scoped_ptr<TileManager> tile_manager_;
bool use_gpu_rasterization_;
scoped_ptr<RasterWorkerPool> raster_worker_pool_;
- scoped_ptr<RasterWorkerPool> direct_raster_worker_pool_;
scoped_ptr<ResourcePool> resource_pool_;
scoped_ptr<ResourcePool> staging_resource_pool_;
scoped_ptr<Renderer> renderer_;