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

Unified Diff: src/core/SkPixmap.cpp

Issue 1521673002: In SkPixmap.cpp, change SkAlphaMul to SkMulDiv255. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Make uppercase consistent. Created 5 years 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 | « include/core/SkCanvas.h ('k') | tests/BitmapTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPixmap.cpp
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index 0098b1b2826fe6b07924e56ad0bd52d9d8c00502..943287bad30a22373b1954342c8f02ad395d2cc5 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -163,9 +163,9 @@ bool SkPixmap::erase(SkColor color, const SkIRect& inArea) const {
// make rgb premultiplied
if (255 != a) {
- r = SkAlphaMul(r, a);
- g = SkAlphaMul(g, a);
- b = SkAlphaMul(b, a);
+ r = SkMulDiv255Round(r, a);
+ g = SkMulDiv255Round(g, a);
+ b = SkMulDiv255Round(b, a);
}
if (kARGB_4444_SkColorType == this->colorType()) {
@@ -186,13 +186,14 @@ bool SkPixmap::erase(SkColor color, const SkIRect& inArea) const {
uint32_t* p = this->writable_addr32(area.fLeft, area.fTop);
if (255 != a && kPremul_SkAlphaType == this->alphaType()) {
- r = SkAlphaMul(r, a);
- g = SkAlphaMul(g, a);
- b = SkAlphaMul(b, a);
+ r = SkMulDiv255Round(r, a);
+ g = SkMulDiv255Round(g, a);
+ b = SkMulDiv255Round(b, a);
}
- uint32_t v = kRGBA_8888_SkColorType == this->colorType() ?
- SkPackARGB_as_RGBA(a, r, g, b) : SkPackARGB_as_BGRA(a, r, g, b);
-
+ uint32_t v = kRGBA_8888_SkColorType == this->colorType()
+ ? SkPackARGB_as_RGBA(a, r, g, b)
+ : SkPackARGB_as_BGRA(a, r, g, b);
+
while (--height >= 0) {
sk_memset32(p, v, width);
p = (uint32_t*)((char*)p + rowBytes);
« no previous file with comments | « include/core/SkCanvas.h ('k') | tests/BitmapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698