Index: cc/resources/resource_provider.h |
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h |
index 3a8d2e0f9ec0325ae56e64de274f6caa3ac073a9..ee0cdad270ca143a6fe92ee4d74e085a3960cd2b 100644 |
--- a/cc/resources/resource_provider.h |
+++ b/cc/resources/resource_provider.h |
@@ -18,6 +18,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/threading/thread_checker.h" |
#include "cc/base/cc_export.h" |
+#include "cc/base/tile_compression_method.h" |
#include "cc/output/context_provider.h" |
#include "cc/output/output_surface.h" |
#include "cc/resources/release_callback_impl.h" |
@@ -86,6 +87,7 @@ class CC_EXPORT ResourceProvider { |
BlockingTaskRunner* blocking_main_thread_task_runner, |
int highp_threshold_min, |
bool use_rgba_4444_texture_format, |
+ bool use_texture_compression, |
size_t id_allocation_chunk_size); |
virtual ~ResourceProvider(); |
@@ -95,9 +97,8 @@ class CC_EXPORT ResourceProvider { |
void DidLoseOutputSurface() { lost_output_surface_ = true; } |
int max_texture_size() const { return max_texture_size_; } |
- ResourceFormat memory_efficient_texture_format() const { |
- return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
- } |
+ ResourceFormat memory_efficient_texture_format( |
+ ResourceFormatUsage usage) const; |
ResourceFormat best_texture_format() const { return best_texture_format_; } |
ResourceFormat yuv_resource_format() const { return yuv_resource_format_; } |
bool use_sync_query() const { return use_sync_query_; } |
@@ -148,6 +149,10 @@ class CC_EXPORT ResourceProvider { |
void DeleteResource(ResourceId id); |
+ void set_preferred_tile_compression_method(TileCompressionMethod method) { |
+ preferred_tile_compression_method_ = method; |
+ } |
+ |
// Update pixels from image, copying source_rect (in image) to dest_offset (in |
// the resource). |
void SetPixels(ResourceId id, |
@@ -453,6 +458,9 @@ class CC_EXPORT ResourceProvider { |
GLenum filter, |
GLint wrap_mode); |
+ bool IsCompressed() const; |
+ size_t CompressedSize() const; |
+ |
int child_id; |
unsigned gl_id; |
// Pixel buffer used for set pixels without unnecessary copying. |
@@ -525,6 +533,7 @@ class CC_EXPORT ResourceProvider { |
BlockingTaskRunner* blocking_main_thread_task_runner, |
int highp_threshold_min, |
bool use_rgba_4444_texture_format, |
+ bool use_texture_compression, |
size_t id_allocation_chunk_size); |
void CleanUpGLIfNeeded(); |
@@ -578,6 +587,8 @@ class CC_EXPORT ResourceProvider { |
bool use_texture_storage_ext_; |
bool use_texture_format_bgra_; |
bool use_texture_usage_hint_; |
+ bool use_compressed_texture_atc_; |
+ bool use_compressed_texture_dxt_; |
bool use_compressed_texture_etc1_; |
ResourceFormat yuv_resource_format_; |
scoped_ptr<TextureUploader> texture_uploader_; |
@@ -588,6 +599,8 @@ class CC_EXPORT ResourceProvider { |
scoped_refptr<Fence> current_read_lock_fence_; |
bool use_rgba_4444_texture_format_; |
+ bool use_texture_compression_; |
+ TileCompressionMethod preferred_tile_compression_method_; |
const size_t id_allocation_chunk_size_; |
scoped_ptr<IdAllocator> texture_id_allocator_; |
@@ -603,22 +616,22 @@ class CC_EXPORT ResourceProvider { |
// TODO(epenner): Move these format conversions to resource_format.h |
// once that builds on mac (npapi.h currently #includes OpenGL.h). |
inline unsigned BitsPerPixel(ResourceFormat format) { |
- switch (format) { |
- case BGRA_8888: |
- case RGBA_8888: |
- return 32; |
- case RGBA_4444: |
- case RGB_565: |
- return 16; |
- case ALPHA_8: |
- case LUMINANCE_8: |
- case RED_8: |
- return 8; |
- case ETC1: |
- return 4; |
- } |
- NOTREACHED(); |
- return 0; |
+ DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
+ static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
+ 32, // RGBA_8888 |
+ 16, // RGBA_4444 |
+ 32, // BGRA_8888 |
+ 8, // ALPHA_8 |
+ 8, // LUMINANCE_8 |
+ 16, // RGB_565, |
+ 4, // ATC |
+ 8, // ATC_IA |
+ 4, // DXT1 |
+ 8, // DXT5 |
+ 4, // ETC1 |
+ 8 // RED_8 |
+ }; |
+ return format_bits_per_pixel[format]; |
} |
inline GLenum GLDataType(ResourceFormat format) { |
@@ -630,6 +643,10 @@ inline GLenum GLDataType(ResourceFormat format) { |
GL_UNSIGNED_BYTE, // ALPHA_8 |
GL_UNSIGNED_BYTE, // LUMINANCE_8 |
GL_UNSIGNED_SHORT_5_6_5, // RGB_565, |
+ GL_UNSIGNED_BYTE, // ATC |
+ GL_UNSIGNED_BYTE, // ATC_IA |
+ GL_UNSIGNED_BYTE, // DXT1 |
+ GL_UNSIGNED_BYTE, // DXT5 |
GL_UNSIGNED_BYTE, // ETC1 |
GL_UNSIGNED_BYTE // RED_8 |
}; |
@@ -639,14 +656,18 @@ inline GLenum GLDataType(ResourceFormat format) { |
inline GLenum GLDataFormat(ResourceFormat format) { |
DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { |
- GL_RGBA, // RGBA_8888 |
- GL_RGBA, // RGBA_4444 |
- GL_BGRA_EXT, // BGRA_8888 |
- GL_ALPHA, // ALPHA_8 |
- GL_LUMINANCE, // LUMINANCE_8 |
- GL_RGB, // RGB_565 |
- GL_ETC1_RGB8_OES, // ETC1 |
- GL_RED_EXT // RED_8 |
+ GL_RGBA, // RGBA_8888 |
+ GL_RGBA, // RGBA_4444 |
+ GL_BGRA_EXT, // BGRA_8888 |
+ GL_ALPHA, // ALPHA_8 |
+ GL_LUMINANCE, // LUMINANCE_8 |
+ GL_RGB, // RGB_565 |
+ GL_ATC_RGB_AMD, // ATC |
+ GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, // ATC_IA |
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT, // DXT1 |
+ GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, // DXT5 |
+ GL_ETC1_RGB8_OES, // ETC1 |
+ GL_RED_EXT // RED_8 |
}; |
return format_gl_data_format[format]; |
} |