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

Unified Diff: include/gpu/GrEffect.h

Issue 24853002: Make GPU coord transforms automatic (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 3 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/GrDrawEffect.h ('k') | include/gpu/GrTBackendEffectFactory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrEffect.h
diff --git a/include/gpu/GrEffect.h b/include/gpu/GrEffect.h
index 4dc294bfe8a1bbd49de162fe63b7dc1ba476f6f3..78752702f549bbd8296379e093e0e14ca428c06e 100644
--- a/include/gpu/GrEffect.h
+++ b/include/gpu/GrEffect.h
@@ -16,6 +16,7 @@
class GrBackendEffectFactory;
class GrContext;
+class GrCoordTransform;
class GrEffect;
class GrVertexEffect;
class SkString;
@@ -83,16 +84,6 @@ class GrEffect : private SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrEffect)
- /**
- * The types of vertex coordinates available to an effect in the vertex shader. Effects can
- * require their own vertex attribute but these coordinates are made available by the framework
- * in all programs.
- */
- enum CoordsType {
- kLocal_CoordsType,
- kPosition_CoordsType,
- };
-
virtual ~GrEffect();
/**
@@ -138,6 +129,12 @@ public:
in generated shader code. */
const char* name() const;
+ int numTransforms() const { return fCoordTransforms.count(); }
+
+ /** Returns the coordinate transformation at index. index must be valid according to
+ numTransforms(). */
+ const GrCoordTransform& coordTransform(int index) const { return *fCoordTransforms[index]; }
+
int numTextures() const { return fTextureAccesses.count(); }
/** Returns the access pattern for the texture at index. index must be valid according to
@@ -205,9 +202,18 @@ public:
protected:
/**
+ * Subclasses call this from their constructor to register coordinate transformations. The
+ * effect subclass manages the lifetime of the transformations (this function only stores a
+ * pointer). The GrCoordTransform is typically a member field of the GrEffect subclass. When the
+ * matrix has perspective, the transformed coordinates will have 3 components. Otherwise they'll
+ * have 2. This must only be called from the constructor because GrEffects are immutable.
+ */
+ void addCoordTransform(const GrCoordTransform* coordTransform);
+
+ /**
* Subclasses call this from their constructor to register GrTextureAccesses. The effect
* subclass manages the lifetime of the accesses (this function only stores a pointer). The
- * GrTextureAccess is typically a member field of the GrEffet subclass. This must only be
+ * GrTextureAccess is typically a member field of the GrEffect subclass. This must only be
* called from the constructor because GrEffects are immutable.
*/
void addTextureAccess(const GrTextureAccess* textureAccess);
@@ -289,15 +295,14 @@ private:
bool result = this->onIsEqual(other);
#ifdef SK_DEBUG
if (result) {
- SkASSERT(this->numTextures() == other.numTextures());
- for (int i = 0; i < this->numTextures(); ++i) {
- SkASSERT(*fTextureAccesses[i] == *other.fTextureAccesses[i]);
- }
+ this->assertEquality(other);
}
#endif
return result;
}
+ SkDEBUGCODE(void assertEquality(const GrEffect& other) const;)
+
/** Subclass implements this to support isEqual(). It will only be called if it is known that
the two effects are of the same subclass (i.e. they return the same object from
getFactory()).*/
@@ -311,6 +316,7 @@ private:
// to inc/dec deferred ref counts.
friend class GrVertexEffect; // to set fHasVertexCode and build fVertexAttribTypes.
+ SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes;
bool fWillReadDstColor;
« no previous file with comments | « include/gpu/GrDrawEffect.h ('k') | include/gpu/GrTBackendEffectFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698