Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: src/gpu/glsl/GrGLSLFragmentShaderBuilder.h

Issue 2114993002: GrFP can express distance vector field req., program builder declares variable for it (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-bevel-api-change
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 * the fragment shader. If the coordinates at index are 3-dimensional, it im mediately emits a 46 * the fragment shader. If the coordinates at index are 3-dimensional, it im mediately emits a
47 * perspective divide into the fragment shader (xy / z) to convert them to 2 D. 47 * perspective divide into the fragment shader (xy / z) to convert them to 2 D.
48 */ 48 */
49 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords , int index) = 0; 49 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords , int index) = 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 /** Returns a variable name that represents a vector to the nearest edge of the shape, in source
57 space coordinates. */
58 virtual const char* distanceVectorName() const = 0;
egdaniel 2016/07/12 13:46:42 with other changes mentioned in comments, I think
dvonbeck 2016/07/13 15:17:13 Done.
59 virtual bool hasDistanceVectorOutput() const = 0;
60
56 // TODO: remove this method. 61 // TODO: remove this method.
57 void declAppendf(const char* fmt, ...); 62 void declAppendf(const char* fmt, ...);
58 63
59 private: 64 private:
60 typedef GrGLSLShaderBuilder INHERITED; 65 typedef GrGLSLShaderBuilder INHERITED;
61 }; 66 };
62 67
63 /* 68 /*
64 * This class is used by fragment processors to build their fragment code. 69 * This class is used by fragment processors to build their fragment code.
65 */ 70 */
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 /** Returns a nonzero key for a surface's origin. This should only be called if a processor will 163 /** Returns a nonzero key for a surface's origin. This should only be called if a processor will
159 use the fragment position and/or sample locations. */ 164 use the fragment position and/or sample locations. */
160 static uint8_t KeyForSurfaceOrigin(GrSurfaceOrigin); 165 static uint8_t KeyForSurfaceOrigin(GrSurfaceOrigin);
161 166
162 GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program); 167 GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program);
163 168
164 // Shared GrGLSLFragmentBuilder interface. 169 // Shared GrGLSLFragmentBuilder interface.
165 bool enableFeature(GLSLFeature) override; 170 bool enableFeature(GLSLFeature) override;
166 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords , 171 virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords ,
167 int index) override; 172 int index) override;
168 const char* fragmentPosition() override; 173 const char* fragmentPosition() override;
robertphillips 2016/07/11 17:55:40 same order as above ?
dvonbeck 2016/07/13 15:17:13 Done.
174 bool hasDistanceVectorOutput() const override;
175 const char* distanceVectorName() const override;
169 176
170 // GrGLSLFPFragmentBuilder interface. 177 // GrGLSLFPFragmentBuilder interface.
171 void appendOffsetToSample(const char* sampleIdx, Coordinates) override; 178 void appendOffsetToSample(const char* sampleIdx, Coordinates) override;
172 void maskSampleCoverage(const char* mask, bool invert = false) override; 179 void maskSampleCoverage(const char* mask, bool invert = false) override;
173 void overrideSampleCoverage(const char* mask) override; 180 void overrideSampleCoverage(const char* mask) override;
174 const SkString& getMangleString() const override { return fMangleString; } 181 const SkString& getMangleString() const override { return fMangleString; }
175 void onBeforeChildProcEmitCode() override; 182 void onBeforeChildProcEmitCode() override;
176 void onAfterChildProcEmitCode() override; 183 void onAfterChildProcEmitCode() override;
177 184
178 // GrGLSLXPFragmentBuilder interface. 185 // GrGLSLXPFragmentBuilder interface.
179 bool hasCustomColorOutput() const override { return fHasCustomColorOutput; } 186 bool hasCustomColorOutput() const override { return fHasCustomColorOutput; }
180 bool hasSecondaryOutput() const override { return fHasSecondaryOutput; } 187 bool hasSecondaryOutput() const override { return fHasSecondaryOutput; }
181 const char* dstColor() override; 188 const char* dstColor() override;
182 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override; 189 void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override;
183 190
184 private: 191 private:
185 // Private public interface, used by GrGLProgramBuilder to build a fragment shader 192 // Private public interface, used by GrGLProgramBuilder to build a fragment shader
193 void enableDistanceVector(const SkString& name);
186 void enableCustomOutput(); 194 void enableCustomOutput();
187 void enableSecondaryOutput(); 195 void enableSecondaryOutput();
188 const char* getPrimaryColorOutputName() const; 196 const char* getPrimaryColorOutputName() const;
189 const char* getSecondaryColorOutputName() const; 197 const char* getSecondaryColorOutputName() const;
190 198
191 #ifdef SK_DEBUG 199 #ifdef SK_DEBUG
192 // As GLSLProcessors emit code, there are some conditions we need to verify. We use the below 200 // As GLSLProcessors emit code, there are some conditions we need to verify. We use the below
193 // state to track this. The reset call is called per processor emitted. 201 // state to track this. The reset call is called per processor emitted.
194 GrProcessor::RequiredFeatures usedProcessorFeatures() const { return fUsedPr ocessorFeatures; } 202 GrProcessor::RequiredFeatures usedProcessorFeatures() const { return fUsedPr ocessorFeatures; }
195 bool hasReadDstColor() const { return fHasReadDstColor; } 203 bool hasReadDstColor() const { return fHasReadDstColor; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 * 1st child's 2nd child". 236 * 1st child's 2nd child".
229 */ 237 */
230 SkString fMangleString; 238 SkString fMangleString;
231 239
232 bool fSetupFragPosition; 240 bool fSetupFragPosition;
233 bool fHasCustomColorOutput; 241 bool fHasCustomColorOutput;
234 int fCustomColorOutputIndex; 242 int fCustomColorOutputIndex;
235 bool fHasSecondaryOutput; 243 bool fHasSecondaryOutput;
236 uint8_t fUsedSampleOffsetArrays; 244 uint8_t fUsedSampleOffsetArrays;
237 bool fHasInitializedSampleMask; 245 bool fHasInitializedSampleMask;
246 SkString fDistanceVectorOutput;
238 247
239 #ifdef SK_DEBUG 248 #ifdef SK_DEBUG
240 // some state to verify shaders and effects are consistent, this is reset be tween effects by 249 // some state to verify shaders and effects are consistent, this is reset be tween effects by
241 // the program creator 250 // the program creator
242 GrProcessor::RequiredFeatures fUsedProcessorFeatures; 251 GrProcessor::RequiredFeatures fUsedProcessorFeatures;
243 bool fHasReadDstColor; 252 bool fHasReadDstColor;
244 #endif 253 #endif
245 254
246 friend class GrGLSLProgramBuilder; 255 friend class GrGLSLProgramBuilder;
247 friend class GrGLProgramBuilder; 256 friend class GrGLProgramBuilder;
248 }; 257 };
249 258
250 #endif 259 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698