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 #include "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" |
9 #include "Sk4x4f.h" | 9 #include "Sk4x4f.h" |
10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Planar version of ramp (S32 no-premul only). | 46 // Planar version of ramp (S32 no-premul only). |
47 template<> | 47 template<> |
48 void ramp<DstType::S32, ApplyPremul::False>(const Sk4f& c, const Sk4f& dc, SkPMC
olor dst[], int n) { | 48 void ramp<DstType::S32, ApplyPremul::False>(const Sk4f& c, const Sk4f& dc, SkPMC
olor dst[], int n) { |
49 SkASSERT(n > 0); | 49 SkASSERT(n > 0); |
50 | 50 |
51 const Sk4f dc4 = dc * 4; | 51 const Sk4f dc4 = dc * 4; |
52 const Sk4x4f dc4x = { Sk4f(dc4[0]), Sk4f(dc4[1]), Sk4f(dc4[2]), Sk4f(dc4[3])
}; | 52 const Sk4x4f dc4x = { Sk4f(dc4[0]), Sk4f(dc4[1]), Sk4f(dc4[2]), Sk4f(dc4[3])
}; |
53 Sk4x4f c4x = Sk4x4f::Transpose(c, c + dc, c + dc * 2, c + dc * 3); | 53 Sk4x4f c4x = Sk4x4f::Transpose(c, c + dc, c + dc * 2, c + dc * 3); |
54 | 54 |
55 while (n >= 4) { | 55 while (n >= 4) { |
56 const Sk4x4f cx4s32 = { | 56 auto r = sk_linear_to_srgb(c4x.r), |
57 c4x.r.rsqrt().invert(), | 57 g = sk_linear_to_srgb(c4x.g), |
58 c4x.g.rsqrt().invert(), | 58 b = sk_linear_to_srgb(c4x.b), |
59 c4x.b.rsqrt().invert(), | 59 a = 255.0f * c4x.a ; |
60 c4x.a | 60 |
61 }; | 61 ( Sk4f_round(r) << 0 |
62 cx4s32.transpose((uint8_t*)dst); | 62 | Sk4f_round(g) << 8 |
| 63 | Sk4f_round(b) << 16 |
| 64 | Sk4f_round(a) << 24).store(dst); |
63 | 65 |
64 c4x.r += dc4x.r; | 66 c4x.r += dc4x.r; |
65 c4x.g += dc4x.g; | 67 c4x.g += dc4x.g; |
66 c4x.b += dc4x.b; | 68 c4x.b += dc4x.b; |
67 c4x.a += dc4x.a; | 69 c4x.a += dc4x.a; |
68 | 70 |
69 dst += 4; | 71 dst += 4; |
70 n -= 4; | 72 n -= 4; |
71 } | 73 } |
72 | 74 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 static_cast<const LinearGradient4fContext*>(state->fCtx); | 477 static_cast<const LinearGradient4fContext*>(state->fCtx); |
476 | 478 |
477 if (ctx->fColorsArePremul) { | 479 if (ctx->fColorsArePremul) { |
478 ctx->shadePremulSpan<DstType::F16, ApplyPremul::False>( | 480 ctx->shadePremulSpan<DstType::F16, ApplyPremul::False>( |
479 x, y, dst.writable_addr64(x, y), count); | 481 x, y, dst.writable_addr64(x, y), count); |
480 } else { | 482 } else { |
481 ctx->shadePremulSpan<DstType::F16, ApplyPremul::True>( | 483 ctx->shadePremulSpan<DstType::F16, ApplyPremul::True>( |
482 x, y, dst.writable_addr64(x, y), count); | 484 x, y, dst.writable_addr64(x, y), count); |
483 } | 485 } |
484 } | 486 } |
OLD | NEW |