| OLD | NEW |
| 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::operator=(const SkPMFloat& that) { | 8 inline SkPMFloat& SkPMFloat::operator=(const SkPMFloat& that) { |
| 9 for (int i = 0; i < 4; i++) { fColor[i] = that.fColor[i]; } | 9 for (int i = 0; i < 4; i++) { fColor[i] = that.fColor[i]; } |
| 10 return *this; | 10 return *this; |
| 11 } | 11 } |
| 12 | 12 |
| 13 inline SkPMFloat::SkPMFloat(SkPMColor c) { | 13 inline SkPMFloat::SkPMFloat(SkPMColor c) { |
| 14 *this = SkPMFloat::FromARGB(SkGetPackedA32(c), | 14 *this = SkPMFloat::FromARGB(SkGetPackedA32(c), |
| 15 SkGetPackedR32(c), | 15 SkGetPackedR32(c), |
| 16 SkGetPackedG32(c), | 16 SkGetPackedG32(c), |
| 17 SkGetPackedB32(c)); | 17 SkGetPackedB32(c)); |
| 18 SkASSERT(this->isValid()); | 18 SkASSERT(this->isValid()); |
| 19 } | 19 } |
| 20 | 20 |
| 21 inline SkPMColor SkPMFloat::trunc() const { |
| 22 return SkPackARGB32(this->a(), this->r(), this->g(), this->b()); |
| 23 } |
| 24 |
| 21 inline SkPMColor SkPMFloat::get() const { | 25 inline SkPMColor SkPMFloat::get() const { |
| 22 SkASSERT(this->isValid()); | 26 SkASSERT(this->isValid()); |
| 23 return SkPackARGB32(this->a()+0.5f, this->r()+0.5f, this->g()+0.5f, this->b(
)+0.5f); | 27 return SkPackARGB32(this->a()+0.5f, this->r()+0.5f, this->g()+0.5f, this->b(
)+0.5f); |
| 24 } | 28 } |
| 25 | 29 |
| 26 inline SkPMColor SkPMFloat::clamped() const { | 30 inline SkPMColor SkPMFloat::clamped() const { |
| 27 float a = this->a(), | 31 float a = this->a(), |
| 28 r = this->r(), | 32 r = this->r(), |
| 29 g = this->g(), | 33 g = this->g(), |
| 30 b = this->b(); | 34 b = this->b(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 } | 57 } |
| 54 | 58 |
| 55 inline void SkPMFloat::ClampTo4PMColors( | 59 inline void SkPMFloat::ClampTo4PMColors( |
| 56 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo
at& d, | 60 const SkPMFloat& a, const SkPMFloat& b, const SkPMFloat&c, const SkPMFlo
at& d, |
| 57 SkPMColor colors[4]) { | 61 SkPMColor colors[4]) { |
| 58 colors[0] = a.clamped(); | 62 colors[0] = a.clamped(); |
| 59 colors[1] = b.clamped(); | 63 colors[1] = b.clamped(); |
| 60 colors[2] = c.clamped(); | 64 colors[2] = c.clamped(); |
| 61 colors[3] = d.clamped(); | 65 colors[3] = d.clamped(); |
| 62 } | 66 } |
| OLD | NEW |