Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: src/opts/SkPMFloat_neon.h

Issue 1286093004: Refactor to put SkXfermode_opts inside SK_OPTS_NS. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/opts/SkOpts_sse2.cpp ('k') | src/opts/SkPMFloat_none.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8 SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) {
9
10 inline SkPMFloat::SkPMFloat(SkPMColor c) {
11 SkPMColorAssert(c); 9 SkPMColorAssert(c);
12 uint8x8_t fix8 = (uint8x8_t)vdup_n_u32(c); 10 uint8x8_t fix8 = (uint8x8_t)vdup_n_u32(c);
13 uint16x8_t fix8_16 = vmovl_u8(fix8); 11 uint16x8_t fix8_16 = vmovl_u8(fix8);
14 uint32x4_t fix8_32 = vmovl_u16(vget_low_u16(fix8_16)); 12 uint32x4_t fix8_32 = vmovl_u16(vget_low_u16(fix8_16));
15 fVec = vmulq_f32(vcvtq_f32_u32(fix8_32), vdupq_n_f32(1.0f/255)); 13 fVec = vmulq_f32(vcvtq_f32_u32(fix8_32), vdupq_n_f32(1.0f/255));
16 SkASSERT(this->isValid()); 14 SkASSERT(this->isValid());
17 } 15 }
18 16
19 inline SkPMColor SkPMFloat::round() const { 17 SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const {
20 // vcvt_u32_f32 truncates, so we round manually by adding a half before conv erting. 18 // vcvt_u32_f32 truncates, so we round manually by adding a half before conv erting.
21 float32x4_t rounded = vmlaq_f32(vdupq_n_f32(0.5f), fVec, vdupq_n_f32(255)); 19 float32x4_t rounded = vmlaq_f32(vdupq_n_f32(0.5f), fVec, vdupq_n_f32(255));
22 uint32x4_t fix8_32 = vcvtq_u32_f32(rounded); 20 uint32x4_t fix8_32 = vcvtq_u32_f32(rounded);
23 uint16x4_t fix8_16 = vqmovn_u32(fix8_32); 21 uint16x4_t fix8_16 = vqmovn_u32(fix8_32);
24 uint8x8_t fix8 = vqmovn_u16(vcombine_u16(fix8_16, vdup_n_u16(0))); 22 uint8x8_t fix8 = vqmovn_u16(vcombine_u16(fix8_16, vdup_n_u16(0)));
25 SkPMColor c = vget_lane_u32((uint32x2_t)fix8, 0); 23 SkPMColor c = vget_lane_u32((uint32x2_t)fix8, 0);
26 SkPMColorAssert(c); 24 SkPMColorAssert(c);
27 return c; 25 return c;
28 } 26 }
29 27
30 inline Sk4f SkPMFloat::alphas() const { 28 SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const {
31 static_assert(SK_A32_SHIFT == 24, "Assuming little-endian."); 29 static_assert(SK_A32_SHIFT == 24, "Assuming little-endian.");
32 return vdupq_lane_f32(vget_high_f32(fVec), 1); // Duplicate high lane of hi gh half i.e. lane 3. 30 return vdupq_lane_f32(vget_high_f32(fVec), 1); // Duplicate high lane of hi gh half i.e. lane 3.
33 } 31 }
34
35 } // namespace
OLDNEW
« no previous file with comments | « src/opts/SkOpts_sse2.cpp ('k') | src/opts/SkPMFloat_none.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698