Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: src/core/SkDraw.cpp

Issue 270023002: fix TriColorShader to respect the paint's alpha (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index a74e3c0f798123845c718fb717a30bba6ca9e4f9..305cdd389f9a5ec0ed95f0c0efb0b766e5d07f25 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -2432,6 +2432,9 @@ size_t SkTriColorShader::contextSize() const {
return sizeof(TriColorShaderContext);
}
void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
+ const unsigned alpha = this->getPaintAlpha();
+ const int alphaScale = alpha + (alpha >> 7);
scroggo 2014/05/05 21:15:02 From the comments in SkColorPriv, it looks like th
reed1 2014/05/05 21:25:15 Done.
+
SkPoint src;
for (int i = 0; i < count; i++) {
@@ -2450,9 +2453,15 @@ void SkTriColorShader::TriColorShaderContext::shadeSpan(int x, int y, SkPMColor
scale0 = 0;
}
+ if (256 != alphaScale) {
+ scale0 = (scale0 * alphaScale) >> 8;
scroggo 2014/05/05 21:15:02 Why not use SkAlphaMul?
reed1 2014/05/05 21:25:15 Done.
+ scale1 = (scale1 * alphaScale) >> 8;
+ scale2 = (scale2 * alphaScale) >> 8;
+ }
+
dstC[i] = SkAlphaMulQ(fColors[0], scale0) +
- SkAlphaMulQ(fColors[1], scale1) +
- SkAlphaMulQ(fColors[2], scale2);
+ SkAlphaMulQ(fColors[1], scale1) +
+ SkAlphaMulQ(fColors[2], scale2);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698