aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-02-26 10:43:16 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-26 10:43:16 -0800
commit870b9ea38672276a3e8506a0101dc559fa04583a (patch)
tree8028f886082df97cf0ac981adeafd522b58a703a /src
parentd223fb21d61b371619b442e95a8de3a3de21b607 (diff)
add auto SkPMFloat <-> Sk4f conversion
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPMFloat.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h
index d2d83d0068..7c093a6a49 100644
--- a/src/core/SkPMFloat.h
+++ b/src/core/SkPMFloat.h
@@ -3,11 +3,21 @@
#include "SkTypes.h"
#include "SkColor.h"
+#include "Sk4x.h"
// A pre-multiplied color in the same order as SkPMColor storing each component as a float.
struct SK_STRUCT_ALIGN(16) SkPMFloat {
float fColor[4];
+ // Normal POD copies and do-nothing initialization.
+ SkPMFloat() = default;
+ SkPMFloat(const SkPMFloat&) = default;
+ SkPMFloat& operator=(const SkPMFloat&) = default;
+
+ // Freely autoconvert between SkPMFloat and Sk4f.
+ /*implicit*/ SkPMFloat(const Sk4f& fs) { fs.storeAligned(fColor); }
+ /*implicit*/ operator Sk4f() const { return Sk4f::LoadAligned(fColor); }
+
float a() const { return fColor[SK_A32_SHIFT / 8]; }
float r() const { return fColor[SK_R32_SHIFT / 8]; }
float g() const { return fColor[SK_G32_SHIFT / 8]; }