Index: src/core/Sk4px.h |
diff --git a/src/core/Sk4px.h b/src/core/Sk4px.h |
index 24a21c66c1c40ff02a1fada344cf5dd4a713ed01..ffde1af504f682504034839b5db142eecf76fa39 100644 |
--- a/src/core/Sk4px.h |
+++ b/src/core/Sk4px.h |
@@ -165,6 +165,34 @@ public: |
} |
} |
+ // As above, but with dst4' = fn(dst4, alpha4). |
+ template <typename Fn, typename Dst> |
+ static void MapDstAlpha(int n, Dst* dst, const SkAlpha* a, const Fn& fn) { |
+ while (n > 0) { |
+ if (n >= 8) { |
+ Sk4px dst0 = fn(Load4(dst+0), Load4Alphas(a+0)), |
+ dst4 = fn(Load4(dst+4), Load4Alphas(a+4)); |
+ dst0.store4(dst+0); |
+ dst4.store4(dst+4); |
+ dst += 8; a += 8; n -= 8; |
+ continue; // Keep our stride at 8 pixels as long as possible. |
+ } |
+ SkASSERT(n <= 7); |
+ if (n >= 4) { |
+ fn(Load4(dst), Load4Alphas(a)).store4(dst); |
+ dst += 4; a += 4; n -= 4; |
+ } |
+ if (n >= 2) { |
+ fn(Load2(dst), Load2Alphas(a)).store2(dst); |
+ dst += 2; a += 2; n -= 2; |
+ } |
+ if (n >= 1) { |
+ fn(Load1(dst), DupAlpha(*a)).store1(dst); |
+ } |
+ break; |
+ } |
+ } |
+ |
// As above, but with dst4' = fn(dst4, src4, alpha4). |
template <typename Fn, typename Dst> |
static void MapDstSrcAlpha(int n, Dst* dst, const SkPMColor* src, const SkAlpha* a, |