diff options
author | 2016-12-12 18:21:32 -0800 | |
---|---|---|
committer | 2016-12-12 18:50:07 -0800 | |
commit | a0ed6f03f6f06eb41cbcc15c0a99b4a78fd91bef (patch) | |
tree | f6eeb56420b457fe9955f21548ca12e6cf7ec68e /libs/hwui/SkiaShader.cpp | |
parent | 84cac20dfdff35932901e978e6b6d3da843a2fa7 (diff) |
Pre-multiply gradient colors the right way
Alpha pre-multiplication must be done after applying the
opto-electronic transfer function when linear blending is
disabled. The correct way would be to pre-multiply before
gamma encoding but this leads to improper blending which
cannot be corrected without using sRGB frame buffers and
texture sampling.
Bug: 33010587
Test: cts-tradefed run singleCommand cts-dev --module CtsUiRenderingTestCases --test android.uirendering.cts.testclasses.GradientTests
Change-Id: I5f04bda4cb9f63674537aef5931621c14d601884
Diffstat (limited to 'libs/hwui/SkiaShader.cpp')
-rw-r--r-- | libs/hwui/SkiaShader.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp index 34e6a06c3dc2..0f6651b83db3 100644 --- a/libs/hwui/SkiaShader.cpp +++ b/libs/hwui/SkiaShader.cpp @@ -81,7 +81,7 @@ static void computeScreenSpaceMatrix(mat4& screenSpace, const SkMatrix& unitMatr } /////////////////////////////////////////////////////////////////////////////// -// gradient shader matrix helpers +// Gradient shader matrix helpers /////////////////////////////////////////////////////////////////////////////// static void toLinearUnitMatrix(const SkPoint pts[2], SkMatrix* matrix) { @@ -161,7 +161,7 @@ bool tryStoreGradient(Caches& caches, const SkShader& shader, const Matrix4 mode gradInfo.fColorOffsets = &colorOffsets[0]; shader.asAGradient(&gradInfo); - if (CC_UNLIKELY(!isSimpleGradient(gradInfo))) { + if (CC_UNLIKELY(!description->isSimpleGradient)) { outData->gradientSampler = (*textureUnit)++; #ifndef SK_SCALAR_IS_FLOAT @@ -174,8 +174,8 @@ bool tryStoreGradient(Caches& caches, const SkShader& shader, const Matrix4 mode outData->gradientSampler = 0; outData->gradientTexture = nullptr; - outData->startColor.setSRGB(gradInfo.fColors[0]); - outData->endColor.setSRGB(gradInfo.fColors[1]); + outData->startColor.setUnPreMultipliedSRGB(gradInfo.fColors[0]); + outData->endColor.setUnPreMultipliedSRGB(gradInfo.fColors[1]); } return true; |