summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-12 03:07:16 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-12 03:07:16 +0000
commiteece11eddc1249a156226a464c734b2ba2c73f1f (patch)
treef3b095e40c75659f4699689e1446dc788b1c60b9 /cc
parent282c71a2664f121895c9963556958faa67119708 (diff)
downloadchromium_src-eece11eddc1249a156226a464c734b2ba2c73f1f.zip
chromium_src-eece11eddc1249a156226a464c734b2ba2c73f1f.tar.gz
chromium_src-eece11eddc1249a156226a464c734b2ba2c73f1f.tar.bz2
cc: Move ResourcePool ownership to LTHI.
Provides a significant amount of cleanup by removing the requirement to plumb resource format and texture target through the Rasterizer interface. BUG=269841 Review URL: https://codereview.chromium.org/228183002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/resources/direct_raster_worker_pool.cc8
-rw-r--r--cc/resources/direct_raster_worker_pool.h2
-rw-r--r--cc/resources/image_raster_worker_pool.cc17
-rw-r--r--cc/resources/image_raster_worker_pool.h9
-rw-r--r--cc/resources/pixel_buffer_raster_worker_pool.cc8
-rw-r--r--cc/resources/pixel_buffer_raster_worker_pool.h2
-rw-r--r--cc/resources/prioritized_tile_set_unittest.cc5
-rw-r--r--cc/resources/raster_worker_pool_perftest.cc3
-rw-r--r--cc/resources/raster_worker_pool_unittest.cc3
-rw-r--r--cc/resources/rasterizer.h6
-rw-r--r--cc/resources/resource_pool.h2
-rw-r--r--cc/resources/tile_manager.cc19
-rw-r--r--cc/resources/tile_manager.h11
-rw-r--r--cc/resources/tile_manager_perftest.cc9
-rw-r--r--cc/resources/tile_manager_unittest.cc5
-rw-r--r--cc/test/fake_picture_layer_tiling_client.cc6
-rw-r--r--cc/test/fake_picture_layer_tiling_client.h1
-rw-r--r--cc/test/fake_tile_manager.cc18
-rw-r--r--cc/test/fake_tile_manager.h7
-rw-r--r--cc/trees/layer_tree_host_impl.cc39
-rw-r--r--cc/trees/layer_tree_host_impl.h2
21 files changed, 77 insertions, 105 deletions
diff --git a/cc/resources/direct_raster_worker_pool.cc b/cc/resources/direct_raster_worker_pool.cc
index d3374a9..0be89c1 100644
--- a/cc/resources/direct_raster_worker_pool.cc
+++ b/cc/resources/direct_raster_worker_pool.cc
@@ -102,14 +102,6 @@ void DirectRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) {
new_raster_required_for_activation_finished_task;
}
-unsigned DirectRasterWorkerPool::GetResourceTarget() const {
- return GL_TEXTURE_2D;
-}
-
-ResourceFormat DirectRasterWorkerPool::GetResourceFormat() const {
- return resource_provider_->best_texture_format();
-}
-
void DirectRasterWorkerPool::CheckForCompletedTasks() {
TRACE_EVENT0("cc", "DirectRasterWorkerPool::CheckForCompletedTasks");
diff --git a/cc/resources/direct_raster_worker_pool.h b/cc/resources/direct_raster_worker_pool.h
index e4022f6..15313a6 100644
--- a/cc/resources/direct_raster_worker_pool.h
+++ b/cc/resources/direct_raster_worker_pool.h
@@ -31,8 +31,6 @@ class CC_EXPORT DirectRasterWorkerPool : public RasterWorkerPool,
virtual void SetClient(RasterizerClient* client) OVERRIDE;
virtual void Shutdown() OVERRIDE {}
virtual void ScheduleTasks(RasterTaskQueue* queue) OVERRIDE;
- virtual unsigned GetResourceTarget() const OVERRIDE;
- virtual ResourceFormat GetResourceFormat() const OVERRIDE;
virtual void CheckForCompletedTasks() OVERRIDE;
// Overridden from internal::RasterizerTaskClient:
diff --git a/cc/resources/image_raster_worker_pool.cc b/cc/resources/image_raster_worker_pool.cc
index 0fd4679..c1434cd 100644
--- a/cc/resources/image_raster_worker_pool.cc
+++ b/cc/resources/image_raster_worker_pool.cc
@@ -14,22 +14,19 @@ namespace cc {
scoped_ptr<RasterWorkerPool> ImageRasterWorkerPool::Create(
base::SequencedTaskRunner* task_runner,
internal::TaskGraphRunner* task_graph_runner,
- ResourceProvider* resource_provider,
- unsigned texture_target) {
+ ResourceProvider* resource_provider) {
return make_scoped_ptr<RasterWorkerPool>(new ImageRasterWorkerPool(
- task_runner, task_graph_runner, resource_provider, texture_target));
+ task_runner, task_graph_runner, resource_provider));
}
ImageRasterWorkerPool::ImageRasterWorkerPool(
base::SequencedTaskRunner* task_runner,
internal::TaskGraphRunner* task_graph_runner,
- ResourceProvider* resource_provider,
- unsigned texture_target)
+ ResourceProvider* resource_provider)
: task_runner_(task_runner),
task_graph_runner_(task_graph_runner),
namespace_token_(task_graph_runner->GetNamespaceToken()),
resource_provider_(resource_provider),
- texture_target_(texture_target),
raster_tasks_pending_(false),
raster_tasks_required_for_activation_pending_(false),
raster_finished_weak_ptr_factory_(this) {}
@@ -129,14 +126,6 @@ void ImageRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) {
TracedValue::FromValue(StateAsValue().release()));
}
-unsigned ImageRasterWorkerPool::GetResourceTarget() const {
- return texture_target_;
-}
-
-ResourceFormat ImageRasterWorkerPool::GetResourceFormat() const {
- return resource_provider_->best_texture_format();
-}
-
void ImageRasterWorkerPool::CheckForCompletedTasks() {
TRACE_EVENT0("cc", "ImageRasterWorkerPool::CheckForCompletedTasks");
diff --git a/cc/resources/image_raster_worker_pool.h b/cc/resources/image_raster_worker_pool.h
index 91d9373..82da770 100644
--- a/cc/resources/image_raster_worker_pool.h
+++ b/cc/resources/image_raster_worker_pool.h
@@ -22,8 +22,7 @@ class CC_EXPORT ImageRasterWorkerPool : public RasterWorkerPool,
static scoped_ptr<RasterWorkerPool> Create(
base::SequencedTaskRunner* task_runner,
internal::TaskGraphRunner* task_graph_runner,
- ResourceProvider* resource_provider,
- unsigned texture_target);
+ ResourceProvider* resource_provider);
// Overridden from RasterWorkerPool:
virtual Rasterizer* AsRasterizer() OVERRIDE;
@@ -32,8 +31,6 @@ class CC_EXPORT ImageRasterWorkerPool : public RasterWorkerPool,
virtual void SetClient(RasterizerClient* client) OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual void ScheduleTasks(RasterTaskQueue* queue) OVERRIDE;
- virtual unsigned GetResourceTarget() const OVERRIDE;
- virtual ResourceFormat GetResourceFormat() const OVERRIDE;
virtual void CheckForCompletedTasks() OVERRIDE;
// Overridden from internal::RasterizerTaskClient:
@@ -43,8 +40,7 @@ class CC_EXPORT ImageRasterWorkerPool : public RasterWorkerPool,
protected:
ImageRasterWorkerPool(base::SequencedTaskRunner* task_runner,
internal::TaskGraphRunner* task_graph_runner,
- ResourceProvider* resource_provider,
- unsigned texture_target);
+ ResourceProvider* resource_provider);
private:
void OnRasterFinished();
@@ -56,7 +52,6 @@ class CC_EXPORT ImageRasterWorkerPool : public RasterWorkerPool,
const internal::NamespaceToken namespace_token_;
RasterizerClient* client_;
ResourceProvider* resource_provider_;
- const unsigned texture_target_;
bool raster_tasks_pending_;
bool raster_tasks_required_for_activation_pending_;
diff --git a/cc/resources/pixel_buffer_raster_worker_pool.cc b/cc/resources/pixel_buffer_raster_worker_pool.cc
index 16a4354..d51fac6 100644
--- a/cc/resources/pixel_buffer_raster_worker_pool.cc
+++ b/cc/resources/pixel_buffer_raster_worker_pool.cc
@@ -222,14 +222,6 @@ void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) {
TracedValue::FromValue(StateAsValue().release()));
}
-unsigned PixelBufferRasterWorkerPool::GetResourceTarget() const {
- return GL_TEXTURE_2D;
-}
-
-ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const {
- return resource_provider_->memory_efficient_texture_format();
-}
-
void PixelBufferRasterWorkerPool::CheckForCompletedTasks() {
TRACE_EVENT0("cc", "PixelBufferRasterWorkerPool::CheckForCompletedTasks");
diff --git a/cc/resources/pixel_buffer_raster_worker_pool.h b/cc/resources/pixel_buffer_raster_worker_pool.h
index 58f2442..f7abab1 100644
--- a/cc/resources/pixel_buffer_raster_worker_pool.h
+++ b/cc/resources/pixel_buffer_raster_worker_pool.h
@@ -36,8 +36,6 @@ class CC_EXPORT PixelBufferRasterWorkerPool
virtual void SetClient(RasterizerClient* client) OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual void ScheduleTasks(RasterTaskQueue* queue) OVERRIDE;
- virtual unsigned GetResourceTarget() const OVERRIDE;
- virtual ResourceFormat GetResourceFormat() const OVERRIDE;
virtual void CheckForCompletedTasks() OVERRIDE;
// Overridden from internal::RasterizerTaskClient:
diff --git a/cc/resources/prioritized_tile_set_unittest.cc b/cc/resources/prioritized_tile_set_unittest.cc
index 58e8102..ebe144e 100644
--- a/cc/resources/prioritized_tile_set_unittest.cc
+++ b/cc/resources/prioritized_tile_set_unittest.cc
@@ -59,8 +59,10 @@ class PrioritizedTileSetTest : public testing::Test {
ResourceProvider::Create(
output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1)
.Pass();
+ resource_pool_ = ResourcePool::Create(
+ resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888);
tile_manager_.reset(
- new FakeTileManager(&tile_manager_client_, resource_provider_.get()));
+ new FakeTileManager(&tile_manager_client_, resource_pool_.get()));
picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile();
}
@@ -81,6 +83,7 @@ class PrioritizedTileSetTest : public testing::Test {
scoped_ptr<FakeOutputSurface> output_surface_;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
scoped_ptr<ResourceProvider> resource_provider_;
+ scoped_ptr<ResourcePool> resource_pool_;
FakeTileManagerClient tile_manager_client_;
scoped_ptr<FakeTileManager> tile_manager_;
scoped_refptr<FakePicturePileImpl> picture_pile_;
diff --git a/cc/resources/raster_worker_pool_perftest.cc b/cc/resources/raster_worker_pool_perftest.cc
index 749985a..fda6bbc 100644
--- a/cc/resources/raster_worker_pool_perftest.cc
+++ b/cc/resources/raster_worker_pool_perftest.cc
@@ -226,8 +226,7 @@ class RasterWorkerPoolPerfTest
raster_worker_pool_ = ImageRasterWorkerPool::Create(
base::MessageLoopProxy::current().get(),
task_graph_runner_.get(),
- resource_provider_.get(),
- GL_TEXTURE_2D);
+ resource_provider_.get());
break;
case RASTER_WORKER_POOL_TYPE_DIRECT:
raster_worker_pool_ = DirectRasterWorkerPool::Create(
diff --git a/cc/resources/raster_worker_pool_unittest.cc b/cc/resources/raster_worker_pool_unittest.cc
index 52b3a26..4385e26 100644
--- a/cc/resources/raster_worker_pool_unittest.cc
+++ b/cc/resources/raster_worker_pool_unittest.cc
@@ -145,8 +145,7 @@ class RasterWorkerPoolTest
raster_worker_pool_ = ImageRasterWorkerPool::Create(
base::MessageLoopProxy::current().get(),
RasterWorkerPool::GetTaskGraphRunner(),
- resource_provider_.get(),
- GL_TEXTURE_2D);
+ resource_provider_.get());
break;
case RASTER_WORKER_POOL_TYPE_DIRECT:
raster_worker_pool_ = DirectRasterWorkerPool::Create(
diff --git a/cc/resources/rasterizer.h b/cc/resources/rasterizer.h
index d53e400..432256d 100644
--- a/cc/resources/rasterizer.h
+++ b/cc/resources/rasterizer.h
@@ -162,12 +162,6 @@ class CC_EXPORT Rasterizer {
// Check for completed tasks and dispatch reply callbacks.
virtual void CheckForCompletedTasks() = 0;
- // Returns the target that needs to be used for raster task resources.
- virtual unsigned GetResourceTarget() const = 0;
-
- // Returns the format that needs to be used for raster task resources.
- virtual ResourceFormat GetResourceFormat() const = 0;
-
protected:
virtual ~Rasterizer() {}
};
diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h
index e321d08..8123152 100644
--- a/cc/resources/resource_pool.h
+++ b/cc/resources/resource_pool.h
@@ -44,6 +44,8 @@ class CC_EXPORT ResourcePool {
return resource_count_ - unused_resources_.size();
}
+ ResourceFormat resource_format() const { return format_; }
+
protected:
ResourcePool(ResourceProvider* resource_provider,
GLenum target,
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index 16b8a3d..4de7ba2 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -397,14 +397,14 @@ scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue(
// static
scoped_ptr<TileManager> TileManager::Create(
TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation) {
return make_scoped_ptr(new TileManager(client,
- resource_provider,
+ resource_pool,
rasterizer,
gpu_rasterizer,
max_raster_usage_bytes,
@@ -414,16 +414,14 @@ scoped_ptr<TileManager> TileManager::Create(
TileManager::TileManager(
TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
bool use_rasterize_on_demand,
RenderingStatsInstrumentation* rendering_stats_instrumentation)
: client_(client),
- resource_pool_(ResourcePool::Create(resource_provider,
- rasterizer->GetResourceTarget(),
- rasterizer->GetResourceFormat())),
+ resource_pool_(resource_pool),
prioritized_tiles_dirty_(false),
all_tiles_that_need_to_be_rasterized_have_memory_(true),
all_tiles_required_for_activation_have_memory_(true),
@@ -436,8 +434,7 @@ TileManager::TileManager(
rendering_stats_instrumentation_(rendering_stats_instrumentation),
did_initialize_visible_tile_(false),
did_check_for_completed_tasks_since_last_schedule_tasks_(true),
- use_rasterize_on_demand_(use_rasterize_on_demand),
- resource_format_(rasterizer->GetResourceFormat()) {
+ use_rasterize_on_demand_(use_rasterize_on_demand) {
Rasterizer* rasterizers[NUM_RASTERIZER_TYPES] = {
rasterizer, // RASTERIZER_TYPE_DEFAULT
gpu_rasterizer, // RASTERIZER_TYPE_GPU
@@ -723,12 +720,6 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
if (state != global_state_) {
global_state_ = state;
prioritized_tiles_dirty_ = true;
- // Soft limit is used for resource pool such that
- // memory returns to soft limit after going over.
- resource_pool_->SetResourceUsageLimits(
- global_state_.soft_memory_limit_in_bytes,
- global_state_.unused_memory_limit_in_bytes,
- global_state_.num_resources_limit);
}
// We need to call CheckForCompletedTasks() once in-between each call
diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h
index 60e6374..f0fc0be 100644
--- a/cc/resources/tile_manager.h
+++ b/cc/resources/tile_manager.h
@@ -150,7 +150,7 @@ class CC_EXPORT TileManager : public RasterizerClient,
static scoped_ptr<TileManager> Create(
TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
@@ -188,8 +188,6 @@ class CC_EXPORT TileManager : public RasterizerClient,
void GetPairedPictureLayers(std::vector<PairedPictureLayer>* layers) const;
- ResourcePool* resource_pool() { return resource_pool_.get(); }
-
void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) {
for (size_t i = 0; i < tiles.size(); ++i) {
ManagedTileState& mts = tiles[i]->managed_state();
@@ -228,7 +226,7 @@ class CC_EXPORT TileManager : public RasterizerClient,
protected:
TileManager(TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
Rasterizer* rasterizer,
Rasterizer* gpu_rasterizer,
size_t max_raster_usage_bytes,
@@ -277,7 +275,8 @@ class CC_EXPORT TileManager : public RasterizerClient,
bool was_canceled);
inline size_t BytesConsumedIfAllocated(const Tile* tile) const {
- return Resource::MemorySizeBytes(tile->size(), resource_format_);
+ return Resource::MemorySizeBytes(tile->size(),
+ resource_pool_->resource_format());
}
void FreeResourceForTile(Tile* tile, RasterMode mode);
@@ -291,7 +290,7 @@ class CC_EXPORT TileManager : public RasterizerClient,
void UpdatePrioritizedTileSetIfNeeded();
TileManagerClient* client_;
- scoped_ptr<ResourcePool> resource_pool_;
+ ResourcePool* resource_pool_;
scoped_ptr<RasterizerDelegate> rasterizer_delegate_;
GlobalStateThatImpactsTilePriority global_state_;
diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc
index b4bc4f5..9a1642a 100644
--- a/cc/resources/tile_manager_perftest.cc
+++ b/cc/resources/tile_manager_perftest.cc
@@ -48,11 +48,11 @@ class TileManagerPerfTest : public testing::Test {
shared_bitmap_manager_.reset(new TestSharedBitmapManager());
resource_provider_ = ResourceProvider::Create(
output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1);
+ resource_pool_ = ResourcePool::Create(
+ resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888);
size_t raster_task_limit_bytes = 32 * 1024 * 1024; // 16-64MB in practice.
- tile_manager_ =
- make_scoped_ptr(new FakeTileManager(&tile_manager_client_,
- resource_provider_.get(),
- raster_task_limit_bytes));
+ tile_manager_ = make_scoped_ptr(new FakeTileManager(
+ &tile_manager_client_, resource_pool_.get(), raster_task_limit_bytes));
picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile();
}
@@ -179,6 +179,7 @@ class TileManagerPerfTest : public testing::Test {
scoped_ptr<FakeOutputSurface> output_surface_;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
scoped_ptr<ResourceProvider> resource_provider_;
+ scoped_ptr<ResourcePool> resource_pool_;
LapTimer timer_;
};
diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc
index 1fac2b4..fac13d6 100644
--- a/cc/resources/tile_manager_unittest.cc
+++ b/cc/resources/tile_manager_unittest.cc
@@ -40,8 +40,10 @@ class TileManagerTest : public testing::TestWithParam<bool>,
shared_bitmap_manager_.reset(new TestSharedBitmapManager());
resource_provider_ = ResourceProvider::Create(
output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1);
+ resource_pool_ = ResourcePool::Create(
+ resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888);
tile_manager_ = make_scoped_ptr(new FakeTileManager(
- this, resource_provider_.get(), allow_on_demand_raster));
+ this, resource_pool_.get(), allow_on_demand_raster));
memory_limit_policy_ = memory_limit_policy;
max_tiles_ = max_tiles;
@@ -149,6 +151,7 @@ class TileManagerTest : public testing::TestWithParam<bool>,
scoped_ptr<FakeOutputSurface> output_surface_;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
scoped_ptr<ResourceProvider> resource_provider_;
+ scoped_ptr<ResourcePool> resource_pool_;
TileMemoryLimitPolicy memory_limit_policy_;
int max_tiles_;
bool ready_to_activate_;
diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc
index 4289b9d4..0c0fce6 100644
--- a/cc/test/fake_picture_layer_tiling_client.cc
+++ b/cc/test/fake_picture_layer_tiling_client.cc
@@ -22,8 +22,10 @@ FakePictureLayerTilingClient::FakePictureLayerTilingClient()
FakePictureLayerTilingClient::FakePictureLayerTilingClient(
ResourceProvider* resource_provider)
- : tile_manager_(
- new FakeTileManager(&tile_manager_client_, resource_provider)),
+ : resource_pool_(
+ ResourcePool::Create(resource_provider, GL_TEXTURE_2D, RGBA_8888)),
+ tile_manager_(
+ new FakeTileManager(&tile_manager_client_, resource_pool_.get())),
pile_(FakePicturePileImpl::CreateInfiniteFilledPile()),
twin_tiling_(NULL),
allow_create_tile_(true),
diff --git a/cc/test/fake_picture_layer_tiling_client.h b/cc/test/fake_picture_layer_tiling_client.h
index 5989bba..7440ea7 100644
--- a/cc/test/fake_picture_layer_tiling_client.h
+++ b/cc/test/fake_picture_layer_tiling_client.h
@@ -59,6 +59,7 @@ class FakePictureLayerTilingClient : public PictureLayerTilingClient {
protected:
FakeTileManagerClient tile_manager_client_;
+ scoped_ptr<ResourcePool> resource_pool_;
scoped_ptr<TileManager> tile_manager_;
scoped_refptr<PicturePileImpl> pile_;
gfx::Size tile_size_;
diff --git a/cc/test/fake_tile_manager.cc b/cc/test/fake_tile_manager.cc
index 4cb690f..4fbf704 100644
--- a/cc/test/fake_tile_manager.cc
+++ b/cc/test/fake_tile_manager.cc
@@ -48,12 +48,6 @@ class FakeRasterizerImpl : public Rasterizer,
}
completed_tasks_.clear();
}
- virtual GLenum GetResourceTarget() const OVERRIDE {
- return GL_TEXTURE_2D;
- }
- virtual ResourceFormat GetResourceFormat() const OVERRIDE {
- return RGBA_8888;
- }
// Overridden from internal::RasterizerTaskClient:
virtual SkCanvas* AcquireCanvasForRaster(internal::RasterTask* task)
@@ -80,9 +74,9 @@ FakeTileManager::FakeTileManager(TileManagerClient* client)
NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
- ResourceProvider* resource_provider)
+ ResourcePool* resource_pool)
: TileManager(client,
- resource_provider,
+ resource_pool,
g_fake_rasterizer.Pointer(),
g_fake_rasterizer.Pointer(),
std::numeric_limits<unsigned>::max(),
@@ -90,10 +84,10 @@ FakeTileManager::FakeTileManager(TileManagerClient* client,
NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
bool allow_on_demand_raster)
: TileManager(client,
- resource_provider,
+ resource_pool,
g_fake_rasterizer.Pointer(),
g_fake_rasterizer.Pointer(),
std::numeric_limits<unsigned>::max(),
@@ -101,10 +95,10 @@ FakeTileManager::FakeTileManager(TileManagerClient* client,
NULL) {}
FakeTileManager::FakeTileManager(TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
size_t raster_task_limit_bytes)
: TileManager(client,
- resource_provider,
+ resource_pool,
g_fake_rasterizer.Pointer(),
g_fake_rasterizer.Pointer(),
raster_task_limit_bytes,
diff --git a/cc/test/fake_tile_manager.h b/cc/test/fake_tile_manager.h
index 0399984..162aebe 100644
--- a/cc/test/fake_tile_manager.h
+++ b/cc/test/fake_tile_manager.h
@@ -15,13 +15,12 @@ namespace cc {
class FakeTileManager : public TileManager {
public:
explicit FakeTileManager(TileManagerClient* client);
+ FakeTileManager(TileManagerClient* client, ResourcePool* resource_pool);
FakeTileManager(TileManagerClient* client,
- ResourceProvider* resource_provider);
- FakeTileManager(TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
bool allow_on_demand_raster);
FakeTileManager(TileManagerClient* client,
- ResourceProvider* resource_provider,
+ ResourcePool* resource_pool,
size_t raster_task_limit_bytes);
virtual ~FakeTileManager();
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index cbfbd45..4a945a2 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -50,6 +50,7 @@
#include "cc/resources/pixel_buffer_raster_worker_pool.h"
#include "cc/resources/prioritized_resource_manager.h"
#include "cc/resources/raster_worker_pool.h"
+#include "cc/resources/resource_pool.h"
#include "cc/resources/texture_mailbox_deleter.h"
#include "cc/resources/ui_resource_bitmap.h"
#include "cc/scheduler/delay_based_time_source.h"
@@ -307,6 +308,7 @@ LayerTreeHostImpl::~LayerTreeHostImpl() {
pending_tree_.reset();
active_tree_.reset();
tile_manager_.reset();
+ resource_pool_.reset();
raster_worker_pool_.reset();
direct_raster_worker_pool_.reset();
}
@@ -1190,6 +1192,15 @@ void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
global_tile_state_.num_resources_limit = policy.num_resources_limit;
+ DCHECK(resource_pool_);
+ resource_pool_->CheckBusyResources();
+ // Soft limit is used for resource pool such that memory returns to soft
+ // limit after going over.
+ resource_pool_->SetResourceUsageLimits(
+ global_tile_state_.soft_memory_limit_in_bytes,
+ global_tile_state_.unused_memory_limit_in_bytes,
+ global_tile_state_.num_resources_limit);
+
DidModifyTilePriorities();
}
@@ -1303,11 +1314,10 @@ 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(tile_manager_->resource_pool());
+ DCHECK(resource_pool_);
- // TODO(vmpstr): Move resource pool to be LTHI member.
- tile_manager_->resource_pool()->CheckBusyResources();
- tile_manager_->resource_pool()->ReduceResourceUsage();
+ resource_pool_->CheckBusyResources();
+ resource_pool_->ReduceResourceUsage();
}
// If we're not visible, we likely released resources, so we want to
// aggressively flush here to make sure those DeleteTextures make it to the
@@ -1803,23 +1813,30 @@ void LayerTreeHostImpl::CreateAndSetTileManager(
DCHECK(proxy_->ImplThreadTaskRunner());
if (using_map_image) {
- raster_worker_pool_ = ImageRasterWorkerPool::Create(
- proxy_->ImplThreadTaskRunner(),
- RasterWorkerPool::GetTaskGraphRunner(),
- resource_provider,
- GetMapImageTextureTarget(context_provider));
+ raster_worker_pool_ =
+ ImageRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(),
+ RasterWorkerPool::GetTaskGraphRunner(),
+ resource_provider);
+ resource_pool_ =
+ ResourcePool::Create(resource_provider,
+ GetMapImageTextureTarget(context_provider),
+ resource_provider->best_texture_format());
} else {
raster_worker_pool_ = PixelBufferRasterWorkerPool::Create(
proxy_->ImplThreadTaskRunner(),
RasterWorkerPool::GetTaskGraphRunner(),
resource_provider,
GetMaxTransferBufferUsageBytes(context_provider));
+ 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_provider,
+ resource_pool_.get(),
raster_worker_pool_->AsRasterizer(),
direct_raster_worker_pool_->AsRasterizer(),
GetMaxRasterTasksUsageBytes(context_provider),
@@ -1848,6 +1865,7 @@ bool LayerTreeHostImpl::InitializeRenderer(
// Note: order is important here.
renderer_.reset();
tile_manager_.reset();
+ resource_pool_.reset();
raster_worker_pool_.reset();
direct_raster_worker_pool_.reset();
resource_provider_.reset();
@@ -1975,6 +1993,7 @@ void LayerTreeHostImpl::ReleaseGL() {
ReleaseTreeResources();
renderer_.reset();
tile_manager_.reset();
+ resource_pool_.reset();
raster_worker_pool_.reset();
direct_raster_worker_pool_.reset();
resource_provider_->InitializeSoftware();
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index b002362..9b51b6b 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -50,6 +50,7 @@ class PaintTimeCounter;
class RasterWorkerPool;
class RenderPassDrawQuad;
class RenderingStatsInstrumentation;
+class ResourcePool;
class ScrollbarLayerImplBase;
class TextureMailboxDeleter;
class TopControlsManager;
@@ -541,6 +542,7 @@ class CC_EXPORT LayerTreeHostImpl
scoped_ptr<TileManager> tile_manager_;
scoped_ptr<RasterWorkerPool> raster_worker_pool_;
scoped_ptr<RasterWorkerPool> direct_raster_worker_pool_;
+ scoped_ptr<ResourcePool> resource_pool_;
scoped_ptr<Renderer> renderer_;
GlobalStateThatImpactsTilePriority global_tile_state_;