diff options
author | brianosman <brianosman@google.com> | 2016-09-07 08:09:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-07 08:09:10 -0700 |
commit | 77320dbabcddf05c0a1489eaf1f496729dc8de0e (patch) | |
tree | 6dce3ee85d2206685279217db47e66dd47839e43 /src/gpu/glsl/GrGLSLShaderBuilder.h | |
parent | d2e39dbc6a68a6cc2a480d0c8082eb204f6b6e77 (diff) |
Add color gamut xform helpers to GrGLSLShaderBuilder
New helper functions inject the necessary shader
function. Texture lookup functions can now insert
the gamut xform at the appropriate place, too.
As written, could be used to transform non-texture
colors (e.g. vertex colors) as well.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2180803005
Review-Url: https://codereview.chromium.org/2180803005
Diffstat (limited to 'src/gpu/glsl/GrGLSLShaderBuilder.h')
-rw-r--r-- | src/gpu/glsl/GrGLSLShaderBuilder.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h index ea36a56a7a..a6ff96dd1b 100644 --- a/src/gpu/glsl/GrGLSLShaderBuilder.h +++ b/src/gpu/glsl/GrGLSLShaderBuilder.h @@ -15,6 +15,8 @@ #include <stdarg.h> +class GrGLSLColorSpaceXformHelper; + /** base class for all shaders builders */ @@ -37,7 +39,8 @@ public: /** Version of above that appends the result to the shader code instead.*/ void appendTextureLookup(SamplerHandle, const char* coordName, - GrSLType coordType = kVec2f_GrSLType); + GrSLType coordType = kVec2f_GrSLType, + GrGLSLColorSpaceXformHelper* colorXformHelper = nullptr); /** Does the work of appendTextureLookup and modulates the result by modulation. The result is @@ -47,7 +50,18 @@ public: void appendTextureLookupAndModulate(const char* modulation, SamplerHandle, const char* coordName, - GrSLType coordType = kVec2f_GrSLType); + GrSLType coordType = kVec2f_GrSLType, + GrGLSLColorSpaceXformHelper* colorXformHelper = nullptr); + + /** Adds a helper function to facilitate color gamut transformation, and produces code that + returns the srcColor transformed into a new gamut (via multiplication by the xform from + colorXformHelper). Premultiplied sources are also handled correctly (colorXformHelper + determines if the source is premultipled or not). */ + void appendColorGamutXform(SkString* out, const char* srcColor, + GrGLSLColorSpaceXformHelper* colorXformHelper); + + /** Version of above that appends the result to the shader code instead. */ + void appendColorGamutXform(const char* srcColor, GrGLSLColorSpaceXformHelper* colorXformHelper); /** Fetches an unfiltered texel from a sampler at integer coordinates. coordExpr must match the dimensionality of the sampler and must be within the sampler's range. coordExpr is emitted |