| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2013 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 #ifndef GrGLPrimitiveProcessor_DEFINED | |
| 9 #define GrGLPrimitiveProcessor_DEFINED | |
| 10 | |
| 11 #include "GrPrimitiveProcessor.h" | |
| 12 #include "glsl/GrGLSLProcessorTypes.h" | |
| 13 #include "glsl/GrGLSLProgramDataManager.h" | |
| 14 #include "glsl/GrGLSLTextureSampler.h" | |
| 15 | |
| 16 class GrBatchTracker; | |
| 17 class GrPrimitiveProcessor; | |
| 18 class GrGLSLGPBuilder; | |
| 19 | |
| 20 class GrGLPrimitiveProcessor { | |
| 21 public: | |
| 22 virtual ~GrGLPrimitiveProcessor() {} | |
| 23 | |
| 24 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | |
| 25 typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray; | |
| 26 | |
| 27 typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords; | |
| 28 typedef SkSTArray<8, ProcCoords> TransformsIn; | |
| 29 typedef SkSTArray<8, GrGLSLTransformedCoordsArray> TransformsOut; | |
| 30 | |
| 31 struct EmitArgs { | |
| 32 EmitArgs(GrGLSLGPBuilder* pb, | |
| 33 const GrPrimitiveProcessor& gp, | |
| 34 const char* outputColor, | |
| 35 const char* outputCoverage, | |
| 36 const TextureSamplerArray& samplers, | |
| 37 const TransformsIn& transformsIn, | |
| 38 TransformsOut* transformsOut) | |
| 39 : fPB(pb) | |
| 40 , fGP(gp) | |
| 41 , fOutputColor(outputColor) | |
| 42 , fOutputCoverage(outputCoverage) | |
| 43 , fSamplers(samplers) | |
| 44 , fTransformsIn(transformsIn) | |
| 45 , fTransformsOut(transformsOut) {} | |
| 46 GrGLSLGPBuilder* fPB; | |
| 47 const GrPrimitiveProcessor& fGP; | |
| 48 const char* fOutputColor; | |
| 49 const char* fOutputCoverage; | |
| 50 const TextureSamplerArray& fSamplers; | |
| 51 const TransformsIn& fTransformsIn; | |
| 52 TransformsOut* fTransformsOut; | |
| 53 }; | |
| 54 | |
| 55 /** | |
| 56 * This is similar to emitCode() in the base class, except it takes a full s
hader builder. | |
| 57 * This allows the effect subclass to emit vertex code. | |
| 58 */ | |
| 59 virtual void emitCode(EmitArgs&) = 0; | |
| 60 | |
| 61 | |
| 62 /** A GrGLPrimitiveProcessor instance can be reused with any GrGLPrimitivePr
ocessor that | |
| 63 produces the same stage key; this function reads data from a GrGLPrimiti
veProcessor and | |
| 64 uploads any uniform variables required by the shaders created in emitCo
de(). The | |
| 65 GrPrimitiveProcessor parameter is guaranteed to be of the same type that
created this | |
| 66 GrGLPrimitiveProcessor and to have an identical processor key as the one
that created this | |
| 67 GrGLPrimitiveProcessor. */ | |
| 68 virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProce
ssor&) = 0; | |
| 69 | |
| 70 static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoor
dTransform&); | |
| 71 | |
| 72 virtual void setTransformData(const GrPrimitiveProcessor&, | |
| 73 const GrGLSLProgramDataManager& pdman, | |
| 74 int index, | |
| 75 const SkTArray<const GrCoordTransform*, true>&
transforms) = 0; | |
| 76 | |
| 77 protected: | |
| 78 void setupUniformColor(GrGLSLGPBuilder* pb, | |
| 79 const char* outputName, | |
| 80 UniformHandle* colorUniform); | |
| 81 | |
| 82 struct Transform { | |
| 83 Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidM
atrix(); } | |
| 84 UniformHandle fHandle; | |
| 85 SkMatrix fCurrentValue; | |
| 86 GrSLType fType; | |
| 87 }; | |
| 88 | |
| 89 SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; | |
| 90 }; | |
| 91 | |
| 92 #endif | |
| OLD | NEW |