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

Unified Diff: src/core/SkBlitRow_D16.cpp

Issue 474983007: fix numerical overflows in 565 blends (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove workaround from nanobench Created 6 years, 4 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 | « bench/nanobench.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBlitRow_D16.cpp
diff --git a/src/core/SkBlitRow_D16.cpp b/src/core/SkBlitRow_D16.cpp
index 1b2be06d12590f2c419739a9eaf5b8a3b94d2a47..e052b3500a2477e0369e0ebb252f8df1112d085b 100644
--- a/src/core/SkBlitRow_D16.cpp
+++ b/src/core/SkBlitRow_D16.cpp
@@ -74,11 +74,8 @@ static void S32A_D565_Blend(uint16_t* SK_RESTRICT dst,
SkPMColorAssert(sc);
if (sc) {
uint16_t dc = *dst;
- unsigned dst_scale = 255 - SkMulDiv255Round(SkGetPackedA32(sc), alpha);
- unsigned dr = SkMulS16(SkPacked32ToR16(sc), alpha) + SkMulS16(SkGetPackedR16(dc), dst_scale);
- unsigned dg = SkMulS16(SkPacked32ToG16(sc), alpha) + SkMulS16(SkGetPackedG16(dc), dst_scale);
- unsigned db = SkMulS16(SkPacked32ToB16(sc), alpha) + SkMulS16(SkGetPackedB16(dc), dst_scale);
- *dst = SkPackRGB16(SkDiv255Round(dr), SkDiv255Round(dg), SkDiv255Round(db));
+ SkPMColor res = SkBlendARGB32(sc, SkPixel16ToPixel32(dc), alpha);
+ *dst = SkPixel32ToPixel16(res);
}
dst += 1;
} while (--count != 0);
« no previous file with comments | « bench/nanobench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698