diff options
author | prashant.n <prashant.n@samsung.com> | 2015-08-03 00:13:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-03 07:14:15 +0000 |
commit | 8e4942838460a8d66a31c46baf265a5a8b61a16a (patch) | |
tree | 4c6837eacb7220a9f6b0107e64df0959c889c514 /cc/resources/resource_pool.cc | |
parent | 06d8e4f230b536b67438d9af56c3a56bd804c05b (diff) | |
download | chromium_src-8e4942838460a8d66a31c46baf265a5a8b61a16a.zip chromium_src-8e4942838460a8d66a31c46baf265a5a8b61a16a.tar.gz chromium_src-8e4942838460a8d66a31c46baf265a5a8b61a16a.tar.bz2 |
1. With introduction of compressed formats, e.g. ETC1, the number of
bits per pixel is becoming less than 8. Computing bytes per pixel by
BitsPerPixel(format) / 8, might give different values. So compute the
bits per row first and divide it by 8 to get the bytes per row.
2. Move resource size computation functions to separate file,
i.e. resource_util.cc.
3. Move resource format related functions to resource_format.h. As
there is dependecy on third_party/khronos/GLES2/gl2.h &
third_party/khronos/GLES2/gl2ext.h, the inlined functions have been
written as non-inlined functions and header files have been included
in resource_format.cc.
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1202843008
Cr-Commit-Position: refs/heads/master@{#341492}
Diffstat (limited to 'cc/resources/resource_pool.cc')
-rw-r--r-- | cc/resources/resource_pool.cc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index 7b65d34..300c48f 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -5,6 +5,7 @@ #include "cc/resources/resource_pool.h" #include "cc/resources/resource_provider.h" +#include "cc/resources/resource_util.h" #include "cc/resources/scoped_resource.h" namespace cc { @@ -48,7 +49,7 @@ scoped_ptr<ScopedResource> ResourcePool::AcquireResource( unused_resources_.erase(it); unused_memory_usage_bytes_ -= - Resource::UncheckedMemorySizeBytes(size, format); + ResourceUtil::UncheckedSizeInBytes<size_t>(size, format); return make_scoped_ptr(resource); } @@ -56,9 +57,10 @@ scoped_ptr<ScopedResource> ResourcePool::AcquireResource( ScopedResource::Create(resource_provider_); resource->AllocateManaged(size, target_, format); - DCHECK(Resource::VerifySizeInBytes(resource->size(), resource->format())); - memory_usage_bytes_ += - Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); + DCHECK(ResourceUtil::VerifySizeInBytes<size_t>(resource->size(), + resource->format())); + memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( + resource->size(), resource->format()); ++resource_count_; return resource.Pass(); } @@ -78,8 +80,8 @@ scoped_ptr<ScopedResource> ResourcePool::TryAcquireResourceWithContentId( DCHECK(resource_provider_->CanLockForWrite(resource->id())); unused_resources_.erase(it); - unused_memory_usage_bytes_ -= - Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); + unused_memory_usage_bytes_ -= ResourceUtil::UncheckedSizeInBytes<size_t>( + resource->size(), resource->format()); return make_scoped_ptr(resource); } @@ -112,7 +114,7 @@ void ResourcePool::ReduceResourceUsage() { // memory is necessarily returned to the OS. ScopedResource* resource = unused_resources_.front().resource; unused_resources_.pop_front(); - unused_memory_usage_bytes_ -= Resource::UncheckedMemorySizeBytes( + unused_memory_usage_bytes_ -= ResourceUtil::UncheckedSizeInBytes<size_t>( resource->size(), resource->format()); DeleteResource(resource); } @@ -129,8 +131,8 @@ bool ResourcePool::ResourceUsageTooHigh() { } void ResourcePool::DeleteResource(ScopedResource* resource) { - size_t resource_bytes = - Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); + size_t resource_bytes = ResourceUtil::UncheckedSizeInBytes<size_t>( + resource->size(), resource->format()); memory_usage_bytes_ -= resource_bytes; --resource_count_; delete resource; @@ -160,8 +162,8 @@ void ResourcePool::CheckBusyResources(bool wait_if_needed) { void ResourcePool::DidFinishUsingResource(ScopedResource* resource, uint64_t content_id) { - unused_memory_usage_bytes_ += - Resource::UncheckedMemorySizeBytes(resource->size(), resource->format()); + unused_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( + resource->size(), resource->format()); unused_resources_.push_back(PoolResource(resource, content_id)); } |