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 || |
+ 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); |
}; |