Chromium Code Reviews| Index: cc/resources/resource_provider.cc |
| diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc |
| index e7d8c130f1eb157de49a0cd3b74be87d929b2c94..bd9e07bdce664676f99985e7fd07004893b8885b 100644 |
| --- a/cc/resources/resource_provider.cc |
| +++ b/cc/resources/resource_provider.cc |
| @@ -14,6 +14,7 @@ |
| #include "cc/base/util.h" |
| #include "cc/output/gl_renderer.h" // For the GLC() macro. |
| #include "cc/resources/platform_color.h" |
| +#include "cc/resources/resource.h" |
|
kaanb
2013/10/18 16:54:49
you shouldn't need this include, isn't it already
powei
2013/10/23 05:36:15
Done.
|
| #include "cc/resources/returned_resource.h" |
| #include "cc/resources/transferable_resource.h" |
| #include "cc/scheduler/texture_uploader.h" |
| @@ -42,6 +43,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 +59,7 @@ bool IsFormatSupportedForStorage(ResourceFormat format) { |
| case RGBA_8888: |
| case BGRA_8888: |
| return true; |
| + case ETC1: |
| case RGBA_4444: |
| case LUMINANCE_8: |
| case RGB_565: |
| @@ -1390,27 +1393,52 @@ void ResourceProvider::BeginSetPixels(ResourceId id) { |
| GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, |
| resource->gl_upload_query_id); |
| if (allocate) { |
| - 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) { |
| + context3d->compressedTexImage2D( |
| + GL_TEXTURE_2D, |
| + 0, /* level */ |
| + GLInternalFormat(resource->format), |
| + resource->size.width(), |
| + resource->size.height(), |
| + 0, /* border */ |
| + cc::Resource::ETC1SizeInBytes(resource->size), |
| + NULL); |
| + } else { |
| + 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); |
| + } |
| } 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) { |
| + context3d->compressedTexSubImage2D( |
| + GL_TEXTURE_2D, |
| + 0, /* level */ |
| + 0, /* x */ |
| + 0, /* y */ |
| + resource->size.width(), |
| + resource->size.height(), |
| + GLDataFormat(resource->format), |
| + cc::Resource::ETC1SizeInBytes(resource->size), |
| + 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); |
| + } |
| } |
| context3d->endQueryEXT(GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM); |
| context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
| @@ -1540,21 +1568,33 @@ void ResourceProvider::LazyAllocate(Resource* resource) { |
| GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id)); |
| if (use_texture_storage_ext_ && IsFormatSupportedForStorage(format)) { |
| GLenum storage_format = TextureToStorageFormat(format); |
| - GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, |
| - 1, |
| - storage_format, |
| - size.width(), |
| - size.height())); |
| + GLC(context3d, |
| + context3d->texStorage2DEXT( |
|
kaanb
2013/10/18 16:54:49
please revert this block, it just changes formatti
powei
2013/10/23 05:36:15
Done.
|
| + GL_TEXTURE_2D, 1, storage_format, 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) { |
| + GLC(context3d, |
| + context3d->compressedTexImage2D( |
| + GL_TEXTURE_2D, |
| + 0, |
| + GLInternalFormat(format), |
| + size.width(), |
| + size.height(), |
| + 0, |
| + cc::Resource::ETC1SizeInBytes(resource->size), |
| + NULL)); |
| + } else { |
| + GLC(context3d, |
| + context3d->texImage2D(GL_TEXTURE_2D, |
| + 0, |
| + GLInternalFormat(format), |
| + size.width(), |
| + size.height(), |
| + 0, |
| + GLDataFormat(format), |
| + GLDataType(format), |
| + NULL)); |
| + } |
| } |
| } |