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

Unified Diff: src/core/SkPMFloat.h

Issue 1015083004: SkPMFloat: avoid loads and stores where possible. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | src/opts/SkPMFloat_SSE2.h » ('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 4534f1142c307c9d1e5976fd79197f9ac01cf2cd..04323ad1fcc26ddda4012fc45a8763a931bce4f8 100644
--- a/src/core/SkPMFloat.h
+++ b/src/core/SkPMFloat.h
@@ -3,8 +3,15 @@
#include "SkTypes.h"
#include "SkColor.h"
+#include "SkColorPriv.h"
#include "Sk4x.h"
+#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+ #include <immintrin.h>
+#elif defined(__ARM_NEON__)
+ #include <arm_neon.h>
+#endif
+
// A pre-multiplied color storing each component in the same order as SkPMColor,
// but as a float in the range [0, 255].
class SK_STRUCT_ALIGN(16) SkPMFloat {
@@ -27,16 +34,12 @@ public:
// Uninitialized.
SkPMFloat() {}
- // Copy and assign are fastest if we remind the compiler we work best as Sk4f.
- SkPMFloat(const SkPMFloat& that) { Sk4f(that).storeAligned(fColor); }
- SkPMFloat& operator=(const SkPMFloat& that) {
- Sk4f(that).storeAligned(fColor);
- return *this;
- }
+ SkPMFloat(const SkPMFloat& that) { *this = that; }
+ SkPMFloat& operator=(const SkPMFloat& that);
- // Freely autoconvert between SkPMFloat and Sk4f.
- /*implicit*/ SkPMFloat(const Sk4f& fs) { fs.storeAligned(fColor); }
- /*implicit*/ operator Sk4f() const { return Sk4f::LoadAligned(fColor); }
+ // Freely autoconvert between SkPMFloat and Sk4f. They're always byte-for-byte identical.
+ /*implicit*/ SkPMFloat(const Sk4f& fs) { *(Sk4f*)this = fs; }
+ /*implicit*/ operator Sk4f() const { return *(const Sk4f*)this; }
float a() const { return fColor[SK_A32_SHIFT / 8]; }
float r() const { return fColor[SK_R32_SHIFT / 8]; }
@@ -59,7 +62,14 @@ public:
}
private:
- float fColor[4];
+ union {
+ float fColor[4];
+#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+ __m128 fColors;
+#elif defined(__ARM_NEON__)
+ float32x4_t fColors;
+#endif
+ };
};
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
« no previous file with comments | « no previous file | src/opts/SkPMFloat_SSE2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698