Index: cc/resources/resource_provider.cc |
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc |
index 506d1d97954cd14f49c1a8422c5987a6519288c3..447db2968a5d638b42259495e2d623e575cf76c3 100644 |
--- a/cc/resources/resource_provider.cc |
+++ b/cc/resources/resource_provider.cc |
@@ -368,6 +368,29 @@ ResourceProvider::~ResourceProvider() { |
gl->Finish(); |
} |
+bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const { |
+ const ContextProvider::Capabilities& caps = |
+ output_surface_->context_provider()->ContextCapabilities(); |
+ |
+ switch (format) { |
+ case ALPHA_8: |
+ case RGBA_4444: |
+ case RGBA_8888: |
+ case RGB_565: |
+ case LUMINANCE_8: |
+ return true; |
+ case BGRA_8888: |
+ return caps.gpu.texture_format_bgra8888; |
+ case ETC1: |
+ return caps.gpu.texture_format_etc1; |
+ case RED_8: |
+ return caps.gpu.texture_rg; |
+ } |
+ |
+ NOTREACHED(); |
+ return false; |
+} |
+ |
bool ResourceProvider::InUseByConsumer(ResourceId id) { |
Resource* resource = GetResource(id); |
return resource->lock_for_read_count > 0 || resource->exported_count > 0 || |
@@ -1503,7 +1526,6 @@ void ResourceProvider::LazyAllocate(Resource* resource) { |
LazyCreate(resource); |
if (!resource->gl_id) |
return; |
- resource->allocated = true; |
GLES2Interface* gl = ContextGL(); |
gfx::Size& size = resource->size; |
ResourceFormat format = resource->format; |
@@ -1523,12 +1545,14 @@ void ResourceProvider::LazyAllocate(Resource* resource) { |
GLenum storage_format = TextureToStorageFormat(format); |
gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), |
size.height()); |
+ resource->allocated = true; |
} else { |
// ETC1 does not support preallocation. |
if (format != ETC1) { |
gl->TexImage2D(resource->target, 0, GLInternalFormat(format), |
size.width(), size.height(), 0, GLDataFormat(format), |
GLDataType(format), NULL); |
+ resource->allocated = true; |
} |
} |
} |