Index: src/core/SkPMFloat.h |
diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h |
index 783fc0d40e5cf017f2ae0d3683a2f5a77a56d7a8..4a5dde88dc1510607657bf0c11b9cd7f99a0feff 100644 |
--- a/src/core/SkPMFloat.h |
+++ b/src/core/SkPMFloat.h |
@@ -5,9 +5,20 @@ |
#include "SkColor.h" |
#include "Sk4x.h" |
-// A pre-multiplied color storing each component as a float in the range [0, 255]. |
+// 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 { |
public: |
+ explicit SkPMFloat(SkPMColor); |
reed1
2015/03/04 16:00:38
I'm not sure if constructors are "safer" than fact
mtklein
2015/03/04 18:16:00
Done.
|
+ SkPMFloat(float a, float r, float g, float b) { |
+ // TODO: faster when specialized? |
+ fColor[SK_A32_SHIFT / 8] = a; |
+ fColor[SK_R32_SHIFT / 8] = r; |
+ fColor[SK_G32_SHIFT / 8] = g; |
+ fColor[SK_B32_SHIFT / 8] = b; |
+ SkASSERT(this->isValid()); |
+ } |
+ |
// Normal POD copies and do-nothing initialization. |
SkPMFloat() = default; |
SkPMFloat(const SkPMFloat&) = default; |
@@ -22,13 +33,6 @@ public: |
float g() const { return fColor[SK_G32_SHIFT / 8]; } |
float b() const { return fColor[SK_B32_SHIFT / 8]; } |
- void setA(float val) { fColor[SK_A32_SHIFT / 8] = val; } |
- void setR(float val) { fColor[SK_R32_SHIFT / 8] = val; } |
- void setG(float val) { fColor[SK_G32_SHIFT / 8] = val; } |
- void setB(float val) { fColor[SK_B32_SHIFT / 8] = val; } |
- |
- void set(SkPMColor); |
- |
// get() and clamped() round component values to the nearest integer. |
SkPMColor get() const; // May SkASSERT(this->isValid()). Some implementations may clamp. |
SkPMColor clamped() const; // Will clamp all values to [0, 255]. Then may assert isValid(). |
@@ -41,7 +45,6 @@ public: |
} |
private: |
- // We mirror SkPMColor order only to make set()/get()/clamped() as fast as possible. |
float fColor[4]; |
}; |