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 ( sk_linear_to_srgb(c4x.r) << 0 |
57 c4x.r.rsqrt().invert(), | 57 | sk_linear_to_srgb(c4x.g) << 8 |
58 c4x.g.rsqrt().invert(), | 58 | sk_linear_to_srgb(c4x.b) << 16 |
59 c4x.b.rsqrt().invert(), | 59 | Sk4f_round(255.0f*c4x.a) << 24).store(dst); |
60 c4x.a | |
61 }; | |
62 cx4s32.transpose((uint8_t*)dst); | |
63 | 60 |
64 c4x.r += dc4x.r; | 61 c4x.r += dc4x.r; |
65 c4x.g += dc4x.g; | 62 c4x.g += dc4x.g; |
66 c4x.b += dc4x.b; | 63 c4x.b += dc4x.b; |
67 c4x.a += dc4x.a; | 64 c4x.a += dc4x.a; |
68 | 65 |
69 dst += 4; | 66 dst += 4; |
70 n -= 4; | 67 n -= 4; |
71 } | 68 } |
72 | 69 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 static_cast<const LinearGradient4fContext*>(state->fCtx); | 472 static_cast<const LinearGradient4fContext*>(state->fCtx); |
476 | 473 |
477 if (ctx->fColorsArePremul) { | 474 if (ctx->fColorsArePremul) { |
478 ctx->shadePremulSpan<DstType::F16, ApplyPremul::False>( | 475 ctx->shadePremulSpan<DstType::F16, ApplyPremul::False>( |
479 x, y, dst.writable_addr64(x, y), count); | 476 x, y, dst.writable_addr64(x, y), count); |
480 } else { | 477 } else { |
481 ctx->shadePremulSpan<DstType::F16, ApplyPremul::True>( | 478 ctx->shadePremulSpan<DstType::F16, ApplyPremul::True>( |
482 x, y, dst.writable_addr64(x, y), count); | 479 x, y, dst.writable_addr64(x, y), count); |
483 } | 480 } |
484 } | 481 } |
OLD | NEW |