diff options
author | kaanb@chromium.org <kaanb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-08 23:57:01 +0000 |
---|---|---|
committer | kaanb@chromium.org <kaanb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-08 23:57:01 +0000 |
commit | 3441c09a309827cf77c50f23f37a6dd486462e60 (patch) | |
tree | 162a948775efc7122f0c562de2238f99da110c6e /cc | |
parent | 91223bb8db5a22776b3b5d21eac5e496bf85cf02 (diff) | |
download | chromium_src-3441c09a309827cf77c50f23f37a6dd486462e60.zip chromium_src-3441c09a309827cf77c50f23f37a6dd486462e60.tar.gz chromium_src-3441c09a309827cf77c50f23f37a6dd486462e60.tar.bz2 |
cc: Defer texture creation to LazyAllocate
BUG=246450
Review URL: https://chromiumcodereview.appspot.com/16417002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/resources/resource_provider.cc | 83 | ||||
-rw-r--r-- | cc/resources/resource_provider.h | 13 | ||||
-rw-r--r-- | cc/resources/resource_provider_unittest.cc | 128 |
3 files changed, 145 insertions, 79 deletions
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 68882c6..6b992b3 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -86,12 +86,19 @@ ResourceProvider::Resource::Resource() format(0), filter(0), image_id(0), + texture_pool(0), + hint(TextureUsageAny), type(static_cast<ResourceType>(0)) {} ResourceProvider::Resource::~Resource() {} ResourceProvider::Resource::Resource( - unsigned texture_id, gfx::Size size, GLenum format, GLenum filter) + unsigned texture_id, + gfx::Size size, + GLenum format, + GLenum filter, + GLenum texture_pool, + TextureUsageHint hint) : gl_id(texture_id), gl_pixel_buffer_id(0), gl_upload_query_id(0), @@ -111,6 +118,8 @@ ResourceProvider::Resource::Resource( format(format), filter(filter), image_id(0), + texture_pool(texture_pool), + hint(hint), type(GLTexture) {} ResourceProvider::Resource::Resource( @@ -134,6 +143,8 @@ ResourceProvider::Resource::Resource( format(format), filter(filter), image_id(0), + texture_pool(0), + hint(TextureUsageAny), type(Bitmap) {} ResourceProvider::Child::Child() {} @@ -210,24 +221,10 @@ ResourceProvider::ResourceId ResourceProvider::CreateGLTexture( gfx::Size size, GLenum format, GLenum texture_pool, TextureUsageHint hint) { DCHECK_LE(size.width(), max_texture_size_); DCHECK_LE(size.height(), max_texture_size_); - DCHECK(thread_checker_.CalledOnValidThread()); - WebGraphicsContext3D* context3d = output_surface_->context3d(); - DCHECK(context3d); - - // Create and set texture properties. Allocation is delayed until needed. - unsigned texture_id = CreateTextureId(context3d); - GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, - GL_TEXTURE_POOL_CHROMIUM, - texture_pool)); - if (use_texture_usage_hint_ && hint == TextureUsageFramebuffer) { - GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, - GL_TEXTURE_USAGE_ANGLE, - GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); - } ResourceId id = next_id_++; - Resource resource(texture_id, size, format, GL_LINEAR); + Resource resource(0, size, format, GL_LINEAR, texture_pool, hint); resource.allocated = false; resources_[id] = resource; return id; @@ -264,7 +261,7 @@ ResourceProvider::CreateResourceFromExternalTexture( texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); ResourceId id = next_id_++; - Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR); + Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR, 0, TextureUsageAny); resource.external = true; resource.allocated = true; resources_[id] = resource; @@ -279,8 +276,7 @@ ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( DCHECK(mailbox.IsValid()); Resource& resource = resources_[id]; if (mailbox.IsTexture()) { - unsigned texture_id = 0; - resource = Resource(texture_id, gfx::Size(), 0, GL_LINEAR); + resource = Resource(0, gfx::Size(), 0, GL_LINEAR, 0, TextureUsageAny); } else { DCHECK(mailbox.IsSharedMemory()); base::SharedMemory* shared_memory = mailbox.shared_memory(); @@ -835,7 +831,8 @@ void ResourceProvider::ReceiveFromChild( GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mailbox.name)); ResourceId id = next_id_++; - Resource resource(texture_id, it->size, it->format, it->filter); + Resource resource( + texture_id, it->size, it->format, it->filter, 0, TextureUsageAny); resource.mailbox.SetName(it->mailbox); // Don't allocate a texture for a child. resource.allocated = true; @@ -928,7 +925,7 @@ void ResourceProvider::AcquirePixelBuffer(ResourceId id) { DCHECK(!resource->exported); DCHECK(!resource->image_id); - if (resource->gl_id) { + if (resource->type == GLTexture) { WebGraphicsContext3D* context3d = output_surface_->context3d(); DCHECK(context3d); if (!resource->gl_pixel_buffer_id) @@ -961,7 +958,7 @@ void ResourceProvider::ReleasePixelBuffer(ResourceId id) { DCHECK(!resource->exported); DCHECK(!resource->image_id); - if (resource->gl_id) { + if (resource->type == GLTexture) { if (!resource->gl_pixel_buffer_id) return; WebGraphicsContext3D* context3d = output_surface_->context3d(); @@ -994,7 +991,7 @@ uint8_t* ResourceProvider::MapPixelBuffer(ResourceId id) { DCHECK(!resource->exported); DCHECK(!resource->image_id); - if (resource->gl_id) { + if (resource->type == GLTexture) { WebGraphicsContext3D* context3d = output_surface_->context3d(); DCHECK(context3d); DCHECK(resource->gl_pixel_buffer_id); @@ -1025,7 +1022,7 @@ void ResourceProvider::UnmapPixelBuffer(ResourceId id) { DCHECK(!resource->exported); DCHECK(!resource->image_id); - if (resource->gl_id) { + if (resource->type == GLTexture) { WebGraphicsContext3D* context3d = output_surface_->context3d(); DCHECK(context3d); DCHECK(resource->gl_pixel_buffer_id); @@ -1112,6 +1109,8 @@ void ResourceProvider::BeginSetPixels(ResourceId id) { CHECK(it != resources_.end()); Resource* resource = &it->second; DCHECK(!resource->pending_set_pixels); + + LazyCreate(resource); DCHECK(resource->gl_id || resource->allocated); DCHECK(ReadLockFenceHasPassed(resource)); DCHECK(!resource->image_id); @@ -1237,6 +1236,35 @@ void ResourceProvider::AbortSetPixels(ResourceId id) { UnlockForWrite(id); } +void ResourceProvider::CreateForTesting(ResourceId id) { + ResourceMap::iterator it = resources_.find(id); + CHECK(it != resources_.end()); + Resource* resource = &it->second; + LazyCreate(resource); +} + +void ResourceProvider::LazyCreate(Resource* resource) { + if (resource->type != GLTexture || resource->gl_id != 0) + return; + + // Early out for resources that don't require texture creation. + if (resource->texture_pool == 0) + return; + + WebGraphicsContext3D* context3d = output_surface_->context3d(); + DCHECK(context3d); + // Create and set texture properties. Allocation is delayed until needed. + resource->gl_id = CreateTextureId(context3d); + GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, + GL_TEXTURE_POOL_CHROMIUM, + resource->texture_pool)); + if (use_texture_usage_hint_ && resource->hint == TextureUsageFramebuffer) { + GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, + GL_TEXTURE_USAGE_ANGLE, + GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); + } +} + void ResourceProvider::AllocateForTesting(ResourceId id) { ResourceMap::iterator it = resources_.find(id); CHECK(it != resources_.end()); @@ -1246,8 +1274,9 @@ void ResourceProvider::AllocateForTesting(ResourceId id) { void ResourceProvider::LazyAllocate(Resource* resource) { DCHECK(resource); - DCHECK(resource->gl_id || resource->allocated); + LazyCreate(resource); + DCHECK(resource->gl_id || resource->allocated); if (resource->allocated || !resource->gl_id) return; resource->allocated = true; @@ -1290,7 +1319,6 @@ void ResourceProvider::AcquireImage(ResourceId id) { CHECK(it != resources_.end()); Resource* resource = &it->second; - DCHECK(resource->gl_id); DCHECK(!resource->pixels); DCHECK(!resource->external); DCHECK(!resource->exported); @@ -1370,8 +1398,8 @@ void ResourceProvider::BindImage(ResourceId id) { DCHECK(!resource->exported); DCHECK(!resource->pixels); DCHECK(resource->image_id); - DCHECK(resource->gl_id); + LazyCreate(resource); resource->allocated = true; WebGraphicsContext3D* context3d = output_surface_->context3d(); @@ -1399,5 +1427,4 @@ int ResourceProvider::GetImageStride(ResourceId id) { return stride; } - } // namespace cc diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index 124f977..ced287d 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h @@ -312,6 +312,9 @@ class CC_EXPORT ResourceProvider { // Use SetPixels or LockForWrite to allocate implicitly. void AllocateForTesting(ResourceId id); + // For tests only! + void CreateForTesting(ResourceId id); + // Sets the current read fence. If a resource is locked for read // and has read fences enabled, the resource will not allow writes // until this fence has passed. @@ -338,7 +341,12 @@ class CC_EXPORT ResourceProvider { struct Resource { Resource(); ~Resource(); - Resource(unsigned texture_id, gfx::Size size, GLenum format, GLenum filter); + Resource(unsigned texture_id, + gfx::Size size, + GLenum format, + GLenum filter, + GLenum texture_pool, + TextureUsageHint hint); Resource(uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter); unsigned gl_id; @@ -364,6 +372,8 @@ class CC_EXPORT ResourceProvider { // TODO(skyostil): Use a separate sampler object for filter state. GLenum filter; unsigned image_id; + GLenum texture_pool; + TextureUsageHint hint; ResourceType type; }; typedef base::hash_map<ResourceId, Resource> ResourceMap; @@ -399,6 +409,7 @@ class CC_EXPORT ResourceProvider { ForShutdown, }; void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); + void LazyCreate(Resource* resource); void LazyAllocate(Resource* resource); OutputSurface* output_surface_; diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index 0ca3d02..e763d0e 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -382,12 +382,6 @@ class ResourceProviderTest return context->GetTextureFilter(); } - void ExpectNumResources(int count) { - EXPECT_EQ(count, static_cast<int>(resource_provider_->num_resources())); - if (GetParam() == ResourceProvider::GLTexture) - EXPECT_EQ(count, context()->texture_count()); - } - protected: scoped_ptr<ContextSharedData> shared_data_; scoped_ptr<OutputSurface> output_surface_; @@ -402,18 +396,24 @@ TEST_P(ResourceProviderTest, Basic) { ResourceProvider::ResourceId id = resource_provider_->CreateResource( size, format, ResourceProvider::TextureUsageAny); - ExpectNumResources(1); + EXPECT_EQ(1, static_cast<int>(resource_provider_->num_resources())); + if (GetParam() == ResourceProvider::GLTexture) + EXPECT_EQ(0, context()->texture_count()); uint8_t data[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); resource_provider_->SetPixels(id, data, rect, rect, gfx::Vector2d()); + if (GetParam() == ResourceProvider::GLTexture) + EXPECT_EQ(1, context()->texture_count()); uint8_t result[4] = { 0 }; GetResourcePixels(id, size, format, result); EXPECT_EQ(0, memcmp(data, result, pixel_size)); resource_provider_->DeleteResource(id); - ExpectNumResources(0); + EXPECT_EQ(0, static_cast<int>(resource_provider_->num_resources())); + if (GetParam() == ResourceProvider::GLTexture) + EXPECT_EQ(0, context()->texture_count()); } TEST_P(ResourceProviderTest, Upload) { @@ -1083,6 +1083,8 @@ TEST_P(ResourceProviderTest, ManagedResource) { int texture_id = 1; // Check that the texture gets created with the right sampler settings. + ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( + size, format, ResourceProvider::TextureUsageAny); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); @@ -1098,8 +1100,7 @@ TEST_P(ResourceProviderTest, ManagedResource) { texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_MANAGED_CHROMIUM)); - ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( - size, format, ResourceProvider::TextureUsageAny); + resource_provider->CreateForTesting(id); EXPECT_NE(0u, id); Mock::VerifyAndClearExpectations(context); @@ -1319,7 +1320,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { return; scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( static_cast<WebKit::WebGraphicsContext3D*>( - new NiceMock<AllocationTrackingContext3D>)); + new StrictMock<AllocationTrackingContext3D>)); scoped_ptr<OutputSurface> output_surface( FakeOutputSurface::Create3d(mock_context.Pass())); @@ -1337,55 +1338,67 @@ TEST_P(ResourceProviderTest, TextureAllocation) { ResourceProvider::Create(output_surface.get(), 0)); // Lazy allocation. Don't allocate when creating the resource. - EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); - EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); - EXPECT_CALL(*context, texImage2D(_, _, _, _, _, _, _, _, _)).Times(0); - EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, _, _, _, _, _, _)) - .Times(0); id = resource_provider->CreateResource( size, format, ResourceProvider::TextureUsageAny); + + EXPECT_CALL(*context, createTexture()).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); resource_provider->DeleteResource(id); + Mock::VerifyAndClearExpectations(context); // Do allocate when we set the pixels. + id = resource_provider->CreateResource( + size, format, ResourceProvider::TextureUsageAny); + EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); - EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); 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); - id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); resource_provider->SetPixels(id, pixels, rect, rect, offset); + + EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); resource_provider->DeleteResource(id); + Mock::VerifyAndClearExpectations(context); // Same for SetPixelsFromBuffer + id = resource_provider->CreateResource( + size, format, ResourceProvider::TextureUsageAny); + resource_provider->AcquirePixelBuffer(id); + EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); - EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); 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); - id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); - resource_provider->AcquirePixelBuffer(id); resource_provider->SetPixelsFromBuffer(id); + resource_provider->ReleasePixelBuffer(id); + + EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); resource_provider->DeleteResource(id); + Mock::VerifyAndClearExpectations(context); // Same for async version. + id = resource_provider->CreateResource( + size, format, ResourceProvider::TextureUsageAny); + resource_provider->AcquirePixelBuffer(id); + EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); - EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) .Times(1); - id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); - resource_provider->AcquirePixelBuffer(id); resource_provider->BeginSetPixels(id); + resource_provider->ReleasePixelBuffer(id); + + EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); resource_provider->DeleteResource(id); + Mock::VerifyAndClearExpectations(context); } @@ -1395,7 +1408,7 @@ TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) { return; scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( static_cast<WebKit::WebGraphicsContext3D*>( - new NiceMock<AllocationTrackingContext3D>)); + new StrictMock<AllocationTrackingContext3D>)); scoped_ptr<OutputSurface> output_surface( FakeOutputSurface::Create3d(mock_context.Pass())); @@ -1409,18 +1422,26 @@ TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) { scoped_ptr<ResourceProvider> resource_provider( ResourceProvider::Create(output_surface.get(), 0)); + id = resource_provider->CreateResource( + size, format, ResourceProvider::TextureUsageAny); + resource_provider->AcquirePixelBuffer(id); + EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) .Times(1); + resource_provider->BeginSetPixels(id); + + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); - id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); - resource_provider->AcquirePixelBuffer(id); - resource_provider->BeginSetPixels(id); resource_provider->ForceSetPixelsToComplete(id); + resource_provider->ReleasePixelBuffer(id); + + EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); + resource_provider->DeleteResource(id); + Mock::VerifyAndClearExpectations(context); } @@ -1430,7 +1451,7 @@ TEST_P(ResourceProviderTest, AbortForcedAsyncUpload) { return; scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( static_cast<WebKit::WebGraphicsContext3D*>( - new NiceMock<AllocationTrackingContext3D>)); + new StrictMock<AllocationTrackingContext3D>)); scoped_ptr<OutputSurface> output_surface( FakeOutputSurface::Create3d(mock_context.Pass())); @@ -1444,20 +1465,31 @@ TEST_P(ResourceProviderTest, AbortForcedAsyncUpload) { scoped_ptr<ResourceProvider> resource_provider( ResourceProvider::Create(output_surface.get(), 0)); - EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(texture_id)); - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(4); - EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) - .Times(1); - EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); - EXPECT_CALL(*context, deleteTexture(_)).Times(1); id = resource_provider->CreateResource( size, format, ResourceProvider::TextureUsageAny); resource_provider->AcquirePixelBuffer(id); + + EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); + EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) + .Times(1); resource_provider->BeginSetPixels(id); + + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); + EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); resource_provider->ForceSetPixelsToComplete(id); + + EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); + EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); resource_provider->AbortSetPixels(id); + resource_provider->ReleasePixelBuffer(id); + + EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); + resource_provider->DeleteResource(id); + Mock::VerifyAndClearExpectations(context); } @@ -1515,13 +1547,6 @@ TEST_P(ResourceProviderTest, GpuMemoryBuffers) { scoped_ptr<ResourceProvider> resource_provider( ResourceProvider::Create(output_surface.get(), 0)); - EXPECT_CALL(*context, createTexture()) - .WillOnce(Return(kTextureId)) - .RetiresOnSaturation(); - - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) - .Times(1) - .RetiresOnSaturation(); id = resource_provider->CreateResource( size, format, ResourceProvider::TextureUsageAny); EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) @@ -1529,7 +1554,10 @@ TEST_P(ResourceProviderTest, GpuMemoryBuffers) { .RetiresOnSaturation(); resource_provider->AcquireImage(id); - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) + EXPECT_CALL(*context, createTexture()) + .WillOnce(Return(kTextureId)) + .RetiresOnSaturation(); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) .RetiresOnSaturation(); EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) .Times(1) |