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

Unified Diff: cc/raster/one_copy_tile_task_worker_pool.cc

Issue 1379783002: Allow one-copy task tile worker pool to use compressed textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove needs_conversion, fix tile size unit test and move modulo 4 DCHECK (for tests) Created 5 years 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/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 286773436d07222ca0fb89557ab69fe69276e73e..c7b07b7e5cdffb19b90720c23e777a3ede8234e1 100644
--- a/cc/raster/one_copy_tile_task_worker_pool.cc
+++ b/cc/raster/one_copy_tile_task_worker_pool.cc
@@ -181,11 +181,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(
@@ -195,7 +195,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()),
@@ -208,7 +208,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_(
@@ -281,9 +281,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,32 +431,41 @@ 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(GL_TEXTURE_2D, 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(GL_TEXTURE_2D,
+ 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(GL_TEXTURE_2D, 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;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698