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

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

Issue 1214443002: Color dodge and burn with SkPMFloat. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: reed Created 5 years, 6 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/SkNx_sse.h ('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 namespace { // See SkPMFloat.h
9 9
10 inline SkPMFloat::SkPMFloat(SkPMColor c) { 10 inline SkPMFloat::SkPMFloat(SkPMColor c) {
11 SkPMColorAssert(c); 11 SkPMColorAssert(c);
12 uint8x8_t fix8 = (uint8x8_t)vdup_n_u32(c); 12 uint8x8_t fix8 = (uint8x8_t)vdup_n_u32(c);
13 uint16x8_t fix8_16 = vmovl_u8(fix8); 13 uint16x8_t fix8_16 = vmovl_u8(fix8);
14 uint32x4_t fix8_32 = vmovl_u16(vget_low_u16(fix8_16)); 14 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)); 15 fVec = vmulq_f32(vcvtq_f32_u32(fix8_32), vdupq_n_f32(1.0f/255));
16 SkASSERT(this->isValid()); 16 SkASSERT(this->isValid());
17 } 17 }
18 18
19 inline SkPMColor SkPMFloat::round() const { 19 inline SkPMColor SkPMFloat::round() const {
20 // vcvt_u32_f32 truncates, so we round manually by adding a half before conv erting. 20 // 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)); 21 float32x4_t rounded = vmlaq_f32(vdupq_n_f32(0.5f), fVec, vdupq_n_f32(255));
22 uint32x4_t fix8_32 = vcvtq_u32_f32(rounded); 22 uint32x4_t fix8_32 = vcvtq_u32_f32(rounded);
23 uint16x4_t fix8_16 = vqmovn_u32(fix8_32); 23 uint16x4_t fix8_16 = vqmovn_u32(fix8_32);
24 uint8x8_t fix8 = vqmovn_u16(vcombine_u16(fix8_16, vdup_n_u16(0))); 24 uint8x8_t fix8 = vqmovn_u16(vcombine_u16(fix8_16, vdup_n_u16(0)));
25 SkPMColor c = vget_lane_u32((uint32x2_t)fix8, 0); 25 SkPMColor c = vget_lane_u32((uint32x2_t)fix8, 0);
26 SkPMColorAssert(c); 26 SkPMColorAssert(c);
27 return c; 27 return c;
28 } 28 }
29 29
30 inline Sk4f SkPMFloat::alphas() const {
31 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.
33 }
34
30 } // namespace 35 } // namespace
OLDNEW
« no previous file with comments | « src/opts/SkNx_sse.h ('k') | src/opts/SkPMFloat_none.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698