summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 11:52:34 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 11:52:34 +0000
commitb796c34f3ff3ff161acb7e36665225f6807ad4c1 (patch)
tree2230e49ef883b46ff50923610c335403b870af4a
parente6791fd4692027e86635adf84b918757eebade45 (diff)
downloadchromium_src-b796c34f3ff3ff161acb7e36665225f6807ad4c1.zip
chromium_src-b796c34f3ff3ff161acb7e36665225f6807ad4c1.tar.gz
chromium_src-b796c34f3ff3ff161acb7e36665225f6807ad4c1.tar.bz2
cc: Reduce command buffer flushes related to creating texture ids.
This significantly reduces command buffer flushes by allocating texture ids in chunks of 64. BUG=309455 TEST=cc_unittests --gtest_filter=ResourceProviderTest.TextureAllocationChunk Review URL: https://codereview.chromium.org/49163004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232332 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/layers/tiled_layer_unittest.cc2
-rw-r--r--cc/output/gl_renderer_unittest.cc32
-rw-r--r--cc/output/software_renderer_unittest.cc2
-rw-r--r--cc/resources/picture_layer_tiling_set_unittest.cc2
-rw-r--r--cc/resources/prioritized_resource_unittest.cc2
-rw-r--r--cc/resources/prioritized_tile_set_unittest.cc6
-rw-r--r--cc/resources/raster_worker_pool_unittest.cc4
-rw-r--r--cc/resources/resource_provider.cc44
-rw-r--r--cc/resources/resource_provider.h11
-rw-r--r--cc/resources/resource_provider_unittest.cc180
-rw-r--r--cc/resources/resource_update_controller_unittest.cc2
-rw-r--r--cc/resources/scoped_resource_unittest.cc8
-rw-r--r--cc/resources/tile_manager_perftest.cc2
-rw-r--r--cc/resources/tile_manager_unittest.cc2
-rw-r--r--cc/resources/video_resource_updater_unittest.cc2
-rw-r--r--cc/test/pixel_test.cc4
-rw-r--r--cc/test/test_web_graphics_context_3d.cc59
-rw-r--r--cc/test/test_web_graphics_context_3d.h3
-rw-r--r--cc/trees/layer_tree_host_impl.cc3
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc1
-rw-r--r--cc/trees/layer_tree_host_unittest.cc6
-rw-r--r--cc/trees/layer_tree_host_unittest_context.cc9
-rw-r--r--cc/trees/layer_tree_settings.cc3
-rw-r--r--cc/trees/layer_tree_settings.h1
24 files changed, 283 insertions, 107 deletions
diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc
index 9bdb907..6f5d485 100644
--- a/cc/layers/tiled_layer_unittest.cc
+++ b/cc/layers/tiled_layer_unittest.cc
@@ -74,7 +74,7 @@ class TiledLayerTest : public testing::Test {
DebugScopedSetImplThreadAndMainThreadBlocked
impl_thread_and_main_thread_blocked(proxy_);
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl(proxy_));
}
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index f94d5c2..b19ae19 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -220,8 +220,8 @@ class GLRendererTest : public testing::Test {
context3d.PassAs<TestWebGraphicsContext3D>()).Pass();
CHECK(output_surface_->BindToClient(&output_surface_client_));
- resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false).Pass();
+ resource_provider_ = ResourceProvider::Create(
+ output_surface_.get(), NULL, 0, false, 1).Pass();
renderer_ = make_scoped_ptr(new FakeRendererGL(&renderer_client_,
&settings_,
output_surface_.get(),
@@ -312,8 +312,8 @@ class GLRendererShaderTest : public testing::Test {
new ShaderCreatorMockGraphicsContext())).Pass();
CHECK(output_surface_->BindToClient(&output_surface_client_));
- resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false).Pass();
+ resource_provider_ = ResourceProvider::Create(
+ output_surface_.get(), NULL, 0, false, 1).Pass();
renderer_.reset(new FakeRendererGL(&renderer_client_,
&settings_,
output_surface_.get(),
@@ -616,7 +616,7 @@ TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -661,7 +661,7 @@ TEST(GLRendererTest2, InitializationWithQuicklyLostContextDoesNotAssert) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -696,7 +696,7 @@ TEST(GLRendererTest2, OpaqueBackground) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -734,7 +734,7 @@ TEST(GLRendererTest2, TransparentBackground) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -766,7 +766,7 @@ TEST(GLRendererTest2, OffscreenOutputSurface) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -842,7 +842,7 @@ TEST(GLRendererTest2, VisibilityChangeIsLastCall) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -902,7 +902,7 @@ TEST(GLRendererTest2, ActiveTextureState) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -989,7 +989,7 @@ TEST(GLRendererTest2, ShouldClearRootRenderPass) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
settings.should_clear_root_render_pass = false;
@@ -1077,7 +1077,7 @@ TEST(GLRendererTest2, ScissorTestWhenClearing) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -1163,7 +1163,7 @@ TEST(GLRendererTest2, NoDiscardOnPartialUpdates) {
output_surface->set_fixed_size(gfx::Size(100, 100));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
settings.partial_swap_enabled = true;
@@ -1342,7 +1342,7 @@ TEST(GLRendererTest2, ScissorAndViewportWithinNonreshapableSurface) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
LayerTreeSettings settings;
FakeRendererClient renderer_client;
@@ -1696,7 +1696,7 @@ class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient {
CHECK(output_surface_.BindToClient(&output_surface_client_));
resource_provider_ =
- ResourceProvider::Create(&output_surface_, NULL, 0, false).Pass();
+ ResourceProvider::Create(&output_surface_, NULL, 0, false, 1).Pass();
renderer_.reset(new FakeRendererGL(
this, &settings_, &output_surface_, resource_provider_.get()));
diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc
index 450d1fe..ef9f43f 100644
--- a/cc/output/software_renderer_unittest.cc
+++ b/cc/output/software_renderer_unittest.cc
@@ -34,7 +34,7 @@ class SoftwareRendererTest : public testing::Test, public RendererClient {
CHECK(output_surface_->BindToClient(&output_surface_client_));
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
renderer_ = SoftwareRenderer::Create(
this, &settings_, output_surface_.get(), resource_provider());
}
diff --git a/cc/resources/picture_layer_tiling_set_unittest.cc b/cc/resources/picture_layer_tiling_set_unittest.cc
index c0d6f0d..91651d4 100644
--- a/cc/resources/picture_layer_tiling_set_unittest.cc
+++ b/cc/resources/picture_layer_tiling_set_unittest.cc
@@ -66,7 +66,7 @@ class PictureLayerTilingSetTestWithResources : public testing::Test {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider =
- ResourceProvider::Create(output_surface.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1);
FakePictureLayerTilingClient client;
client.SetTileSize(gfx::Size(256, 256));
diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc
index 82178c2..b58774d 100644
--- a/cc/resources/prioritized_resource_unittest.cc
+++ b/cc/resources/prioritized_resource_unittest.cc
@@ -26,7 +26,7 @@ class PrioritizedResourceTest : public testing::Test {
DebugScopedSetImplThread impl_thread(&proxy_);
CHECK(output_surface_->BindToClient(&output_surface_client_));
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
}
virtual ~PrioritizedResourceTest() {
diff --git a/cc/resources/prioritized_tile_set_unittest.cc b/cc/resources/prioritized_tile_set_unittest.cc
index 4bf27fb..c62bda9 100644
--- a/cc/resources/prioritized_tile_set_unittest.cc
+++ b/cc/resources/prioritized_tile_set_unittest.cc
@@ -57,7 +57,11 @@ class PrioritizedTileSetTest : public testing::Test {
CHECK(output_surface_->BindToClient(&output_surface_client_));
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false).Pass();
+ ResourceProvider::Create(output_surface_.get(),
+ NULL,
+ 0,
+ false,
+ 1).Pass();
tile_manager_.reset(
new FakeTileManager(&tile_manager_client_, resource_provider_.get()));
picture_pile_ = FakePicturePileImpl::CreatePile();
diff --git a/cc/resources/raster_worker_pool_unittest.cc b/cc/resources/raster_worker_pool_unittest.cc
index 2c8973b..f64419e 100644
--- a/cc/resources/raster_worker_pool_unittest.cc
+++ b/cc/resources/raster_worker_pool_unittest.cc
@@ -67,8 +67,8 @@ class RasterWorkerPoolTest : public testing::Test,
output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass();
CHECK(output_surface_->BindToClient(&output_surface_client_));
- resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false).Pass();
+ resource_provider_ = ResourceProvider::Create(
+ output_surface_.get(), NULL, 0, false, 1).Pass();
}
virtual ~RasterWorkerPoolTest() {
resource_provider_.reset();
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 874fe3f..36c6f9e 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -216,12 +216,14 @@ scoped_ptr<ResourceProvider> ResourceProvider::Create(
OutputSurface* output_surface,
SharedBitmapManager* shared_bitmap_manager,
int highp_threshold_min,
- bool use_rgba_4444_texture_format) {
+ bool use_rgba_4444_texture_format,
+ size_t texture_id_allocation_chunk_size) {
scoped_ptr<ResourceProvider> resource_provider(
new ResourceProvider(output_surface,
shared_bitmap_manager,
highp_threshold_min,
- use_rgba_4444_texture_format));
+ use_rgba_4444_texture_format,
+ texture_id_allocation_chunk_size));
bool success = false;
if (resource_provider->Context3d()) {
@@ -647,7 +649,7 @@ const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
context3d->waitSyncPoint(resource->mailbox.sync_point()));
resource->mailbox.ResetSyncPoint();
}
- resource->gl_id = context3d->createTexture();
+ resource->gl_id = NextTextureId();
GLC(context3d, context3d->bindTexture(resource->target, resource->gl_id));
GLC(context3d,
context3d->consumeTextureCHROMIUM(resource->target,
@@ -791,7 +793,8 @@ ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() {
ResourceProvider::ResourceProvider(OutputSurface* output_surface,
SharedBitmapManager* shared_bitmap_manager,
int highp_threshold_min,
- bool use_rgba_4444_texture_format)
+ bool use_rgba_4444_texture_format,
+ size_t texture_id_allocation_chunk_size)
: output_surface_(output_surface),
shared_bitmap_manager_(shared_bitmap_manager),
lost_output_surface_(false),
@@ -804,8 +807,10 @@ ResourceProvider::ResourceProvider(OutputSurface* output_surface,
use_shallow_flush_(false),
max_texture_size_(0),
best_texture_format_(RGBA_8888),
- use_rgba_4444_texture_format_(use_rgba_4444_texture_format) {
+ use_rgba_4444_texture_format_(use_rgba_4444_texture_format),
+ texture_id_allocation_chunk_size_(texture_id_allocation_chunk_size) {
DCHECK(output_surface_->HasClient());
+ DCHECK(texture_id_allocation_chunk_size_);
}
void ResourceProvider::InitializeSoftware() {
@@ -863,6 +868,14 @@ void ResourceProvider::CleanUpGLIfNeeded() {
DCHECK(context3d);
context3d->makeContextCurrent();
texture_uploader_.reset();
+ if (!unused_texture_ids_.empty()) {
+ size_t size = unused_texture_ids_.size();
+ scoped_ptr<WebKit::WebGLId[]> ids(new WebKit::WebGLId[size]);
+ for (size_t i = 0; i < size; ++i)
+ ids[i] = unused_texture_ids_[i];
+ GLC(context3d, context3d->deleteTextures(size, ids.get()));
+ unused_texture_ids_.clear();
+ }
Finish();
}
@@ -988,7 +1001,7 @@ void ResourceProvider::ReceiveFromChild(
// (and is simpler) to wait.
if (it->sync_point)
GLC(context3d, context3d->waitSyncPoint(it->sync_point));
- GLC(context3d, texture_id = context3d->createTexture());
+ texture_id = NextTextureId();
GLC(context3d, context3d->bindTexture(it->target, texture_id));
GLC(context3d,
context3d->consumeTextureCHROMIUM(it->target, it->mailbox.name));
@@ -1546,11 +1559,12 @@ void ResourceProvider::LazyCreate(Resource* resource) {
if (resource->texture_pool == 0)
return;
+ resource->gl_id = NextTextureId();
+
WebGraphicsContext3D* context3d = Context3d();
DCHECK(context3d);
// Create and set texture properties. Allocation is delayed until needed.
- GLC(context3d, resource->gl_id = context3d->createTexture());
GLC(context3d, context3d->bindTexture(resource->target, resource->gl_id));
GLC(context3d,
context3d->texParameteri(
@@ -1729,4 +1743,20 @@ WebKit::WebGraphicsContext3D* ResourceProvider::Context3d() const {
return context_provider ? context_provider->Context3d() : NULL;
}
+unsigned ResourceProvider::NextTextureId() {
+ if (unused_texture_ids_.empty()) {
+ size_t size = texture_id_allocation_chunk_size_;
+ scoped_ptr<WebKit::WebGLId[]> ids(new WebKit::WebGLId[size]);
+ WebGraphicsContext3D* context3d = Context3d();
+ DCHECK(context3d);
+ GLC(context3d, context3d->genTextures(size, ids.get()));
+ unused_texture_ids_.assign(ids.get(), ids.get() + size);
+ }
+
+ unsigned gl_id = unused_texture_ids_.front();
+ unused_texture_ids_.pop_front();
+
+ return gl_id;
+}
+
} // namespace cc
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h
index 23f1414..d1ed64a6 100644
--- a/cc/resources/resource_provider.h
+++ b/cc/resources/resource_provider.h
@@ -65,7 +65,8 @@ class CC_EXPORT ResourceProvider {
OutputSurface* output_surface,
SharedBitmapManager* shared_bitmap_manager,
int highp_threshold_min,
- bool use_rgba_4444_texture_format);
+ bool use_rgba_4444_texture_format,
+ size_t texture_id_allocation_chunk_size);
virtual ~ResourceProvider();
void InitializeSoftware();
@@ -432,7 +433,8 @@ class CC_EXPORT ResourceProvider {
ResourceProvider(OutputSurface* output_surface,
SharedBitmapManager* shared_bitmap_manager,
int highp_threshold_min,
- bool use_rgba_4444_texture_format);
+ bool use_rgba_4444_texture_format,
+ size_t texture_id_allocation_chunk_size);
void CleanUpGLIfNeeded();
@@ -469,6 +471,8 @@ class CC_EXPORT ResourceProvider {
// Returns NULL if the output_surface_ does not have a ContextProvider.
WebKit::WebGraphicsContext3D* Context3d() const;
+ unsigned NextTextureId();
+
OutputSurface* output_surface_;
SharedBitmapManager* shared_bitmap_manager_;
bool lost_output_surface_;
@@ -492,6 +496,9 @@ class CC_EXPORT ResourceProvider {
scoped_refptr<Fence> current_read_lock_fence_;
bool use_rgba_4444_texture_format_;
+ size_t texture_id_allocation_chunk_size_;
+ std::deque<unsigned> unused_texture_ids_;
+
DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
};
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index baf7e8c..8b2b01bd 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -99,6 +99,8 @@ class TextureStateTrackingContext : public TestWebGraphicsContext3D {
base::AutoLock lock(namespace_->lock);
return namespace_->next_texture_id++;
}
+ virtual void RetireTextureId(WebKit::WebGLId) OVERRIDE {
+ }
};
// Shared data between multiple ResourceProviderContext. This contains mailbox
@@ -479,9 +481,13 @@ class ResourceProviderTest
shared_bitmap_manager_.reset(new TestSharedBitmapManager());
resource_provider_ = ResourceProvider::Create(
- output_surface_.get(), shared_bitmap_manager_.get(), 0, false);
+ output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1);
child_resource_provider_ = ResourceProvider::Create(
- child_output_surface_.get(), shared_bitmap_manager_.get(), 0, false);
+ child_output_surface_.get(),
+ shared_bitmap_manager_.get(),
+ 0,
+ false,
+ 1);
}
static void CollectResources(ReturnedResourceArray* array,
@@ -1022,7 +1028,11 @@ TEST_P(ResourceProviderTest, TransferSoftwareToNonUber) {
CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
scoped_ptr<ResourceProvider> parent_resource_provider(
- ResourceProvider::Create(parent_output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(parent_output_surface.get(),
+ NULL,
+ 0,
+ false,
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
@@ -1076,7 +1086,11 @@ TEST_P(ResourceProviderTest, TransferGLToSoftware) {
CHECK(child_output_surface->BindToClient(&child_output_surface_client));
scoped_ptr<ResourceProvider> child_resource_provider(
- ResourceProvider::Create(child_output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(child_output_surface.get(),
+ NULL,
+ 0,
+ false,
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
@@ -1424,7 +1438,11 @@ class ResourceProviderTestTextureFilters : public ResourceProviderTest {
CHECK(child_output_surface->BindToClient(&child_output_surface_client));
scoped_ptr<ResourceProvider> child_resource_provider(
- ResourceProvider::Create(child_output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(child_output_surface.get(),
+ NULL,
+ 0,
+ false,
+ 1));
scoped_ptr<TextureStateTrackingContext> parent_context_owned(
new TextureStateTrackingContext);
@@ -1436,7 +1454,11 @@ class ResourceProviderTestTextureFilters : public ResourceProviderTest {
CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
scoped_ptr<ResourceProvider> parent_resource_provider(
- ResourceProvider::Create(parent_output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(parent_output_surface.get(),
+ NULL,
+ 0,
+ false,
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
@@ -2037,7 +2059,7 @@ TEST_P(ResourceProviderTest, ScopedSampler) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
@@ -2118,7 +2140,7 @@ TEST_P(ResourceProviderTest, ManagedResource) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
@@ -2163,7 +2185,7 @@ TEST_P(ResourceProviderTest, TextureWrapMode) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
@@ -2216,7 +2238,7 @@ TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create(
base::Bind(&EmptyReleaseCallback));
@@ -2251,7 +2273,7 @@ TEST_P(ResourceProviderTest, TextureMailbox_GLTexture2D) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
unsigned texture_id = 1;
unsigned sync_point = 30;
@@ -2315,7 +2337,7 @@ TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
unsigned texture_id = 1;
unsigned sync_point = 30;
@@ -2366,8 +2388,8 @@ TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) {
class AllocationTrackingContext3D : public TestWebGraphicsContext3D {
public:
- MOCK_METHOD0(createTexture, WebGLId());
- MOCK_METHOD1(deleteTexture, void(WebGLId texture_id));
+ MOCK_METHOD0(NextTextureId, WebGLId());
+ MOCK_METHOD1(RetireTextureId, void(WebGLId id));
MOCK_METHOD2(bindTexture, void(WGC3Denum target, WebGLId texture));
MOCK_METHOD9(texImage2D,
void(WGC3Denum target,
@@ -2444,7 +2466,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
gfx::Size size(2, 2);
gfx::Vector2d offset(0, 0);
@@ -2458,11 +2480,11 @@ TEST_P(ResourceProviderTest, TextureAllocation) {
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
- EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1);
resource_provider->CreateForTesting(id);
- EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
resource_provider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
@@ -2471,13 +2493,13 @@ TEST_P(ResourceProviderTest, TextureAllocation) {
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
- EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1);
EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1);
resource_provider->SetPixels(id, pixels, rect, rect, offset);
- EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
resource_provider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
@@ -2487,7 +2509,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) {
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
resource_provider->AcquirePixelBuffer(id);
- EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
.Times(1);
@@ -2496,7 +2518,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) {
resource_provider->ReleasePixelBuffer(id);
- EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
resource_provider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
@@ -2520,13 +2542,13 @@ TEST_P(ResourceProviderTest, PixelBuffer_GLTexture) {
int texture_id = 123;
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
resource_provider->AcquirePixelBuffer(id);
- EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
.Times(1);
@@ -2536,7 +2558,7 @@ TEST_P(ResourceProviderTest, PixelBuffer_GLTexture) {
resource_provider->ReleasePixelBuffer(id);
- EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
resource_provider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
@@ -2557,7 +2579,7 @@ TEST_P(ResourceProviderTest, PixelBuffer_Bitmap) {
const uint32_t kBadBeef = 0xbadbeef;
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
@@ -2603,13 +2625,13 @@ TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) {
int texture_id = 123;
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
resource_provider->AcquirePixelBuffer(id);
- EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _))
.Times(1);
@@ -2622,7 +2644,7 @@ TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) {
resource_provider->ReleasePixelBuffer(id);
- EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
resource_provider->DeleteResource(id);
Mock::VerifyAndClearExpectations(context);
@@ -2644,9 +2666,9 @@ TEST_P(ResourceProviderTest, PixelBufferLostContext) {
int texture_id = 123;
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
- EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
@@ -2682,7 +2704,7 @@ TEST_P(ResourceProviderTest, Image_GLTexture) {
const unsigned kImageId = 234u;
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
@@ -2711,7 +2733,7 @@ TEST_P(ResourceProviderTest, Image_GLTexture) {
.RetiresOnSaturation();
resource_provider->UnmapImage(id);
- EXPECT_CALL(*context, createTexture())
+ EXPECT_CALL(*context, NextTextureId())
.WillOnce(Return(kTextureId))
.RetiresOnSaturation();
// Once in CreateTextureId and once in BindForSampling
@@ -2744,7 +2766,7 @@ TEST_P(ResourceProviderTest, Image_GLTexture) {
EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
.Times(1)
.RetiresOnSaturation();
- EXPECT_CALL(*context, deleteTexture(kTextureId))
+ EXPECT_CALL(*context, RetireTextureId(kTextureId))
.Times(1)
.RetiresOnSaturation();
{
@@ -2774,7 +2796,7 @@ TEST_P(ResourceProviderTest, Image_Bitmap) {
const uint32_t kBadBeef = 0xbadbeef;
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
@@ -2825,7 +2847,7 @@ TEST(ResourceProviderTest, BasicInitializeGLSoftware) {
scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)));
EXPECT_TRUE(output_surface->BindToClient(&client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
@@ -2857,18 +2879,22 @@ TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
CHECK(output_surface->BindToClient(&output_surface_client));
gfx::Size size(4, 4);
- scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
- output_surface.get(), shared_bitmap_manager_.get(), 0, false));
+ scoped_ptr<ResourceProvider> resource_provider(
+ ResourceProvider::Create(output_surface.get(),
+ shared_bitmap_manager_.get(),
+ 0,
+ false,
+ 1));
int texture_id = 123;
ResourceProvider::ResourceId id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1);
EXPECT_NE(0u, id);
- EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
resource_provider->AllocateForTesting(id);
- EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
resource_provider->DeleteResource(id);
}
@@ -2887,15 +2913,19 @@ TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) {
CHECK(output_surface->BindToClient(&output_surface_client));
gfx::Size size(4, 4);
- scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
- output_surface.get(), shared_bitmap_manager_.get(), 0, false));
+ scoped_ptr<ResourceProvider> resource_provider(
+ ResourceProvider::Create(output_surface.get(),
+ shared_bitmap_manager_.get(),
+ 0,
+ false,
+ 1));
int texture_id = 123;
uint8_t pixels[8];
ResourceProvider::ResourceId id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1);
EXPECT_NE(0u, id);
- EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
EXPECT_CALL(*context,
compressedTexImage2D(
@@ -2903,7 +2933,7 @@ TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) {
resource_provider->SetPixels(
id, pixels, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(0, 0));
- EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1);
resource_provider->DeleteResource(id);
}
@@ -2912,5 +2942,69 @@ INSTANTIATE_TEST_CASE_P(
ResourceProviderTest,
::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap));
+class TextureIdAllocationTrackingContext : public TestWebGraphicsContext3D {
+ public:
+ virtual WebKit::WebGLId NextTextureId() OVERRIDE {
+ base::AutoLock lock(namespace_->lock);
+ return namespace_->next_texture_id++;
+ }
+ virtual void RetireTextureId(WebKit::WebGLId) OVERRIDE {
+ }
+ WebKit::WebGLId PeekTextureId() {
+ base::AutoLock lock(namespace_->lock);
+ return namespace_->next_texture_id;
+ }
+};
+
+TEST(ResourceProviderTest, TextureAllocationChunkSize) {
+ scoped_ptr<TextureIdAllocationTrackingContext> context_owned(
+ new TextureIdAllocationTrackingContext);
+ TextureIdAllocationTrackingContext* context = context_owned.get();
+
+ FakeOutputSurfaceClient output_surface_client;
+ scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
+ context_owned.PassAs<TestWebGraphicsContext3D>()));
+ CHECK(output_surface->BindToClient(&output_surface_client));
+
+ gfx::Size size(1, 1);
+ ResourceFormat format = RGBA_8888;
+
+ {
+ size_t kTextureAllocationChunkSize = 1;
+ scoped_ptr<ResourceProvider> resource_provider(
+ ResourceProvider::Create(output_surface.get(),
+ NULL,
+ 0,
+ false,
+ kTextureAllocationChunkSize));
+
+ ResourceProvider::ResourceId id = resource_provider->CreateResource(
+ size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
+ resource_provider->AllocateForTesting(id);
+ Mock::VerifyAndClearExpectations(context);
+
+ DCHECK_EQ(2u, context->PeekTextureId());
+ resource_provider->DeleteResource(id);
+ }
+
+ {
+ size_t kTextureAllocationChunkSize = 8;
+ scoped_ptr<ResourceProvider> resource_provider(
+ ResourceProvider::Create(output_surface.get(),
+ NULL,
+ 0,
+ false,
+ kTextureAllocationChunkSize));
+
+ ResourceProvider::ResourceId id = resource_provider->CreateResource(
+ size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
+ resource_provider->AllocateForTesting(id);
+ Mock::VerifyAndClearExpectations(context);
+
+ DCHECK_EQ(10u, context->PeekTextureId());
+ resource_provider->DeleteResource(id);
+ }
+}
+
} // namespace
} // namespace cc
diff --git a/cc/resources/resource_update_controller_unittest.cc b/cc/resources/resource_update_controller_unittest.cc
index da413ef..98d2dd2 100644
--- a/cc/resources/resource_update_controller_unittest.cc
+++ b/cc/resources/resource_update_controller_unittest.cc
@@ -137,7 +137,7 @@ class ResourceUpdateControllerTest : public Test {
CHECK(output_surface_->BindToClient(&output_surface_client_));
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
}
void AppendFullUploadsOfIndexedTextureToUpdateQueue(int count,
diff --git a/cc/resources/scoped_resource_unittest.cc b/cc/resources/scoped_resource_unittest.cc
index dc0df8b..a68e60e 100644
--- a/cc/resources/scoped_resource_unittest.cc
+++ b/cc/resources/scoped_resource_unittest.cc
@@ -19,7 +19,7 @@ TEST(ScopedResourceTest, NewScopedResource) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
scoped_ptr<ScopedResource> texture =
ScopedResource::create(resource_provider.get());
@@ -37,7 +37,7 @@ TEST(ScopedResourceTest, CreateScopedResource) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
scoped_ptr<ScopedResource> texture =
ScopedResource::create(resource_provider.get());
texture->Allocate(gfx::Size(30, 30),
@@ -59,7 +59,7 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
{
scoped_ptr<ScopedResource> texture =
ScopedResource::create(resource_provider.get());
@@ -93,7 +93,7 @@ TEST(ScopedResourceTest, LeakScopedResource) {
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
- ResourceProvider::Create(output_surface.get(), NULL, 0, false));
+ ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1));
{
scoped_ptr<ScopedResource> texture =
ScopedResource::create(resource_provider.get());
diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc
index f533e65..6091ada 100644
--- a/cc/resources/tile_manager_perftest.cc
+++ b/cc/resources/tile_manager_perftest.cc
@@ -40,7 +40,7 @@ class TileManagerPerfTest : public testing::Test {
CHECK(output_surface_->BindToClient(&output_surface_client_));
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
tile_manager_ = make_scoped_ptr(
new FakeTileManager(&tile_manager_client_, resource_provider_.get()));
picture_pile_ = FakePicturePileImpl::CreatePile();
diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc
index c5bc6da..4a070a8 100644
--- a/cc/resources/tile_manager_unittest.cc
+++ b/cc/resources/tile_manager_unittest.cc
@@ -26,7 +26,7 @@ class TileManagerTest : public testing::TestWithParam<bool> {
CHECK(output_surface_->BindToClient(&output_surface_client_));
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
tile_manager_ = make_scoped_ptr(
new FakeTileManager(&tile_manager_client_, resource_provider_.get()));
diff --git a/cc/resources/video_resource_updater_unittest.cc b/cc/resources/video_resource_updater_unittest.cc
index 86cbc3f..dcb72e3 100644
--- a/cc/resources/video_resource_updater_unittest.cc
+++ b/cc/resources/video_resource_updater_unittest.cc
@@ -26,7 +26,7 @@ class VideoResourceUpdaterTest : public testing::Test {
FakeOutputSurface::Create3d(context3d.Pass());
CHECK(output_surface3d_->BindToClient(&client_));
resource_provider3d_ =
- ResourceProvider::Create(output_surface3d_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface3d_.get(), NULL, 0, false, 1);
}
scoped_refptr<media::VideoFrame> CreateTestYUVVideoFrame() {
diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc
index 17c3aeb..0e09d8a 100644
--- a/cc/test/pixel_test.cc
+++ b/cc/test/pixel_test.cc
@@ -167,7 +167,7 @@ void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) {
output_surface_->BindToClient(fake_client_.get());
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
texture_mailbox_deleter_ = make_scoped_ptr(new TextureMailboxDeleter);
@@ -210,7 +210,7 @@ void PixelTest::SetUpSoftwareRenderer() {
output_surface_.reset(new PixelTestOutputSurface(device.Pass()));
output_surface_->BindToClient(fake_client_.get());
resource_provider_ =
- ResourceProvider::Create(output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
renderer_ = SoftwareRenderer::Create(fake_client_.get(),
&settings_,
output_surface_.get(),
diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc
index 0c15f20..b111a64 100644
--- a/cc/test/test_web_graphics_context_3d.cc
+++ b/cc/test/test_web_graphics_context_3d.cc
@@ -216,13 +216,8 @@ void TestWebGraphicsContext3D::genTextures(WGC3Dsizei count, WebGLId* ids) {
}
void TestWebGraphicsContext3D::deleteBuffers(WGC3Dsizei count, WebGLId* ids) {
- base::AutoLock lock(namespace_->lock);
- for (int i = 0; i < count; ++i) {
- unsigned context_id = ids[i] >> 17;
- unsigned buffer_id = ids[i] & 0x1ffff;
- DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id);
- DCHECK_EQ(context_id, context_id_);
- }
+ for (int i = 0; i < count; ++i)
+ RetireBufferId(ids[i]);
}
void TestWebGraphicsContext3D::deleteFramebuffers(
@@ -238,6 +233,8 @@ void TestWebGraphicsContext3D::deleteRenderbuffers(
}
void TestWebGraphicsContext3D::deleteTextures(WGC3Dsizei count, WebGLId* ids) {
+ for (int i = 0; i < count; ++i)
+ RetireTextureId(ids[i]);
base::AutoLock lock(namespace_->lock);
for (int i = 0; i < count; ++i) {
namespace_->textures.Remove(ids[i]);
@@ -459,10 +456,11 @@ void TestWebGraphicsContext3D::bindBuffer(WebKit::WGC3Denum target,
bound_buffer_ = buffer;
if (!bound_buffer_)
return;
- unsigned context_id = buffer >> 17;
- unsigned buffer_id = buffer & 0x1ffff;
+ unsigned context_id = buffer >> 16;
+ unsigned buffer_id = buffer & 0xffff;
base::AutoLock lock(namespace_->lock);
- DCHECK(buffer_id && buffer_id < namespace_->next_buffer_id);
+ DCHECK(buffer_id);
+ DCHECK_LT(buffer_id, namespace_->next_buffer_id);
DCHECK_EQ(context_id, context_id_);
base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers;
@@ -531,11 +529,7 @@ WebKit::WGC3Duint TestWebGraphicsContext3D::createImageCHROMIUM(
void TestWebGraphicsContext3D::destroyImageCHROMIUM(
WebKit::WGC3Duint id) {
- base::AutoLock lock(namespace_->lock);
- unsigned context_id = id >> 17;
- unsigned image_id = id & 0x1ffff;
- DCHECK(image_id && image_id < namespace_->next_image_id);
- DCHECK_EQ(context_id, context_id_);
+ RetireImageId(id);
}
void TestWebGraphicsContext3D::getImageParameterivCHROMIUM(
@@ -586,22 +580,49 @@ WebGLId TestWebGraphicsContext3D::NextTextureId() {
return texture_id;
}
+void TestWebGraphicsContext3D::RetireTextureId(WebGLId id) {
+ base::AutoLock lock(namespace_->lock);
+ unsigned context_id = id >> 16;
+ unsigned texture_id = id & 0xffff;
+ DCHECK(texture_id);
+ DCHECK_LT(texture_id, namespace_->next_texture_id);
+ DCHECK_EQ(context_id, context_id_);
+}
+
WebGLId TestWebGraphicsContext3D::NextBufferId() {
base::AutoLock lock(namespace_->lock);
WebGLId buffer_id = namespace_->next_buffer_id++;
- DCHECK(buffer_id < (1 << 17));
- buffer_id |= context_id_ << 17;
+ DCHECK(buffer_id < (1 << 16));
+ buffer_id |= context_id_ << 16;
return buffer_id;
}
+void TestWebGraphicsContext3D::RetireBufferId(WebGLId id) {
+ base::AutoLock lock(namespace_->lock);
+ unsigned context_id = id >> 16;
+ unsigned buffer_id = id & 0xffff;
+ DCHECK(buffer_id);
+ DCHECK_LT(buffer_id, namespace_->next_buffer_id);
+ DCHECK_EQ(context_id, context_id_);
+}
+
WebKit::WGC3Duint TestWebGraphicsContext3D::NextImageId() {
base::AutoLock lock(namespace_->lock);
WGC3Duint image_id = namespace_->next_image_id++;
- DCHECK(image_id < (1 << 17));
- image_id |= context_id_ << 17;
+ DCHECK(image_id < (1 << 16));
+ image_id |= context_id_ << 16;
return image_id;
}
+void TestWebGraphicsContext3D::RetireImageId(WebGLId id) {
+ base::AutoLock lock(namespace_->lock);
+ unsigned context_id = id >> 16;
+ unsigned image_id = id & 0xffff;
+ DCHECK(image_id);
+ DCHECK_LT(image_id, namespace_->next_image_id);
+ DCHECK_EQ(context_id, context_id_);
+}
+
size_t TestWebGraphicsContext3D::GetTransferBufferMemoryUsedBytes() const {
size_t total_bytes = 0;
base::ScopedPtrHashMap<unsigned, Buffer>& buffers = namespace_->buffers;
diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h
index 796e34d..0d3c122 100644
--- a/cc/test/test_web_graphics_context_3d.h
+++ b/cc/test/test_web_graphics_context_3d.h
@@ -215,10 +215,13 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D {
static const WebKit::WebGLId kExternalTextureId;
virtual WebKit::WebGLId NextTextureId();
+ virtual void RetireTextureId(WebKit::WebGLId id);
virtual WebKit::WebGLId NextBufferId();
+ virtual void RetireBufferId(WebKit::WebGLId id);
virtual WebKit::WebGLId NextImageId();
+ virtual void RetireImageId(WebKit::WebGLId id);
size_t GetTransferBufferMemoryUsedBytes() const;
void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes);
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 0b71c84..0815f35 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1660,7 +1660,8 @@ bool LayerTreeHostImpl::InitializeRenderer(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_,
settings_.highp_threshold_min,
- settings_.use_rgba_4444_textures);
+ settings_.use_rgba_4444_textures,
+ settings_.texture_id_allocation_chunk_size);
if (!resource_provider)
return false;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index afb641f..3707290 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -92,6 +92,7 @@ class LayerTreeHostImplTest : public testing::Test,
LayerTreeSettings settings;
settings.minimum_occlusion_tracking_size = gfx::Size();
settings.impl_side_painting = true;
+ settings.texture_id_allocation_chunk_size = 1;
host_impl_ = LayerTreeHostImpl::Create(
settings, this, &proxy_, &stats_instrumentation_, NULL);
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index c0e40c6..19786f8 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -1441,6 +1441,7 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers);
class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest {
public:
virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ settings->texture_id_allocation_chunk_size = 1;
// Make sure partial texture updates are turned off.
settings->max_partial_texture_updates = 0;
// Linear fade animator prevents scrollbars from drawing immediately.
@@ -1619,6 +1620,7 @@ class LayerTreeHostTestAtomicCommitWithPartialUpdate
: public LayerTreeHostTest {
public:
virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ settings->texture_id_allocation_chunk_size = 1;
// Allow one partial texture update.
settings->max_partial_texture_updates = 1;
// No partial updates when impl side painting is enabled.
@@ -3755,6 +3757,10 @@ class LayerTreeHostTestUIResource : public LayerTreeHostTest {
public:
LayerTreeHostTestUIResource() : num_ui_resources_(0), num_commits_(0) {}
+ virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ settings->texture_id_allocation_chunk_size = 1;
+ }
+
virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
virtual void DidCommit() OVERRIDE {
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 5596346..ce5dfe1 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -1091,7 +1091,11 @@ class LayerTreeHostContextTestDontUseLostResources
child_output_surface_ = FakeOutputSurface::Create3d();
child_output_surface_->BindToClient(&output_surface_client_);
child_resource_provider_ =
- ResourceProvider::Create(child_output_surface_.get(), NULL, 0, false);
+ ResourceProvider::Create(child_output_surface_.get(),
+ NULL,
+ 0,
+ false,
+ 1);
}
static void EmptyReleaseCallback(unsigned sync_point, bool lost) {}
@@ -1799,6 +1803,9 @@ SINGLE_AND_MULTI_THREAD_TEST_F(
class UIResourceLostTest : public LayerTreeHostContextTest {
public:
UIResourceLostTest() : time_step_(0) {}
+ virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ settings->texture_id_allocation_chunk_size = 1;
+ }
virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
virtual void AfterTest() OVERRIDE {}
diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc
index b089a09..bdad5e3 100644
--- a/cc/trees/layer_tree_settings.cc
+++ b/cc/trees/layer_tree_settings.cc
@@ -58,7 +58,8 @@ LayerTreeSettings::LayerTreeSettings()
ignore_root_layer_flings(false),
use_rgba_4444_textures(false),
always_overscroll(false),
- touch_hit_testing(true) {
+ touch_hit_testing(true),
+ texture_id_allocation_chunk_size(64) {
}
LayerTreeSettings::~LayerTreeSettings() {}
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h
index fafeb4d..e88f882 100644
--- a/cc/trees/layer_tree_settings.h
+++ b/cc/trees/layer_tree_settings.h
@@ -69,6 +69,7 @@ class CC_EXPORT LayerTreeSettings {
bool use_rgba_4444_textures;
bool always_overscroll;
bool touch_hit_testing;
+ size_t texture_id_allocation_chunk_size;
LayerTreeDebugState initial_debug_state;
};