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

Unified Diff: src/core/SkPMFloat.h

Issue 973553004: Don't guarantee any particular color order for SkPMFloat. Hide fColor. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: 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 | no next file » | 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 7c093a6a49ff60b2b973c0f658dedd134ebba7be..936487e842dfc9dd11e88f1a49a31943dc6441f5 100644
--- a/src/core/SkPMFloat.h
+++ b/src/core/SkPMFloat.h
@@ -5,10 +5,9 @@
#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];
-
+// A pre-multiplied color storing each component as a float.
+class SK_STRUCT_ALIGN(16) SkPMFloat {
+public:
// Normal POD copies and do-nothing initialization.
SkPMFloat() = default;
SkPMFloat(const SkPMFloat&) = default;
@@ -30,7 +29,7 @@ struct SK_STRUCT_ALIGN(16) SkPMFloat {
void set(SkPMColor);
- SkPMColor get() const; // May SkASSERT(this->isValid()).
+ SkPMColor get() const; // May SkASSERT(this->isValid()). Some implementations may clamp.
SkPMColor clamped() const; // Will clamp all values to [0,1], then SkASSERT(this->isValid()).
bool isValid() const {
@@ -39,6 +38,10 @@ struct SK_STRUCT_ALIGN(16) SkPMFloat {
&& this->g() >= 0 && this->g() <= this->a()
&& this->b() >= 0 && this->b() <= this->a();
}
+
+private:
+ // We mirror SkPMColor order only to make set()/get()/clamped() as fast as possible.
+ float fColor[4];
};
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698