OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrGLFragmentShaderBuilder_DEFINED | 8 #ifndef GrGLFragmentShaderBuilder_DEFINED |
9 #define GrGLFragmentShaderBuilder_DEFINED | 9 #define GrGLFragmentShaderBuilder_DEFINED |
10 | 10 |
11 #include "GrGLShaderBuilder.h" | 11 #include "GrGLShaderBuilder.h" |
12 | 12 |
| 13 #include "glsl/GrGLSLProcessorTypes.h" |
| 14 |
13 class GrGLVarying; | 15 class GrGLVarying; |
14 | 16 |
15 /* | 17 /* |
16 * This base class encapsulates the functionality which the GP uses to build fra
gment shaders | 18 * This base class encapsulates the functionality which the GP uses to build fra
gment shaders |
17 */ | 19 */ |
18 class GrGLFragmentBuilder : public GrGLShaderBuilder { | 20 class GrGLFragmentBuilder : public GrGLShaderBuilder { |
19 public: | 21 public: |
20 GrGLFragmentBuilder(GrGLProgramBuilder* program) | 22 GrGLFragmentBuilder(GrGLProgramBuilder* program) |
21 : INHERITED(program) { | 23 : INHERITED(program) { |
22 fSubstageIndices.push_back(0); | 24 fSubstageIndices.push_back(0); |
(...skipping 12 matching lines...) Expand all Loading... |
35 * If the feature is supported then true is returned and any necessary #exte
nsion declarations | 37 * If the feature is supported then true is returned and any necessary #exte
nsion declarations |
36 * are added to the shaders. If the feature is not supported then false will
be returned. | 38 * are added to the shaders. If the feature is not supported then false will
be returned. |
37 */ | 39 */ |
38 virtual bool enableFeature(GLSLFeature) = 0; | 40 virtual bool enableFeature(GLSLFeature) = 0; |
39 | 41 |
40 /** | 42 /** |
41 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in | 43 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in |
42 * the fragment shader. If the coordinates at index are 3-dimensional, it im
mediately emits a | 44 * the fragment shader. If the coordinates at index are 3-dimensional, it im
mediately emits a |
43 * perspective divide into the fragment shader (xy / z) to convert them to 2
D. | 45 * perspective divide into the fragment shader (xy / z) to convert them to 2
D. |
44 */ | 46 */ |
45 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra
y& coords, | 47 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords
, int index) = 0; |
46 int index) = 0; | |
47 | 48 |
48 | 49 |
49 /** Returns a variable name that represents the position of the fragment in
the FS. The position | 50 /** Returns a variable name that represents the position of the fragment in
the FS. The position |
50 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ | 51 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ |
51 virtual const char* fragmentPosition() = 0; | 52 virtual const char* fragmentPosition() = 0; |
52 | 53 |
53 /** | 54 /** |
54 * Fragment procs with child procs should call these functions before/after
calling emitCode | 55 * Fragment procs with child procs should call these functions before/after
calling emitCode |
55 * on a child proc. | 56 * on a child proc. |
56 */ | 57 */ |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 121 |
121 /** Returns a key for reading the fragment location. This should only be cal
led if there is an | 122 /** Returns a key for reading the fragment location. This should only be cal
led if there is an |
122 effect that will requires the fragment position. If the fragment position
is not required, | 123 effect that will requires the fragment position. If the fragment position
is not required, |
123 the key is 0. */ | 124 the key is 0. */ |
124 static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const Gr
GLCaps&); | 125 static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const Gr
GLCaps&); |
125 | 126 |
126 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, uint8_t fragPosKey); | 127 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, uint8_t fragPosKey); |
127 | 128 |
128 // true public interface, defined explicitly in the abstract interfaces abov
e | 129 // true public interface, defined explicitly in the abstract interfaces abov
e |
129 bool enableFeature(GLSLFeature) override; | 130 bool enableFeature(GLSLFeature) override; |
130 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra
y& coords, | 131 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords
, |
131 int index) override; | 132 int index) override; |
132 const char* fragmentPosition() override; | 133 const char* fragmentPosition() override; |
133 const char* dstColor() override; | 134 const char* dstColor() override; |
134 | 135 |
135 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override; | 136 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override; |
136 | 137 |
137 private: | 138 private: |
138 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader | 139 // Private public interface, used by GrGLProgramBuilder to build a fragment
shader |
139 void enableCustomOutput(); | 140 void enableCustomOutput(); |
140 void enableSecondaryOutput(); | 141 void enableSecondaryOutput(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // the program creator | 195 // the program creator |
195 bool fHasReadDstColor; | 196 bool fHasReadDstColor; |
196 bool fHasReadFragmentPosition; | 197 bool fHasReadFragmentPosition; |
197 | 198 |
198 friend class GrGLProgramBuilder; | 199 friend class GrGLProgramBuilder; |
199 | 200 |
200 typedef GrGLXPFragmentBuilder INHERITED; | 201 typedef GrGLXPFragmentBuilder INHERITED; |
201 }; | 202 }; |
202 | 203 |
203 #endif | 204 #endif |
OLD | NEW |