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

Unified Diff: cc/resources/resource_pool.cc

Issue 1202843008: cc: Fix BytesPerPixel issue and refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 5 years, 5 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
Index: cc/resources/resource_pool.cc
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
index f5c71678f2740a5966f41958c08a0bf49f77ae70..d60d0b130accdba8ca2e6787a41efb614a44cbca 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, 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()));
+ DCHECK(ResourceUtil::VerifySizeInBytes<size_t>(resource->size(),
+ resource->format()));
memory_usage_bytes_ +=
- Resource::UncheckedMemorySizeBytes(resource->size(), resource->format());
+ ResourceUtil::UncheckedSizeInBytes(resource->size(), resource->format());
++resource_count_;
return resource.Pass();
}
@@ -79,7 +81,7 @@ scoped_ptr<ScopedResource> ResourcePool::TryAcquireResourceWithContentId(
unused_resources_.erase(it);
unused_memory_usage_bytes_ -=
- Resource::UncheckedMemorySizeBytes(resource->size(), resource->format());
+ ResourceUtil::UncheckedSizeInBytes(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();
- size_t resource_bytes = Resource::UncheckedMemorySizeBytes(
+ size_t resource_bytes = ResourceUtil::UncheckedSizeInBytes(
resource->size(), resource->format());
memory_usage_bytes_ -= resource_bytes;
unused_memory_usage_bytes_ -= resource_bytes;
@@ -152,7 +154,7 @@ 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());
+ ResourceUtil::UncheckedSizeInBytes(resource->size(), resource->format());
unused_resources_.push_back(PoolResource(resource, content_id));
}

Powered by Google App Engine
This is Rietveld 408576698