aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkConfig8888.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-06-14 13:38:56 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-06-14 13:38:56 +0000
commit61c49f357a03f68c12c2650ac9915657298352a4 (patch)
tree6ad8576201ad45375bedce8b0ed853d963c21cba /src/core/SkConfig8888.cpp
parent68b6eca42ed2bf9b4daaa2f210c9c14d7a5d0e3f (diff)
Improve the performance of SkConvertConfig8888Pixels using Array lookup
BUG=242097 R=kbr@chromium.org, vangelis@chromium.org, zmo@chromium.org, gman@chromium.org, bsalomon@google.com, reed@google.com, tomhudson@chromium.org, noel@chromium.org Author: jun.a.jiang@intel.com Review URL: https://chromiumcodereview.appspot.com/15402003 git-svn-id: http://skia.googlecode.com/svn/trunk@9605 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkConfig8888.cpp')
-rw-r--r--src/core/SkConfig8888.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/core/SkConfig8888.cpp b/src/core/SkConfig8888.cpp
index f889f20744..dd5cbc4724 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);
}