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

Unified Diff: cc/raster/one_copy_tile_task_worker_pool.cc

Issue 1351283003: Allow task pools to reason about transparency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make StagingBuffer constructor non-explicit Created 5 years, 3 months 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
« no previous file with comments | « cc/raster/one_copy_tile_task_worker_pool.h ('k') | cc/raster/tile_task_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c5518e3cd88d5a1e348f22dbce8d6c5cfb70d304..86a0561b1ca9ed585da8d4eabbf4bec62cdfa16d 100644
--- a/cc/raster/one_copy_tile_task_worker_pool.cc
+++ b/cc/raster/one_copy_tile_task_worker_pool.cc
@@ -100,8 +100,14 @@ void WaitForQueryResult(gpu::gles2::GLES2Interface* gl, unsigned query_id) {
} // namespace
-OneCopyTileTaskWorkerPool::StagingBuffer::StagingBuffer(const gfx::Size& size)
- : size(size), texture_id(0), image_id(0), query_id(0), content_id(0) {}
+OneCopyTileTaskWorkerPool::StagingBuffer::StagingBuffer(const gfx::Size& size,
+ ResourceFormat format)
+ : size(size),
+ format(format),
+ texture_id(0),
+ image_id(0),
+ query_id(0),
+ content_id(0) {}
OneCopyTileTaskWorkerPool::StagingBuffer::~StagingBuffer() {
DCHECK_EQ(texture_id, 0u);
@@ -169,11 +175,12 @@ scoped_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create(
ResourceProvider* resource_provider,
int max_copy_texture_chromium_size,
bool use_persistent_gpu_memory_buffers,
- int max_staging_buffer_usage_in_bytes) {
+ int max_staging_buffer_usage_in_bytes,
+ bool use_rgba_4444_texture_format) {
return make_scoped_ptr<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool(
task_runner, task_graph_runner, resource_provider,
max_copy_texture_chromium_size, use_persistent_gpu_memory_buffers,
- max_staging_buffer_usage_in_bytes));
+ max_staging_buffer_usage_in_bytes, use_rgba_4444_texture_format));
}
OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
@@ -182,7 +189,8 @@ OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
ResourceProvider* resource_provider,
int max_copy_texture_chromium_size,
bool use_persistent_gpu_memory_buffers,
- int max_staging_buffer_usage_in_bytes)
+ int max_staging_buffer_usage_in_bytes,
+ bool use_rgba_4444_texture_format)
: task_runner_(task_runner),
task_graph_runner_(task_graph_runner),
namespace_token_(task_graph_runner->GetNamespaceToken()),
@@ -195,6 +203,7 @@ OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool(
use_persistent_gpu_memory_buffers_(use_persistent_gpu_memory_buffers),
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),
staging_buffer_usage_in_bytes_(0),
free_staging_buffer_usage_in_bytes_(0),
staging_buffer_expiration_delay_(
@@ -326,12 +335,17 @@ void OneCopyTileTaskWorkerPool::CheckForCompletedTasks() {
completed_tasks_.clear();
}
-ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat() const {
- return resource_provider_->memory_efficient_texture_format();
+ResourceFormat OneCopyTileTaskWorkerPool::GetResourceFormat(
+ bool must_support_alpha) const {
+ return use_rgba_4444_texture_format_
+ ? RGBA_4444
+ : resource_provider_->best_texture_format();
}
-bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle() const {
- return !PlatformColor::SameComponentOrder(GetResourceFormat());
+bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle(
+ bool must_support_alpha) const {
+ return !PlatformColor::SameComponentOrder(
+ GetResourceFormat(must_support_alpha));
}
scoped_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster(
@@ -340,12 +354,9 @@ scoped_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster(
uint64_t previous_content_id) {
// TODO(danakj): If resource_content_id != 0, we only need to copy/upload
// the dirty rect.
- DCHECK_EQ(resource->format(),
- resource_provider_->memory_efficient_texture_format());
- return make_scoped_ptr<RasterBuffer>(new RasterBufferImpl(
- this, resource_provider_,
- resource_provider_->memory_efficient_texture_format(), resource,
- previous_content_id));
+ return make_scoped_ptr<RasterBuffer>(
+ new RasterBufferImpl(this, resource_provider_, resource->format(),
+ resource, previous_content_id));
}
void OneCopyTileTaskWorkerPool::ReleaseBufferForRaster(
@@ -376,13 +387,11 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread(
if (!staging_buffer->gpu_memory_buffer) {
staging_buffer->gpu_memory_buffer =
resource_provider_->gpu_memory_buffer_manager()
- ->AllocateGpuMemoryBuffer(
- staging_buffer->size,
- BufferFormat(
- resource_provider_->memory_efficient_texture_format()),
- use_persistent_gpu_memory_buffers_
- ? gfx::BufferUsage::PERSISTENT_MAP
- : gfx::BufferUsage::MAP);
+ ->AllocateGpuMemoryBuffer(staging_buffer->size,
+ BufferFormat(resource->format()),
+ use_persistent_gpu_memory_buffers_
+ ? gfx::BufferUsage::PERSISTENT_MAP
+ : gfx::BufferUsage::MAP);
DCHECK_EQ(gfx::NumberOfPlanesForBufferFormat(
staging_buffer->gpu_memory_buffer->GetFormat()),
1u);
@@ -408,9 +417,9 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread(
DCHECK(!playback_rect.IsEmpty())
<< "Why are we rastering a tile that's not dirty?";
TileTaskWorkerPool::PlaybackToMemory(
- data, resource_provider_->memory_efficient_texture_format(),
- staging_buffer->size, static_cast<size_t>(stride), raster_source,
- raster_full_rect, playback_rect, scale, include_images);
+ data, resource->format(), staging_buffer->size,
+ static_cast<size_t>(stride), raster_source, raster_full_rect,
+ playback_rect, scale, include_images);
staging_buffer->gpu_memory_buffer->Unmap();
staging_buffer->content_id = new_content_id;
}
@@ -426,8 +435,8 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread(
gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
DCHECK(gl);
- unsigned image_target = resource_provider_->GetImageTextureTarget(
- resource_provider_->memory_efficient_texture_format());
+ unsigned image_target =
+ resource_provider_->GetImageTextureTarget(resource->format());
// Create and bind staging texture.
if (!staging_buffer->texture_id) {
@@ -447,8 +456,7 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread(
staging_buffer->image_id = gl->CreateImageCHROMIUM(
staging_buffer->gpu_memory_buffer->AsClientBuffer(),
staging_buffer->size.width(), staging_buffer->size.height(),
- GLInternalFormat(
- resource_provider_->memory_efficient_texture_format()));
+ GLInternalFormat(resource->format()));
gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
}
} else {
@@ -475,9 +483,7 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread(
}
int bytes_per_row =
- (BitsPerPixel(resource_provider_->memory_efficient_texture_format()) *
- resource->size().width()) /
- 8;
+ (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.
@@ -529,8 +535,7 @@ bool OneCopyTileTaskWorkerPool::OnMemoryDump(
base::AutoLock lock(lock_);
for (const auto& buffer : buffers_) {
- buffer->OnMemoryDump(pmd,
- resource_provider_->memory_efficient_texture_format(),
+ buffer->OnMemoryDump(pmd, buffer->format,
std::find(free_buffers_.begin(), free_buffers_.end(),
buffer) != free_buffers_.end());
}
@@ -539,14 +544,14 @@ bool OneCopyTileTaskWorkerPool::OnMemoryDump(
}
void OneCopyTileTaskWorkerPool::AddStagingBuffer(
- const StagingBuffer* staging_buffer) {
+ const StagingBuffer* staging_buffer,
+ ResourceFormat format) {
lock_.AssertAcquired();
DCHECK(buffers_.find(staging_buffer) == buffers_.end());
buffers_.insert(staging_buffer);
- int buffer_usage_in_bytes = ResourceUtil::UncheckedSizeInBytes<int>(
- staging_buffer->size,
- resource_provider_->memory_efficient_texture_format());
+ int buffer_usage_in_bytes =
+ ResourceUtil::UncheckedSizeInBytes<int>(staging_buffer->size, format);
staging_buffer_usage_in_bytes_ += buffer_usage_in_bytes;
}
@@ -557,8 +562,7 @@ void OneCopyTileTaskWorkerPool::RemoveStagingBuffer(
DCHECK(buffers_.find(staging_buffer) != buffers_.end());
buffers_.erase(staging_buffer);
int buffer_usage_in_bytes = ResourceUtil::UncheckedSizeInBytes<int>(
- staging_buffer->size,
- resource_provider_->memory_efficient_texture_format());
+ staging_buffer->size, staging_buffer->format);
DCHECK_GE(staging_buffer_usage_in_bytes_, buffer_usage_in_bytes);
staging_buffer_usage_in_bytes_ -= buffer_usage_in_bytes;
}
@@ -568,8 +572,7 @@ void OneCopyTileTaskWorkerPool::MarkStagingBufferAsFree(
lock_.AssertAcquired();
int buffer_usage_in_bytes = ResourceUtil::UncheckedSizeInBytes<int>(
- staging_buffer->size,
- resource_provider_->memory_efficient_texture_format());
+ staging_buffer->size, staging_buffer->format);
free_staging_buffer_usage_in_bytes_ += buffer_usage_in_bytes;
}
@@ -578,8 +581,7 @@ void OneCopyTileTaskWorkerPool::MarkStagingBufferAsBusy(
lock_.AssertAcquired();
int buffer_usage_in_bytes = ResourceUtil::UncheckedSizeInBytes<int>(
- staging_buffer->size,
- resource_provider_->memory_efficient_texture_format());
+ staging_buffer->size, staging_buffer->format);
DCHECK_GE(free_staging_buffer_usage_in_bytes_, buffer_usage_in_bytes);
free_staging_buffer_usage_in_bytes_ -= buffer_usage_in_bytes;
}
@@ -647,12 +649,13 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource,
}
}
- // Find staging buffer of correct size.
+ // Find staging buffer of correct size and format.
if (!staging_buffer) {
StagingBufferDeque::iterator it =
std::find_if(free_buffers_.begin(), free_buffers_.end(),
[resource](const StagingBuffer* buffer) {
- return buffer->size == resource->size();
+ return buffer->size == resource->size() &&
+ buffer->format == resource->format();
});
if (it != free_buffers_.end()) {
staging_buffer = free_buffers_.take(it);
@@ -662,8 +665,9 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource,
// Create new staging buffer if necessary.
if (!staging_buffer) {
- staging_buffer = make_scoped_ptr(new StagingBuffer(resource->size()));
- AddStagingBuffer(staging_buffer.get());
+ staging_buffer = make_scoped_ptr(
+ new StagingBuffer(resource->size(), resource->format()));
+ AddStagingBuffer(staging_buffer.get(), resource->format());
}
// Release enough free buffers to stay within the limit.
« no previous file with comments | « cc/raster/one_copy_tile_task_worker_pool.h ('k') | cc/raster/tile_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698