aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkColor.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-01-21 15:29:10 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-21 15:29:10 -0800
commit353c148d8e8c9031daca34c6f9d6bcc6f08706c7 (patch)
tree2688f89d13fd991cefaf2a6e9cd79e48fa31417c /include/core/SkColor.h
parent07caf56e723ec04a024f952177f7f4daba06c82c (diff)
experiment: float color components
Diffstat (limited to 'include/core/SkColor.h')
-rw-r--r--include/core/SkColor.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/core/SkColor.h b/include/core/SkColor.h
index 1ba1331c1a..77946387e5 100644
--- a/include/core/SkColor.h
+++ b/include/core/SkColor.h
@@ -160,4 +160,44 @@ SK_API SkPMColor SkPreMultiplyColor(SkColor c);
*/
typedef SkPMColor (*SkXfermodeProc)(SkPMColor src, SkPMColor dst);
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*
+ * The float values are 0...1 premultiplied
+ */
+struct SK_ATTRIBUTE(aligned(16)) SkPM4f {
+ float fVec[4];
+
+ float a() const { return fVec[SK_A32_SHIFT/8]; }
+};
+
+/*
+ * The float values are 0...1 unpremultiplied
+ */
+struct SkColor4f {
+ float fA;
+ float fR;
+ float fG;
+ float fB;
+
+ bool operator==(const SkColor4f& other) const {
+ return fA == other.fA && fR == other.fR && fG == other.fG && fB == other.fB;
+ }
+ bool operator!=(const SkColor4f& other) const {
+ return !(*this == other);
+ }
+
+ const float* vec() const { return &fA; }
+ float* vec() { return &fA; }
+
+ static SkColor4f Pin(float a, float r, float g, float b);
+ static SkColor4f FromColor(SkColor);
+
+ SkColor4f pin() const {
+ return Pin(fA, fR, fG, fB);
+ }
+
+ SkPM4f premul() const;
+};
+
#endif