Index: cc/resources/resource_pool.cc |
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc |
index 45f36e27816d04451e1f92e786dcf21911fd3f34..d3a8d5b68ca97bb87228f66245e7d5abf9e99a5f 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) |
+ bool use_memory_efficient_format) |
: resource_provider_(resource_provider), |
target_(target), |
- format_(format), |
+ use_memory_efficient_format_(use_memory_efficient_format), |
max_memory_usage_bytes_(0), |
max_unused_memory_usage_bytes_(0), |
max_resource_count_(0), |
@@ -36,13 +36,15 @@ ResourcePool::~ResourcePool() { |
} |
scoped_ptr<ScopedResource> 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,13 +55,18 @@ scoped_ptr<ScopedResource> ResourcePool::AcquireResource( |
scoped_ptr<ScopedResource> resource = |
ScopedResource::Create(resource_provider_); |
- resource->AllocateManaged(size, target_, format_); |
+ resource->AllocateManaged(size, target_, format); |
memory_usage_bytes_ += resource->bytes(); |
++resource_count_; |
return resource.Pass(); |
} |
+scoped_ptr<ScopedResource> ResourcePool::AcquireResource( |
+ const gfx::Size& size) { |
+ return AcquireResource(size, resource_format()); |
+} |
+ |
void ResourcePool::ReleaseResource(scoped_ptr<ScopedResource> resource) { |
busy_resources_.push_back(resource.release()); |
} |
@@ -105,6 +112,14 @@ bool ResourcePool::ResourceUsageTooHigh() { |
return false; |
} |
+ResourceFormat ResourcePool::resource_format() const { |
+ if (use_memory_efficient_format_) { |
reveman
2015/01/15 16:33:11
I would prefer if all format decisions are made by
peterp
2015/01/16 12:10:11
Ok, I've removed this logic and changed the pool t
|
+ return resource_provider_->memory_efficient_texture_format(); |
+ } else { |
+ return resource_provider_->best_texture_format(); |
+ } |
+} |
+ |
void ResourcePool::CheckBusyResources(bool wait_if_needed) { |
ResourceList::iterator it = busy_resources_.begin(); |