OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 namespace { // See SkPMFloat.h |
| 9 |
8 // For SkPMFloat(SkPMColor), we widen our 8 bit components (fix8) to 8-bit compo
nents in 32 bits | 10 // For SkPMFloat(SkPMColor), we widen our 8 bit components (fix8) to 8-bit compo
nents in 32 bits |
9 // (fix8_32), then convert those to floats. | 11 // (fix8_32), then convert those to floats. |
10 | 12 |
11 // round() does the opposite, working from floats to 8-bit-in-32-bits, then back
to packed 8 bit. | 13 // round() does the opposite, working from floats to 8-bit-in-32-bits, then back
to packed 8 bit. |
12 | 14 |
13 // roundClamp() is the same as _SSE2: floats to 8-in-32, to 8-in-16, to packed 8
bit, with | 15 // roundClamp() is the same as _SSE2: floats to 8-in-32, to 8-in-16, to packed 8
bit, with |
14 // _mm_packus_epi16() both clamping and narrowing. | 16 // _mm_packus_epi16() both clamping and narrowing. |
15 | 17 |
16 inline SkPMFloat::SkPMFloat(SkPMColor c) { | 18 inline SkPMFloat::SkPMFloat(SkPMColor c) { |
17 SkPMColorAssert(c); | 19 SkPMColorAssert(c); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 c2 = _mm_cvttps_epi32(_mm_add_ps(_mm_set1_ps(0.5f), c.fVec)), | 76 c2 = _mm_cvttps_epi32(_mm_add_ps(_mm_set1_ps(0.5f), c.fVec)), |
75 c3 = _mm_cvttps_epi32(_mm_add_ps(_mm_set1_ps(0.5f), d.fVec)); | 77 c3 = _mm_cvttps_epi32(_mm_add_ps(_mm_set1_ps(0.5f), d.fVec)); |
76 __m128i c3210 = _mm_packus_epi16(_mm_packus_epi16(c0, c1), | 78 __m128i c3210 = _mm_packus_epi16(_mm_packus_epi16(c0, c1), |
77 _mm_packus_epi16(c2, c3)); | 79 _mm_packus_epi16(c2, c3)); |
78 _mm_storeu_si128((__m128i*)colors, c3210); | 80 _mm_storeu_si128((__m128i*)colors, c3210); |
79 SkPMColorAssert(colors[0]); | 81 SkPMColorAssert(colors[0]); |
80 SkPMColorAssert(colors[1]); | 82 SkPMColorAssert(colors[1]); |
81 SkPMColorAssert(colors[2]); | 83 SkPMColorAssert(colors[2]); |
82 SkPMColorAssert(colors[3]); | 84 SkPMColorAssert(colors[3]); |
83 } | 85 } |
| 86 |
| 87 } // namespace |
OLD | NEW |