Index: src/gpu/GrGeometryProcessor.cpp |
diff --git a/src/gpu/GrGeometryProcessor.cpp b/src/gpu/GrGeometryProcessor.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..26f8d9a40445705e1b555f518e2c637dc7d3cb13 |
--- /dev/null |
+++ b/src/gpu/GrGeometryProcessor.cpp |
@@ -0,0 +1,48 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include "GrGeometryProcessor.h" |
+#include "gl/GrGLGeometryProcessor.h" |
+#include "gl/builders/GrGLProgramBuilder.h" |
+#include "gl/builders/GrGLVertexShaderBuilder.h" |
+ |
+const GrGeometryProcessor* GrGeometryProcessor::CreatePassthroughGP(size_t vertexStride) { |
+ class NullGP : public GrGeometryProcessor { |
+ public: |
+ NullGP(size_t vertexStride) { |
+ this->initClassID<NullGP>(); |
+ fPosAttr = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVertexAttribType)); |
+ // Must call this after setting fPosAttr as that function adds 2 floats to the vertex |
+ // stride. |
+ SkASSERT(vertexStride >= sizeof(float) * 2); |
+ fVertexStride = vertexStride; |
+ } |
+ |
+ const char* name() const override { return "Null"; } |
+ |
+ void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {} |
+ |
+ GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps& caps) const override { |
+ class GLGP : public GrGLGeometryProcessor { |
+ private: |
+ void onEmitCode(EmitArgs& emitArgs, GrGPArgs* gpArgs) override { |
+ SkASSERT(!emitArgs.fTransformsIn.count()); |
+ const NullGP& gp = emitArgs.fGP.cast<NullGP>(); |
+ GrGLGPBuilder* pb = emitArgs.fPB; |
+ GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
+ vsBuilder->emitAttributes(gp); |
+ this->setupPosition(pb, gpArgs, gp.fPosAttr->fName); |
+ } |
+ void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override {} |
+ }; |
+ return new GLGP(); |
+ } |
+ private: |
+ const Attribute* fPosAttr; |
+ }; |
+ return new NullGP(vertexStride); |
+} |