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

Unified Diff: cc/resources/resource_pool.cc

Issue 2243013002: Refactor ResourcePool::AcquireResource() and add test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test failure. Created 4 years, 4 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/resources/resource_pool.h ('k') | cc/resources/resource_pool_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_pool.cc
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
index 669897a0a3ba5e74c896c45cf766dd6b3566ffeb..41358702b7cf56683ab88608a09bdd5c5beac64f 100644
--- a/cc/resources/resource_pool.cc
+++ b/cc/resources/resource_pool.cc
@@ -94,9 +94,9 @@ ResourcePool::~ResourcePool() {
DCHECK_EQ(0u, total_resource_count_);
}
-Resource* ResourcePool::AcquireResource(const gfx::Size& size,
- ResourceFormat format,
- const gfx::ColorSpace& color_space) {
+Resource* ResourcePool::ReuseResource(const gfx::Size& size,
+ ResourceFormat format,
+ const gfx::ColorSpace& color_space) {
// Finding resources in |unused_resources_| from MRU to LRU direction, touches
// LRU resources only if needed, which increases possibility of expiring more
// LRU resources within kResourceExpirationDelayMs.
@@ -119,7 +119,12 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size,
resource->size(), resource->format());
return resource;
}
+ return nullptr;
+}
+Resource* ResourcePool::CreateResource(const gfx::Size& size,
+ ResourceFormat format,
+ const gfx::ColorSpace& color_space) {
std::unique_ptr<PoolResource> pool_resource =
PoolResource::Create(resource_provider_);
@@ -150,6 +155,16 @@ Resource* ResourcePool::AcquireResource(const gfx::Size& size,
return resource;
}
+Resource* ResourcePool::AcquireResource(const gfx::Size& size,
+ ResourceFormat format,
+ const gfx::ColorSpace& color_space) {
+ Resource* reused_resource = ReuseResource(size, format, color_space);
+ if (reused_resource)
+ return reused_resource;
+
+ return CreateResource(size, format, color_space);
+}
+
// Iterate over all three resource lists (unused, in-use, and busy), updating
// the invalidation and content IDs to allow for future partial raster. The
// first unused resource found (if any) will be returned and used for partial
« no previous file with comments | « cc/resources/resource_pool.h ('k') | cc/resources/resource_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698