blob: 448b509d408e8545c4a25a01d9e30a9db0fae946 [file] [log] [blame]
mtkleina2f4be72015-02-23 10:04:34 -08001#include "SkColorPriv.h"
mtkleina2f4be72015-02-23 10:04:34 -08002
3inline void SkPMFloat::set(SkPMColor c) {
mtklein60d2a322015-03-03 07:46:15 -08004 this->setA(SkGetPackedA32(c));
5 this->setR(SkGetPackedR32(c));
6 this->setG(SkGetPackedG32(c));
7 this->setB(SkGetPackedB32(c));
mtkleina2f4be72015-02-23 10:04:34 -08008 SkASSERT(this->isValid());
9}
10
11inline SkPMColor SkPMFloat::get() const {
12 SkASSERT(this->isValid());
mtklein60d2a322015-03-03 07:46:15 -080013 return SkPackARGB32(this->a(), this->r(), this->g(), this->b());
mtkleina2f4be72015-02-23 10:04:34 -080014}
15
16inline SkPMColor SkPMFloat::clamped() const {
17 float a = this->a(),
18 r = this->r(),
19 g = this->g(),
20 b = this->b();
mtklein60d2a322015-03-03 07:46:15 -080021 a = a < 0 ? 0 : (a > 255 ? 255 : a);
22 r = r < 0 ? 0 : (r > 255 ? 255 : r);
23 g = g < 0 ? 0 : (g > 255 ? 255 : g);
24 b = b < 0 ? 0 : (b > 255 ? 255 : b);
25 return SkPackARGB32(a, r, g, b);
mtkleina2f4be72015-02-23 10:04:34 -080026}