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 GrGLSLFragmentShaderBuilder_DEFINED | 8 #ifndef GrGLSLFragmentShaderBuilder_DEFINED |
9 #define GrGLSLFragmentShaderBuilder_DEFINED | 9 #define GrGLSLFragmentShaderBuilder_DEFINED |
10 | 10 |
11 #include "GrGLSLShaderBuilder.h" | 11 #include "GrGLSLShaderBuilder.h" |
12 | 12 |
13 #include "GrProcessor.h" | 13 #include "GrProcessor.h" |
14 #include "glsl/GrGLSLProcessorTypes.h" | |
15 | 14 |
16 class GrRenderTarget; | 15 class GrRenderTarget; |
17 class GrGLSLVarying; | 16 class GrGLSLVarying; |
18 | 17 |
19 /* | 18 /* |
20 * This base class encapsulates the common functionality which all processors us
e to build fragment | 19 * This base class encapsulates the common functionality which all processors us
e to build fragment |
21 * shaders. | 20 * shaders. |
22 */ | 21 */ |
23 class GrGLSLFragmentBuilder : public GrGLSLShaderBuilder { | 22 class GrGLSLFragmentBuilder : public GrGLSLShaderBuilder { |
24 public: | 23 public: |
(...skipping 11 matching lines...) Expand all Loading... |
36 }; | 35 }; |
37 | 36 |
38 /** | 37 /** |
39 * If the feature is supported then true is returned and any necessary #exte
nsion declarations | 38 * If the feature is supported then true is returned and any necessary #exte
nsion declarations |
40 * are added to the shaders. If the feature is not supported then false will
be returned. | 39 * are added to the shaders. If the feature is not supported then false will
be returned. |
41 */ | 40 */ |
42 virtual bool enableFeature(GLSLFeature) = 0; | 41 virtual bool enableFeature(GLSLFeature) = 0; |
43 | 42 |
44 /** | 43 /** |
45 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in | 44 * This returns a variable name to access the 2D, perspective correct versio
n of the coords in |
46 * the fragment shader. If the coordinates at index are 3-dimensional, it im
mediately emits a | 45 * the fragment shader. The passed in coordinates must either be of type kVe
c2f or kVec3f. If |
47 * perspective divide into the fragment shader (xy / z) to convert them to 2
D. | 46 * the coordinates are 3-dimensional, it a perspective divide into is emitte
d into the |
| 47 * fragment shader (xy / z) to convert them to 2D. |
48 */ | 48 */ |
49 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords
, int index) = 0; | 49 virtual SkString ensureCoords2D(const GrShaderVar&) = 0; |
50 | 50 |
51 | 51 |
52 /** Returns a variable name that represents the position of the fragment in
the FS. The position | 52 /** Returns a variable name that represents the position of the fragment in
the FS. The position |
53 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ | 53 is in device space (e.g. 0,0 is the top left and pixel centers are at ha
lf-integers). */ |
54 virtual const char* fragmentPosition() = 0; | 54 virtual const char* fragmentPosition() = 0; |
55 | 55 |
56 // TODO: remove this method. | 56 // TODO: remove this method. |
57 void declAppendf(const char* fmt, ...); | 57 void declAppendf(const char* fmt, ...); |
58 | 58 |
59 private: | 59 private: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 class GrGLSLFragmentShaderBuilder : public GrGLSLPPFragmentBuilder, public GrGLS
LXPFragmentBuilder { | 160 class GrGLSLFragmentShaderBuilder : public GrGLSLPPFragmentBuilder, public GrGLS
LXPFragmentBuilder { |
161 public: | 161 public: |
162 /** Returns a nonzero key for a surface's origin. This should only be called
if a processor will | 162 /** Returns a nonzero key for a surface's origin. This should only be called
if a processor will |
163 use the fragment position and/or sample locations. */ | 163 use the fragment position and/or sample locations. */ |
164 static uint8_t KeyForSurfaceOrigin(GrSurfaceOrigin); | 164 static uint8_t KeyForSurfaceOrigin(GrSurfaceOrigin); |
165 | 165 |
166 GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program); | 166 GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program); |
167 | 167 |
168 // Shared GrGLSLFragmentBuilder interface. | 168 // Shared GrGLSLFragmentBuilder interface. |
169 bool enableFeature(GLSLFeature) override; | 169 bool enableFeature(GLSLFeature) override; |
170 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords
, | 170 virtual SkString ensureCoords2D(const GrShaderVar&) override; |
171 int index) override; | |
172 const char* fragmentPosition() override; | 171 const char* fragmentPosition() override; |
173 const char* distanceVectorName() const override; | 172 const char* distanceVectorName() const override; |
174 | 173 |
175 // GrGLSLFPFragmentBuilder interface. | 174 // GrGLSLFPFragmentBuilder interface. |
176 void appendOffsetToSample(const char* sampleIdx, Coordinates) override; | 175 void appendOffsetToSample(const char* sampleIdx, Coordinates) override; |
177 void maskSampleCoverage(const char* mask, bool invert = false) override; | 176 void maskSampleCoverage(const char* mask, bool invert = false) override; |
178 void overrideSampleCoverage(const char* mask) override; | 177 void overrideSampleCoverage(const char* mask) override; |
179 const SkString& getMangleString() const override { return fMangleString; } | 178 const SkString& getMangleString() const override { return fMangleString; } |
180 void onBeforeChildProcEmitCode() override; | 179 void onBeforeChildProcEmitCode() override; |
181 void onAfterChildProcEmitCode() override; | 180 void onAfterChildProcEmitCode() override; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // the program creator | 246 // the program creator |
248 GrProcessor::RequiredFeatures fUsedProcessorFeatures; | 247 GrProcessor::RequiredFeatures fUsedProcessorFeatures; |
249 bool fHasReadDstColor; | 248 bool fHasReadDstColor; |
250 #endif | 249 #endif |
251 | 250 |
252 friend class GrGLSLProgramBuilder; | 251 friend class GrGLSLProgramBuilder; |
253 friend class GrGLProgramBuilder; | 252 friend class GrGLProgramBuilder; |
254 }; | 253 }; |
255 | 254 |
256 #endif | 255 #endif |
OLD | NEW |