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

Unified Diff: src/core/SkConfig8888.cpp

Issue 15402003: Improve the performance of SkConvertConfig8888Pixels using Array lookup (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: change to use SkMulDiv255Round to benifit ARM architecture Created 7 years, 6 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/SkConfig8888.cpp
diff --git a/src/core/SkConfig8888.cpp b/src/core/SkConfig8888.cpp
index f889f20744fa3b3f3c20189ae9ea56f31ac96a78..dd5cbc47240cb3379bc7796fbc37547a70394e40 100644
--- a/src/core/SkConfig8888.cpp
+++ b/src/core/SkConfig8888.cpp
@@ -1,5 +1,6 @@
#include "SkConfig8888.h"
#include "SkMathPriv.h"
+#include "SkUnPreMultiply.h"
namespace {
@@ -57,23 +58,20 @@ inline uint32_t convert_pixel(uint32_t pixel) {
uint32_t a, r, g, b;
unpack_config8888<IN_A_IDX, IN_R_IDX, IN_G_IDX, IN_B_IDX>(pixel, &a, &r, &g, &b);
if (IN_PM && !OUT_PM) {
- // We're doing the explicit divide to match WebKit layout
- // test expectations. We can modify and rebaseline if there
- // it can be shown that there is a more performant way to
- // unpremul.
+ // Using SkUnPreMultiply::ApplyScale is faster than (value * 0xff) / a.
if (a) {
- r = r * 0xff / a;
- g = g * 0xff / a;
- b = b * 0xff / a;
+ SkUnPreMultiply::Scale scale = SkUnPreMultiply::GetScale(a);
+ r = SkUnPreMultiply::ApplyScale(scale, r);
+ g = SkUnPreMultiply::ApplyScale(scale, g);
+ b = SkUnPreMultiply::ApplyScale(scale, b);
} else {
return 0;
}
} else if (!IN_PM && OUT_PM) {
- // This matches WebKit's conversion which we are replacing.
- // We can consider alternative rounding rules for performance.
- r = SkMulDiv255Ceiling(r, a);
- g = SkMulDiv255Ceiling(g, a);
- b = SkMulDiv255Ceiling(b, a);
+ // This matches SkUnPreMultiply conversion which we are replacing.
+ r = SkMulDiv255Round(r, a);
+ g = SkMulDiv255Round(g, a);
+ b = SkMulDiv255Round(b, a);
}
return pack_config8888<OUT_A_IDX, OUT_R_IDX, OUT_G_IDX, OUT_B_IDX>(a, r, g, b);
}
« 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