aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPMFloat.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2015-04-03 12:47:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-03 12:47:48 -0700
commite758579d4f85f4615d62e87847dd3f8b38e3a6e2 (patch)
tree92c840da319692114516ad4d3b83d31f079573ee /src/core/SkPMFloat.h
parent6b5dab889579f1cc9e1b5278f4ecdc4c63fe78c9 (diff)
Revert of Code's more readable when SkPMFloat is an Sk4f. (patchset #3 id:40001 of https://codereview.chromium.org/1061603002/)
Reason for revert: missed some neon code Original issue's description: > Code's more readable when SkPMFloat is an Sk4f. > #floats > > BUG=skia: > BUG=skia:3592 > > Committed: https://skia.googlesource.com/skia/+/6b5dab889579f1cc9e1b5278f4ecdc4c63fe78c9 TBR=reed@google.com,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1056143004
Diffstat (limited to 'src/core/SkPMFloat.h')
-rw-r--r--src/core/SkPMFloat.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h
index eb575f2ee4..a327025f3c 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 SkPMFloat : public Sk4f {
+class SK_STRUCT_ALIGN(16) SkPMFloat {
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,17 +28,20 @@ public:
explicit SkPMFloat(SkPMColor);
SkPMFloat(float a, float r, float g, float b)
#ifdef SK_PMCOLOR_IS_RGBA
- : INHERITED(r,g,b,a) {}
+ : fColors(r,g,b,a) {}
#else
- : INHERITED(b,g,r,a) {}
+ : fColors(b,g,r,a) {}
#endif
- SkPMFloat(const Sk4f& fs) : INHERITED(fs) {}
- float a() const { return this->kth<SK_A32_SHIFT / 8>(); }
- float r() const { return this->kth<SK_R32_SHIFT / 8>(); }
- float g() const { return this->kth<SK_G32_SHIFT / 8>(); }
- float b() const { return this->kth<SK_B32_SHIFT / 8>(); }
+ // 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<SK_A32_SHIFT / 8>(); }
+ float r() const { return fColors.kth<SK_R32_SHIFT / 8>(); }
+ float g() const { return fColors.kth<SK_G32_SHIFT / 8>(); }
+ float b() const { return fColors.kth<SK_B32_SHIFT / 8>(); }
// N.B. All methods returning an SkPMColor call SkPMColorAssert on that result before returning.
@@ -64,7 +67,7 @@ public:
}
private:
- typedef Sk4f INHERITED;
+ Sk4f fColors;
};
#ifdef SKNX_NO_SIMD