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 "SkPM4fPriv.h" | 8 #include "SkPM4fPriv.h" |
9 #include "SkUtils.h" | 9 #include "SkUtils.h" |
10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 p.r *= p.r; | 61 p.r *= p.r; |
62 p.g *= p.g; | 62 p.g *= p.g; |
63 p.b *= p.b; | 63 p.b *= p.b; |
64 | 64 |
65 return p; | 65 return p; |
66 } | 66 } |
67 | 67 |
68 // Store an Sk4x4f back to 4 interlaced 8888 sRGB pixels. | 68 // Store an Sk4x4f back to 4 interlaced 8888 sRGB pixels. |
69 static void store_4_srgb(void* ptr, const Sk4x4f& p) { | 69 static void store_4_srgb(void* ptr, const Sk4x4f& p) { |
70 // Convert back to sRGB and [0,255], again approximating sRGB as gamma == 2. | 70 // Convert back to sRGB and [0,255], again approximating sRGB as gamma == 2. |
71 auto r = p.r.sqrt() * 255.0f + 0.5f, | 71 auto r = p.r.rsqrt().invert() * 255.0f + 0.5f, |
72 g = p.g.sqrt() * 255.0f + 0.5f, | 72 g = p.g.rsqrt().invert() * 255.0f + 0.5f, |
73 b = p.b.sqrt() * 255.0f + 0.5f, | 73 b = p.b.rsqrt().invert() * 255.0f + 0.5f, |
74 a = p.a * 255.0f + 0.5f; | 74 a = p.a * 255.0f + 0.5f; |
75 Sk4x4f{r,g,b,a}.transpose((uint8_t*)ptr); | 75 Sk4x4f{r,g,b,a}.transpose((uint8_t*)ptr); |
76 } | 76 } |
77 | 77 |
78 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 78 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
79 | 79 |
80 template <DstType D> void general_1(const SkXfermode* xfer, uint32_t dst[], | 80 template <DstType D> void general_1(const SkXfermode* xfer, uint32_t dst[], |
81 const SkPM4f* src, int count, const SkAlpha
aa[]) { | 81 const SkPM4f* src, int count, const SkAlpha
aa[]) { |
82 const SkPM4f s = rgba_to_pmcolor_order(*src); | 82 const SkPM4f s = rgba_to_pmcolor_order(*src); |
83 SkXfermodeProc4f proc = xfer->getProc4f(); | 83 SkXfermodeProc4f proc = xfer->getProc4f(); |
84 SkPM4f d; | 84 SkPM4f d; |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 518 |
519 const LCD32Proc procs[] = { | 519 const LCD32Proc procs[] = { |
520 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, | 520 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, |
521 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, | 521 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, |
522 | 522 |
523 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, | 523 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, |
524 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, | 524 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, |
525 }; | 525 }; |
526 return procs[flags]; | 526 return procs[flags]; |
527 } | 527 } |
OLD | NEW |