aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-05-11 14:14:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-11 19:44:39 +0000
commitb6deea8f0ed61475382fc48c7359118bfdcbff85 (patch)
treeb06cb1b81f0c5cb9f0aa92e85207c6059f9e18cb /include/private
parentce5e326016f7ade56afc2381e0f951b6c2ebc779 (diff)
Setup for another attempt to split up opLists
Split out of: https://skia-review.googlesource.com/c/14186 (Split up opLists (take 3)) Change-Id: Ifa600c88fb9185991d3197c7776c820f54c9bf0f Reviewed-on: https://skia-review.googlesource.com/16540 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include/private')
-rw-r--r--include/private/GrSurfaceProxy.h51
1 files changed, 23 insertions, 28 deletions
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index b2ccfe0b7f..29bb8620e0 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -45,27 +45,24 @@ public:
fTarget->unref();
}
- if (!(--fRefCnt)) {
- delete this;
- return;
- }
-
- this->validate();
+ --fRefCnt;
+ this->didRemoveRefOrPendingIO();
}
void validate() const {
-#ifdef SK_DEBUG
- SkASSERT(fRefCnt >= 1);
+#ifdef SK_DEBUG
+ SkASSERT(fRefCnt >= 0);
SkASSERT(fPendingReads >= 0);
SkASSERT(fPendingWrites >= 0);
SkASSERT(fRefCnt + fPendingReads + fPendingWrites >= 1);
if (fTarget) {
- SkASSERT(!fPendingReads && !fPendingWrites);
// The backing GrSurface can have more refs than the proxy if the proxy
// started off wrapping an external resource (that came in with refs).
// The GrSurface should never have fewer refs than the proxy however.
SkASSERT(fTarget->fRefCnt >= fRefCnt);
+ SkASSERT(fTarget->fPendingReads >= fPendingReads);
+ SkASSERT(fTarget->fPendingWrites >= fPendingWrites);
}
#endif
}
@@ -96,9 +93,6 @@ protected:
fTarget->fRefCnt += (fRefCnt-1); // don't xfer the proxy's creation ref
fTarget->fPendingReads += fPendingReads;
fTarget->fPendingWrites += fPendingWrites;
-
- fPendingReads = 0;
- fPendingWrites = 0;
}
bool internalHasPendingIO() const {
@@ -123,18 +117,16 @@ protected:
private:
// This class is used to manage conversion of refs to pending reads/writes.
- friend class GrTextureProxyRef;
+ friend class GrSurfaceProxyRef;
template <typename, GrIOType> friend class GrPendingIOResource;
void addPendingRead() const {
this->validate();
+ ++fPendingReads;
if (fTarget) {
fTarget->addPendingRead();
- return;
}
-
- ++fPendingReads;
}
void completedRead() const {
@@ -142,21 +134,19 @@ private:
if (fTarget) {
fTarget->completedRead();
- return;
}
-
- SkFAIL("How was the read completed if the Proxy hasn't been instantiated?");
+
+ --fPendingReads;
+ this->didRemoveRefOrPendingIO();
}
void addPendingWrite() const {
this->validate();
+ ++fPendingWrites;
if (fTarget) {
fTarget->addPendingWrite();
- return;
}
-
- ++fPendingWrites;
}
void completedWrite() const {
@@ -164,10 +154,16 @@ private:
if (fTarget) {
fTarget->completedWrite();
- return;
}
-
- SkFAIL("How was the write completed if the Proxy hasn't been instantiated?");
+
+ --fPendingWrites;
+ this->didRemoveRefOrPendingIO();
+ }
+
+ void didRemoveRefOrPendingIO() const {
+ if (0 == fPendingReads && 0 == fPendingWrites && 0 == fRefCnt) {
+ delete this;
+ }
}
mutable int32_t fRefCnt;
@@ -374,14 +370,13 @@ private:
mutable size_t fGpuMemorySize;
// The last opList that wrote to or is currently going to write to this surface
- // The opList can be closed (e.g., no render target context is currently bound
- // to this renderTarget).
+ // The opList can be closed (e.g., no surface context is currently bound
+ // to this proxy).
// This back-pointer is required so that we can add a dependancy between
// the opList used to create the current contents of this surface
// and the opList of a destination surface to which this one is being drawn or copied.
GrOpList* fLastOpList;
-
typedef GrIORefProxy INHERITED;
};