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

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

Issue 1284333002: Revert of 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/SkPMFloat_neon.h ('k') | src/opts/SkPMFloat_sse.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 SK_ALWAYS_INLINE SkPMFloat::SkPMFloat(SkPMColor c) { 8 namespace { // See SkPMFloat.h
9
10 inline SkPMFloat::SkPMFloat(SkPMColor c) {
9 float inv255 = 1.0f/255; 11 float inv255 = 1.0f/255;
10 *this = SkPMFloat::FromARGB(SkGetPackedA32(c) * inv255, 12 *this = SkPMFloat::FromARGB(SkGetPackedA32(c) * inv255,
11 SkGetPackedR32(c) * inv255, 13 SkGetPackedR32(c) * inv255,
12 SkGetPackedG32(c) * inv255, 14 SkGetPackedG32(c) * inv255,
13 SkGetPackedB32(c) * inv255); 15 SkGetPackedB32(c) * inv255);
14 SkASSERT(this->isValid()); 16 SkASSERT(this->isValid());
15 } 17 }
16 18
17 SK_ALWAYS_INLINE SkPMColor SkPMFloat::round() const { 19 inline SkPMColor SkPMFloat::round() const {
18 float a = this->a(), 20 float a = this->a(),
19 r = this->r(), 21 r = this->r(),
20 g = this->g(), 22 g = this->g(),
21 b = this->b(); 23 b = this->b();
22 a = a < 0 ? 0 : (a > 1 ? 1 : a); 24 a = a < 0 ? 0 : (a > 1 ? 1 : a);
23 r = r < 0 ? 0 : (r > 1 ? 1 : r); 25 r = r < 0 ? 0 : (r > 1 ? 1 : r);
24 g = g < 0 ? 0 : (g > 1 ? 1 : g); 26 g = g < 0 ? 0 : (g > 1 ? 1 : g);
25 b = b < 0 ? 0 : (b > 1 ? 1 : b); 27 b = b < 0 ? 0 : (b > 1 ? 1 : b);
26 SkPMColor c = SkPackARGB32(255*a+0.5f, 255*r+0.5f, 255*g+0.5f, 255*b+0.5f); 28 SkPMColor c = SkPackARGB32(255*a+0.5f, 255*r+0.5f, 255*g+0.5f, 255*b+0.5f);
27 SkPMColorAssert(c); 29 SkPMColorAssert(c);
28 return c; 30 return c;
29 } 31 }
30 32
31 SK_ALWAYS_INLINE Sk4f SkPMFloat::alphas() const { 33 inline Sk4f SkPMFloat::alphas() const {
32 return Sk4f(this->a()); 34 return Sk4f(this->a());
33 } 35 }
36
37 } // namespace
OLDNEW
« no previous file with comments | « src/opts/SkPMFloat_neon.h ('k') | src/opts/SkPMFloat_sse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698