Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(216)

Unified Diff: src/core/SkBlitter_ARGB32.cpp

Issue 5758043: Blend alpha correctly for ARGB32, ARGB16 (4444), and A8 modes. Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: don't include 5752045 in this CL Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkBlitter_ARGB32.cpp
diff --git a/src/core/SkBlitter_ARGB32.cpp b/src/core/SkBlitter_ARGB32.cpp
index 24ab330769adfe129572ea3792f87216c87d4de5..8483bc5817d647ef98d0b2ef31c520f4d7191a8c 100644
--- a/src/core/SkBlitter_ARGB32.cpp
+++ b/src/core/SkBlitter_ARGB32.cpp
@@ -46,12 +46,18 @@ SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint)
fColor = color;
fSrcA = SkColorGetA(color);
+#ifndef SK_BLEND_CORRECTLY
unsigned scale = SkAlpha255To256(fSrcA);
fSrcR = SkAlphaMul(SkColorGetR(color), scale);
fSrcG = SkAlphaMul(SkColorGetG(color), scale);
fSrcB = SkAlphaMul(SkColorGetB(color), scale);
Stephen White 2012/05/08 14:50:49 It looks like fSrc[RGB] are not used outside the c
+#endif
+#ifndef SK_BLEND_CORRECTLY
Stephen White 2012/05/08 14:50:49 Perhaps you could also merge these two #ifdef bloc
fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB);
+#else
+ fPMColor = SkPreMultiplyColor(color);
+#endif
fColor32Proc = SkBlitRow::ColorProcFactory();
}
@@ -194,7 +200,11 @@ void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
color = SkAlphaMulQ(color, SkAlpha255To256(alpha));
}
+#ifdef SK_BLEND_CORRECTLY
+ unsigned dst_scale = SkAlphaToInvScale8(SkGetPackedA32(color));
+#else
unsigned dst_scale = 255 - SkGetPackedA32(color);
+#endif
uint32_t rowBytes = fDevice.rowBytes();
while (--height >= 0) {
device[0] = color + SkAlphaMulQ(device[0], dst_scale);

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b