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

Unified Diff: cc/resources/resource_pool.h

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 | « no previous file | cc/resources/resource_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_pool.h
diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h
index 9f87c44379713fe9cb49a6ff9d9ecab3ddbf65e4..5bf8c81064d2ed72244db37f8652a1d99f6e91e2 100644
--- a/cc/resources/resource_pool.h
+++ b/cc/resources/resource_pool.h
@@ -44,6 +44,7 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider {
~ResourcePool() override;
+ // Tries to reuse a resource. If none are available, makes a new one.
Resource* AcquireResource(const gfx::Size& size,
ResourceFormat format,
const gfx::ColorSpace& color_space);
@@ -99,6 +100,7 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider {
bool ResourceUsageTooHigh();
private:
+ FRIEND_TEST_ALL_PREFIXES(ResourcePoolTest, ReuseResource);
class PoolResource : public ScopedResource {
public:
static std::unique_ptr<PoolResource> Create(
@@ -128,6 +130,16 @@ class CC_EXPORT ResourcePool : public base::trace_event::MemoryDumpProvider {
gfx::Rect invalidated_rect_;
};
+ // Tries to reuse a resource. Returns |nullptr| if none are available.
+ Resource* ReuseResource(const gfx::Size& size,
+ ResourceFormat format,
+ const gfx::ColorSpace& color_space);
+
+ // Creates a new resource without trying to reuse an old one.
+ Resource* CreateResource(const gfx::Size& size,
+ ResourceFormat format,
+ const gfx::ColorSpace& color_space);
+
void DidFinishUsingResource(std::unique_ptr<PoolResource> resource);
void DeleteResource(std::unique_ptr<PoolResource> resource);
static void UpdateResourceContentIdAndInvalidation(
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698