From 8bde4e839b4c55733b730a71cd9beaff95e01fe4 Mon Sep 17 00:00:00 2001 From: peterp Date: Mon, 19 Jan 2015 02:21:07 -0800 Subject: Support different formats in the same resource pool. This allows us to use different formats for tiles with opaque or translucent content for better memory savings or quality. BUG=434699 Review URL: https://codereview.chromium.org/817133006 Cr-Commit-Position: refs/heads/master@{#312090} --- cc/resources/resource_pool.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cc/resources/resource_pool.cc') diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index 45f36e2..f0a871d 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -11,10 +11,10 @@ namespace cc { ResourcePool::ResourcePool(ResourceProvider* resource_provider, GLenum target, - ResourceFormat format) + ResourceFormat default_format) : resource_provider_(resource_provider), target_(target), - format_(format), + default_format_(default_format), max_memory_usage_bytes_(0), max_unused_memory_usage_bytes_(0), max_resource_count_(0), @@ -36,13 +36,15 @@ ResourcePool::~ResourcePool() { } scoped_ptr ResourcePool::AcquireResource( - const gfx::Size& size) { + const gfx::Size& size, ResourceFormat format) { for (ResourceList::iterator it = unused_resources_.begin(); it != unused_resources_.end(); ++it) { ScopedResource* resource = *it; DCHECK(resource_provider_->CanLockForWrite(resource->id())); + if (resource->format() != format) + continue; if (resource->size() != size) continue; @@ -53,7 +55,7 @@ scoped_ptr ResourcePool::AcquireResource( scoped_ptr resource = ScopedResource::Create(resource_provider_); - resource->AllocateManaged(size, target_, format_); + resource->AllocateManaged(size, target_, format); memory_usage_bytes_ += resource->bytes(); ++resource_count_; -- cgit v1.1