| 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 "SkPM4fPriv.h" | 14 #include "SkPM4fPriv.h" |
| 15 #include "SkRasterPipeline.h" | 15 #include "SkRasterPipeline.h" |
| 16 #include "SkSRGB.h" | 16 #include "SkSRGB.h" |
| 17 #include "SkUtils.h" | 17 #include "SkUtils.h" |
| 18 #include <utility> | 18 #include <utility> |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2 | 22 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2 |
| 23 static constexpr int N = 8; | 23 static constexpr int N = 8; |
| 24 #else | 24 #else |
| 25 static constexpr int N = 4; | 25 static constexpr int N = 4; |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 using SkNf = SkNx<N, float>; | 28 using SkNf = SkNx<N, float>; |
| 29 using SkNi = SkNx<N, int>; | 29 using SkNi = SkNx<N, int>; |
| 30 using SkNh = SkNx<N, uint16_t>; | 30 using SkNh = SkNx<N, uint16_t>; |
| 31 | 31 |
| 32 struct BodyStage; | 32 struct BodyStage; |
| 33 struct TailStage; | 33 struct TailStage; |
| 34 | 34 |
| 35 using Body = void(SK_VECTORCALL *)(BodyStage*, size_t, SkNf,SkNf,SkN
f,SkNf, | 35 using Body = void(SK_VECTORCALL *)(BodyStage*, size_t, SkNf,SkNf,SkN
f,SkNf, |
| 36 SkNf,SkNf,SkN
f,SkNf); | 36 SkNf,SkNf,SkN
f,SkNf); |
| 37 using Tail = void(SK_VECTORCALL *)(TailStage*, size_t, size_t, SkNf,SkNf,SkN
f,SkNf, | 37 using Tail = void(SK_VECTORCALL *)(TailStage*, size_t, size_t, SkNf,SkNf,SkN
f,SkNf, |
| 38 SkNf,SkNf,SkN
f,SkNf); | 38 SkNf,SkNf,SkN
f,SkNf); |
| 39 struct BodyStage { Body next; void* ctx; }; | 39 struct BodyStage { Body next; void* ctx; }; |
| 40 struct TailStage { Tail next; void* ctx; }; | 40 struct TailStage { Tail next; void* ctx; }; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 case 6: ptr[5] = buf[5]; | 374 case 6: ptr[5] = buf[5]; |
| 375 case 5: ptr[4] = buf[4]; | 375 case 5: ptr[4] = buf[4]; |
| 376 case 4: ptr[3] = buf[3]; | 376 case 4: ptr[3] = buf[3]; |
| 377 case 3: ptr[2] = buf[2]; | 377 case 3: ptr[2] = buf[2]; |
| 378 case 2: ptr[1] = buf[1]; | 378 case 2: ptr[1] = buf[1]; |
| 379 } | 379 } |
| 380 ptr[0] = buf[0]; | 380 ptr[0] = buf[0]; |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 | 383 |
| 384 STAGE(store_f32, false) { | |
| 385 auto ptr = *(SkPM4f**)ctx + x; | |
| 386 | |
| 387 SkPM4f buf[8]; | |
| 388 SkNf::Store4(kIsTail ? buf : ptr, r,g,b,a); | |
| 389 if (kIsTail) { | |
| 390 switch (tail & (N-1)) { | |
| 391 case 7: ptr[6] = buf[6]; | |
| 392 case 6: ptr[5] = buf[5]; | |
| 393 case 5: ptr[4] = buf[4]; | |
| 394 case 4: ptr[3] = buf[3]; | |
| 395 case 3: ptr[2] = buf[2]; | |
| 396 case 2: ptr[1] = buf[1]; | |
| 397 } | |
| 398 ptr[0] = buf[0]; | |
| 399 } | |
| 400 } | |
| 401 | |
| 402 | 384 |
| 403 // Load 8-bit SkPMColor-order sRGB. | 385 // Load 8-bit SkPMColor-order sRGB. |
| 404 STAGE(load_d_srgb, true) { | 386 STAGE(load_d_srgb, true) { |
| 405 auto ptr = *(const uint32_t**)ctx + x; | 387 auto ptr = *(const uint32_t**)ctx + x; |
| 406 | 388 |
| 407 auto px = load<kIsTail>(tail, ptr); | 389 auto px = load<kIsTail>(tail, ptr); |
| 408 auto to_int = [](const SkNx<N, uint32_t>& v) { return SkNi::Load(&v); }; | 390 auto to_int = [](const SkNx<N, uint32_t>& v) { return SkNi::Load(&v); }; |
| 409 dr = sk_linear_from_srgb_math(to_int((px >> SK_R32_SHIFT) & 0xff)); | 391 dr = sk_linear_from_srgb_math(to_int((px >> SK_R32_SHIFT) & 0xff)); |
| 410 dg = sk_linear_from_srgb_math(to_int((px >> SK_G32_SHIFT) & 0xff)); | 392 dg = sk_linear_from_srgb_math(to_int((px >> SK_G32_SHIFT) & 0xff)); |
| 411 db = sk_linear_from_srgb_math(to_int((px >> SK_B32_SHIFT) & 0xff)); | 393 db = sk_linear_from_srgb_math(to_int((px >> SK_B32_SHIFT) & 0xff)); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 } | 568 } |
| 587 | 569 |
| 588 } // namespace SK_OPTS_NS | 570 } // namespace SK_OPTS_NS |
| 589 | 571 |
| 590 #undef SI | 572 #undef SI |
| 591 #undef STAGE | 573 #undef STAGE |
| 592 #undef RGBA_XFERMODE | 574 #undef RGBA_XFERMODE |
| 593 #undef RGB_XFERMODE | 575 #undef RGB_XFERMODE |
| 594 | 576 |
| 595 #endif//SkRasterPipeline_opts_DEFINED | 577 #endif//SkRasterPipeline_opts_DEFINED |
| OLD | NEW |