OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "GrGeometryProcessor.h" |
| 9 #include "gl/GrGLGeometryProcessor.h" |
| 10 #include "gl/builders/GrGLProgramBuilder.h" |
| 11 #include "gl/builders/GrGLVertexShaderBuilder.h" |
| 12 |
| 13 const GrGeometryProcessor* GrGeometryProcessor::CreatePassthroughGP(size_t verte
xStride) { |
| 14 class NullGP : public GrGeometryProcessor { |
| 15 public: |
| 16 NullGP(size_t vertexStride) { |
| 17 this->initClassID<NullGP>(); |
| 18 fPosAttr = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrV
ertexAttribType)); |
| 19 // Must call this after setting fPosAttr as that function adds 2 flo
ats to the vertex |
| 20 // stride. |
| 21 SkASSERT(vertexStride >= sizeof(float) * 2); |
| 22 fVertexStride = vertexStride; |
| 23 } |
| 24 |
| 25 const char* name() const override { return "Null"; } |
| 26 |
| 27 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override {} |
| 28 |
| 29 GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps& caps) const o
verride { |
| 30 class GLGP : public GrGLGeometryProcessor { |
| 31 private: |
| 32 void onEmitCode(EmitArgs& emitArgs, GrGPArgs* gpArgs) override { |
| 33 SkASSERT(!emitArgs.fTransformsIn.count()); |
| 34 const NullGP& gp = emitArgs.fGP.cast<NullGP>(); |
| 35 GrGLGPBuilder* pb = emitArgs.fPB; |
| 36 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
| 37 vsBuilder->emitAttributes(gp); |
| 38 this->setupPosition(pb, gpArgs, gp.fPosAttr->fName); |
| 39 } |
| 40 void setData(const GrGLProgramDataManager&, const GrPrimitivePro
cessor&) override {} |
| 41 }; |
| 42 return new GLGP(); |
| 43 } |
| 44 private: |
| 45 const Attribute* fPosAttr; |
| 46 }; |
| 47 return new NullGP(vertexStride); |
| 48 } |
OLD | NEW |