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

Unified Diff: src/gpu/gl/GrGLEffectArray.h

Issue 25474006: Move VertexBuilder to a GrGLFullShaderBuilder subclass (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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
Index: src/gpu/gl/GrGLEffectArray.h
diff --git a/src/gpu/gl/GrGLEffectArray.h b/src/gpu/gl/GrGLEffectArray.h
index 49f712fccd0d21f9876a89db0716b0b74e8949dd..0a7f26e6f062ae2d414a0aa929010b2a5eabf6b4 100644
--- a/src/gpu/gl/GrGLEffectArray.h
+++ b/src/gpu/gl/GrGLEffectArray.h
@@ -15,7 +15,9 @@
class GrEffectStage;
class GrGLEffectArrayBuilder;
+class GrGLVertexEffectArrayBuilder;
class GrGLShaderBuilder;
+class GrGLFullShaderBuilder;
/**
* This class encapsulates an array of GrGLEffects and their supporting data (coord transforms
@@ -34,7 +36,7 @@ public:
static EffectKey GenTransformKey(const GrDrawEffect&);
static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
- ~GrGLEffectArray() { fGLEffects.deleteAll(); }
+ virtual ~GrGLEffectArray() { fGLEffects.deleteAll(); }
/**
* Assigns a texture unit to each sampler. It starts on *texUnitIdx and writes the next
@@ -45,9 +47,9 @@ public:
/**
* Calls setData() on each effect, and sets their transformation matrices and texture bindings.
*/
- void setData(GrGpuGL*,
- const GrGLUniformManager&,
- const GrEffectStage* effectStages[]);
+ virtual void setData(GrGpuGL*,
+ const GrGLUniformManager&,
+ const GrEffectStage* effectStages[]) = 0;
/**
* Passed to GrGLEffects so they can add transformed coordinates to their shader code.
@@ -97,12 +99,44 @@ public:
typedef SkTArray<TextureSampler> TextureSamplerArray;
-private:
+protected:
friend class GrGLEffectArrayBuilder;
- GrGLEffectArray(int reserveCount, bool explicitLocalCoords)
- : fTransforms(reserveCount)
- , fSamplers(reserveCount)
+ GrGLEffectArray(int reserveCount) : fSamplers(reserveCount) {}
+
+ /**
+ * Helper for setData(). Binds all the textures for an effect.
+ */
+ void bindTextures(GrGpuGL*, const GrEffectRef&, int effectIdx);
+
+ struct Sampler {
+ SkDEBUGCODE(Sampler() : fTextureUnit(-1) {})
+ UniformHandle fUniform;
+ int fTextureUnit;
+ };
+
+ SkTDArray<GrGLEffect*> fGLEffects;
+ SkTArray<SkSTArray<4, Sampler, true> > fSamplers;
+};
+
+/**
+ * This is a GrGLEffectArray implementation that does coord transforms with the vertex shader.
+ */
+class GrGLVertexEffectArray : public GrGLEffectArray {
+public:
+ /**
+ * Calls setData() on each effect, and sets their transformation matrices and texture bindings.
+ */
+ virtual void setData(GrGpuGL*,
+ const GrGLUniformManager&,
+ const GrEffectStage* effectStages[]) SK_OVERRIDE;
+
+private:
+ friend class GrGLVertexEffectArrayBuilder;
+
+ GrGLVertexEffectArray(int reserveCount, bool explicitLocalCoords)
+ : INHERITED(reserveCount)
+ , fTransforms(reserveCount)
, fHasExplicitLocalCoords(explicitLocalCoords) {
}
@@ -111,11 +145,6 @@ private:
*/
void setTransformData(const GrGLUniformManager&, const GrDrawEffect&, int effectIdx);
- /**
- * Helper for setData(). Binds all the textures for an effect.
- */
- void bindTextures(GrGpuGL*, const GrEffectRef&, int effectIdx);
-
struct Transform {
Transform() { fCurrentValue = SkMatrix::InvalidMatrix(); }
UniformHandle fHandle;
@@ -123,16 +152,10 @@ private:
SkMatrix fCurrentValue;
};
- struct Sampler {
- SkDEBUGCODE(Sampler() : fTextureUnit(-1) {})
- UniformHandle fUniform;
- int fTextureUnit;
- };
-
- SkTDArray<GrGLEffect*> fGLEffects;
SkTArray<SkSTArray<2, Transform, true> > fTransforms;
- SkTArray<SkSTArray<4, Sampler, true> > fSamplers;
bool fHasExplicitLocalCoords;
+
+ typedef GrGLEffectArray INHERITED;
};
////////////////////////////////////////////////////////////////////////////////
@@ -142,16 +165,38 @@ private:
*/
class GrGLEffectArrayBuilder {
public:
- GrGLEffectArrayBuilder(GrGLShaderBuilder* builder, int reserveCount);
-
/**
* Emits the effect's shader code, and stores the necessary uniforms internally.
*/
- void emitEffect(const GrEffectStage&,
- GrGLEffectArray::EffectKey,
- const char* outColor,
- const char* inColor,
- int stageIndex);
+ virtual void emitEffect(const GrEffectStage&,
+ GrGLEffectArray::EffectKey,
+ const char* outColor,
+ const char* inColor,
+ int stageIndex) = 0;
+
+protected:
+ /**
+ * Helper for emitEffect(). Emits uniforms for an effect's texture accesses and appends the
+ * necessary data to the TextureSamplerArray* object so effects can add texture lookups.
+ */
+ static void emitSamplers(GrGLShaderBuilder*,
+ GrGLEffectArray*,
+ const GrEffectRef&,
+ GrGLEffectArray::TextureSamplerArray*);
+};
+
+/**
+ * This class is used by GrGLFullShaderBuilder to construct a GrGLVertexEffectArray.
+ */
+class GrGLVertexEffectArrayBuilder : public GrGLEffectArrayBuilder {
+public:
+ GrGLVertexEffectArrayBuilder(GrGLFullShaderBuilder*, int reserveCount);
+
+ virtual void emitEffect(const GrEffectStage&,
+ GrGLEffectArray::EffectKey,
+ const char* outColor,
+ const char* inColor,
+ int stageIndex) SK_OVERRIDE;
/**
* Finalizes the building process and returns the effect array. After this call, the builder
@@ -176,16 +221,10 @@ private:
GrGLEffectArray::EffectKey,
GrGLEffectArray::TransformedCoordsArray*);
- /**
- * Helper for emitEffect(). Emits uniforms for an effect's texture accesses. The uniform info
- * as well as texture access parameters are appended to the TextureSamplerArray* object, which
- * is in turn passed to the effect's emitCode() function.
- */
- void emitSamplers(const GrEffectRef&,
- GrGLEffectArray::TextureSamplerArray*);
+ GrGLFullShaderBuilder* fBuilder;
+ SkAutoTDelete<GrGLVertexEffectArray> fEffectArray;
- GrGLShaderBuilder* fBuilder;
- SkAutoTDelete<GrGLEffectArray> fEffectArray;
+ typedef GrGLEffectArrayBuilder INHERITED;
};
#endif

Powered by Google App Engine
This is Rietveld 408576698