Index: cc/raster/one_copy_tile_task_worker_pool.cc |
diff --git a/cc/raster/one_copy_tile_task_worker_pool.cc b/cc/raster/one_copy_tile_task_worker_pool.cc |
index 1252205579e43db85996543b572e368be3959961..38e307629891082400cbb5f0d55fb4368020f0a4 100644 |
--- a/cc/raster/one_copy_tile_task_worker_pool.cc |
+++ b/cc/raster/one_copy_tile_task_worker_pool.cc |
@@ -185,11 +185,11 @@ scoped_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create( |
int max_copy_texture_chromium_size, |
bool use_partial_raster, |
int max_staging_buffer_usage_in_bytes, |
- bool use_rgba_4444_texture_format) { |
+ ResourceFormat preferred_tile_format) { |
return make_scoped_ptr<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool( |
task_runner, task_graph_runner, resource_provider, |
max_copy_texture_chromium_size, use_partial_raster, |
- max_staging_buffer_usage_in_bytes, use_rgba_4444_texture_format)); |
+ max_staging_buffer_usage_in_bytes, preferred_tile_format)); |
} |
OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( |
@@ -199,7 +199,7 @@ OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( |
int max_copy_texture_chromium_size, |
bool use_partial_raster, |
int max_staging_buffer_usage_in_bytes, |
- bool use_rgba_4444_texture_format) |
+ ResourceFormat preferred_tile_format) |
: task_runner_(task_runner), |
task_graph_runner_(task_graph_runner), |
namespace_token_(task_graph_runner->GetNamespaceToken()), |
@@ -212,7 +212,7 @@ OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( |
use_partial_raster_(use_partial_raster), |
bytes_scheduled_since_last_flush_(0), |
max_staging_buffer_usage_in_bytes_(max_staging_buffer_usage_in_bytes), |
- use_rgba_4444_texture_format_(use_rgba_4444_texture_format), |
+ preferred_tile_format_(preferred_tile_format), |
staging_buffer_usage_in_bytes_(0), |
free_staging_buffer_usage_in_bytes_(0), |
staging_buffer_expiration_delay_( |
@@ -285,9 +285,13 @@ void OneCopyTileTaskWorkerPool::CheckForCompletedTasks() { |
ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat( |
bool must_support_alpha) const { |
- return use_rgba_4444_texture_format_ |
- ? RGBA_4444 |
- : resource_provider_->best_texture_format(); |
+ if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && |
+ (DoesResourceFormatSupportAlpha(preferred_tile_format_) || |
+ !must_support_alpha)) { |
+ return preferred_tile_format_; |
+ } |
+ |
+ return resource_provider_->best_texture_format(); |
} |
bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( |
@@ -427,31 +431,39 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread( |
#endif |
} |
- int bytes_per_row = |
- (BitsPerPixel(resource->format()) * resource->size().width()) / 8; |
- int chunk_size_in_rows = |
- std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); |
- // Align chunk size to 4. Required to support compressed texture formats. |
- chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); |
- int y = 0; |
- int height = resource->size().height(); |
- while (y < height) { |
- // Copy at most |chunk_size_in_rows|. |
- int rows_to_copy = std::min(chunk_size_in_rows, height - y); |
- DCHECK_GT(rows_to_copy, 0); |
- |
- gl->CopySubTextureCHROMIUM( |
- staging_buffer->texture_id, resource_lock->texture_id(), 0, y, 0, y, |
- resource->size().width(), rows_to_copy, false, false, false); |
- y += rows_to_copy; |
- |
- // Increment |bytes_scheduled_since_last_flush_| by the amount of memory |
- // used for this copy operation. |
- bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; |
- |
- if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) { |
- gl->ShallowFlushCHROMIUM(); |
- bytes_scheduled_since_last_flush_ = 0; |
+ // Since compressed texture's cannot be pre-allocated we might have an |
+ // unallocated resource in which case we need to perform a full size copy. |
+ if (IsResourceFormatCompressed(resource->format())) { |
+ gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, |
+ resource_lock->texture_id()); |
+ } else { |
+ int bytes_per_row = |
+ (BitsPerPixel(resource->format()) * resource->size().width()) / 8; |
+ int chunk_size_in_rows = |
+ std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); |
+ // Align chunk size to 4. Required to support compressed texture formats. |
+ chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); |
+ int y = 0; |
+ int height = resource->size().height(); |
+ while (y < height) { |
+ // Copy at most |chunk_size_in_rows|. |
+ int rows_to_copy = std::min(chunk_size_in_rows, height - y); |
+ DCHECK_GT(rows_to_copy, 0); |
+ |
+ gl->CopySubTextureCHROMIUM( |
+ staging_buffer->texture_id, resource_lock->texture_id(), 0, y, 0, y, |
+ resource->size().width(), rows_to_copy, false, false, false); |
+ y += rows_to_copy; |
+ |
+ // Increment |bytes_scheduled_since_last_flush_| by the amount of memory |
+ // used for this copy operation. |
+ bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; |
+ |
+ if (bytes_scheduled_since_last_flush_ >= |
+ max_bytes_per_copy_operation_) { |
+ gl->ShallowFlushCHROMIUM(); |
+ bytes_scheduled_since_last_flush_ = 0; |
+ } |
} |
} |