OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 SkRasterPipeline_opts_DEFINED | 8 #ifndef SkRasterPipeline_opts_DEFINED |
9 #define SkRasterPipeline_opts_DEFINED | 9 #define SkRasterPipeline_opts_DEFINED |
10 | 10 |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkHalf.h" | 12 #include "SkHalf.h" |
13 #include "SkPM4f.h" | 13 #include "SkPM4f.h" |
14 #include "SkRasterPipeline.h" | 14 #include "SkRasterPipeline.h" |
15 #include "SkSRGB.h" | 15 #include "SkSRGB.h" |
16 #include <utility> | 16 #include <utility> |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2 | 20 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2 |
21 static constexpr int N = 8; | 21 static constexpr int N = 8; |
22 #else | 22 #else |
23 static constexpr int N = 4; | 23 static constexpr int N = 4; |
24 #endif | 24 #endif |
25 | 25 |
26 using SkNf = SkNx<N, float>; | 26 using SkNf = SkNx<N, float>; |
27 using SkNi = SkNx<N, int>; | 27 using SkNi = SkNx<N, int>; |
28 using SkNh = SkNx<N, uint16_t>; | 28 using SkNh = SkNx<N, uint16_t>; |
29 | 29 |
30 struct BodyStage; | 30 struct BodyStage; |
31 struct TailStage; | 31 struct TailStage; |
32 | 32 |
33 using Body = void(SK_VECTORCALL *)(BodyStage*, size_t, SkNf,SkNf,SkN
f,SkNf, | 33 using Body = void(SK_VECTORCALL *)(BodyStage*, size_t, SkNf,SkNf,SkN
f,SkNf, |
34 SkNf,SkNf,SkN
f,SkNf); | 34 SkNf,SkNf,SkN
f,SkNf); |
35 using Tail = void(SK_VECTORCALL *)(TailStage*, size_t, size_t, SkNf,SkNf,SkN
f,SkNf, | 35 using Tail = void(SK_VECTORCALL *)(TailStage*, size_t, size_t, SkNf,SkNf,SkN
f,SkNf, |
36 SkNf,SkNf,SkN
f,SkNf); | 36 SkNf,SkNf,SkN
f,SkNf); |
37 struct BodyStage { Body next; void* ctx; }; | 37 struct BodyStage { Body next; void* ctx; }; |
38 struct TailStage { Tail next; void* ctx; }; | 38 struct TailStage { Tail next; void* ctx; }; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 case 6: ptr[5] = buf[5]; | 372 case 6: ptr[5] = buf[5]; |
373 case 5: ptr[4] = buf[4]; | 373 case 5: ptr[4] = buf[4]; |
374 case 4: ptr[3] = buf[3]; | 374 case 4: ptr[3] = buf[3]; |
375 case 3: ptr[2] = buf[2]; | 375 case 3: ptr[2] = buf[2]; |
376 case 2: ptr[1] = buf[1]; | 376 case 2: ptr[1] = buf[1]; |
377 } | 377 } |
378 ptr[0] = buf[0]; | 378 ptr[0] = buf[0]; |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
| 382 STAGE(store_f32, false) { |
| 383 auto ptr = *(SkPM4f**)ctx + x; |
| 384 |
| 385 SkPM4f buf[8]; |
| 386 SkNf::Store4(kIsTail ? buf : ptr, r,g,b,a); |
| 387 if (kIsTail) { |
| 388 switch (tail & (N-1)) { |
| 389 case 7: ptr[6] = buf[6]; |
| 390 case 6: ptr[5] = buf[5]; |
| 391 case 5: ptr[4] = buf[4]; |
| 392 case 4: ptr[3] = buf[3]; |
| 393 case 3: ptr[2] = buf[2]; |
| 394 case 2: ptr[1] = buf[1]; |
| 395 } |
| 396 ptr[0] = buf[0]; |
| 397 } |
| 398 } |
| 399 |
382 | 400 |
383 // Load 8-bit SkPMColor-order sRGB. | 401 // Load 8-bit SkPMColor-order sRGB. |
384 STAGE(load_d_srgb, true) { | 402 STAGE(load_d_srgb, true) { |
385 auto ptr = *(const uint32_t**)ctx + x; | 403 auto ptr = *(const uint32_t**)ctx + x; |
386 | 404 |
387 auto px = load<kIsTail>(tail, ptr); | 405 auto px = load<kIsTail>(tail, ptr); |
388 auto to_int = [](const SkNx<N, uint32_t>& v) { return SkNi::Load(&v); }; | 406 auto to_int = [](const SkNx<N, uint32_t>& v) { return SkNi::Load(&v); }; |
389 dr = sk_linear_from_srgb_math(to_int((px >> SK_R32_SHIFT) & 0xff)); | 407 dr = sk_linear_from_srgb_math(to_int((px >> SK_R32_SHIFT) & 0xff)); |
390 dg = sk_linear_from_srgb_math(to_int((px >> SK_G32_SHIFT) & 0xff)); | 408 dg = sk_linear_from_srgb_math(to_int((px >> SK_G32_SHIFT) & 0xff)); |
391 db = sk_linear_from_srgb_math(to_int((px >> SK_B32_SHIFT) & 0xff)); | 409 db = sk_linear_from_srgb_math(to_int((px >> SK_B32_SHIFT) & 0xff)); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 559 } |
542 | 560 |
543 } // namespace SK_OPTS_NS | 561 } // namespace SK_OPTS_NS |
544 | 562 |
545 #undef SI | 563 #undef SI |
546 #undef STAGE | 564 #undef STAGE |
547 #undef RGBA_XFERMODE | 565 #undef RGBA_XFERMODE |
548 #undef RGB_XFERMODE | 566 #undef RGB_XFERMODE |
549 | 567 |
550 #endif//SkRasterPipeline_opts_DEFINED | 568 #endif//SkRasterPipeline_opts_DEFINED |
OLD | NEW |