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

Unified Diff: cc/resource_provider.h

Issue 12197004: cc: Enforce correct recycling in resource pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use fence interface. Created 7 years, 10 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/resource_provider.h
diff --git a/cc/resource_provider.h b/cc/resource_provider.h
index c4776c21f9f6a89b0023abcaf1fd582786f87cb2..af22a6b18a7bb1336e7e81401b600af4bc0c5b6c 100644
--- a/cc/resource_provider.h
+++ b/cc/resource_provider.h
@@ -221,6 +221,11 @@ public:
DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware);
};
+ class Fence : public base::RefCounted<Fence> {
+ public:
+ virtual bool hasPassed() = 0;
+ };
+
// Acquire pixel buffer for resource. The pixel buffer can be used to
// set resource pixels without performing unnecessary copying.
void acquirePixelBuffer(ResourceId id);
@@ -241,6 +246,18 @@ public:
// Use setPixels or lockForWrite to allocate implicitly.
void allocateForTesting(ResourceId id);
+ // Sets the current read fence. If a resource is locked for read
+ // and has read fences enabled, the resource will not allow writes
+ // until this fence has passed.
+ void setReadLockFence(Fence* fence) { m_currentReadLockFence = fence; }
+ Fence* getReadLockFence() { return m_currentReadLockFence; }
+
+ // Enable read lock fences for a specific resource.
+ void enableReadLockFences(ResourceProvider::ResourceId, bool enable);
+
+ // Indicates if we can currently lock this resource for write.
+ bool canLockForWrite(ResourceId);
+
private:
struct Resource {
Resource();
@@ -263,6 +280,8 @@ private:
bool markedForDeletion;
bool pendingSetPixels;
bool allocated;
+ bool enableReadLockFences;
+ scoped_refptr<Fence> readLockFence;
gfx::Size size;
GLenum format;
// TODO(skyostil): Use a separate sampler object for filter state.
@@ -279,6 +298,9 @@ private:
};
typedef base::hash_map<int, Child> ChildMap;
+ bool readLockFenceHasPassed(Resource* resource) { return !resource->readLockFence ||
nduca 2013/02/05 22:39:05 does ? operator clean this? blah ? blah->hasPassed
+ resource->readLockFence->hasPassed(); }
+
explicit ResourceProvider(OutputSurface*);
bool initialize();
@@ -309,6 +331,8 @@ private:
base::ThreadChecker m_threadChecker;
+ scoped_refptr<Fence> m_currentReadLockFence;
+
DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
};
« cc/resource_pool.cc ('K') | « cc/resource_pool.cc ('k') | cc/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698