Chromium Code Reviews| 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 namespace { // See SkPMFloat.h | 8 namespace { // See SkPMFloat.h |
| 9 | 9 |
| 10 inline SkPMFloat::SkPMFloat(SkPMColor c) { | 10 inline SkPMFloat::SkPMFloat(SkPMColor c) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 b = b < 0 ? 0 : (b > 1 ? 1 : b); | 27 b = b < 0 ? 0 : (b > 1 ? 1 : b); |
| 28 SkPMColor c = SkPackARGB32(255*a+0.5f, 255*r+0.5f, 255*g+0.5f, 255*b+0.5f); | 28 SkPMColor c = SkPackARGB32(255*a+0.5f, 255*r+0.5f, 255*g+0.5f, 255*b+0.5f); |
| 29 SkPMColorAssert(c); | 29 SkPMColorAssert(c); |
| 30 return c; | 30 return c; |
| 31 } | 31 } |
| 32 | 32 |
| 33 inline Sk4f SkPMFloat::alphas() const { | 33 inline Sk4f SkPMFloat::alphas() const { |
| 34 return Sk4f(this->a()); | 34 return Sk4f(this->a()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 inline SkPMFloat SkPMFloat::FromBGRx(SkColor c) { | 37 inline SkPMFloat SkPMFloat::FromOpaqueColor(SkColor c) { |
| 38 SkASSERT(SkColorGetA(c) == 0xFF); | |
| 38 float inv255 = 1.0f / 255; | 39 float inv255 = 1.0f / 255; |
| 39 SkPMFloat pmf = SkPMFloat::FromARGB(1.0f, | 40 SkPMFloat pmf = SkPMFloat::FromARGB(1.0f, |
| 40 SkGetPackedR32(c) * inv255, | 41 SkGetPackedR32(c) * inv255, |
| 41 SkGetPackedG32(c) * inv255, | 42 SkGetPackedG32(c) * inv255, |
| 42 SkGetPackedB32(c) * inv255); | 43 SkGetPackedB32(c) * inv255); |
|
Noel Gordon
2015/08/20 01:43:29
Yes, that's a better function name, and the SkGetP
| |
| 43 SkASSERT(pmf.isValid()); | 44 SkASSERT(pmf.isValid()); |
| 44 return pmf; | 45 return pmf; |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace | 48 } // namespace |
| OLD | NEW |