Index: src/gpu/gl/GrGLGeometryProcessor.h |
diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h |
index 3c95830fb290878505408c26045e42c4983170be..88b69a6d8fb0252a090a34143e1eb8b0b4dd72ed 100644 |
--- a/src/gpu/gl/GrGLGeometryProcessor.h |
+++ b/src/gpu/gl/GrGLGeometryProcessor.h |
@@ -127,6 +127,7 @@ private: |
}; |
class GrGLPathRendering; |
+class GrGLVertexBuilder; |
/** |
* If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, then it must inherit |
* from this class. Since paths don't have vertices, this class is only meant to be used internally |
@@ -143,26 +144,47 @@ public: |
const SkTArray<const GrCoordTransform*, true>& transforms); |
protected: |
- const char* position() const { return "pos3"; } |
- |
// Many GrGeometryProcessors do not need explicit local coords |
void emitTransforms(GrGLGPBuilder* gp, |
- const char* position, |
+ const GrShaderVar& posVar, |
const SkMatrix& localMatrix, |
const TransformsIn& tin, |
TransformsOut* tout) { |
- this->emitTransforms(gp, position, position, localMatrix, tin, tout); |
+ this->emitTransforms(gp, posVar, posVar.c_str(), localMatrix, tin, tout); |
} |
void emitTransforms(GrGLGPBuilder*, |
- const char* position, |
+ const GrShaderVar& posVar, |
const char* localCoords, |
const SkMatrix& localMatrix, |
const TransformsIn&, |
TransformsOut*); |
+ struct GrGPArgs { |
+ // The variable used by a GP to store its position. It can be |
+ // either a vec2 or a vec3 depending on the presence of perspective. |
+ GrShaderVar fPositionVar; |
+ }; |
+ |
+ // Create the correct type of position variable given the CTM |
+ static void SetupPosition(GrGLVertexBuilder* vsBuilder, |
+ GrGPArgs* gpArgs, |
+ const char* posName, |
+ const SkMatrix& mat, |
+ const char* matName); |
+ |
+ static uint32_t ComputePosKey(const SkMatrix& mat) { |
+ if (mat.isIdentity()) { |
+ return 0x0; |
+ } else if (!mat.hasPerspective()) { |
+ return 0x01; |
+ } else { |
+ return 0x02; |
+ } |
+ } |
+ |
private: |
- virtual void onEmitCode(EmitArgs&) = 0; |
+ virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0; |
typedef GrGLPrimitiveProcessor INHERITED; |
}; |