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 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 /* | 61 /* |
62 * This class is used by fragment processors to build their fragment code. | 62 * This class is used by fragment processors to build their fragment code. |
63 */ | 63 */ |
64 class GrGLSLFPFragmentBuilder : virtual public GrGLSLFragmentBuilder { | 64 class GrGLSLFPFragmentBuilder : virtual public GrGLSLFragmentBuilder { |
65 public: | 65 public: |
66 /** Appease the compiler; the derived class initializes GrGLSLFragmentBuilde
r. */ | 66 /** Appease the compiler; the derived class initializes GrGLSLFragmentBuilde
r. */ |
67 GrGLSLFPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {} | 67 GrGLSLFPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {} |
68 | 68 |
69 /** | 69 /** |
| 70 * Subtracts sample coverage from the fragment. Any sample whose correspondi
ng bit is not found |
| 71 * in the mask will not be written out to the framebuffer. |
| 72 * |
| 73 * @param mask int that contains the sample mask. Bit N corresponds to
the Nth sample. |
| 74 * @param invert perform a bit-wise NOT on the provided mask before apply
ing it? |
| 75 * |
| 76 * Requires GLSL support for sample variables. |
| 77 */ |
| 78 virtual void maskSampleCoverage(const char* mask, bool invert = false) = 0; |
| 79 |
| 80 /** |
70 * Fragment procs with child procs should call these functions before/after
calling emitCode | 81 * Fragment procs with child procs should call these functions before/after
calling emitCode |
71 * on a child proc. | 82 * on a child proc. |
72 */ | 83 */ |
73 virtual void onBeforeChildProcEmitCode() = 0; | 84 virtual void onBeforeChildProcEmitCode() = 0; |
74 virtual void onAfterChildProcEmitCode() = 0; | 85 virtual void onAfterChildProcEmitCode() = 0; |
75 | 86 |
76 virtual const SkString& getMangleString() const = 0; | 87 virtual const SkString& getMangleString() const = 0; |
77 }; | 88 }; |
78 | 89 |
79 /* | 90 /* |
80 * This class is used by primitive processors to build their fragment code. | 91 * This class is used by primitive processors to build their fragment code. |
81 */ | 92 */ |
82 class GrGLSLPPFragmentBuilder : public GrGLSLFPFragmentBuilder { | 93 class GrGLSLPPFragmentBuilder : public GrGLSLFPFragmentBuilder { |
83 public: | 94 public: |
84 /** Appease the compiler; the derived class initializes GrGLSLFragmentBuilde
r. */ | 95 /** Appease the compiler; the derived class initializes GrGLSLFragmentBuilde
r. */ |
85 GrGLSLPPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {} | 96 GrGLSLPPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {} |
| 97 |
| 98 /** |
| 99 * Overrides the fragment's sample coverage. The provided mask determines wh
ich samples will now |
| 100 * be written out to the framebuffer. Note that this mask can be reduced by
a future call to |
| 101 * maskSampleCoverage. |
| 102 * |
| 103 * If a primitive processor uses this method, it must guarantee that every c
odepath through the |
| 104 * shader overrides the sample mask at some point. |
| 105 * |
| 106 * @param mask int that contains the new coverage mask. Bit N corresponds
to the Nth sample. |
| 107 * |
| 108 * Requires NV_sample_mask_override_coverage. |
| 109 */ |
| 110 virtual void overrideSampleCoverage(const char* mask) = 0; |
86 }; | 111 }; |
87 | 112 |
88 /* | 113 /* |
89 * This class is used by Xfer processors to build their fragment code. | 114 * This class is used by Xfer processors to build their fragment code. |
90 */ | 115 */ |
91 class GrGLSLXPFragmentBuilder : virtual public GrGLSLFragmentBuilder { | 116 class GrGLSLXPFragmentBuilder : virtual public GrGLSLFragmentBuilder { |
92 public: | 117 public: |
93 /** Appease the compiler; the derived class initializes GrGLSLFragmentBuilde
r. */ | 118 /** Appease the compiler; the derived class initializes GrGLSLFragmentBuilde
r. */ |
94 GrGLSLXPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {} | 119 GrGLSLXPFragmentBuilder() : GrGLSLFragmentBuilder(nullptr) {} |
95 | 120 |
(...skipping 24 matching lines...) Expand all Loading... |
120 | 145 |
121 GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program, uint8_t fragPosKe
y); | 146 GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program, uint8_t fragPosKe
y); |
122 | 147 |
123 // Shared GrGLSLFragmentBuilder interface. | 148 // Shared GrGLSLFragmentBuilder interface. |
124 bool enableFeature(GLSLFeature) override; | 149 bool enableFeature(GLSLFeature) override; |
125 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords
, | 150 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords
, |
126 int index) override; | 151 int index) override; |
127 const char* fragmentPosition() override; | 152 const char* fragmentPosition() override; |
128 | 153 |
129 // GrGLSLFPFragmentBuilder interface. | 154 // GrGLSLFPFragmentBuilder interface. |
| 155 void maskSampleCoverage(const char* mask, bool invert = false) override; |
| 156 void overrideSampleCoverage(const char* mask) override; |
130 const SkString& getMangleString() const override { return fMangleString; } | 157 const SkString& getMangleString() const override { return fMangleString; } |
131 void onBeforeChildProcEmitCode() override; | 158 void onBeforeChildProcEmitCode() override; |
132 void onAfterChildProcEmitCode() override; | 159 void onAfterChildProcEmitCode() override; |
133 | 160 |
134 // GrGLSLXPFragmentBuilder interface. | 161 // GrGLSLXPFragmentBuilder interface. |
135 bool hasCustomColorOutput() const override { return fHasCustomColorOutput; } | 162 bool hasCustomColorOutput() const override { return fHasCustomColorOutput; } |
136 bool hasSecondaryOutput() const override { return fHasSecondaryOutput; } | 163 bool hasSecondaryOutput() const override { return fHasSecondaryOutput; } |
137 const char* dstColor() override; | 164 const char* dstColor() override; |
138 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override; | 165 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override; |
139 | 166 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 * have "_c3_c1_c2" appended to its name, which can be interpreted as "base
proc's 3rd child's | 217 * have "_c3_c1_c2" appended to its name, which can be interpreted as "base
proc's 3rd child's |
191 * 1st child's 2nd child". | 218 * 1st child's 2nd child". |
192 */ | 219 */ |
193 SkString fMangleString; | 220 SkString fMangleString; |
194 | 221 |
195 bool fSetupFragPosition; | 222 bool fSetupFragPosition; |
196 bool fTopLeftFragPosRead; | 223 bool fTopLeftFragPosRead; |
197 bool fHasCustomColorOutput; | 224 bool fHasCustomColorOutput; |
198 int fCustomColorOutputIndex; | 225 int fCustomColorOutputIndex; |
199 bool fHasSecondaryOutput; | 226 bool fHasSecondaryOutput; |
| 227 bool fHasInitializedSampleMask; |
200 | 228 |
201 // some state to verify shaders and effects are consistent, this is reset be
tween effects by | 229 // some state to verify shaders and effects are consistent, this is reset be
tween effects by |
202 // the program creator | 230 // the program creator |
203 bool fHasReadDstColor; | 231 bool fHasReadDstColor; |
204 bool fHasReadFragmentPosition; | 232 bool fHasReadFragmentPosition; |
205 | 233 |
206 friend class GrGLSLProgramBuilder; | 234 friend class GrGLSLProgramBuilder; |
207 friend class GrGLProgramBuilder; | 235 friend class GrGLProgramBuilder; |
208 }; | 236 }; |
209 | 237 |
210 #endif | 238 #endif |
OLD | NEW |