OLD | NEW |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
1 inline SkPMFloat& SkPMFloat::operator=(const SkPMFloat& that) { | 8 inline SkPMFloat& SkPMFloat::operator=(const SkPMFloat& that) { |
2 fColors = that.fColors; | 9 fColors = that.fColors; |
3 return *this; | 10 return *this; |
4 } | 11 } |
5 | 12 |
6 // For SkPMFloat(SkPMFColor), we widen our 8 bit components (fix8) to 8-bit comp
onents in 16 bits | 13 // For SkPMFloat(SkPMFColor), we widen our 8 bit components (fix8) to 8-bit comp
onents in 16 bits |
7 // (fix8_16), then widen those to 8-bit-in-32-bits (fix8_32), and finally conver
t those to floats. | 14 // (fix8_16), then widen those to 8-bit-in-32-bits (fix8_32), and finally conver
t those to floats. |
8 | 15 |
9 // get() and clamped() do the opposite, working from floats to 8-bit-in-32-bit, | 16 // get() and clamped() do the opposite, working from floats to 8-bit-in-32-bit, |
10 // to 8-bit-in-16-bit, back down to 8-bit components. | 17 // to 8-bit-in-16-bit, back down to 8-bit components. |
(...skipping 23 matching lines...) Expand all Loading... |
34 float32x4_t add_half = vaddq_f32(fColors, vdupq_n_f32(0.5f)); | 41 float32x4_t add_half = vaddq_f32(fColors, vdupq_n_f32(0.5f)); |
35 uint32x4_t fix8_32 = vcvtq_u32_f32(add_half); // vcvtq_u32_f32 truncates,
so round manually | 42 uint32x4_t fix8_32 = vcvtq_u32_f32(add_half); // vcvtq_u32_f32 truncates,
so round manually |
36 uint16x4_t fix8_16 = vqmovn_u32(fix8_32); | 43 uint16x4_t fix8_16 = vqmovn_u32(fix8_32); |
37 uint8x8_t fix8 = vqmovn_u16(vcombine_u16(fix8_16, vdup_n_u16(0))); | 44 uint8x8_t fix8 = vqmovn_u16(vcombine_u16(fix8_16, vdup_n_u16(0))); |
38 SkPMColor c = vget_lane_u32((uint32x2_t)fix8, 0); | 45 SkPMColor c = vget_lane_u32((uint32x2_t)fix8, 0); |
39 SkPMColorAssert(c); | 46 SkPMColorAssert(c); |
40 return c; | 47 return c; |
41 } | 48 } |
42 | 49 |
43 // TODO: we should be able to beat these loops on all three methods. | 50 // TODO: we should be able to beat these loops on all three methods. |
44 inline void SkPMFloat::From4PMColors(SkPMFloat floats[4], const SkPMColor colors
[4]) { | 51 inline void SkPMFloat::From4PMColors(const SkPMColor colors[4], |
45 for (int i = 0; i < 4; i++) { floats[i] = FromPMColor(colors[i]); } | 52 SkPMFloat* a, SkPMFloat* b, SkPMFloat* c, S
kPMFloat* d) { |
| 53 *a = FromPMColor(colors[0]); |
| 54 *b = FromPMColor(colors[1]); |
| 55 *c = FromPMColor(colors[2]); |
| 56 *d = FromPMColor(colors[3]); |
46 } | 57 } |
47 | 58 |
48 inline void SkPMFloat::To4PMColors(SkPMColor colors[4], const SkPMFloat floats[4
]) { | 59 inline void SkPMFloat::To4PMColors( |
49 for (int i = 0; i < 4; i++) { colors[i] = floats[i].get(); } | 60 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo
at& d, |
| 61 SkPMColor colors[4]) { |
| 62 colors[0] = a.get(); |
| 63 colors[1] = b.get(); |
| 64 colors[2] = c.get(); |
| 65 colors[3] = d.get(); |
50 } | 66 } |
51 | 67 |
52 inline void SkPMFloat::ClampTo4PMColors(SkPMColor colors[4], const SkPMFloat flo
ats[4]) { | 68 inline void SkPMFloat::ClampTo4PMColors( |
53 for (int i = 0; i < 4; i++) { colors[i] = floats[i].clamped(); } | 69 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo
at& d, |
| 70 SkPMColor colors[4]) { |
| 71 colors[0] = a.clamped(); |
| 72 colors[1] = b.clamped(); |
| 73 colors[2] = c.clamped(); |
| 74 colors[3] = d.clamped(); |
54 } | 75 } |
OLD | NEW |