OLD | NEW |
1 #include "SkColorPriv.h" | 1 #include "SkColorPriv.h" |
2 | 2 |
3 inline void SkPMFloat::set(SkPMColor c) { | 3 inline void SkPMFloat::set(SkPMColor c) { |
4 float scale = 1.0f / 255.0f; | 4 this->setA(SkGetPackedA32(c)); |
5 this->setA(SkGetPackedA32(c) * scale); | 5 this->setR(SkGetPackedR32(c)); |
6 this->setR(SkGetPackedR32(c) * scale); | 6 this->setG(SkGetPackedG32(c)); |
7 this->setG(SkGetPackedG32(c) * scale); | 7 this->setB(SkGetPackedB32(c)); |
8 this->setB(SkGetPackedB32(c) * scale); | |
9 SkASSERT(this->isValid()); | 8 SkASSERT(this->isValid()); |
10 } | 9 } |
11 | 10 |
12 inline SkPMColor SkPMFloat::get() const { | 11 inline SkPMColor SkPMFloat::get() const { |
13 SkASSERT(this->isValid()); | 12 SkASSERT(this->isValid()); |
14 return SkPackARGB32(this->a() * 255, this->r() * 255, this->g() * 255, this-
>b() * 255); | 13 return SkPackARGB32(this->a(), this->r(), this->g(), this->b()); |
15 } | 14 } |
16 | 15 |
17 inline SkPMColor SkPMFloat::clamped() const { | 16 inline SkPMColor SkPMFloat::clamped() const { |
18 float a = this->a(), | 17 float a = this->a(), |
19 r = this->r(), | 18 r = this->r(), |
20 g = this->g(), | 19 g = this->g(), |
21 b = this->b(); | 20 b = this->b(); |
22 a = a < 0 ? 0 : (a > 1 ? 1 : a); | 21 a = a < 0 ? 0 : (a > 255 ? 255 : a); |
23 r = r < 0 ? 0 : (r > 1 ? 1 : r); | 22 r = r < 0 ? 0 : (r > 255 ? 255 : r); |
24 g = g < 0 ? 0 : (g > 1 ? 1 : g); | 23 g = g < 0 ? 0 : (g > 255 ? 255 : g); |
25 b = b < 0 ? 0 : (b > 1 ? 1 : b); | 24 b = b < 0 ? 0 : (b > 255 ? 255 : b); |
26 return SkPackARGB32(a * 255, r * 255, g * 255, b * 255); | 25 return SkPackARGB32(a, r, g, b); |
27 } | 26 } |
OLD | NEW |