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

Unified Diff: src/core/SkPM4f.h

Issue 1774523002: make pm4f be RGBA always, not pmcolor order (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « src/core/SkColor.cpp ('k') | src/core/SkPM4fPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPM4f.h
diff --git a/src/core/SkPM4f.h b/src/core/SkPM4f.h
index fb22783dcc44203a8c3931982f645e3de7dde956..2bf2f23a92e5634dd64132feb47f02d5a16da282 100644
--- a/src/core/SkPM4f.h
+++ b/src/core/SkPM4f.h
@@ -9,29 +9,73 @@
#define SkPM4f_DEFINED
#include "SkColorPriv.h"
+#include "SkNx.h"
+
+static inline Sk4f swizzle_rb(const Sk4f& x) {
+ return Sk4f(x[2], x[1], x[0], x[3]);
mtklein 2016/03/07 16:13:49 We'll have better opportunity to improve this late
reed1 2016/03/07 17:39:07 Done.
+}
+
+static inline Sk4f swizzle_rgba_to_pmorder(const Sk4f& x) {
+#ifdef SK_PMCOLOR_IS_BGRA
+ return Sk4f(x[2], x[1], x[0], x[3]);
mtklein 2016/03/07 16:13:49 return swizzle_rb(x); ?
reed1 2016/03/07 17:39:07 Done.
+#else
+ return x;
+#endif
+}
+
+static inline Sk4f swizzle_pmorder_to_rgba(const Sk4f& x) {
+#ifdef SK_PMCOLOR_IS_BGRA
+ return Sk4f(x[2], x[1], x[0], x[3]);
mtklein 2016/03/07 16:13:49 ditto
reed1 2016/03/07 17:39:07 Done.
+#else
+ return x;
+#endif
+}
/*
* The float values are 0...1 premultiplied
*/
struct SkPM4f {
enum {
+#if 0
A = SK_A32_SHIFT/8,
R = SK_R32_SHIFT/8,
G = SK_G32_SHIFT/8,
B = SK_B32_SHIFT/8,
+#else
+ R, G, B, A,
+#endif
};
float fVec[4];
float a() const { return fVec[A]; }
- SkColor4f unpremul() const;
+ SkPM4f rgba() const { return *this; }
mtklein 2016/03/07 16:13:49 It seems weird for these to return SkPM4f. Only r
reed1 2016/03/07 17:39:07 Moved to call-site
+ SkPM4f bgra() const { return{{ fVec[2], fVec[1], fVec[0], fVec[3] }}; }
+ SkPM4f pmorder() const {
+#ifdef SK_PMCOLOR_IS_BGRA
+ return this->bgra();
+#else
+ return this->rgba();
+#endif
+ }
+ static SkPM4f From4f(const Sk4f& x) {
+ SkPM4f pm;
+ x.store(pm.fVec);
+ return pm;
+ }
+ static SkPM4f FromF16(const uint16_t[4]);
static SkPM4f FromPMColor(SkPMColor);
- // half-float routines
+ Sk4f to4f() const { return Sk4f::Load(fVec); }
+ Sk4f to4f_rgba() const { return this->to4f(); }
+ Sk4f to4f_bgra() const { return swizzle_rb(this->to4f()); }
+ Sk4f to4f_pmorder() const { return swizzle_rgba_to_pmorder(this->to4f()); }
+
void toF16(uint16_t[4]) const;
uint64_t toF16() const; // 4 float16 values packed into uint64_t
- static SkPM4f FromF16(const uint16_t[4]);
+
+ SkColor4f unpremul() const;
#ifdef SK_DEBUG
void assertIsUnit() const;
@@ -42,5 +86,4 @@ struct SkPM4f {
typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst);
-
#endif
« no previous file with comments | « src/core/SkColor.cpp ('k') | src/core/SkPM4fPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698