diff options
author | 2017-05-04 08:52:22 -0400 | |
---|---|---|
committer | 2017-05-04 13:29:29 +0000 | |
commit | 952a2435f7a38624ffbd0ac3b44d30f4b887a48b (patch) | |
tree | d3076827d7fdb1e6864b0a69cc9596a5bae1a64f /include/gpu/GrGpuResourceRef.h | |
parent | 9f3dcb3f760274d42e28095fd3cf0f484168d996 (diff) |
Add GrGpuTextureProxyRef
Basically a GrTextureProxified clone of GrGpuResourceRef
Change-Id: I8772550bb867ef2cf2d53efef0a0346bb7c90eb6
Reviewed-on: https://skia-review.googlesource.com/15221
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/gpu/GrGpuResourceRef.h')
-rw-r--r-- | include/gpu/GrGpuResourceRef.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/gpu/GrGpuResourceRef.h b/include/gpu/GrGpuResourceRef.h index 3a170f44d2..f82b502574 100644 --- a/include/gpu/GrGpuResourceRef.h +++ b/include/gpu/GrGpuResourceRef.h @@ -89,6 +89,64 @@ private: typedef SkNoncopyable INHERITED; }; +class GrTextureProxy; + +class GrTextureProxyRef : SkNoncopyable { +public: + virtual ~GrTextureProxyRef(); + + GrTextureProxy* getProxy() const { return fProxy; } + + /** Does this object own a pending read or write on the resource it is wrapping. */ + bool ownsPendingIO() const { return fPendingIO; } + + /** What type of IO does this represent? This is independent of whether a normal ref or a + pending IO is currently held. */ + GrIOType ioType() const { return fIOType; } + + /** Shortcut for calling setProxy() with NULL. It cannot be called after markingPendingIO + is called. */ + void reset(); + +protected: + GrTextureProxyRef(); + + /** ioType expresses what type of IO operations will be marked as + pending on the resource when markPendingIO is called. */ + GrTextureProxyRef(sk_sp<GrTextureProxy>, GrIOType); + + /** ioType expresses what type of IO operations will be marked as + pending on the resource when markPendingIO is called. */ + void setProxy(sk_sp<GrTextureProxy>, GrIOType); + +private: + /** Called by owning GrProgramElement when the program element is first scheduled for + execution. It can only be called once. */ + void markPendingIO() const; + + /** Called when the program element/draw state is no longer owned by GrOpList-client code. + This lets the cache know that the drawing code will no longer schedule additional reads or + writes to the resource using the program element or draw state. It can only be called once. + */ + void removeRef() const; + + /** Called to indicate that the previous pending IO is complete. Useful when the owning object + still has refs, so it is not about to destroy this GrGpuResourceRef, but its previously + pending executions have been complete. Can only be called if removeRef() was not previously + called. */ + void pendingIOComplete() const; + + friend class GrResourceIOProcessor; + + GrTextureProxy* fProxy; + mutable bool fOwnRef; + mutable bool fPendingIO; + GrIOType fIOType; + + typedef SkNoncopyable INHERITED; +}; + + /** * Templated version of GrGpuResourceRef to enforce type safety. */ |