Make GrDrawState and GrEffectStage use the pending io/exec ref mechanisms.
BUG=skia:2889
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/542723004
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h
index f4cee51..a3ae9a8 100644
--- a/include/gpu/GrEffectStage.h
+++ b/include/gpu/GrEffectStage.h
@@ -13,9 +13,8 @@
#include "GrBackendEffectFactory.h"
#include "GrEffect.h"
+#include "GrProgramElementRef.h"
#include "SkMatrix.h"
-#include "GrTypes.h"
-
#include "SkShader.h"
class GrEffectStage {
@@ -136,10 +135,12 @@
const int* getVertexAttribIndices() const { return fVertexAttribIndices; }
int getVertexAttribIndexCount() const { return fEffect->numVertexAttribs(); }
+ void convertToPendingExec() { fEffect.convertToPendingExec(); }
+
private:
bool fCoordChangeMatrixSet;
SkMatrix fCoordChangeMatrix;
- SkAutoTUnref<const GrEffect> fEffect;
+ GrProgramElementRef<const GrEffect> fEffect;
int fVertexAttribIndices[2];
};
diff --git a/include/gpu/GrProgramElementRef.h b/include/gpu/GrProgramElementRef.h
index 1e3b4f8..920ab78 100644
--- a/include/gpu/GrProgramElementRef.h
+++ b/include/gpu/GrProgramElementRef.h
@@ -42,7 +42,7 @@
operator T*() { return fObj; }
/** If T is const, the type returned from operator-> will also be const. */
- typedef typename SkTConstType<typename SkAutoTUnref<T>::BlockRef<T>,
+ typedef typename SkTConstType<typename SkAutoTUnref<T>::template BlockRef<T>,
SkTIsConst<T>::value>::type BlockRefType;
/**
diff --git a/include/gpu/GrTextureAccess.h b/include/gpu/GrTextureAccess.h
index 9f56171..3d44d9e 100644
--- a/include/gpu/GrTextureAccess.h
+++ b/include/gpu/GrTextureAccess.h
@@ -10,7 +10,7 @@
#include "SkRefCnt.h"
#include "SkShader.h"
-#include "SkTypes.h"
+#include "GrProgramResource.h"
class GrTexture;
@@ -112,8 +112,10 @@
* key. However, if a GrEffect uses different swizzles based on its input then it must
* consider that variation in its key-generation.
*/
-class GrTextureAccess : SkNoncopyable {
+class GrTextureAccess : public SkNoncopyable {
public:
+ SK_DECLARE_INST_COUNT_ROOT(GrTextureAccess);
+
/**
* A default GrTextureAccess must have reset() called on it in a GrEffect subclass's
* constructor if it will be accessible via GrEffect::textureAccess().
@@ -155,13 +157,18 @@
strcmp(fSwizzle, other.fSwizzle));
#endif
return fParams == other.fParams &&
- (fTexture.get() == other.fTexture.get()) &&
+ (this->getTexture() == other.getTexture()) &&
(0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1));
}
bool operator!= (const GrTextureAccess& other) const { return !(*this == other); }
- GrTexture* getTexture() const { return fTexture.get(); }
+ GrTexture* getTexture() const { return (GrTexture*)fTexture.getResource(); }
+
+ /**
+ * For internal use by GrEffect.
+ */
+ const GrProgramResource* getTextureProgramResource() const { return &fTexture; }
/**
* Returns a string representing the swizzle. The string is is null-terminated.
@@ -177,10 +184,10 @@
private:
void setSwizzle(const char*);
- GrTextureParams fParams;
- SkAutoTUnref<GrTexture> fTexture;
- uint32_t fSwizzleMask;
- char fSwizzle[5];
+ GrProgramResource fTexture;
+ GrTextureParams fParams;
+ uint32_t fSwizzleMask;
+ char fSwizzle[5];
typedef SkNoncopyable INHERITED;
};