aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders/gradients/SkGradientShader.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-10-30 13:47:41 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-31 14:55:14 +0000
commitf06ead925c631c42fae734de1e7c72237a2e91f4 (patch)
treed2ae0175607b41087df6bcc55d6fe4342eecc739 /src/shaders/gradients/SkGradientShader.cpp
parent761f44853fcead7e7a105e1870cb970646814058 (diff)
Add support for transfer functions to GrColorSpaceXform
With this change, untagged sources (eg N32) are treated as sRGB data, which causes a huge number of GMs to render more correctly in GPU sRGB/F16/etc... configs. Also, because the sources are treated as having a color space, we actually do gamut conversion for wide or narrow gamut outputs. This change also applies the transfer function math to individual colors in the case of gradient stops and color shaders. (The CPU backend doesn't do this yet, but I think we've decided there's no reason not to support it). Bug: skia: Change-Id: If76e9e4a268f9f74110ff4bbe4fe189ba5d19d9f Reviewed-on: https://skia-review.googlesource.com/64100 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/shaders/gradients/SkGradientShader.cpp')
-rw-r--r--src/shaders/gradients/SkGradientShader.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp
index 7d31e50f84..279491b177 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -184,6 +184,7 @@ SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc, const SkMatri
fColorSpace = SkColorSpace::MakeSRGBLinear();
} else {
// The color space refers to the float colors, so it must be linear gamma
+ // TODO: GPU code no longer requires this (see GrGradientEffect). Remove this restriction?
SkASSERT(desc.fColorSpace->gammaIsLinear());
fColorSpace = desc.fColorSpace;
}
@@ -1260,8 +1261,11 @@ GrGradientEffect::GrGradientEffect(ClassID classID, const CreateArgs& args, bool
fPremulType = kAfterInterp_PremulType;
}
- // Convert input colors to GrColor4f, possibly premul, and apply color space xform
+ // Convert input colors to GrColor4f, possibly premul, and apply color space xform.
+ // The xform is constructed assuming floats as input, but the color space can have a
+ // transfer function on it, which will be applied below.
auto colorSpaceXform = GrColorSpaceXform::Make(shader.fColorSpace.get(),
+ kRGBA_float_GrPixelConfig,
args.fDstColorSpace);
SkASSERT(shader.fOrigColors && shader.fOrigColors4f);
fColors4f.setCount(shader.fColorCount);