Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6784)

Unified Diff: cc/resources/resource_provider.cc

Issue 27973002: cc: Adding ETC1 support to UIResourceBitmap and ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed latest comments, rebased Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 0a214a44fa283de5a3224682520448ae47397430..82ca73b800947114673d8687a1e3fb247d9f6c37 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -47,6 +47,7 @@ GLenum TextureToStorageFormat(ResourceFormat format) {
case RGBA_4444:
case LUMINANCE_8:
case RGB_565:
+ case ETC1:
NOTREACHED();
break;
}
@@ -62,6 +63,7 @@ bool IsFormatSupportedForStorage(ResourceFormat format) {
case RGBA_4444:
case LUMINANCE_8:
case RGB_565:
+ case ETC1:
return false;
}
return false;
@@ -838,6 +840,7 @@ 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_);
@@ -1264,6 +1267,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();
@@ -1596,15 +1600,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));
no sievers 2013/10/23 22:49:59 I don't think glCompressedTexImage2D() supports pa
powei 2013/10/23 23:25:58 Done. Thanks for catching that.
+ } else {
+ GLC(context3d,
+ context3d->texImage2D(GL_TEXTURE_2D,
+ 0,
+ GLInternalFormat(format),
+ size.width(),
+ size.height(),
+ 0,
+ GLDataFormat(format),
+ GLDataType(format),
+ NULL));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698