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