aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-01-13 18:06:16 -0800
committerJeff Brown <jeffbrown@google.com>2011-01-13 18:12:27 -0800
commitb450292fabdb04f8904725898ab7fa84abe51bdf (patch)
tree6b47ac6fb84b9ebbfd35ae686547d6f1f9c080d6
parent3f396d7a86880aaf29fcce22a8204cf49e8d69d9 (diff)
downloadexternal_skia-b450292fabdb04f8904725898ab7fa84abe51bdf.zip
external_skia-b450292fabdb04f8904725898ab7fa84abe51bdf.tar.gz
external_skia-b450292fabdb04f8904725898ab7fa84abe51bdf.tar.bz2
Unroll skia ARGB8888 blitter loops.
Measured a 25% performance improvement on Tegra 2 for S32_Opaque_BlitRow32. skia_bench -config 8888 -repeat 100 -match bitmap_8888_A Iteration time is reduced from ~130ms to ~100ms. Change-Id: I7345a04b21d5e0c696b1f4aca763bfeda822c7b5
-rw-r--r--src/core/SkBlitRow_D32.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/core/SkBlitRow_D32.cpp b/src/core/SkBlitRow_D32.cpp
index 0036025..3300ead 100644
--- a/src/core/SkBlitRow_D32.cpp
+++ b/src/core/SkBlitRow_D32.cpp
@@ -2,6 +2,8 @@
#include "SkColorPriv.h"
#include "SkUtils.h"
+#define UNROLL
+
static void S32_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst,
const SkPMColor* SK_RESTRICT src,
int count, U8CPU alpha) {
@@ -16,11 +18,28 @@ static void S32_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst,
if (count > 0) {
unsigned src_scale = SkAlpha255To256(alpha);
unsigned dst_scale = 256 - src_scale;
+
+#ifdef UNROLL
+ if (count & 1) {
+ *dst = SkAlphaMulQ(*(src++), src_scale) + SkAlphaMulQ(*dst, dst_scale);
+ dst += 1;
+ count -= 1;
+ }
+
+ const SkPMColor* SK_RESTRICT srcEnd = src + count;
+ while (src != srcEnd) {
+ *dst = SkAlphaMulQ(*(src++), src_scale) + SkAlphaMulQ(*dst, dst_scale);
+ dst += 1;
+ *dst = SkAlphaMulQ(*(src++), src_scale) + SkAlphaMulQ(*dst, dst_scale);
+ dst += 1;
+ }
+#else
do {
*dst = SkAlphaMulQ(*src, src_scale) + SkAlphaMulQ(*dst, dst_scale);
src += 1;
dst += 1;
} while (--count > 0);
+#endif
}
}
@@ -31,6 +50,21 @@ static void S32A_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst,
int count, U8CPU alpha) {
SkASSERT(255 == alpha);
if (count > 0) {
+#ifdef UNROLL
+ if (count & 1) {
+ *dst = SkPMSrcOver(*(src++), *dst);
+ dst += 1;
+ count -= 1;
+ }
+
+ const SkPMColor* SK_RESTRICT srcEnd = src + count;
+ while (src != srcEnd) {
+ *dst = SkPMSrcOver(*(src++), *dst);
+ dst += 1;
+ *dst = SkPMSrcOver(*(src++), *dst);
+ dst += 1;
+ }
+#else
do {
#ifdef TEST_SRC_ALPHA
SkPMColor sc = *src;
@@ -48,6 +82,7 @@ static void S32A_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst,
src += 1;
dst += 1;
} while (--count > 0);
+#endif
}
}
@@ -56,11 +91,27 @@ static void S32A_Blend_BlitRow32(SkPMColor* SK_RESTRICT dst,
int count, U8CPU alpha) {
SkASSERT(alpha <= 255);
if (count > 0) {
+#ifdef UNROLL
+ if (count & 1) {
+ *dst = SkBlendARGB32(*(src++), *dst, alpha);
+ dst += 1;
+ count -= 1;
+ }
+
+ const SkPMColor* SK_RESTRICT srcEnd = src + count;
+ while (src != srcEnd) {
+ *dst = SkBlendARGB32(*(src++), *dst, alpha);
+ dst += 1;
+ *dst = SkBlendARGB32(*(src++), *dst, alpha);
+ dst += 1;
+ }
+#else
do {
*dst = SkBlendARGB32(*src, *dst, alpha);
src += 1;
dst += 1;
} while (--count > 0);
+#endif
}
}