зеркало из https://github.com/mozilla/moz-skia.git
fix TriColorShader to respect the paint's alpha
results can be seen in new gm: vertices_80 BUG=skia: R=scroggo@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/270023002 git-svn-id: http://skia.googlecode.com/svn/trunk@14581 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
60da8f3952
Коммит
06a3206262
|
@ -181,6 +181,15 @@ static inline unsigned SkAlpha255To256(U8CPU alpha) {
|
|||
return alpha + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a 0..255 value into a 0..256 value, rounding up if the value is >= 0x80.
|
||||
* This is slightly more accurate than SkAlpha255To256.
|
||||
*/
|
||||
static inline unsigned Sk255To256(U8CPU value) {
|
||||
SkASSERT(SkToU8(value) == value);
|
||||
return value + (value >> 7);
|
||||
}
|
||||
|
||||
/** Multiplify value by 0..256, and shift the result down 8
|
||||
(i.e. return (value * alpha256) >> 8)
|
||||
*/
|
||||
|
|
|
@ -2432,6 +2432,8 @@ size_t SkTriColorShader::contextSize() const {
|
|||
return sizeof(TriColorShaderContext);
|
||||
}
|
||||
void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
|
||||
const int alphaScale = Sk255To256(this->getPaintAlpha());
|
||||
|
||||
SkPoint src;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -2450,6 +2452,12 @@ void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor
|
|||
scale0 = 0;
|
||||
}
|
||||
|
||||
if (256 != alphaScale) {
|
||||
scale0 = SkAlphaMul(scale0, alphaScale);
|
||||
scale1 = SkAlphaMul(scale1, alphaScale);
|
||||
scale2 = SkAlphaMul(scale2, alphaScale);
|
||||
}
|
||||
|
||||
dstC[i] = SkAlphaMulQ(fColors[0], scale0) +
|
||||
SkAlphaMulQ(fColors[1], scale1) +
|
||||
SkAlphaMulQ(fColors[2], scale2);
|
||||
|
|
Загрузка…
Ссылка в новой задаче