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

Unified Diff: src/core/SkPMFloat.h

Issue 977773002: Update SkPMFloat API a bit. (Closed) Base URL: https://skia.googlesource.com/skia.git@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 | 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 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];
};
« 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