From 7792dbf7ea089b3bcb81792a3ecda8a6f8b421e7 Mon Sep 17 00:00:00 2001 From: mtklein Date: Fri, 3 Apr 2015 13:08:28 -0700 Subject: Code's more readable when SkPMFloat is an Sk4f. #floats BUG=skia: BUG=skia:3592 Committed: https://skia.googlesource.com/skia/+/6b5dab889579f1cc9e1b5278f4ecdc4c63fe78c9 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-Arm64-Debug-Android-Trybot Review URL: https://codereview.chromium.org/1061603002 --- src/core/SkPMFloat.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/core/SkPMFloat.h') diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h index a327025f3c..eb575f2ee4 100644 --- a/src/core/SkPMFloat.h +++ b/src/core/SkPMFloat.h @@ -15,7 +15,7 @@ // A pre-multiplied color storing each component in the same order as SkPMColor, // but as a float in the range [0, 255]. -class SK_STRUCT_ALIGN(16) SkPMFloat { +class SkPMFloat : public Sk4f { public: static SkPMFloat FromPMColor(SkPMColor c) { return SkPMFloat(c); } static SkPMFloat FromARGB(float a, float r, float g, float b) { return SkPMFloat(a,r,g,b); } @@ -28,20 +28,17 @@ public: explicit SkPMFloat(SkPMColor); SkPMFloat(float a, float r, float g, float b) #ifdef SK_PMCOLOR_IS_RGBA - : fColors(r,g,b,a) {} + : INHERITED(r,g,b,a) {} #else - : fColors(b,g,r,a) {} + : INHERITED(b,g,r,a) {} #endif + SkPMFloat(const Sk4f& fs) : INHERITED(fs) {} - // Freely autoconvert between SkPMFloat and Sk4f. - /*implicit*/ SkPMFloat(const Sk4f& fs) { fColors = fs; } - /*implicit*/ operator Sk4f() const { return fColors; } - - float a() const { return fColors.kth(); } - float r() const { return fColors.kth(); } - float g() const { return fColors.kth(); } - float b() const { return fColors.kth(); } + float a() const { return this->kth(); } + float r() const { return this->kth(); } + float g() const { return this->kth(); } + float b() const { return this->kth(); } // N.B. All methods returning an SkPMColor call SkPMColorAssert on that result before returning. @@ -67,7 +64,7 @@ public: } private: - Sk4f fColors; + typedef Sk4f INHERITED; }; #ifdef SKNX_NO_SIMD -- cgit v1.2.3