Chromium Code Reviews| Index: cc/resources/resource_provider.cc |
| diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc |
| index d76fc4b45c9516bd90a4b5b9e9817ddd18ff8a85..c6c725fb487274b8fa9ae8336019492a531ebbe8 100644 |
| --- a/cc/resources/resource_provider.cc |
| +++ b/cc/resources/resource_provider.cc |
| @@ -42,6 +42,7 @@ GLenum TextureToStorageFormat(ResourceFormat format) { |
| case BGRA_8888: |
| storage_format = GL_BGRA8_EXT; |
| break; |
| + case ETC1: |
| case RGBA_4444: |
| case LUMINANCE_8: |
| case RGB_565: |
| @@ -57,6 +58,7 @@ bool IsFormatSupportedForStorage(ResourceFormat format) { |
| case RGBA_8888: |
| case BGRA_8888: |
| return true; |
| + case ETC1: |
| case RGBA_4444: |
| case LUMINANCE_8: |
| case RGB_565: |
| @@ -803,9 +805,10 @@ bool ResourceProvider::InitializeGL() { |
| use_texture_storage_ext_ = caps.texture_storage; |
| use_shallow_flush_ = caps.shallow_flush; |
| use_texture_usage_hint_ = caps.texture_usage; |
| + use_compressed_texture_etc1_ = caps.texture_format_etc1; |
| - texture_uploader_ = |
| - TextureUploader::Create(context3d, use_map_sub, use_shallow_flush_); |
| + texture_uploader_ = TextureUploader::Create( |
| + context3d, use_map_sub, use_shallow_flush_, use_compressed_texture_etc1_); |
| GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, |
| &max_texture_size_)); |
| best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra); |
| @@ -1210,6 +1213,7 @@ void ResourceProvider::AcquirePixelBuffer(ResourceId id) { |
| DCHECK(!resource->external); |
| DCHECK_EQ(resource->exported_count, 0); |
| DCHECK(!resource->image_id); |
| + DCHECK_NE(ETC1, resource->format); |
| if (resource->type == GLTexture) { |
| WebGraphicsContext3D* context3d = Context3d(); |
| @@ -1219,7 +1223,7 @@ void ResourceProvider::AcquirePixelBuffer(ResourceId id) { |
| context3d->bindBuffer( |
| GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
| resource->gl_pixel_buffer_id); |
| - unsigned bytes_per_pixel = BytesPerPixel(resource->format); |
| + unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8; |
| context3d->bufferData( |
| GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
| resource->size.height() * RoundUp(bytes_per_pixel |
| @@ -1367,6 +1371,7 @@ void ResourceProvider::BeginSetPixels(ResourceId id) { |
| DCHECK(ReadLockFenceHasPassed(resource)); |
| DCHECK(!resource->image_id); |
| + gfx::Size& size = resource->size; |
|
aelias_OOO_until_Jul13
2013/10/23 19:54:07
Please delete the "&", it doesn't look like you're
powei
2013/10/23 22:20:07
Done.
|
| bool allocate = !resource->allocated; |
| resource->allocated = true; |
| LockForWrite(id); |
| @@ -1386,27 +1391,58 @@ void ResourceProvider::BeginSetPixels(ResourceId id) { |
| GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, |
| resource->gl_upload_query_id); |
| if (allocate) { |
|
no sievers
2013/10/23 20:33:15
I think the change in here is wrong. Don't the UI
powei
2013/10/23 22:20:07
Done. Removed. You're right. I got careless and
|
| - context3d->asyncTexImage2DCHROMIUM( |
| - GL_TEXTURE_2D, |
| - 0, /* level */ |
| - GLInternalFormat(resource->format), |
| - resource->size.width(), |
| - resource->size.height(), |
| - 0, /* border */ |
| - GLDataFormat(resource->format), |
| - GLDataType(resource->format), |
| - NULL); |
| + if (resource->format == ETC1) { |
| + DCHECK(use_compressed_texture_etc1_); |
| + DCHECK_EQ(0, size.width() % 4); |
| + DCHECK_EQ(0, size.height() % 4); |
| + context3d->compressedTexImage2D( |
| + GL_TEXTURE_2D, |
| + 0, /* level */ |
| + GLInternalFormat(resource->format), |
| + size.width(), |
| + size.height(), |
| + 0, /* border */ |
| + cc::Resource::MemorySizeBytes(size, resource->format), |
| + NULL); |
| + } else { |
| + context3d->asyncTexImage2DCHROMIUM( |
| + GL_TEXTURE_2D, |
| + 0, /* level */ |
| + GLInternalFormat(resource->format), |
| + size.width(), |
| + size.height(), |
| + 0, /* border */ |
| + GLDataFormat(resource->format), |
| + GLDataType(resource->format), |
| + NULL); |
| + } |
| } else { |
| - context3d->asyncTexSubImage2DCHROMIUM( |
| - GL_TEXTURE_2D, |
| - 0, /* level */ |
| - 0, /* x */ |
| - 0, /* y */ |
| - resource->size.width(), |
| - resource->size.height(), |
| - GLDataFormat(resource->format), |
| - GLDataType(resource->format), |
| - NULL); |
| + if (resource->format == ETC1) { |
| + DCHECK(use_compressed_texture_etc1_); |
| + DCHECK_EQ(0, size.width() % 4); |
| + DCHECK_EQ(0, size.height() % 4); |
| + context3d->compressedTexSubImage2D( |
| + GL_TEXTURE_2D, |
| + 0, /* level */ |
| + 0, /* x */ |
| + 0, /* y */ |
| + size.width(), |
| + size.height(), |
| + GLDataFormat(resource->format), |
| + cc::Resource::MemorySizeBytes(size, resource->format), |
| + NULL); |
| + } else { |
| + context3d->asyncTexSubImage2DCHROMIUM( |
| + GL_TEXTURE_2D, |
| + 0, /* level */ |
| + 0, /* x */ |
| + 0, /* y */ |
| + size.width(), |
| + size.height(), |
| + GLDataFormat(resource->format), |
| + GLDataType(resource->format), |
| + NULL); |
| + } |
| } |
| context3d->endQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM); |
| context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
| @@ -1542,15 +1578,32 @@ void ResourceProvider::LazyAllocate(Resource* resource) { |
| size.width(), |
| size.height())); |
| } else { |
| - GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, |
| - 0, |
| - GLInternalFormat(format), |
| - size.width(), |
| - size.height(), |
| - 0, |
| - GLDataFormat(format), |
| - GLDataType(format), |
| - NULL)); |
| + if (format == ETC1) { |
| + DCHECK(use_compressed_texture_etc1_); |
| + DCHECK_EQ(0, size.width() % 4); |
| + DCHECK_EQ(0, size.height() % 4); |
| + GLC(context3d, |
| + context3d->compressedTexImage2D( |
| + GL_TEXTURE_2D, |
| + 0, |
| + GLInternalFormat(format), |
| + size.width(), |
| + size.height(), |
| + 0, |
| + cc::Resource::MemorySizeBytes(size, format), |
| + NULL)); |
| + } else { |
| + GLC(context3d, |
| + context3d->texImage2D(GL_TEXTURE_2D, |
| + 0, |
| + GLInternalFormat(format), |
| + size.width(), |
| + size.height(), |
| + 0, |
| + GLDataFormat(format), |
| + GLDataType(format), |
| + NULL)); |
| + } |
| } |
| } |