| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef Sk4px_DEFINED | 8 #ifndef Sk4px_DEFINED |
| 9 #define Sk4px_DEFINED | 9 #define Sk4px_DEFINED |
| 10 | 10 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 fn(Load2(dst), Load2(src)).store2(dst); | 158 fn(Load2(dst), Load2(src)).store2(dst); |
| 159 dst += 2; src += 2; n -= 2; | 159 dst += 2; src += 2; n -= 2; |
| 160 } | 160 } |
| 161 if (n >= 1) { | 161 if (n >= 1) { |
| 162 fn(Load1(dst), Load1(src)).store1(dst); | 162 fn(Load1(dst), Load1(src)).store1(dst); |
| 163 } | 163 } |
| 164 break; | 164 break; |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 // As above, but with dst4' = fn(dst4, alpha4). |
| 169 template <typename Fn, typename Dst> |
| 170 static void MapDstAlpha(int n, Dst* dst, const SkAlpha* a, const Fn& fn) { |
| 171 while (n > 0) { |
| 172 if (n >= 8) { |
| 173 Sk4px dst0 = fn(Load4(dst+0), Load4Alphas(a+0)), |
| 174 dst4 = fn(Load4(dst+4), Load4Alphas(a+4)); |
| 175 dst0.store4(dst+0); |
| 176 dst4.store4(dst+4); |
| 177 dst += 8; a += 8; n -= 8; |
| 178 continue; // Keep our stride at 8 pixels as long as possible. |
| 179 } |
| 180 SkASSERT(n <= 7); |
| 181 if (n >= 4) { |
| 182 fn(Load4(dst), Load4Alphas(a)).store4(dst); |
| 183 dst += 4; a += 4; n -= 4; |
| 184 } |
| 185 if (n >= 2) { |
| 186 fn(Load2(dst), Load2Alphas(a)).store2(dst); |
| 187 dst += 2; a += 2; n -= 2; |
| 188 } |
| 189 if (n >= 1) { |
| 190 fn(Load1(dst), DupAlpha(*a)).store1(dst); |
| 191 } |
| 192 break; |
| 193 } |
| 194 } |
| 195 |
| 168 // As above, but with dst4' = fn(dst4, src4, alpha4). | 196 // As above, but with dst4' = fn(dst4, src4, alpha4). |
| 169 template <typename Fn, typename Dst> | 197 template <typename Fn, typename Dst> |
| 170 static void MapDstSrcAlpha(int n, Dst* dst, const SkPMColor* src, const SkAl
pha* a, | 198 static void MapDstSrcAlpha(int n, Dst* dst, const SkPMColor* src, const SkAl
pha* a, |
| 171 const Fn& fn) { | 199 const Fn& fn) { |
| 172 while (n > 0) { | 200 while (n > 0) { |
| 173 if (n >= 8) { | 201 if (n >= 8) { |
| 174 Sk4px dst0 = fn(Load4(dst+0), Load4(src+0), Load4Alphas(a+0)), | 202 Sk4px dst0 = fn(Load4(dst+0), Load4(src+0), Load4Alphas(a+0)), |
| 175 dst4 = fn(Load4(dst+4), Load4(src+4), Load4Alphas(a+4)); | 203 dst4 = fn(Load4(dst+4), Load4(src+4), Load4Alphas(a+4)); |
| 176 dst0.store4(dst+0); | 204 dst0.store4(dst+0); |
| 177 dst4.store4(dst+4); | 205 dst4.store4(dst+4); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 206 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | 234 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
| 207 #include "../opts/Sk4px_SSE2.h" | 235 #include "../opts/Sk4px_SSE2.h" |
| 208 #elif defined(SK_ARM_HAS_NEON) | 236 #elif defined(SK_ARM_HAS_NEON) |
| 209 #include "../opts/Sk4px_NEON.h" | 237 #include "../opts/Sk4px_NEON.h" |
| 210 #else | 238 #else |
| 211 #include "../opts/Sk4px_none.h" | 239 #include "../opts/Sk4px_none.h" |
| 212 #endif | 240 #endif |
| 213 #endif | 241 #endif |
| 214 | 242 |
| 215 #endif//Sk4px_DEFINED | 243 #endif//Sk4px_DEFINED |
| OLD | NEW |