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

Unified Diff: src/core/Sk4px.h

Issue 1278253003: Sk4px blit mask. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: note overflow Created 5 years, 4 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 | src/core/SkBlitMask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | src/core/SkBlitMask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698