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

Unified Diff: include/gpu/GrGpuResource.h

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 8 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 | « include/gpu/GrDrawContext.h ('k') | include/gpu/GrGpuResourceRef.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrGpuResource.h
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index 8103959984b14ccf5a7fde91783b5a8120eda178..8539ba37bdd920dd5f25f85d56121cc16a2f82e2 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -12,10 +12,22 @@
#include "GrTypesPriv.h"
#include "SkData.h"
+#include "GrDrawContext.h"
+
class GrContext;
+class GrDrawContext;
class GrGpu;
class GrResourceCache;
class SkTraceMemoryDump;
+class GrRenderTarget;
+class GrSurface;
+class GrDrawTarget;
+class GrGpuResource;
+
+extern GrDrawTarget* getLastDT6(GrGpuResource* rt);
+
+// Due to header woes
+extern void addRequiredDep(GrDrawTarget* dst, GrDrawTarget* src);
/**
* Base class for GrGpuResource. Handles the various types of refs we need. Separated out as a base
@@ -94,7 +106,34 @@ protected:
bool internalHasRef() const { return SkToBool(fRefCnt); }
private:
- void addPendingRead() const {
+ void addPendingRead(const DERIVED* dst) const {
+ const DERIVED* src = static_cast<const DERIVED*>(this);
+ if ((const_cast<DERIVED*>(src))->arrgh()) {
+ SkASSERT(dst);
+ SkASSERT((const_cast<DERIVED*>(dst))->arrgh());
+
+ GrDrawTarget* dstDT = getLastDT6(const_cast<DERIVED*>(dst));
+ GrDrawTarget* srcDT = getLastDT6(const_cast<DERIVED*>(src));
+
+ SkASSERT(dstDT || !srcDT);
+
+ if (src->fromRawPixels2()) {
+ // adding a read on uploaded content
+ SkASSERT(!srcDT);
+ } else {
+ // adding a read on rendered content
+ if (srcDT) {
+ SkASSERT(dstDT);
+
+ if (dstDT == srcDT) {
+ // self-read - presumably for dst reads
+ } else {
+ addRequiredDep(dstDT, srcDT);
+ }
+ }
+ }
+ }
+
this->validate();
++fPendingReads;
}
@@ -123,6 +162,7 @@ private:
}
}
+public:
mutable int32_t fRefCnt;
mutable int32_t fPendingReads;
mutable int32_t fPendingWrites;
@@ -134,12 +174,59 @@ private:
template <typename, GrIOType> friend class GrPendingIOResource;
};
+
/**
* Base class for objects that can be kept in the GrResourceCache.
*/
class SK_API GrGpuResource : public GrIORef<GrGpuResource> {
public:
+ enum Type2 {
+ kSurface,
+ kOther
+ };
+public:
+
+ Type2 type1() const { return fType1; }
+ virtual GrRenderTarget* arrgh() = 0;
+
+private:
+ // fFromRawPixels2, fException & fException2 are just for the alternate testing system
+ mutable bool fFromRawPixels2;
+ mutable bool fException; // there are often textures from raw data which do not have a key
+public:
+ mutable bool fException2; // yuv textures have a key but have been rendered to
+ // as have CMM alpha masks
+
+ void validate() const {
+ if (fException) {
+ SkASSERT(fFromRawPixels2);
+ }
+ if (!fFromRawPixels2) {
+ SkASSERT(!fException); // can't be an exception w/o being from raw pixels
+ }
+ }
+
+ bool fromRawPixels2() const {
+ this->validate();
+ return fFromRawPixels2;
+ }
+
+ void setFromRawPixels(bool fromRawPixels) const {
+ this->validate();
+
+ fFromRawPixels2 = fromRawPixels;
+
+ this->validate();
+ }
+
+ bool exception() const { return fException; }
+
+ void setException(bool exception) {
+ this->validate();
+ fException = exception;
+ this->validate();
+ }
enum LifeCycle {
/**
@@ -265,7 +352,7 @@ protected:
// initialized (i.e. not in a base class constructor).
void registerWithCache();
- GrGpuResource(GrGpu*, LifeCycle);
+ GrGpuResource(GrGpu*, LifeCycle, Type2);
virtual ~GrGpuResource();
GrGpu* getGpu() const { return fGpu; }
@@ -346,6 +433,8 @@ private:
SkAutoTUnref<const SkData> fData;
+ Type2 fType1;
+
typedef GrIORef<GrGpuResource> INHERITED;
friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and notifyRefCntIsZero.
};
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | include/gpu/GrGpuResourceRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698