Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: src/core/SkPMFloat.h

Issue 954323002: add auto SkPMFloat <-> Sk4f conversion (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/PMFloatTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPMFloat.h
diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h
index d2d83d0068c1dc78b25c23c35115dd7ae05b2099..7c093a6a49ff60b2b973c0f658dedd134ebba7be 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]; }
« no previous file with comments | « no previous file | tests/PMFloatTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698