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

Unified Diff: src/core/SkXfermode4f.cpp

Issue 2020463003: Use special case for 0x00 and 0xFF alpha to go faster. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/SkXfermode4f.cpp
diff --git a/src/core/SkXfermode4f.cpp b/src/core/SkXfermode4f.cpp
index 267985d8a277d747cb1d7077bcbb521417076fc3..4d224ac0ad788d59af06b219f716555eae01b0dd 100644
--- a/src/core/SkXfermode4f.cpp
+++ b/src/core/SkXfermode4f.cpp
@@ -213,33 +213,25 @@ template <DstType D> void src_1(const SkXfermode*, uint32_t dst[],
count -= 4;
}
} else { // kSRGB
- while (count >= 4) {
- Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.0f);
-
- /* If we ever natively support convert 255_linear -> 255_srgb, then perhaps
- * it would be faster (and possibly allow more code sharing with kLinear) to
- * stay in that space.
- */
- Sk4f r0 = lerp(s4, load_dst<D>(dst[0]), Sk4f(aa4[0]));
- Sk4f r1 = lerp(s4, load_dst<D>(dst[1]), Sk4f(aa4[1]));
- Sk4f r2 = lerp(s4, load_dst<D>(dst[2]), Sk4f(aa4[2]));
- Sk4f r3 = lerp(s4, load_dst<D>(dst[3]), Sk4f(aa4[3]));
- Sk4f_ToBytes((uint8_t*)dst,
- linear_unit_to_srgb_255f(r0),
- linear_unit_to_srgb_255f(r1),
- linear_unit_to_srgb_255f(r2),
- linear_unit_to_srgb_255f(r3));
-
- dst += 4;
- aa += 4;
- count -= 4;
+ SkPMColor srcColor = store_dst<D>(s4);
+ while (count-- > 0) {
+ SkAlpha cover = *aa++;
+ switch (cover) {
+ case 0xFF: {
+ *dst++ = srcColor;
+ break;
+ }
+ case 0x00: {
+ dst++;
+ break;
+ }
+ default: {
+ Sk4f d4 = load_dst<D>(*dst);
+ *dst++ = store_dst<D>(lerp(s4, d4, cover));
mtklein 2016/05/27 15:58:49 lerp() takes 3 Sk4f arguments in range [0,1]. I t
mtklein_C 2016/05/27 16:57:59 Nevermind, it's the other lerp!
herb_g 2016/05/27 16:59:18 There are two lerp calls: static Sk4f lerp(const S
+ }
+ }
}
- }
- for (int i = 0; i < count; ++i) {
- unsigned a = aa[i];
- Sk4f d4 = load_dst<D>(dst[i]);
- dst[i] = store_dst<D>(lerp(s4, d4, a));
- }
+ } // kSRGB
} else {
sk_memset32(dst, store_dst<D>(s4), count);
}
« 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