diff options
-rw-r--r-- | cc/layers/painted_scrollbar_layer.cc | 1 | ||||
-rw-r--r-- | cc/output/gl_renderer.cc | 1 | ||||
-rw-r--r-- | cc/output/gl_renderer_unittest.cc | 1 | ||||
-rw-r--r-- | cc/output/renderer_pixeltest.cc | 7 | ||||
-rw-r--r-- | cc/output/software_renderer_unittest.cc | 9 | ||||
-rw-r--r-- | cc/resources/prioritized_resource_manager.cc | 2 | ||||
-rw-r--r-- | cc/resources/resource_pool.cc | 1 | ||||
-rw-r--r-- | cc/resources/resource_provider.cc | 86 | ||||
-rw-r--r-- | cc/resources/resource_provider.h | 13 | ||||
-rw-r--r-- | cc/resources/resource_provider_unittest.cc | 84 | ||||
-rw-r--r-- | cc/resources/scoped_resource.cc | 3 | ||||
-rw-r--r-- | cc/resources/ui_resource_bitmap.cc | 2 | ||||
-rw-r--r-- | cc/resources/ui_resource_bitmap.h | 7 | ||||
-rw-r--r-- | cc/resources/video_resource_updater.cc | 1 | ||||
-rw-r--r-- | cc/test/fake_scoped_ui_resource.cc | 5 | ||||
-rw-r--r-- | cc/test/render_pass_test_common.cc | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 11 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 12 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_context.cc | 1 |
20 files changed, 197 insertions, 59 deletions
diff --git a/cc/layers/painted_scrollbar_layer.cc b/cc/layers/painted_scrollbar_layer.cc index 4cc7bf8..f5795de 100644 --- a/cc/layers/painted_scrollbar_layer.cc +++ b/cc/layers/painted_scrollbar_layer.cc @@ -218,6 +218,7 @@ scoped_refptr<UIResourceBitmap> PaintedScrollbarLayer::RasterizeScrollbarPart( scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create(new uint8_t[rect.width() * rect.height() * 4], UIResourceBitmap::RGBA8, + UIResourceBitmap::CLAMP_TO_EDGE, rect.size()); SkBitmap skbitmap; diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 35cca80..f7e3a23 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -1706,6 +1706,7 @@ void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, quad->texture_size, GL_RGBA, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); } diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index 7687b55..75b8277 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -1195,6 +1195,7 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { cc::ResourceProvider::ResourceId mask = resource_provider_->CreateResource(gfx::Size(20, 12), resource_provider_->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider_->AllocateForTesting(mask); diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc index cd74e50..daa5039 100644 --- a/cc/output/renderer_pixeltest.cc +++ b/cc/output/renderer_pixeltest.cc @@ -112,7 +112,8 @@ scoped_ptr<TextureDrawQuad> CreateTestTextureDrawQuad( std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color); ResourceProvider::ResourceId resource = resource_provider->CreateResource( - rect.size(), GL_RGBA, ResourceProvider::TextureUsageAny); + rect.size(), GL_RGBA, GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny); resource_provider->SetPixels( resource, reinterpret_cast<uint8_t*>(&pixels.front()), @@ -409,22 +410,26 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest { resource_provider_->CreateResource( this->device_viewport_size_, GL_LUMINANCE, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); ResourceProvider::ResourceId u_resource = resource_provider_->CreateResource( this->device_viewport_size_, GL_LUMINANCE, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); ResourceProvider::ResourceId v_resource = resource_provider_->CreateResource( this->device_viewport_size_, GL_LUMINANCE, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); ResourceProvider::ResourceId a_resource = 0; if (with_alpha) { a_resource = resource_provider_->CreateResource( this->device_viewport_size_, GL_LUMINANCE, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); } diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc index 6125fb6..b8a5b21 100644 --- a/cc/output/software_renderer_unittest.cc +++ b/cc/output/software_renderer_unittest.cc @@ -146,10 +146,12 @@ TEST_F(SoftwareRendererTest, TileQuad) { ResourceProvider::ResourceId resource_yellow = resource_provider()->CreateResource( - outer_size, GL_RGBA, ResourceProvider::TextureUsageAny); + outer_size, GL_RGBA, GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny); ResourceProvider::ResourceId resource_cyan = resource_provider()->CreateResource( - inner_size, GL_RGBA, ResourceProvider::TextureUsageAny); + inner_size, GL_RGBA, GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny); SkBitmap yellow_tile; yellow_tile.setConfig( @@ -232,7 +234,8 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { ResourceProvider::ResourceId resource_cyan = resource_provider()->CreateResource( - tile_size, GL_RGBA, ResourceProvider::TextureUsageAny); + tile_size, GL_RGBA, GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny); SkBitmap cyan_tile; // The lowest five rows are yellow. cyan_tile.setConfig( diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc index 8118885..e0b5dca 100644 --- a/cc/resources/prioritized_resource_manager.cc +++ b/cc/resources/prioritized_resource_manager.cc @@ -455,7 +455,7 @@ PrioritizedResource::Backing* PrioritizedResourceManager::CreateBacking( DCHECK(resource_provider); ResourceProvider::ResourceId resource_id = resource_provider->CreateManagedResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); PrioritizedResource::Backing* backing = new PrioritizedResource::Backing( resource_id, resource_provider, size, format); memory_use_bytes_ += backing->bytes(); diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index afcc114..75f7d1e 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -14,6 +14,7 @@ ResourcePool::Resource::Resource(cc::ResourceProvider* resource_provider, : cc::Resource(resource_provider->CreateManagedResource( size, format, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny), size, format), diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 9779a54..850e02a 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -54,21 +54,6 @@ bool IsTextureFormatSupportedForStorage(GLenum format) { return (format == GL_RGBA || format == GL_BGRA_EXT); } -unsigned CreateTextureId(WebGraphicsContext3D* context3d) { - unsigned texture_id = 0; - GLC(context3d, texture_id = context3d->createTexture()); - GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, texture_id)); - GLC(context3d, context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); - GLC(context3d, context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); - GLC(context3d, context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); - GLC(context3d, context3d->texParameteri( - GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); - return texture_id; -} - } // namespace ResourceProvider::Resource::Resource() @@ -93,6 +78,7 @@ ResourceProvider::Resource::Resource() filter(0), image_id(0), texture_pool(0), + wrap_mode(0), hint(TextureUsageAny), type(static_cast<ResourceType>(0)) {} @@ -104,6 +90,7 @@ ResourceProvider::Resource::Resource( GLenum format, GLenum filter, GLenum texture_pool, + GLint wrap_mode, TextureUsageHint hint) : gl_id(texture_id), gl_pixel_buffer_id(0), @@ -126,11 +113,18 @@ ResourceProvider::Resource::Resource( filter(filter), image_id(0), texture_pool(texture_pool), + wrap_mode(wrap_mode), hint(hint), - type(GLTexture) {} + type(GLTexture) { + DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); +} ResourceProvider::Resource::Resource( - uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter) + uint8_t* pixels, + gfx::Size size, + GLenum format, + GLenum filter, + GLint wrap_mode) : gl_id(0), gl_pixel_buffer_id(0), gl_upload_query_id(0), @@ -152,8 +146,11 @@ ResourceProvider::Resource::Resource( filter(filter), image_id(0), texture_pool(0), + wrap_mode(wrap_mode), hint(TextureUsageAny), - type(Bitmap) {} + type(Bitmap) { + DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); +} ResourceProvider::Child::Child() {} @@ -193,13 +190,16 @@ bool ResourceProvider::InUseByConsumer(ResourceId id) { } ResourceProvider::ResourceId ResourceProvider::CreateResource( - gfx::Size size, GLenum format, TextureUsageHint hint) { + gfx::Size size, GLenum format, GLint wrap_mode, TextureUsageHint hint) { DCHECK(!size.IsEmpty()); switch (default_resource_type_) { case GLTexture: - return CreateGLTexture( - size, format, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, hint); + return CreateGLTexture(size, format, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, + wrap_mode, hint); case Bitmap: + // The only wrap_mode currently implemented in software mode is + // GL_CLAMP_TO_EDGE. + // http://crbug.com/284796 DCHECK(format == GL_RGBA); return CreateBitmap(size); case InvalidType: @@ -211,12 +211,12 @@ ResourceProvider::ResourceId ResourceProvider::CreateResource( } ResourceProvider::ResourceId ResourceProvider::CreateManagedResource( - gfx::Size size, GLenum format, TextureUsageHint hint) { + gfx::Size size, GLenum format, GLint wrap_mode, TextureUsageHint hint) { DCHECK(!size.IsEmpty()); switch (default_resource_type_) { case GLTexture: - return CreateGLTexture( - size, format, GL_TEXTURE_POOL_MANAGED_CHROMIUM, hint); + return CreateGLTexture(size, format, GL_TEXTURE_POOL_MANAGED_CHROMIUM, + wrap_mode, hint); case Bitmap: DCHECK(format == GL_RGBA); return CreateBitmap(size); @@ -229,13 +229,17 @@ ResourceProvider::ResourceId ResourceProvider::CreateManagedResource( } ResourceProvider::ResourceId ResourceProvider::CreateGLTexture( - gfx::Size size, GLenum format, GLenum texture_pool, TextureUsageHint hint) { + gfx::Size size, + GLenum format, + GLenum texture_pool, + GLint wrap_mode, + TextureUsageHint hint) { DCHECK_LE(size.width(), max_texture_size_); DCHECK_LE(size.height(), max_texture_size_); DCHECK(thread_checker_.CalledOnValidThread()); ResourceId id = next_id_++; - Resource resource(0, size, format, GL_LINEAR, texture_pool, hint); + Resource resource(0, size, format, GL_LINEAR, texture_pool, wrap_mode, hint); resource.allocated = false; resources_[id] = resource; return id; @@ -247,7 +251,7 @@ ResourceProvider::ResourceId ResourceProvider::CreateBitmap(gfx::Size size) { uint8_t* pixels = new uint8_t[4 * size.GetArea()]; ResourceId id = next_id_++; - Resource resource(pixels, size, GL_RGBA, GL_LINEAR); + Resource resource(pixels, size, GL_RGBA, GL_LINEAR, GL_CLAMP_TO_EDGE); resource.allocated = true; resources_[id] = resource; return id; @@ -272,7 +276,8 @@ 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, 0, TextureUsageAny); + Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR, 0, GL_CLAMP_TO_EDGE, + TextureUsageAny); resource.external = true; resource.allocated = true; resources_[id] = resource; @@ -287,14 +292,15 @@ ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( DCHECK(mailbox.IsValid()); Resource& resource = resources_[id]; if (mailbox.IsTexture()) { - resource = Resource(0, gfx::Size(), 0, GL_LINEAR, 0, TextureUsageAny); + resource = Resource(0, gfx::Size(), 0, GL_LINEAR, 0, GL_CLAMP_TO_EDGE, + TextureUsageAny); } else { DCHECK(mailbox.IsSharedMemory()); base::SharedMemory* shared_memory = mailbox.shared_memory(); DCHECK(shared_memory->memory()); uint8_t* pixels = reinterpret_cast<uint8_t*>(shared_memory->memory()); resource = Resource(pixels, mailbox.shared_memory_size(), - GL_RGBA, GL_LINEAR); + GL_RGBA, GL_LINEAR, GL_CLAMP_TO_EDGE); } resource.external = true; resource.allocated = true; @@ -884,7 +890,8 @@ void ResourceProvider::ReceiveFromChild( it->mailbox.name)); ResourceId id = next_id_++; Resource resource( - texture_id, it->size, it->format, it->filter, 0, TextureUsageAny); + texture_id, it->size, it->format, it->filter, 0, GL_CLAMP_TO_EDGE, + TextureUsageAny); resource.mailbox.SetName(it->mailbox); // Don't allocate a texture for a child. resource.allocated = true; @@ -1242,6 +1249,11 @@ void ResourceProvider::CreateForTesting(ResourceId id) { LazyCreate(GetResource(id)); } +GLint ResourceProvider::WrapModeForTesting(ResourceId id) { + Resource* resource = GetResource(id); + return resource->wrap_mode; +} + void ResourceProvider::LazyCreate(Resource* resource) { if (resource->type != GLTexture || resource->gl_id != 0) return; @@ -1252,8 +1264,18 @@ void ResourceProvider::LazyCreate(Resource* resource) { WebGraphicsContext3D* context3d = Context3d(); DCHECK(context3d); + // Create and set texture properties. Allocation is delayed until needed. - resource->gl_id = CreateTextureId(context3d); + GLC(context3d, resource->gl_id = context3d->createTexture()); + GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); + GLC(context3d, context3d->texParameteri( + GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); + GLC(context3d, context3d->texParameteri( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); + GLC(context3d, context3d->texParameteri( + GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, resource->wrap_mode)); + GLC(context3d, context3d->texParameteri( + GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, resource->wrap_mode)); GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, resource->texture_pool)); diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index 412c92b..e2d7878 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h @@ -79,18 +79,21 @@ class CC_EXPORT ResourceProvider { // Creates a resource of the default resource type. ResourceId CreateResource(gfx::Size size, GLenum format, + GLint wrap_mode, TextureUsageHint hint); // Creates a resource which is tagged as being managed for GPU memory // accounting purposes. ResourceId CreateManagedResource(gfx::Size size, GLenum format, + GLint wrap_mode, TextureUsageHint hint); // You can also explicitly create a specific resource type. ResourceId CreateGLTexture(gfx::Size size, GLenum format, GLenum texture_pool, + GLint wrap_mode, TextureUsageHint hint); ResourceId CreateBitmap(gfx::Size size); @@ -310,6 +313,8 @@ class CC_EXPORT ResourceProvider { // For tests only! void CreateForTesting(ResourceId id); + GLint WrapModeForTesting(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. @@ -335,8 +340,13 @@ class CC_EXPORT ResourceProvider { GLenum format, GLenum filter, GLenum texture_pool, + GLint wrap_mode, TextureUsageHint hint); - Resource(uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter); + Resource(uint8_t* pixels, + gfx::Size size, + GLenum format, + GLenum filter, + GLint wrap_mode); unsigned gl_id; // Pixel buffer used for set pixels without unnecessary copying. @@ -363,6 +373,7 @@ class CC_EXPORT ResourceProvider { GLenum filter; unsigned image_id; GLenum texture_pool; + GLint wrap_mode; TextureUsageHint hint; ResourceType type; }; diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index dec66d6..3f786ef 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -432,7 +432,7 @@ void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); EXPECT_EQ(1, static_cast<int>(resource_provider->num_resources())); if (expected_default_type == ResourceProvider::GLTexture) EXPECT_EQ(0, context->texture_count()); @@ -464,7 +464,7 @@ TEST_P(ResourceProviderTest, Upload) { ASSERT_EQ(16U, pixel_size); ResourceProvider::ResourceId id = resource_provider_->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); uint8_t image[16] = { 0 }; gfx::Rect image_rect(size); @@ -548,13 +548,13 @@ TEST_P(ResourceProviderTest, TransferResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); 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, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); uint8_t data2[4] = { 5, 5, 5, 5 }; child_resource_provider->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); @@ -684,7 +684,7 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id = child_resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); uint8_t data[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); @@ -747,7 +747,7 @@ TEST_P(ResourceProviderTest, TextureFilters) { ASSERT_EQ(4U, pixel_size); ResourceProvider::ResourceId id = child_resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); uint8_t data[4] = { 1, 2, 3, 4 }; gfx::Rect rect(size); child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); @@ -1114,7 +1114,7 @@ TEST_P(ResourceProviderTest, ScopedSampler) { GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); ResourceProvider::ResourceId id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(id); // Creating a sampler with the default filter should not change any texture @@ -1175,7 +1175,7 @@ TEST_P(ResourceProviderTest, ManagedResource) { // Check that the texture gets created with the right sampler settings. ResourceProvider::ResourceId id = resource_provider->CreateManagedResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); @@ -1197,6 +1197,56 @@ TEST_P(ResourceProviderTest, ManagedResource) { Mock::VerifyAndClearExpectations(context); } +TEST_P(ResourceProviderTest, TextureWrapMode) { + // Sampling is only supported for GL textures. + if (GetParam() != ResourceProvider::GLTexture) + return; + + scoped_ptr<TextureStateTrackingContext> context_owned( + new TextureStateTrackingContext); + TextureStateTrackingContext* 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)); + + scoped_ptr<ResourceProvider> resource_provider( + ResourceProvider::Create(output_surface.get(), 0)); + + gfx::Size size(1, 1); + WGC3Denum format = GL_RGBA; + int texture_id = 1; + GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; + + for (int i = 0; i < 2; ++i) { + GLint wrap_mode = i ? GL_CLAMP_TO_EDGE : GL_REPEAT; + // Check that the texture gets created with the right sampler settings. + ResourceProvider::ResourceId id = resource_provider->CreateGLTexture( + size, format, texture_pool, wrap_mode, + ResourceProvider::TextureUsageAny); + 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); + } +} + static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { @@ -1445,7 +1495,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { // Lazy allocation. Don't allocate when creating the resource. id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); @@ -1458,7 +1508,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { // Do allocate when we set the pixels. id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); @@ -1473,7 +1523,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { // Same for async version. id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AcquirePixelBuffer(id); EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); @@ -1512,7 +1562,7 @@ TEST_P(ResourceProviderTest, PixelBuffer_GLTexture) { ResourceProvider::Create(output_surface.get(), 0)); id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AcquirePixelBuffer(id); EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); @@ -1549,7 +1599,7 @@ TEST_P(ResourceProviderTest, PixelBuffer_Bitmap) { ResourceProvider::Create(output_surface.get(), 0)); id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AcquirePixelBuffer(id); void* data = resource_provider->MapPixelBuffer(id); @@ -1595,7 +1645,7 @@ TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) { ResourceProvider::Create(output_surface.get(), 0)); id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AcquirePixelBuffer(id); EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); @@ -1638,7 +1688,7 @@ TEST_P(ResourceProviderTest, PixelBufferLostContext) { EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(texture_id)); id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); resource_provider->AcquirePixelBuffer(id); @@ -1674,7 +1724,7 @@ TEST_P(ResourceProviderTest, Image_GLTexture) { ResourceProvider::Create(output_surface.get(), 0)); id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); EXPECT_CALL(*context, createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES)) .WillOnce(Return(kImageId)) .RetiresOnSaturation(); @@ -1745,7 +1795,7 @@ TEST_P(ResourceProviderTest, Image_Bitmap) { ResourceProvider::Create(output_surface.get(), 0)); id = resource_provider->CreateResource( - size, format, ResourceProvider::TextureUsageAny); + size, format, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AcquireImage(id); const int kStride = 0; diff --git a/cc/resources/scoped_resource.cc b/cc/resources/scoped_resource.cc index e444eee..525fb73 100644 --- a/cc/resources/scoped_resource.cc +++ b/cc/resources/scoped_resource.cc @@ -22,7 +22,8 @@ bool ScopedResource::Allocate(gfx::Size size, DCHECK(!size.IsEmpty()); set_dimensions(size, format); - set_id(resource_provider_->CreateResource(size, format, hint)); + set_id(resource_provider_->CreateResource( + size, format, GL_CLAMP_TO_EDGE, hint)); #ifndef NDEBUG allocate_thread_id_ = base::PlatformThread::CurrentId(); diff --git a/cc/resources/ui_resource_bitmap.cc b/cc/resources/ui_resource_bitmap.cc index 8bbfb37..1510607d 100644 --- a/cc/resources/ui_resource_bitmap.cc +++ b/cc/resources/ui_resource_bitmap.cc @@ -11,10 +11,12 @@ namespace cc { scoped_refptr<UIResourceBitmap> UIResourceBitmap::Create(uint8_t* pixels, UIResourceFormat format, + UIResourceWrapMode wrap_mode, gfx::Size size) { scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap(); ret->pixels_ = scoped_ptr<uint8_t[]>(pixels); ret->format_ = format; + ret->wrap_mode_ = wrap_mode; ret->size_ = size; return ret; diff --git a/cc/resources/ui_resource_bitmap.h b/cc/resources/ui_resource_bitmap.h index dbf7069..e1b5aee 100644 --- a/cc/resources/ui_resource_bitmap.h +++ b/cc/resources/ui_resource_bitmap.h @@ -22,14 +22,20 @@ class CC_EXPORT UIResourceBitmap enum UIResourceFormat { RGBA8 }; + enum UIResourceWrapMode { + CLAMP_TO_EDGE, + REPEAT + }; // Takes ownership of “pixels”. static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels, UIResourceFormat format, + UIResourceWrapMode wrap_mode, gfx::Size size); gfx::Size GetSize() const { return size_; } UIResourceFormat GetFormat() const { return format_; } + UIResourceWrapMode GetWrapMode() const { return wrap_mode_; } uint8_t* GetPixels() { return pixels_.get(); } private: @@ -40,6 +46,7 @@ class CC_EXPORT UIResourceBitmap scoped_ptr<uint8_t[]> pixels_; UIResourceFormat format_; + UIResourceWrapMode wrap_mode_; gfx::Size size_; DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap); diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc index 33682eb..f278c59 100644 --- a/cc/resources/video_resource_updater.cc +++ b/cc/resources/video_resource_updater.cc @@ -195,6 +195,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( resource_id = resource_provider_->CreateResource(output_plane_resource_size, output_resource_format, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); DCHECK(mailbox.IsZero()); diff --git a/cc/test/fake_scoped_ui_resource.cc b/cc/test/fake_scoped_ui_resource.cc index 02f0fa9..ce5ee11 100644 --- a/cc/test/fake_scoped_ui_resource.cc +++ b/cc/test/fake_scoped_ui_resource.cc @@ -16,7 +16,10 @@ scoped_ptr<FakeScopedUIResource> FakeScopedUIResource::Create( FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host) { ResetCounters(); bitmap_ = UIResourceBitmap::Create( - new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1)); + new uint8_t[1], + UIResourceBitmap::RGBA8, + UIResourceBitmap::CLAMP_TO_EDGE, + gfx::Size(1, 1)); host_ = host; id_ = host_->CreateUIResource(this); } diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc index 1807467..13e5c54 100644 --- a/cc/test/render_pass_test_common.cc +++ b/cc/test/render_pass_test_common.cc @@ -37,42 +37,49 @@ void TestRenderPass::AppendOneOfEveryQuadType( resource_provider->CreateResource( gfx::Size(45, 5), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource1); cc::ResourceProvider::ResourceId resource2 = resource_provider->CreateResource( gfx::Size(346, 61), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource2); cc::ResourceProvider::ResourceId resource3 = resource_provider->CreateResource( gfx::Size(12, 134), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource3); cc::ResourceProvider::ResourceId resource4 = resource_provider->CreateResource( gfx::Size(56, 12), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource4); cc::ResourceProvider::ResourceId resource5 = resource_provider->CreateResource( gfx::Size(73, 26), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource5); cc::ResourceProvider::ResourceId resource6 = resource_provider->CreateResource( gfx::Size(64, 92), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource6); cc::ResourceProvider::ResourceId resource7 = resource_provider->CreateResource( gfx::Size(9, 14), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource7); @@ -214,6 +221,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( resource_provider->CreateResource( gfx::Size(20, 12), resource_provider->best_texture_format(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(plane_resources[i]); } diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 0b47e9d..773a689 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -640,6 +640,7 @@ void LayerTreeHost::SetOverhangBitmap(const SkBitmap& bitmap) { scoped_refptr<UIResourceBitmap> overhang_ui_bitmap(UIResourceBitmap::Create( new uint8_t[bitmap.width() * bitmap.height() * bitmap.bytesPerPixel()], UIResourceBitmap::RGBA8, + UIResourceBitmap::REPEAT, gfx::Size(bitmap.width(), bitmap.height()))); bitmap.copyPixelsTo( overhang_ui_bitmap->GetPixels(), diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 5d74be4..08e4ac1 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -2601,6 +2601,16 @@ void LayerTreeHostImpl::CreateUIResource( DCHECK_GT(uid, 0); DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); + GLint wrap_mode = 0; + switch (bitmap->GetWrapMode()) { + case UIResourceBitmap::CLAMP_TO_EDGE: + wrap_mode = GL_CLAMP_TO_EDGE; + break; + case UIResourceBitmap::REPEAT: + wrap_mode = GL_REPEAT; + break; + } + // Allow for multiple creation requests with the same UIResourceId. The // previous resource is simply deleted. ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); @@ -2609,6 +2619,7 @@ void LayerTreeHostImpl::CreateUIResource( id = resource_provider_->CreateResource( bitmap->GetSize(), resource_provider_->best_texture_format(), + wrap_mode, ResourceProvider::TextureUsageAny); ui_resource_map_[uid] = id; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 1e73b31..7ae7c41 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -1509,6 +1509,7 @@ class MissingTextureAnimatingLayer : public DidDrawCheckLayer { ResourceProvider::ResourceId resource = resource_provider->CreateResource(gfx::Size(1, 1), GL_RGBA, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); resource_provider->AllocateForTesting(resource); PushTileProperties(0, 0, resource, gfx::Rect(), false); @@ -2600,6 +2601,7 @@ class BlendStateCheckLayer : public LayerImpl { resource_id_(resource_provider->CreateResource( gfx::Size(1, 1), GL_RGBA, + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny)) { resource_provider->AllocateForTesting(resource_id_); SetAnchorPoint(gfx::PointF()); @@ -3054,7 +3056,10 @@ TEST_F(LayerTreeHostImplViewportCoveredTest, ViewportCoveredOverhangBitmap) { // Specify an overhang bitmap to use. scoped_refptr<UIResourceBitmap> ui_resource_bitmap(UIResourceBitmap::Create( - new uint8_t[4], UIResourceBitmap::RGBA8, gfx::Size(1, 1))); + new uint8_t[4], + UIResourceBitmap::RGBA8, + UIResourceBitmap::REPEAT, + gfx::Size(1, 1))); UIResourceId ui_resource_id = 12345; host_impl_->CreateUIResource(ui_resource_id, ui_resource_bitmap); host_impl_->SetOverhangUIResource(ui_resource_id, gfx::Size(32, 32)); @@ -6439,7 +6444,10 @@ TEST_F(LayerTreeHostImplTest, UIResourceManagement) { UIResourceId ui_resource_id = 1; scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( - new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1)); + new uint8_t[1], + UIResourceBitmap::RGBA8, + UIResourceBitmap::CLAMP_TO_EDGE, + gfx::Size(1, 1)); host_impl_->CreateUIResource(ui_resource_id, bitmap); EXPECT_EQ(1u, context3d->NumTextures()); ResourceProvider::ResourceId id1 = diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index 16196ee..c250b0c 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc @@ -1265,6 +1265,7 @@ class LayerTreeHostContextTestDontUseLostResources ResourceProvider::ResourceId texture = resource_provider->CreateResource( gfx::Size(4, 4), resource_provider->default_resource_type(), + GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny); ResourceProvider::ScopedWriteLockGL lock(resource_provider, texture); |