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

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

Issue 960023002: Spin off some fixes to land right away. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try inline instead Created 5 years, 9 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 #include "SkColorPriv.h" 1 #include "SkColorPriv.h"
2 #include "SkPMFloat.h"
3 2
4 inline void SkPMFloat::set(SkPMColor c) { 3 inline void SkPMFloat::set(SkPMColor c) {
5 float scale = 1.0f / 255.0f; 4 float scale = 1.0f / 255.0f;
6 this->setA(SkGetPackedA32(c) * scale); 5 this->setA(SkGetPackedA32(c) * scale);
7 this->setR(SkGetPackedR32(c) * scale); 6 this->setR(SkGetPackedR32(c) * scale);
8 this->setG(SkGetPackedG32(c) * scale); 7 this->setG(SkGetPackedG32(c) * scale);
9 this->setB(SkGetPackedB32(c) * scale); 8 this->setB(SkGetPackedB32(c) * scale);
10 SkASSERT(this->isValid()); 9 SkASSERT(this->isValid());
11 } 10 }
12 11
13 inline SkPMColor SkPMFloat::get() const { 12 inline SkPMColor SkPMFloat::get() const {
14 SkASSERT(this->isValid()); 13 SkASSERT(this->isValid());
15 return SkPackARGB32(this->a() * 255, this->r() * 255, this->g() * 255, this- >b() * 255); 14 return SkPackARGB32(this->a() * 255, this->r() * 255, this->g() * 255, this- >b() * 255);
16 } 15 }
17 16
18 inline SkPMColor SkPMFloat::clamped() const { 17 inline SkPMColor SkPMFloat::clamped() const {
19 float a = this->a(), 18 float a = this->a(),
20 r = this->r(), 19 r = this->r(),
21 g = this->g(), 20 g = this->g(),
22 b = this->b(); 21 b = this->b();
23 a = a < 0 ? 0 : (a > 1 ? 1 : a); 22 a = a < 0 ? 0 : (a > 1 ? 1 : a);
24 r = r < 0 ? 0 : (r > 1 ? 1 : r); 23 r = r < 0 ? 0 : (r > 1 ? 1 : r);
25 g = g < 0 ? 0 : (g > 1 ? 1 : g); 24 g = g < 0 ? 0 : (g > 1 ? 1 : g);
26 b = b < 0 ? 0 : (b > 1 ? 1 : b); 25 b = b < 0 ? 0 : (b > 1 ? 1 : b);
27 return SkPackARGB32(a * 255, r * 255, g * 255, b * 255); 26 return SkPackARGB32(a * 255, r * 255, g * 255, b * 255);
28 } 27 }
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