diff options
author | dongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-21 22:58:58 +0000 |
---|---|---|
committer | dongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-21 23:00:56 +0000 |
commit | 655041fca6018aeb1aba86201d50e68beb0c9ee6 (patch) | |
tree | 2227bc838cb4ef7c70c8bc42d5d0d51a5ab23f70 | |
parent | ec89d0c82318812a6d999d418b771d0030af60fe (diff) | |
download | chromium_src-655041fca6018aeb1aba86201d50e68beb0c9ee6.zip chromium_src-655041fca6018aeb1aba86201d50e68beb0c9ee6.tar.gz chromium_src-655041fca6018aeb1aba86201d50e68beb0c9ee6.tar.bz2 |
cc: Use a normal texture for background texture.
We prefer immutable texture to mutable texture and normal texture to framebuffer target texture.
There are 3 changes;
1. Introduce TextureHint enum to clarify immutable and framebuffer target.
2. The texture for render pass and background filter target is changed from mutable
framebuffer texture to immutable framebuffer texture.
3. The texture for background filter source is changed from mutable framebuffer
texture to mutable texture.
TEST=ResourceProviderTest.TextureHint, ResourceProviderTest.TextureAllocationHint
BUG=404986
Review URL: https://codereview.chromium.org/486853002
Cr-Commit-Position: refs/heads/master@{#291223}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291223 0039d316-1c4b-4281-b951-d872f2087c98
22 files changed, 241 insertions, 193 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index c46c1be..fcb2733 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -98,9 +98,8 @@ bool HeadsUpDisplayLayerImpl::WillDraw(DrawMode draw_mode, } if (!hud_resource_->id()) { - hud_resource_->Allocate(content_bounds(), - ResourceProvider::TextureUsageAny, - RGBA_8888); + hud_resource_->Allocate( + content_bounds(), ResourceProvider::TextureHintImmutable, RGBA_8888); } return LayerImpl::WillDraw(draw_mode, resource_provider); diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc index a61190c..594867e 100644 --- a/cc/layers/texture_layer_impl.cc +++ b/cc/layers/texture_layer_impl.cc @@ -103,7 +103,7 @@ bool TextureLayerImpl::WillDraw(DrawMode draw_mode, if (!texture_copy_->id()) { texture_copy_->Allocate(texture_mailbox_.shared_memory_size(), - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); } diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 8b7277b..eed0229 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -409,7 +409,7 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame, enlarge_pass_texture_amount_.y()); if (!texture->id()) texture->Allocate( - size, ResourceProvider::TextureUsageFramebuffer, RGBA_8888); + size, ResourceProvider::TextureHintImmutableFramebuffer, RGBA_8888); DCHECK(texture->id()); return BindFramebufferToTexture(frame, texture, render_pass->output_rect); diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 92af7bc..7fcf540 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -899,11 +899,9 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( scoped_ptr<ScopedResource> device_background_texture = ScopedResource::Create(resource_provider_); - // The TextureUsageFramebuffer hint makes ResourceProvider avoid immutable - // storage allocation (texStorage2DEXT) for this texture. copyTexImage2D fails - // when called on a texture having immutable storage. + // CopyTexImage2D fails when called on a texture having immutable storage. device_background_texture->Allocate( - window_rect.size(), ResourceProvider::TextureUsageFramebuffer, RGBA_8888); + window_rect.size(), ResourceProvider::TextureHintDefault, RGBA_8888); { ResourceProvider::ScopedWriteLockGL lock(resource_provider_, device_background_texture->id()); @@ -941,7 +939,9 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( scoped_ptr<ScopedResource> background_texture = ScopedResource::Create(resource_provider_); background_texture->Allocate( - quad->rect.size(), ResourceProvider::TextureUsageFramebuffer, RGBA_8888); + quad->rect.size(), + ResourceProvider::TextureHintImmutableFramebuffer, + RGBA_8888); const RenderPass* target_render_pass = frame->current_render_pass; bool using_background_texture = @@ -1929,13 +1929,13 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, if (on_demand_tile_raster_resource_id_) resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); - on_demand_tile_raster_resource_id_ = - resource_provider_->CreateGLTexture(quad->texture_size, - GL_TEXTURE_2D, - GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - quad->texture_format); + on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( + quad->texture_size, + GL_TEXTURE_2D, + GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + quad->texture_format); } // Create and run on-demand raster task for tile. diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index 6999c08..5566d6b 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -1273,7 +1273,7 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { ResourceProvider::ResourceId mask = resource_provider_->CreateResource( gfx::Size(20, 12), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider_->best_texture_format()); resource_provider_->AllocateForTesting(mask); diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc index d4885d3..cc72967 100644 --- a/cc/output/renderer_pixeltest.cc +++ b/cc/output/renderer_pixeltest.cc @@ -129,7 +129,7 @@ void CreateTestTextureDrawQuad(const gfx::Rect& rect, ResourceProvider::ResourceId resource = resource_provider->CreateResource(rect.size(), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, RGBA_8888); resource_provider->SetPixels( resource, @@ -1217,7 +1217,7 @@ TYPED_TEST(RendererPixelTest, RenderPassAndMaskWithPartialQuad) { this->resource_provider_->CreateResource( mask_rect.size(), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, RGBA_8888); { SkAutoLockPixels lock(bitmap); @@ -2176,7 +2176,7 @@ TYPED_TEST(RendererPixelTest, WrapModeRepeat) { this->resource_provider_->CreateResource( texture_rect.size(), GL_REPEAT, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, RGBA_8888); this->resource_provider_->SetPixels( resource, diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc index dfde701..cd82679 100644 --- a/cc/output/software_renderer_unittest.cc +++ b/cc/output/software_renderer_unittest.cc @@ -151,15 +151,17 @@ TEST_F(SoftwareRendererTest, TileQuad) { InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); ResourceProvider::ResourceId resource_yellow = - resource_provider()->CreateResource(outer_size, - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - RGBA_8888); + resource_provider()->CreateResource( + outer_size, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + RGBA_8888); ResourceProvider::ResourceId resource_cyan = - resource_provider()->CreateResource(inner_size, - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - RGBA_8888); + resource_provider()->CreateResource( + inner_size, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + RGBA_8888); SkBitmap yellow_tile; yellow_tile.allocN32Pixels(outer_size.width(), outer_size.height()); @@ -244,10 +246,11 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { InitializeRenderer(make_scoped_ptr(new SoftwareOutputDevice)); ResourceProvider::ResourceId resource_cyan = - resource_provider()->CreateResource(tile_size, - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - RGBA_8888); + resource_provider()->CreateResource( + tile_size, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + RGBA_8888); SkBitmap cyan_tile; // The lowest five rows are yellow. cyan_tile.allocN32Pixels(tile_size.width(), tile_size.height()); diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc index 81af9fb..54ed308 100644 --- a/cc/resources/prioritized_resource_manager.cc +++ b/cc/resources/prioritized_resource_manager.cc @@ -455,7 +455,7 @@ PrioritizedResource::Backing* PrioritizedResourceManager::CreateBacking( size, GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, format); PrioritizedResource::Backing* backing = new PrioritizedResource::Backing( resource_id, resource_provider, size, format); diff --git a/cc/resources/raster_worker_pool_perftest.cc b/cc/resources/raster_worker_pool_perftest.cc index 74bb988..96d046e 100644 --- a/cc/resources/raster_worker_pool_perftest.cc +++ b/cc/resources/raster_worker_pool_perftest.cc @@ -180,7 +180,8 @@ class RasterWorkerPoolPerfTestBase { for (unsigned i = 0; i < num_raster_tasks; ++i) { scoped_ptr<ScopedResource> resource( ScopedResource::Create(resource_provider_.get())); - resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); + resource->Allocate( + size, ResourceProvider::TextureHintImmutable, RGBA_8888); ImageDecodeTask::Vector dependencies = image_decode_tasks; raster_tasks->push_back( diff --git a/cc/resources/raster_worker_pool_unittest.cc b/cc/resources/raster_worker_pool_unittest.cc index 3b43c09..4991237 100644 --- a/cc/resources/raster_worker_pool_unittest.cc +++ b/cc/resources/raster_worker_pool_unittest.cc @@ -208,7 +208,7 @@ class RasterWorkerPoolTest scoped_ptr<ScopedResource> resource( ScopedResource::Create(resource_provider_.get())); - resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); + resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); const Resource* const_resource = resource.get(); ImageDecodeTask::Vector empty; @@ -226,7 +226,7 @@ class RasterWorkerPoolTest scoped_ptr<ScopedResource> resource( ScopedResource::Create(resource_provider_.get())); - resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); + resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); const Resource* const_resource = resource.get(); ImageDecodeTask::Vector empty; diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 8a09842..521eb13 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -248,7 +248,7 @@ ResourceProvider::Resource::Resource() bound_image_id(0), texture_pool(0), wrap_mode(0), - hint(TextureUsageAny), + hint(TextureHintImmutable), type(InvalidType), format(RGBA_8888), shared_bitmap(NULL) { @@ -263,7 +263,7 @@ ResourceProvider::Resource::Resource(GLuint texture_id, GLenum filter, GLenum texture_pool, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format) : child_id(0), gl_id(texture_id), @@ -337,7 +337,7 @@ ResourceProvider::Resource::Resource(uint8_t* pixels, bound_image_id(0), texture_pool(0), wrap_mode(wrap_mode), - hint(TextureUsageAny), + hint(TextureHintImmutable), type(Bitmap), format(RGBA_8888), shared_bitmap(bitmap) { @@ -381,7 +381,7 @@ ResourceProvider::Resource::Resource(const SharedBitmapId& bitmap_id, bound_image_id(0), texture_pool(0), wrap_mode(wrap_mode), - hint(TextureUsageAny), + hint(TextureHintImmutable), type(Bitmap), format(RGBA_8888), shared_bitmap_id(bitmap_id), @@ -629,7 +629,7 @@ bool ResourceProvider::AllowOverlay(ResourceId id) { ResourceProvider::ResourceId ResourceProvider::CreateResource( const gfx::Size& size, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format) { DCHECK(!size.IsEmpty()); switch (default_resource_type_) { @@ -655,7 +655,7 @@ ResourceProvider::ResourceId ResourceProvider::CreateManagedResource( const gfx::Size& size, GLenum target, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format) { DCHECK(!size.IsEmpty()); switch (default_resource_type_) { @@ -682,7 +682,7 @@ ResourceProvider::ResourceId ResourceProvider::CreateGLTexture( GLenum target, GLenum texture_pool, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format) { DCHECK_LE(size.width(), max_texture_size_); DCHECK_LE(size.height(), max_texture_size_); @@ -741,7 +741,7 @@ ResourceProvider::ResourceId ResourceProvider::CreateResourceFromIOSurface( GL_LINEAR, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, GL_CLAMP_TO_EDGE, - TextureUsageAny, + TextureHintImmutable, RGBA_8888); LazyCreate(&resource); GLES2Interface* gl = ContextGL(); @@ -770,7 +770,7 @@ ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( GL_LINEAR, 0, GL_CLAMP_TO_EDGE, - TextureUsageAny, + TextureHintImmutable, RGBA_8888); } else { DCHECK(mailbox.IsSharedMemory()); @@ -1418,7 +1418,7 @@ void ResourceProvider::ReceiveFromChild( it->filter, 0, it->is_repeated ? GL_REPEAT : GL_CLAMP_TO_EDGE, - TextureUsageAny, + TextureHintImmutable, it->format); resource.mailbox = TextureMailbox(it->mailbox_holder.mailbox, it->mailbox_holder.texture_target, @@ -2048,7 +2048,7 @@ void ResourceProvider::LazyCreate(Resource* resource) { GLC(gl, gl->TexParameteri( resource->target, GL_TEXTURE_POOL_CHROMIUM, resource->texture_pool)); - if (use_texture_usage_hint_ && resource->hint == TextureUsageFramebuffer) { + if (use_texture_usage_hint_ && (resource->hint & TextureHintFramebuffer)) { GLC(gl, gl->TexParameteri(resource->target, GL_TEXTURE_USAGE_ANGLE, @@ -2074,7 +2074,7 @@ void ResourceProvider::LazyAllocate(Resource* resource) { ResourceFormat format = resource->format; GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format) && - resource->hint != TextureUsageFramebuffer) { + (resource->hint & TextureHintImmutable)) { GLenum storage_format = TextureToStorageFormat(format); GLC(gl, gl->TexStorage2DEXT( diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index dfbff55..9bdc800 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h @@ -60,9 +60,12 @@ class CC_EXPORT ResourceProvider { typedef std::vector<ResourceId> ResourceIdArray; typedef std::set<ResourceId> ResourceIdSet; typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; - enum TextureUsageHint { - TextureUsageAny, - TextureUsageFramebuffer, + enum TextureHint { + TextureHintDefault = 0x0, + TextureHintImmutable = 0x1, + TextureHintFramebuffer = 0x2, + TextureHintImmutableFramebuffer = + TextureHintImmutable | TextureHintFramebuffer }; enum ResourceType { InvalidType = 0, @@ -106,7 +109,7 @@ class CC_EXPORT ResourceProvider { // Creates a resource of the default resource type. ResourceId CreateResource(const gfx::Size& size, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format); // Creates a resource which is tagged as being managed for GPU memory @@ -114,7 +117,7 @@ class CC_EXPORT ResourceProvider { ResourceId CreateManagedResource(const gfx::Size& size, GLenum target, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format); // You can also explicitly create a specific resource type. @@ -122,7 +125,7 @@ class CC_EXPORT ResourceProvider { GLenum target, GLenum texture_pool, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format); ResourceId CreateBitmap(const gfx::Size& size, GLint wrap_mode); @@ -387,7 +390,7 @@ class CC_EXPORT ResourceProvider { GLenum filter, GLenum texture_pool, GLint wrap_mode, - TextureUsageHint hint, + TextureHint hint, ResourceFormat format); Resource(uint8_t* pixels, SharedBitmap* bitmap, @@ -436,7 +439,7 @@ class CC_EXPORT ResourceProvider { unsigned bound_image_id; GLenum texture_pool; GLint wrap_mode; - TextureUsageHint hint; + TextureHint hint; ResourceType type; ResourceFormat format; SharedBitmapId shared_bitmap_id; diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index 0d85648..18e3e9a 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -497,7 +497,7 @@ void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); EXPECT_EQ(1, static_cast<int>(resource_provider->num_resources())); if (expected_default_type == ResourceProvider::GLTexture) EXPECT_EQ(0u, context->NumTextures()); @@ -529,7 +529,7 @@ TEST_P(ResourceProviderTest, Upload) { ASSERT_EQ(16U, pixel_size); ResourceProvider::ResourceId id = resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t image[16] = { 0 }; gfx::Rect image_rect(size); @@ -598,18 +598,18 @@ TEST_P(ResourceProviderTest, TransferGLResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = { 5, 5, 5, 5 }; child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); child_resource_provider_->MapImageRasterBuffer(id3); child_resource_provider_->UnmapImageRasterBuffer(id3); @@ -839,7 +839,7 @@ TEST_P(ResourceProviderTest, ReadLockCountStopsReturnToChildOrDelete) { ResourceFormat format = RGBA_8888; ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = {1, 2, 3, 4}; gfx::Rect rect(size); child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); @@ -945,18 +945,18 @@ TEST_P(ResourceProviderTest, TransferSoftwareResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = { 5, 5, 5, 5 }; child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data3[4] = { 6, 7, 8, 9 }; SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); SkCanvas* raster_canvas = child_resource_provider_->MapImageRasterBuffer(id3); @@ -1181,7 +1181,7 @@ TEST_P(ResourceProviderTest, TransferGLToSoftware) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); @@ -1228,7 +1228,7 @@ TEST_P(ResourceProviderTest, TransferInvalidSoftware) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); @@ -1276,13 +1276,13 @@ TEST_P(ResourceProviderTest, DeleteExportedResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = {5, 5, 5, 5}; child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); @@ -1370,13 +1370,13 @@ TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = {1, 2, 3, 4}; gfx::Rect rect(size); child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = {5, 5, 5, 5}; child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); @@ -1481,7 +1481,7 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider_->SetPixels(id, data, rect, rect, gfx::Vector2d()); @@ -1531,7 +1531,7 @@ TEST_P(ResourceProviderTest, UnuseTransferredResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data[4] = {1, 2, 3, 4}; gfx::Rect rect(size); child_resource_provider_->SetPixels(id, data, rect, rect, gfx::Vector2d()); @@ -1682,7 +1682,7 @@ class ResourceProviderTestTextureFilters : public ResourceProviderTest { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id = child_resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); // The new texture is created with GL_LINEAR. EXPECT_CALL(*child_context, bindTexture(GL_TEXTURE_2D, child_texture_id)) @@ -1948,7 +1948,10 @@ TEST_P(ResourceProviderTest, LostResourceInParent) { ResourceFormat format = RGBA_8888; ResourceProvider::ResourceId resource = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + format); child_resource_provider_->AllocateForTesting(resource); // Expect a GL resource to be lost. bool should_lose_resource = GetParam() == ResourceProvider::GLTexture; @@ -2001,7 +2004,10 @@ TEST_P(ResourceProviderTest, LostResourceInGrandParent) { ResourceFormat format = RGBA_8888; ResourceProvider::ResourceId resource = child_resource_provider_->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + format); child_resource_provider_->AllocateForTesting(resource); ReturnedResourceArray returned_to_child; @@ -2287,7 +2293,7 @@ TEST_P(ResourceProviderTest, ScopedSampler) { int texture_id = 1; ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); // Check that the texture gets created with the right sampler settings. EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) @@ -2372,7 +2378,7 @@ TEST_P(ResourceProviderTest, ManagedResource) { size, GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, format); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); EXPECT_CALL(*context, @@ -2419,12 +2425,70 @@ TEST_P(ResourceProviderTest, TextureWrapMode) { for (int texture_id = 1; texture_id <= 2; ++texture_id) { GLint wrap_mode = texture_id == 1 ? GL_CLAMP_TO_EDGE : GL_REPEAT; // Check that the texture gets created with the right sampler settings. + ResourceProvider::ResourceId id = resource_provider->CreateGLTexture( + size, + GL_TEXTURE_2D, + texture_pool, + wrap_mode, + ResourceProvider::TextureHintImmutable, + format); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); + EXPECT_CALL(*context, + texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); + EXPECT_CALL(*context, + texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); + EXPECT_CALL(*context, + texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode)); + EXPECT_CALL(*context, + texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode)); + EXPECT_CALL(*context, + texParameteri(GL_TEXTURE_2D, + GL_TEXTURE_POOL_CHROMIUM, + GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); + resource_provider->CreateForTesting(id); + EXPECT_NE(0u, id); + + Mock::VerifyAndClearExpectations(context); + } +} + +TEST_P(ResourceProviderTest, TextureHint) { + // Sampling is only supported for GL textures. + if (GetParam() != ResourceProvider::GLTexture) + return; + + scoped_ptr<TextureStateTrackingContext> context_owned( + new TextureStateTrackingContext); + TextureStateTrackingContext* context = context_owned.get(); + context->set_support_texture_storage(true); + context->set_support_texture_usage(true); + + FakeOutputSurfaceClient output_surface_client; + scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( + context_owned.PassAs<TestWebGraphicsContext3D>())); + CHECK(output_surface->BindToClient(&output_surface_client)); + + scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( + output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); + + gfx::Size size(1, 1); + ResourceFormat format = RGBA_8888; + GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; + + const ResourceProvider::TextureHint hints[4] = { + ResourceProvider::TextureHintDefault, + ResourceProvider::TextureHintImmutable, + ResourceProvider::TextureHintFramebuffer, + ResourceProvider::TextureHintImmutableFramebuffer, + }; + for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { + // Check that the texture gets created with the right sampler settings. ResourceProvider::ResourceId id = resource_provider->CreateGLTexture(size, GL_TEXTURE_2D, texture_pool, - wrap_mode, - ResourceProvider::TextureUsageAny, + GL_CLAMP_TO_EDGE, + hints[texture_id - 1], format); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); EXPECT_CALL(*context, @@ -2433,14 +2497,22 @@ TEST_P(ResourceProviderTest, TextureWrapMode) { texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); EXPECT_CALL( *context, - texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode)); + texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); EXPECT_CALL( *context, - texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode)); + texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); + // Check only TextureHintFramebuffer set GL_TEXTURE_USAGE_ANGLE. + bool is_framebuffer_hint = + hints[texture_id - 1] & ResourceProvider::TextureHintFramebuffer; + EXPECT_CALL(*context, + texParameteri(GL_TEXTURE_2D, + GL_TEXTURE_USAGE_ANGLE, + GL_FRAMEBUFFER_ATTACHMENT_ANGLE)) + .Times(is_framebuffer_hint ? 1 : 0); resource_provider->CreateForTesting(id); EXPECT_NE(0u, id); @@ -2823,7 +2895,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { // Lazy allocation. Don't allocate when creating the resource. id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); @@ -2836,7 +2908,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { // Do allocate when we set the pixels. id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); @@ -2851,7 +2923,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { // Same for async version. id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); resource_provider->AcquirePixelRasterBuffer(id); EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); @@ -2869,44 +2941,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { Mock::VerifyAndClearExpectations(context); } -TEST_P(ResourceProviderTest, TextureAllocationStorageUsageAny) { - // Only for GL textures. - if (GetParam() != ResourceProvider::GLTexture) - return; - scoped_ptr<AllocationTrackingContext3D> context_owned( - new StrictMock<AllocationTrackingContext3D>); - AllocationTrackingContext3D* context = context_owned.get(); - context->set_support_texture_storage(true); - - FakeOutputSurfaceClient output_surface_client; - scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( - context_owned.PassAs<TestWebGraphicsContext3D>())); - CHECK(output_surface->BindToClient(&output_surface_client)); - - scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( - output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); - - gfx::Size size(2, 2); - ResourceFormat format = RGBA_8888; - ResourceProvider::ResourceId id = 0; - int texture_id = 123; - - // Lazy allocation. Don't allocate when creating the resource. - id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); - - EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); - EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)).Times(1); - resource_provider->AllocateForTesting(id); - - EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); - resource_provider->DeleteResource(id); - - Mock::VerifyAndClearExpectations(context); -} - -TEST_P(ResourceProviderTest, TextureAllocationStorageUsageFramebuffer) { +TEST_P(ResourceProviderTest, TextureAllocationHint) { // Only for GL textures. if (GetParam() != ResourceProvider::GLTexture) return; @@ -2914,6 +2949,7 @@ TEST_P(ResourceProviderTest, TextureAllocationStorageUsageFramebuffer) { new StrictMock<AllocationTrackingContext3D>); AllocationTrackingContext3D* context = context_owned.get(); context->set_support_texture_storage(true); + context->set_support_texture_usage(true); FakeOutputSurfaceClient output_surface_client; scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( @@ -2925,25 +2961,33 @@ TEST_P(ResourceProviderTest, TextureAllocationStorageUsageFramebuffer) { gfx::Size size(2, 2); ResourceFormat format = RGBA_8888; - ResourceProvider::ResourceId id = 0; - int texture_id = 123; - // Lazy allocation. Don't allocate when creating the resource. - id = resource_provider->CreateResource( - size, - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageFramebuffer, - format); - - EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); - EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); - EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); - resource_provider->AllocateForTesting(id); + const ResourceProvider::TextureHint hints[4] = { + ResourceProvider::TextureHintDefault, + ResourceProvider::TextureHintImmutable, + ResourceProvider::TextureHintFramebuffer, + ResourceProvider::TextureHintImmutableFramebuffer, + }; + for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { + // Lazy allocation. Don't allocate when creating the resource. + ResourceProvider::ResourceId id = resource_provider->CreateResource( + size, GL_CLAMP_TO_EDGE, hints[texture_id - 1], format); + + EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); + EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); + bool is_immutable_hint = + hints[texture_id - 1] & ResourceProvider::TextureHintImmutable; + EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)) + .Times(is_immutable_hint ? 1 : 0); + EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)) + .Times(is_immutable_hint ? 0 : 1); + resource_provider->AllocateForTesting(id); - EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); - resource_provider->DeleteResource(id); + EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); + resource_provider->DeleteResource(id); - Mock::VerifyAndClearExpectations(context); + Mock::VerifyAndClearExpectations(context); + } } TEST_P(ResourceProviderTest, PixelBuffer_GLTexture) { @@ -2967,7 +3011,7 @@ TEST_P(ResourceProviderTest, PixelBuffer_GLTexture) { output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); resource_provider->AcquirePixelRasterBuffer(id); EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); @@ -3008,7 +3052,7 @@ TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) { output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); resource_provider->AcquirePixelRasterBuffer(id); EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); @@ -3051,7 +3095,7 @@ TEST_P(ResourceProviderTest, PixelBufferLostContext) { EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id)); id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); @@ -3088,7 +3132,7 @@ TEST_P(ResourceProviderTest, Image_GLTexture) { output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); const int kStride = 4; void* dummy_mapped_buffer_address = NULL; @@ -3182,7 +3226,7 @@ TEST_P(ResourceProviderTest, Image_Bitmap) { output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); SkBitmap bitmap; bitmap.allocN32Pixels(size.width(), size.height()); @@ -3230,7 +3274,7 @@ TEST_P(ResourceProviderTest, CopyResource_GLTexture) { output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); source_id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); const int kStride = 4; void* dummy_mapped_buffer_address = NULL; @@ -3257,7 +3301,7 @@ TEST_P(ResourceProviderTest, CopyResource_GLTexture) { Mock::VerifyAndClearExpectations(context); dest_id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); EXPECT_CALL(*context, NextTextureId()) .WillOnce(Return(kDestTextureId)) @@ -3308,7 +3352,7 @@ TEST_P(ResourceProviderTest, CopyResource_Bitmap) { output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); source_id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); SkBitmap bitmap; bitmap.allocN32Pixels(size.width(), size.height()); @@ -3319,7 +3363,7 @@ TEST_P(ResourceProviderTest, CopyResource_Bitmap) { resource_provider->UnmapImageRasterBuffer(source_id); dest_id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); resource_provider->CopyResource(source_id, dest_id); @@ -3406,7 +3450,7 @@ TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { int texture_id = 123; ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); EXPECT_NE(0u, id); EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); @@ -3442,7 +3486,7 @@ TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) { uint8_t pixels[8]; ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, ETC1); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, ETC1); EXPECT_NE(0u, id); EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); @@ -3500,7 +3544,7 @@ TEST(ResourceProviderTest, TextureAllocationChunkSize) { false)); ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); resource_provider->AllocateForTesting(id); Mock::VerifyAndClearExpectations(context); @@ -3519,7 +3563,7 @@ TEST(ResourceProviderTest, TextureAllocationChunkSize) { false)); ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format); + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); resource_provider->AllocateForTesting(id); Mock::VerifyAndClearExpectations(context); diff --git a/cc/resources/scoped_resource.cc b/cc/resources/scoped_resource.cc index 68ae59f..407de51 100644 --- a/cc/resources/scoped_resource.cc +++ b/cc/resources/scoped_resource.cc @@ -16,7 +16,7 @@ ScopedResource::~ScopedResource() { } void ScopedResource::Allocate(const gfx::Size& size, - ResourceProvider::TextureUsageHint hint, + ResourceProvider::TextureHint hint, ResourceFormat format) { DCHECK(!id()); DCHECK(!size.IsEmpty()); @@ -41,7 +41,7 @@ void ScopedResource::AllocateManaged(const gfx::Size& size, size, target, GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, format)); #if DCHECK_IS_ON diff --git a/cc/resources/scoped_resource.h b/cc/resources/scoped_resource.h index 9f58395..f2c1a0d 100644 --- a/cc/resources/scoped_resource.h +++ b/cc/resources/scoped_resource.h @@ -26,7 +26,7 @@ class CC_EXPORT ScopedResource : public Resource { virtual ~ScopedResource(); void Allocate(const gfx::Size& size, - ResourceProvider::TextureUsageHint hint, + ResourceProvider::TextureHint hint, ResourceFormat format); void AllocateManaged(const gfx::Size& size, GLenum target, diff --git a/cc/resources/scoped_resource_unittest.cc b/cc/resources/scoped_resource_unittest.cc index 5042221..5b5f143 100644 --- a/cc/resources/scoped_resource_unittest.cc +++ b/cc/resources/scoped_resource_unittest.cc @@ -45,9 +45,8 @@ TEST(ScopedResourceTest, CreateScopedResource) { output_surface.get(), shared_bitmap_manager.get(), 0, false, 1, false)); scoped_ptr<ScopedResource> texture = ScopedResource::Create(resource_provider.get()); - texture->Allocate(gfx::Size(30, 30), - ResourceProvider::TextureUsageAny, - RGBA_8888); + texture->Allocate( + gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); // The texture has an allocated byte-size now. size_t expected_bytes = 30 * 30 * 4; @@ -72,9 +71,8 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted) { ScopedResource::Create(resource_provider.get()); EXPECT_EQ(0u, resource_provider->num_resources()); - texture->Allocate(gfx::Size(30, 30), - ResourceProvider::TextureUsageAny, - RGBA_8888); + texture->Allocate( + gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); EXPECT_LT(0u, texture->id()); EXPECT_EQ(1u, resource_provider->num_resources()); } @@ -84,9 +82,8 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted) { scoped_ptr<ScopedResource> texture = ScopedResource::Create(resource_provider.get()); EXPECT_EQ(0u, resource_provider->num_resources()); - texture->Allocate(gfx::Size(30, 30), - ResourceProvider::TextureUsageAny, - RGBA_8888); + texture->Allocate( + gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); EXPECT_LT(0u, texture->id()); EXPECT_EQ(1u, resource_provider->num_resources()); texture->Free(); @@ -108,9 +105,8 @@ TEST(ScopedResourceTest, LeakScopedResource) { ScopedResource::Create(resource_provider.get()); EXPECT_EQ(0u, resource_provider->num_resources()); - texture->Allocate(gfx::Size(30, 30), - ResourceProvider::TextureUsageAny, - RGBA_8888); + texture->Allocate( + gfx::Size(30, 30), ResourceProvider::TextureHintImmutable, RGBA_8888); EXPECT_LT(0u, texture->id()); EXPECT_EQ(1u, resource_provider->num_resources()); diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc index bf72b45..836f2ce 100644 --- a/cc/resources/video_resource_updater.cc +++ b/cc/resources/video_resource_updater.cc @@ -193,11 +193,11 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( if (resource_id == 0) { // TODO(danakj): Abstract out hw/sw resource create/delete from // ResourceProvider and stop using ResourceProvider in this class. - resource_id = - resource_provider_->CreateResource(output_plane_resource_size, - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - output_resource_format); + resource_id = resource_provider_->CreateResource( + output_plane_resource_size, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + output_resource_format); DCHECK(mailbox.IsZero()); diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc index 9b04370..a62f3ff 100644 --- a/cc/test/render_pass_test_common.cc +++ b/cc/test/render_pass_test_common.cc @@ -34,43 +34,43 @@ void TestRenderPass::AppendOneOfEveryQuadType( ResourceProvider::ResourceId resource1 = resource_provider->CreateResource( gfx::Size(45, 5), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource1); ResourceProvider::ResourceId resource2 = resource_provider->CreateResource( gfx::Size(346, 61), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource2); ResourceProvider::ResourceId resource3 = resource_provider->CreateResource( gfx::Size(12, 134), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource3); ResourceProvider::ResourceId resource4 = resource_provider->CreateResource( gfx::Size(56, 12), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource4); ResourceProvider::ResourceId resource5 = resource_provider->CreateResource( gfx::Size(73, 26), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource5); ResourceProvider::ResourceId resource6 = resource_provider->CreateResource( gfx::Size(64, 92), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource6); ResourceProvider::ResourceId resource7 = resource_provider->CreateResource( gfx::Size(9, 14), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource7); @@ -231,12 +231,11 @@ void TestRenderPass::AppendOneOfEveryQuadType( ResourceProvider::ResourceId plane_resources[4]; for (int i = 0; i < 4; ++i) { - plane_resources[i] = - resource_provider->CreateResource( - gfx::Size(20, 12), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + plane_resources[i] = resource_provider->CreateResource( + gfx::Size(20, 12), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureHintImmutable, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(plane_resources[i]); } YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h index abdb8c1..a7d5e0b 100644 --- a/cc/test/test_web_graphics_context_3d.h +++ b/cc/test/test_web_graphics_context_3d.h @@ -307,6 +307,9 @@ class TestWebGraphicsContext3D { void set_support_texture_storage(bool support) { test_capabilities_.gpu.texture_storage = support; } + void set_support_texture_usage(bool support) { + test_capabilities_.gpu.texture_usage = support; + } void set_support_sync_query(bool support) { test_capabilities_.gpu.sync_query = support; } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index f04a96c..e39fee0 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -3304,11 +3304,11 @@ void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, format = ETC1; break; } - id = resource_provider_->CreateResource( - bitmap.GetSize(), - wrap_mode, - ResourceProvider::TextureUsageAny, - format); + id = + resource_provider_->CreateResource(bitmap.GetSize(), + wrap_mode, + ResourceProvider::TextureHintImmutable, + format); UIResourceData data; data.resource_id = id; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 5a83a01..16f59c2 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -3577,7 +3577,7 @@ class BlendStateCheckLayer : public LayerImpl { resource_id_(resource_provider->CreateResource( gfx::Size(1, 1), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, RGBA_8888)) { resource_provider->AllocateForTesting(resource_id_); SetBounds(gfx::Size(10, 10)); diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index 8fd9743..d27e25f 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc @@ -724,7 +724,7 @@ class LayerTreeHostContextTestDontUseLostResources child_resource_provider_->CreateResource( gfx::Size(4, 4), GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, + ResourceProvider::TextureHintImmutable, RGBA_8888); ResourceProvider::ScopedWriteLockGL lock(child_resource_provider_.get(), resource); |