OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLSLPrimitiveProcessor_DEFINED | 8 #ifndef GrGLSLPrimitiveProcessor_DEFINED |
9 #define GrGLSLPrimitiveProcessor_DEFINED | 9 #define GrGLSLPrimitiveProcessor_DEFINED |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 struct EmitArgs { | 36 struct EmitArgs { |
37 EmitArgs(GrGLSLVertexBuilder* vertBuilder, | 37 EmitArgs(GrGLSLVertexBuilder* vertBuilder, |
38 GrGLSLPPFragmentBuilder* fragBuilder, | 38 GrGLSLPPFragmentBuilder* fragBuilder, |
39 GrGLSLVaryingHandler* varyingHandler, | 39 GrGLSLVaryingHandler* varyingHandler, |
40 GrGLSLUniformHandler* uniformHandler, | 40 GrGLSLUniformHandler* uniformHandler, |
41 const GrGLSLCaps* caps, | 41 const GrGLSLCaps* caps, |
42 const GrPrimitiveProcessor& gp, | 42 const GrPrimitiveProcessor& gp, |
43 const char* outputColor, | 43 const char* outputColor, |
44 const char* outputCoverage, | 44 const char* outputCoverage, |
| 45 const char* distanceVectorName, |
45 const SamplerHandle* texSamplers, | 46 const SamplerHandle* texSamplers, |
46 const SamplerHandle* bufferSamplers, | 47 const SamplerHandle* bufferSamplers, |
47 const TransformsIn& transformsIn, | 48 const TransformsIn& transformsIn, |
48 TransformsOut* transformsOut) | 49 TransformsOut* transformsOut) |
49 : fVertBuilder(vertBuilder) | 50 : fVertBuilder(vertBuilder) |
50 , fFragBuilder(fragBuilder) | 51 , fFragBuilder(fragBuilder) |
51 , fVaryingHandler(varyingHandler) | 52 , fVaryingHandler(varyingHandler) |
52 , fUniformHandler(uniformHandler) | 53 , fUniformHandler(uniformHandler) |
53 , fGLSLCaps(caps) | 54 , fGLSLCaps(caps) |
54 , fGP(gp) | 55 , fGP(gp) |
55 , fOutputColor(outputColor) | 56 , fOutputColor(outputColor) |
56 , fOutputCoverage(outputCoverage) | 57 , fOutputCoverage(outputCoverage) |
| 58 , fDistanceVectorName(distanceVectorName) |
57 , fTexSamplers(texSamplers) | 59 , fTexSamplers(texSamplers) |
58 , fBufferSamplers(bufferSamplers) | 60 , fBufferSamplers(bufferSamplers) |
59 , fTransformsIn(transformsIn) | 61 , fTransformsIn(transformsIn) |
60 , fTransformsOut(transformsOut) {} | 62 , fTransformsOut(transformsOut) {} |
61 GrGLSLVertexBuilder* fVertBuilder; | 63 GrGLSLVertexBuilder* fVertBuilder; |
62 GrGLSLPPFragmentBuilder* fFragBuilder; | 64 GrGLSLPPFragmentBuilder* fFragBuilder; |
63 GrGLSLVaryingHandler* fVaryingHandler; | 65 GrGLSLVaryingHandler* fVaryingHandler; |
64 GrGLSLUniformHandler* fUniformHandler; | 66 GrGLSLUniformHandler* fUniformHandler; |
65 const GrGLSLCaps* fGLSLCaps; | 67 const GrGLSLCaps* fGLSLCaps; |
66 const GrPrimitiveProcessor& fGP; | 68 const GrPrimitiveProcessor& fGP; |
67 const char* fOutputColor; | 69 const char* fOutputColor; |
68 const char* fOutputCoverage; | 70 const char* fOutputCoverage; |
| 71 const char* fDistanceVectorName; |
69 const SamplerHandle* fTexSamplers; | 72 const SamplerHandle* fTexSamplers; |
70 const SamplerHandle* fBufferSamplers; | 73 const SamplerHandle* fBufferSamplers; |
71 const TransformsIn& fTransformsIn; | 74 const TransformsIn& fTransformsIn; |
72 TransformsOut* fTransformsOut; | 75 TransformsOut* fTransformsOut; |
73 }; | 76 }; |
74 | 77 |
75 /** | 78 /** |
76 * This is similar to emitCode() in the base class, except it takes a full s
hader builder. | 79 * This is similar to emitCode() in the base class, except it takes a full s
hader builder. |
77 * This allows the effect subclass to emit vertex code. | 80 * This allows the effect subclass to emit vertex code. |
78 */ | 81 */ |
79 virtual void emitCode(EmitArgs&) = 0; | 82 virtual void emitCode(EmitArgs&) = 0; |
80 | 83 |
81 | |
82 /** A GrGLSLPrimitiveProcessor instance can be reused with any GrGLSLPrimiti
veProcessor that | 84 /** A GrGLSLPrimitiveProcessor instance can be reused with any GrGLSLPrimiti
veProcessor that |
83 produces the same stage key; this function reads data from a GrGLSLPrimi
tiveProcessor and | 85 produces the same stage key; this function reads data from a GrGLSLPrimi
tiveProcessor and |
84 uploads any uniform variables required by the shaders created in emitCo
de(). The | 86 uploads any uniform variables required by the shaders created in emitCo
de(). The |
85 GrPrimitiveProcessor parameter is guaranteed to be of the same type that
created this | 87 GrPrimitiveProcessor parameter is guaranteed to be of the same type that
created this |
86 GrGLSLPrimitiveProcessor and to have an identical processor key as the o
ne that created this | 88 GrGLSLPrimitiveProcessor and to have an identical processor key as the o
ne that created this |
87 GrGLSLPrimitiveProcessor. */ | 89 GrGLSLPrimitiveProcessor. */ |
88 virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProce
ssor&) = 0; | 90 virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProce
ssor&) = 0; |
89 | 91 |
90 static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoor
dTransform&); | 92 static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoor
dTransform&); |
91 | 93 |
92 virtual void setTransformData(const GrPrimitiveProcessor&, | 94 virtual void setTransformData(const GrPrimitiveProcessor&, |
93 const GrGLSLProgramDataManager& pdman, | 95 const GrGLSLProgramDataManager& pdman, |
94 int index, | 96 int index, |
95 const SkTArray<const GrCoordTransform*, true>&
transforms) = 0; | 97 const SkTArray<const GrCoordTransform*, true>&
transforms) = 0; |
96 | 98 |
97 protected: | 99 protected: |
98 void setupUniformColor(GrGLSLPPFragmentBuilder* fragBuilder, | 100 void setupUniformColor(GrGLSLPPFragmentBuilder* fragBuilder, |
99 GrGLSLUniformHandler* uniformHandler, | 101 GrGLSLUniformHandler* uniformHandler, |
100 const char* outputName, | 102 const char* outputName, |
101 UniformHandle* colorUniform); | 103 UniformHandle* colorUniform); |
102 | 104 |
103 struct Transform { | 105 struct Transform { |
104 Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidM
atrix(); } | 106 Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidM
atrix(); } |
105 SkMatrix fCurrentValue; | 107 SkMatrix fCurrentValue; |
106 GrSLType fType; | 108 GrSLType fType; |
107 }; | 109 }; |
108 }; | 110 }; |
109 | 111 |
110 #endif | 112 #endif |
OLD | NEW |