summaryrefslogtreecommitdiffstats
path: root/cc/resources
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-05 15:30:16 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-05 15:30:16 +0000
commitefa4841b71067fdadf7ab1012f8eb6a0ffef50e4 (patch)
treec1669f190250db8368c75cd10810b949e12f26e9 /cc/resources
parentf5073b6aad9eaec6f9235baf1446c4c9cf3d0d05 (diff)
downloadchromium_src-efa4841b71067fdadf7ab1012f8eb6a0ffef50e4.zip
chromium_src-efa4841b71067fdadf7ab1012f8eb6a0ffef50e4.tar.gz
chromium_src-efa4841b71067fdadf7ab1012f8eb6a0ffef50e4.tar.bz2
[cc] Allow resources and ui resources to specify wrap mode
All textures are currently GL_CLAMP_TO_EDGE. This is good for tiles, but not good for the background linen texture, which needs to be repeated. Add a mechanism to specify the texture wrap mode. BUG=133097 Review URL: https://chromiumcodereview.appspot.com/22529002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources')
-rw-r--r--cc/resources/prioritized_resource_manager.cc2
-rw-r--r--cc/resources/resource_pool.cc1
-rw-r--r--cc/resources/resource_provider.cc86
-rw-r--r--cc/resources/resource_provider.h13
-rw-r--r--cc/resources/resource_provider_unittest.cc84
-rw-r--r--cc/resources/scoped_resource.cc3
-rw-r--r--cc/resources/ui_resource_bitmap.cc2
-rw-r--r--cc/resources/ui_resource_bitmap.h7
-rw-r--r--cc/resources/video_resource_updater.cc1
9 files changed, 147 insertions, 52 deletions
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());