Chromium Code Reviews| 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 c66c2ad5e3f995cadf6c8a27e893a2e430b50a7c..5dddd0b3e4ebf35577f7e24d3fbe76bffd8eda91 100644 |
| --- a/cc/raster/one_copy_tile_task_worker_pool.cc |
| +++ b/cc/raster/one_copy_tile_task_worker_pool.cc |
| @@ -181,11 +181,13 @@ 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 memory_efficient_format, |
| + ResourceFormat memory_efficient_format_with_alpha) { |
| 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, memory_efficient_format, |
| + memory_efficient_format_with_alpha)); |
| } |
| OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( |
| @@ -195,7 +197,8 @@ 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 memory_efficient_format, |
| + ResourceFormat memory_efficient_format_with_alpha) |
| : task_runner_(task_runner), |
| task_graph_runner_(task_graph_runner), |
| namespace_token_(task_graph_runner->GetNamespaceToken()), |
| @@ -208,7 +211,8 @@ 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), |
| + memory_efficient_format_(memory_efficient_format), |
| + memory_efficient_format_with_alpha_(memory_efficient_format_with_alpha), |
| staging_buffer_usage_in_bytes_(0), |
| free_staging_buffer_usage_in_bytes_(0), |
| staging_buffer_expiration_delay_( |
| @@ -342,9 +346,13 @@ void OneCopyTileTaskWorkerPool::CheckForCompletedTasks() { |
| ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat( |
| bool must_support_alpha) const { |
|
reveman
2015/11/30 16:41:45
Can we adjust this interface to match RendererSett
christiank
2015/12/01 15:01:07
Sure! That will leave it to TileManager::Determine
|
| - return use_rgba_4444_texture_format_ |
| - ? RGBA_4444 |
| - : resource_provider_->best_texture_format(); |
| + if (memory_efficient_format_with_alpha_ != RGBA_8888 && must_support_alpha) |
|
reveman
2015/11/30 16:41:45
I think these RGBA_8888 checks will be confusing f
christiank
2015/12/01 15:01:07
I agree that it's a bit confusing. I don't quite f
reveman
2015/12/01 17:27:24
I think it would be much cleaner and easier to und
christiank
2015/12/02 16:18:14
Now I see what you mean. Sounds good to me, defini
|
| + return memory_efficient_format_with_alpha_; |
| + |
| + if (memory_efficient_format_ != RGBA_8888 && !must_support_alpha) |
| + return memory_efficient_format_; |
| + |
| + return resource_provider_->best_texture_format(); |
| } |
| bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( |
| @@ -488,32 +496,48 @@ 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); |
| + |
| + if (IsResourceFormatCompressed(resource->format())) { |
|
reveman
2015/11/30 16:41:45
This is never going to be true thanks to the check
christiank
2015/12/01 15:01:07
Oh, that's sloppy of me. You're absolutely right.
|
| + gl->CompressedCopySubTextureCHROMIUM( |
| + GL_TEXTURE_2D, staging_buffer->texture_id, |
| + resource_lock->texture_id(), 0, y, 0, y, resource->size().width(), |
| + rows_to_copy); |
| + } else { |
| + 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; |
| + } |
| } |
| } |