| 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 GrGLSLShaderBuilder_DEFINED | 8 #ifndef GrGLSLShaderBuilder_DEFINED |
| 9 #define GrGLSLShaderBuilder_DEFINED | 9 #define GrGLSLShaderBuilder_DEFINED |
| 10 | 10 |
| 11 #include "GrAllocator.h" | 11 #include "GrAllocator.h" |
| 12 #include "glsl/GrGLSLUniformHandler.h" | 12 #include "glsl/GrGLSLUniformHandler.h" |
| 13 #include "glsl/GrGLSLShaderVar.h" | 13 #include "glsl/GrGLSLShaderVar.h" |
| 14 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
| 15 | 15 |
| 16 #include <stdarg.h> | 16 #include <stdarg.h> |
| 17 | 17 |
| 18 class GrGLSLColorSpaceXformHelper; |
| 19 |
| 18 /** | 20 /** |
| 19 base class for all shaders builders | 21 base class for all shaders builders |
| 20 */ | 22 */ |
| 21 class GrGLSLShaderBuilder { | 23 class GrGLSLShaderBuilder { |
| 22 public: | 24 public: |
| 23 GrGLSLShaderBuilder(GrGLSLProgramBuilder* program); | 25 GrGLSLShaderBuilder(GrGLSLProgramBuilder* program); |
| 24 virtual ~GrGLSLShaderBuilder() {} | 26 virtual ~GrGLSLShaderBuilder() {} |
| 25 | 27 |
| 26 typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle; | 28 typedef GrGLSLUniformHandler::SamplerHandle SamplerHandle; |
| 27 | 29 |
| 28 /** Appends a 2D texture sample with projection if necessary. coordType must
either be Vec2f or | 30 /** Appends a 2D texture sample with projection if necessary. coordType must
either be Vec2f or |
| 29 Vec3f. The latter is interpreted as projective texture coords. The vec l
ength and swizzle | 31 Vec3f. The latter is interpreted as projective texture coords. The vec l
ength and swizzle |
| 30 order of the result depends on the GrTextureAccess associated with the G
rGLSLSampler. | 32 order of the result depends on the GrTextureAccess associated with the G
rGLSLSampler. |
| 31 */ | 33 */ |
| 32 void appendTextureLookup(SkString* out, | 34 void appendTextureLookup(SkString* out, |
| 33 SamplerHandle, | 35 SamplerHandle, |
| 34 const char* coordName, | 36 const char* coordName, |
| 35 GrSLType coordType = kVec2f_GrSLType) const; | 37 GrSLType coordType = kVec2f_GrSLType) const; |
| 36 | 38 |
| 37 /** Version of above that appends the result to the shader code instead.*/ | 39 /** Version of above that appends the result to the shader code instead.*/ |
| 38 void appendTextureLookup(SamplerHandle, | 40 void appendTextureLookup(SamplerHandle, |
| 39 const char* coordName, | 41 const char* coordName, |
| 40 GrSLType coordType = kVec2f_GrSLType); | 42 GrSLType coordType = kVec2f_GrSLType, |
| 43 GrGLSLColorSpaceXformHelper* colorXformHelper = nul
lptr); |
| 41 | 44 |
| 42 | 45 |
| 43 /** Does the work of appendTextureLookup and modulates the result by modulat
ion. The result is | 46 /** Does the work of appendTextureLookup and modulates the result by modulat
ion. The result is |
| 44 always a vec4. modulation and the swizzle specified by GrGLSLSampler mus
t both be | 47 always a vec4. modulation and the swizzle specified by GrGLSLSampler mus
t both be |
| 45 vec4 or float. If modulation is "" or nullptr it this function acts as t
hough | 48 vec4 or float. If modulation is "" or nullptr it this function acts as t
hough |
| 46 appendTextureLookup were called. */ | 49 appendTextureLookup were called. */ |
| 47 void appendTextureLookupAndModulate(const char* modulation, | 50 void appendTextureLookupAndModulate(const char* modulation, |
| 48 SamplerHandle, | 51 SamplerHandle, |
| 49 const char* coordName, | 52 const char* coordName, |
| 50 GrSLType coordType = kVec2f_GrSLType); | 53 GrSLType coordType = kVec2f_GrSLType, |
| 54 GrGLSLColorSpaceXformHelper* colorXformH
elper = nullptr); |
| 55 |
| 56 /** Adds a helper function to facilitate color gamut transformation, and pro
duces code that |
| 57 returns the srcColor transformed into a new gamut (via multiplication by
the xform from |
| 58 colorXformHelper). Premultiplied sources are also handled correctly (col
orXformHelper |
| 59 determines if the source is premultipled or not). */ |
| 60 void appendColorGamutXform(SkString* out, const char* srcColor, |
| 61 GrGLSLColorSpaceXformHelper* colorXformHelper); |
| 62 |
| 63 /** Version of above that appends the result to the shader code instead. */ |
| 64 void appendColorGamutXform(const char* srcColor, GrGLSLColorSpaceXformHelper
* colorXformHelper); |
| 51 | 65 |
| 52 /** Fetches an unfiltered texel from a sampler at integer coordinates. coord
Expr must match the | 66 /** Fetches an unfiltered texel from a sampler at integer coordinates. coord
Expr must match the |
| 53 dimensionality of the sampler and must be within the sampler's range. co
ordExpr is emitted | 67 dimensionality of the sampler and must be within the sampler's range. co
ordExpr is emitted |
| 54 exactly once, so expressions like "idx++" are acceptable. */ | 68 exactly once, so expressions like "idx++" are acceptable. */ |
| 55 void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) c
onst; | 69 void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) c
onst; |
| 56 | 70 |
| 57 /** Version of above that appends the result to the shader code instead.*/ | 71 /** Version of above that appends the result to the shader code instead.*/ |
| 58 void appendTexelFetch(SamplerHandle, const char* coordExpr); | 72 void appendTexelFetch(SamplerHandle, const char* coordExpr); |
| 59 | 73 |
| 60 /** | 74 /** |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 int fCodeIndex; | 254 int fCodeIndex; |
| 241 bool fFinalized; | 255 bool fFinalized; |
| 242 | 256 |
| 243 friend class GrGLSLProgramBuilder; | 257 friend class GrGLSLProgramBuilder; |
| 244 friend class GrGLProgramBuilder; | 258 friend class GrGLProgramBuilder; |
| 245 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. | 259 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. |
| 246 friend class GrGLPathProgramBuilder; // to access fInputs. | 260 friend class GrGLPathProgramBuilder; // to access fInputs. |
| 247 friend class GrVkPipelineStateBuilder; | 261 friend class GrVkPipelineStateBuilder; |
| 248 }; | 262 }; |
| 249 #endif | 263 #endif |
| OLD | NEW |