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

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

Issue 1055093002: SkPMFloat: fewer internal this->isValid() assertions. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: doc Created 5 years, 8 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') | no next file » | 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 inline SkPMFloat::SkPMFloat(SkPMColor c) { 8 inline SkPMFloat::SkPMFloat(SkPMColor c) {
9 *this = SkPMFloat::FromARGB(SkGetPackedA32(c), 9 *this = SkPMFloat::FromARGB(SkGetPackedA32(c),
10 SkGetPackedR32(c), 10 SkGetPackedR32(c),
11 SkGetPackedG32(c), 11 SkGetPackedG32(c),
12 SkGetPackedB32(c)); 12 SkGetPackedB32(c));
13 SkASSERT(this->isValid()); 13 SkASSERT(this->isValid());
14 } 14 }
15 15
16 inline SkPMColor SkPMFloat::trunc() const { 16 inline SkPMColor SkPMFloat::trunc() const {
17 return SkPackARGB32(this->a(), this->r(), this->g(), this->b()); 17 return SkPackARGB32(this->a(), this->r(), this->g(), this->b());
18 } 18 }
19 19
20 inline SkPMColor SkPMFloat::get() const { 20 inline SkPMColor SkPMFloat::get() const {
21 SkASSERT(this->isValid()); 21 SkPMColor c = SkPackARGB32(this->a()+0.5f, this->r()+0.5f, this->g()+0.5f, t his->b()+0.5f);
22 return SkPackARGB32(this->a()+0.5f, this->r()+0.5f, this->g()+0.5f, this->b( )+0.5f); 22 SkPMColorAssert(c);
23 return c;
23 } 24 }
24 25
25 inline SkPMColor SkPMFloat::clamped() const { 26 inline SkPMColor SkPMFloat::clamped() const {
26 float a = this->a(), 27 float a = this->a(),
27 r = this->r(), 28 r = this->r(),
28 g = this->g(), 29 g = this->g(),
29 b = this->b(); 30 b = this->b();
30 a = a < 0 ? 0 : (a > 255 ? 255 : a); 31 a = a < 0 ? 0 : (a > 255 ? 255 : a);
31 r = r < 0 ? 0 : (r > 255 ? 255 : r); 32 r = r < 0 ? 0 : (r > 255 ? 255 : r);
32 g = g < 0 ? 0 : (g > 255 ? 255 : g); 33 g = g < 0 ? 0 : (g > 255 ? 255 : g);
33 b = b < 0 ? 0 : (b > 255 ? 255 : b); 34 b = b < 0 ? 0 : (b > 255 ? 255 : b);
34 return SkPackARGB32(a+0.5f, r+0.5f, g+0.5f, b+0.5f); 35 SkPMColor c = SkPackARGB32(a+0.5f, r+0.5f, g+0.5f, b+0.5f);
36 SkPMColorAssert(c);
37 return c;
35 } 38 }
36 39
37 inline void SkPMFloat::From4PMColors(const SkPMColor colors[4], 40 inline void SkPMFloat::From4PMColors(const SkPMColor colors[4],
38 SkPMFloat* a, SkPMFloat* b, SkPMFloat* c, S kPMFloat* d) { 41 SkPMFloat* a, SkPMFloat* b, SkPMFloat* c, S kPMFloat* d) {
39 *a = FromPMColor(colors[0]); 42 *a = FromPMColor(colors[0]);
40 *b = FromPMColor(colors[1]); 43 *b = FromPMColor(colors[1]);
41 *c = FromPMColor(colors[2]); 44 *c = FromPMColor(colors[2]);
42 *d = FromPMColor(colors[3]); 45 *d = FromPMColor(colors[3]);
43 } 46 }
44 47
45 inline void SkPMFloat::To4PMColors( 48 inline void SkPMFloat::To4PMColors(
46 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo at& d, 49 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo at& d,
47 SkPMColor colors[4]) { 50 SkPMColor colors[4]) {
48 colors[0] = a.get(); 51 colors[0] = a.get();
49 colors[1] = b.get(); 52 colors[1] = b.get();
50 colors[2] = c.get(); 53 colors[2] = c.get();
51 colors[3] = d.get(); 54 colors[3] = d.get();
52 } 55 }
53 56
54 inline void SkPMFloat::ClampTo4PMColors( 57 inline void SkPMFloat::ClampTo4PMColors(
55 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo at& d, 58 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo at& d,
56 SkPMColor colors[4]) { 59 SkPMColor colors[4]) {
57 colors[0] = a.clamped(); 60 colors[0] = a.clamped();
58 colors[1] = b.clamped(); 61 colors[1] = b.clamped();
59 colors[2] = c.clamped(); 62 colors[2] = c.clamped();
60 colors[3] = d.clamped(); 63 colors[3] = d.clamped();
61 } 64 }
OLDNEW
« no previous file with comments | « src/opts/SkPMFloat_neon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698