| 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 class GrGLVarying; | 13 class GrGLVarying; |
| 14 | 14 |
| 15 /* | 15 /* |
| 16 * This base class encapsulates the functionality which the GP uses to build fra
gment shaders | 16 * This base class encapsulates the functionality which the GP uses to build fra
gment shaders |
| 17 */ | 17 */ |
| 18 class GrGLGPFragmentBuilder : public GrGLShaderBuilder { | 18 class GrGLFragmentBuilder : public GrGLShaderBuilder { |
| 19 public: | 19 public: |
| 20 GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} | 20 GrGLFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} |
| 21 virtual ~GrGLGPFragmentBuilder() {} | 21 virtual ~GrGLFragmentBuilder() {} |
| 22 /** | 22 /** |
| 23 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile | 23 * Use of these features may require a GLSL extension to be enabled. Shaders
may not compile |
| 24 * if code is added that uses one of these features without calling enableFe
ature() | 24 * if code is added that uses one of these features without calling enableFe
ature() |
| 25 */ | 25 */ |
| 26 enum GLSLFeature { | 26 enum GLSLFeature { |
| 27 kStandardDerivatives_GLSLFeature = 0, | 27 kStandardDerivatives_GLSLFeature = 0, |
| 28 kLastGLSLFeature = kStandardDerivatives_GLSLFeature | 28 kLastGLSLFeature = kStandardDerivatives_GLSLFeature |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 /** | 31 /** |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 friend class GrGLPathProcessor; | 51 friend class GrGLPathProcessor; |
| 52 | 52 |
| 53 typedef GrGLShaderBuilder INHERITED; | 53 typedef GrGLShaderBuilder INHERITED; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 /* | 56 /* |
| 57 * Fragment processor's, in addition to all of the above, may need to use dst co
lor so they use | 57 * Fragment processor's, in addition to all of the above, may need to use dst co
lor so they use |
| 58 * this builder to create their shader. Because this is the only shader builder
the FP sees, we | 58 * this builder to create their shader. Because this is the only shader builder
the FP sees, we |
| 59 * just call it FPShaderBuilder | 59 * just call it FPShaderBuilder |
| 60 */ | 60 */ |
| 61 class GrGLFPFragmentBuilder : public GrGLGPFragmentBuilder { | 61 class GrGLXPFragmentBuilder : public GrGLFragmentBuilder { |
| 62 public: | 62 public: |
| 63 GrGLFPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} | 63 GrGLXPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} |
| 64 | 64 |
| 65 /** Returns the variable name that holds the color of the destination pixel.
This may be NULL if | 65 /** Returns the variable name that holds the color of the destination pixel.
This may be NULL if |
| 66 no effect advertised that it will read the destination. */ | 66 no effect advertised that it will read the destination. */ |
| 67 virtual const char* dstColor() = 0; | 67 virtual const char* dstColor() = 0; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 typedef GrGLGPFragmentBuilder INHERITED; | 70 typedef GrGLFragmentBuilder INHERITED; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // TODO rename to Fragment Builder | 73 // TODO rename to Fragment Builder |
| 74 class GrGLFragmentShaderBuilder : public GrGLFPFragmentBuilder { | 74 class GrGLFragmentShaderBuilder : public GrGLXPFragmentBuilder { |
| 75 public: | 75 public: |
| 76 typedef uint8_t DstReadKey; | 76 typedef uint8_t DstReadKey; |
| 77 typedef uint8_t FragPosKey; | 77 typedef uint8_t FragPosKey; |
| 78 | 78 |
| 79 /** Returns a key for adding code to read the copy-of-dst color in service
of effects that | 79 /** Returns a key for adding code to read the copy-of-dst color in service
of effects that |
| 80 require reading the dst. It must not return 0 because 0 indicates that t
here is no dst | 80 require reading the dst. It must not return 0 because 0 indicates that t
here is no dst |
| 81 copy read at all (in which case this function should not be called). */ | 81 copy read at all (in which case this function should not be called). */ |
| 82 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&); | 82 static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&); |
| 83 | 83 |
| 84 /** Returns a key for reading the fragment location. This should only be cal
led if there is an | 84 /** Returns a key for reading the fragment location. This should only be cal
led if there is an |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 bool fTopLeftFragPosRead; | 149 bool fTopLeftFragPosRead; |
| 150 int fCustomColorOutputIndex; | 150 int fCustomColorOutputIndex; |
| 151 | 151 |
| 152 // some state to verify shaders and effects are consistent, this is reset be
tween effects by | 152 // some state to verify shaders and effects are consistent, this is reset be
tween effects by |
| 153 // the program creator | 153 // the program creator |
| 154 bool fHasReadDstColor; | 154 bool fHasReadDstColor; |
| 155 bool fHasReadFragmentPosition; | 155 bool fHasReadFragmentPosition; |
| 156 | 156 |
| 157 friend class GrGLProgramBuilder; | 157 friend class GrGLProgramBuilder; |
| 158 | 158 |
| 159 typedef GrGLFPFragmentBuilder INHERITED; | 159 typedef GrGLXPFragmentBuilder INHERITED; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 #endif | 162 #endif |
| OLD | NEW |