Index: cc/resources/resource_provider.cc |
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc |
index 6d6ac9d839871002e9facb7e84546a56bd32be29..c899891c51f4bcec14a7e76b170a74e181fc543c 100644 |
--- a/cc/resources/resource_provider.cc |
+++ b/cc/resources/resource_provider.cc |
@@ -57,10 +57,6 @@ unsigned CreateTextureId(WebGraphicsContext3D* context3d) { |
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; |
} |
@@ -87,6 +83,7 @@ ResourceProvider::Resource::Resource() |
filter(0), |
image_id(0), |
texture_pool(0), |
+ wrap_mode(0), |
hint(TextureUsageAny), |
type(static_cast<ResourceType>(0)) {} |
@@ -98,6 +95,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), |
@@ -119,11 +117,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), |
@@ -144,8 +149,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() {} |
@@ -197,8 +205,8 @@ ResourceProvider::ResourceId ResourceProvider::CreateResource( |
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, |
+ GL_CLAMP_TO_EDGE, hint); |
case Bitmap: |
DCHECK(format == GL_RGBA); |
return CreateBitmap(size); |
@@ -215,8 +223,8 @@ ResourceProvider::ResourceId ResourceProvider::CreateManagedResource( |
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, |
+ GL_CLAMP_TO_EDGE, hint); |
case Bitmap: |
DCHECK(format == GL_RGBA); |
return CreateBitmap(size); |
@@ -229,13 +237,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 +259,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 +284,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 +300,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; |
@@ -880,7 +894,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; |
@@ -1279,6 +1294,10 @@ void ResourceProvider::LazyCreate(Resource* resource) { |
DCHECK(context3d); |
// Create and set texture properties. Allocation is delayed until needed. |
resource->gl_id = CreateTextureId(context3d); |
+ GLC(context3d, context3d->texParameteri( |
+ GL_TEXTURE_2D, GL_TEXTURE_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)); |