Index: cc/resources/resource_provider.cc |
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc |
index 848c59f292a2802dabcaf40681cd38e463bc8c50..700ead61c5822aebddc51322072ef2e7267e9219 100644 |
--- a/cc/resources/resource_provider.cc |
+++ b/cc/resources/resource_provider.cc |
@@ -121,10 +121,11 @@ gfx::GpuMemoryBuffer::Format ToGpuMemoryBufferFormat(ResourceFormat format) { |
return gfx::GpuMemoryBuffer::BGRA_8888; |
case RGBA_4444: |
return gfx::GpuMemoryBuffer::RGBA_4444; |
+ case ETC1: |
+ return gfx::GpuMemoryBuffer::ETC1; |
case ALPHA_8: |
case LUMINANCE_8: |
case RGB_565: |
- case ETC1: |
case RED_8: |
break; |
} |
@@ -392,13 +393,14 @@ scoped_ptr<ResourceProvider> ResourceProvider::Create( |
BlockingTaskRunner* blocking_main_thread_task_runner, |
int highp_threshold_min, |
bool use_rgba_4444_texture_format, |
+ bool use_tile_compression, |
size_t id_allocation_chunk_size, |
bool use_persistent_map_for_gpu_memory_buffers) { |
scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( |
output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, |
blocking_main_thread_task_runner, highp_threshold_min, |
- use_rgba_4444_texture_format, id_allocation_chunk_size, |
- use_persistent_map_for_gpu_memory_buffers)); |
+ use_rgba_4444_texture_format, use_tile_compression, |
+ id_allocation_chunk_size, use_persistent_map_for_gpu_memory_buffers)); |
resource_provider->Initialize(); |
return resource_provider; |
} |
@@ -430,6 +432,15 @@ ResourceProvider::~ResourceProvider() { |
gl->Finish(); |
} |
+ResourceFormat ResourceProvider::memory_efficient_texture_format( |
+ bool must_be_noncompressed, |
+ bool must_support_alpha) const { |
+ if (use_tile_compression_ && !must_be_noncompressed && !must_support_alpha) |
+ return ETC1; |
+ |
+ return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
+} |
+ |
bool ResourceProvider::InUseByConsumer(ResourceId id) { |
Resource* resource = GetResource(id); |
return resource->lock_for_read_count > 0 || resource->exported_count > 0 || |
@@ -1080,6 +1091,7 @@ ResourceProvider::ResourceProvider( |
BlockingTaskRunner* blocking_main_thread_task_runner, |
int highp_threshold_min, |
bool use_rgba_4444_texture_format, |
+ bool use_tile_compression, |
size_t id_allocation_chunk_size, |
bool use_persistent_map_for_gpu_memory_buffers) |
: output_surface_(output_surface), |
@@ -1100,6 +1112,7 @@ ResourceProvider::ResourceProvider( |
best_texture_format_(RGBA_8888), |
best_render_buffer_format_(RGBA_8888), |
use_rgba_4444_texture_format_(use_rgba_4444_texture_format), |
+ use_tile_compression_(use_tile_compression), |
id_allocation_chunk_size_(id_allocation_chunk_size), |
use_sync_query_(false), |
use_persistent_map_for_gpu_memory_buffers_( |
@@ -1877,9 +1890,15 @@ void ResourceProvider::CopyResource(ResourceId source_id, |
} |
DCHECK(!dest_resource->image_id); |
dest_resource->allocated = true; |
- gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, |
- dest_resource->gl_id, rect.x(), rect.y(), rect.x(), |
- rect.y(), rect.width(), rect.height()); |
+ if (IsResourceFormatCompressed(source_resource->format)) { |
+ // TODO(christiank): Should use CompressedCopySubTextureCHROMIUM. |
reveman
2015/07/21 04:26:33
Let's fix this TODO before landing this patch.
|
+ gl->CompressedCopyTextureCHROMIUM( |
+ dest_resource->target, source_resource->gl_id, dest_resource->gl_id); |
+ } else { |
+ gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, |
+ dest_resource->gl_id, rect.x(), rect.y(), |
+ rect.x(), rect.y(), rect.width(), rect.height()); |
+ } |
if (source_resource->gl_read_lock_query_id) { |
// End query and create a read lock fence that will prevent access to |
// source resource until CopySubTextureCHROMIUM command has completed. |