aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPMFloat.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-03-02 14:07:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-02 14:07:14 -0800
commit7ab42771859145884e1b28c8c45f0a5a728b22ac (patch)
treea226105b65a3d877636323af35e86ed45bf4adef /src/core/SkPMFloat.h
parent8a8d841d485ff36b64d838575eb3735c1ddcf929 (diff)
Don't guarantee any particular color order for SkPMFloat. Hide fColor.
Also add a little note that get() may incidentally clamp. BUG=skia: Review URL: https://codereview.chromium.org/973553004
Diffstat (limited to 'src/core/SkPMFloat.h')
-rw-r--r--src/core/SkPMFloat.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h
index 7c093a6a49..936487e842 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