aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-03-05 11:31:59 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-05 11:31:59 -0800
commit548bf38b28986fab6770350b72247d7114d98184 (patch)
treead92b0b624d3b9b5b5d8558f11ac5e736c0e46ca /src/core
parent7750c6fa9931241e21eee1c3cfec4c1288660f46 (diff)
4-at-a-time SkPMColor -> SkPMFloat API.
Please see if this looks usable. It may even give a perf boost if you use it, even without custom implementations for each instruction set. I've been trying this morning to beat this naive loop implementation, but so far no luck with either _SSE2.h or _SSSE3.h. It's possible this is an artifact of the microbenchmark, because we're not doing anything between the conversions. I'd like to see how this fits into real code, what assembly's generated, what the hot spots are, etc. I've updated the tests to test these new APIs, and splintered off a pair of new benchmarks that use the new APIs. This required some minor rejiggering in the benches. BUG=skia: Review URL: https://codereview.chromium.org/978213003
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPMFloat.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h
index 444cb78fc8..2e06ea93e6 100644
--- a/src/core/SkPMFloat.h
+++ b/src/core/SkPMFloat.h
@@ -12,6 +12,12 @@ public:
static SkPMFloat FromPMColor(SkPMColor c) { return SkPMFloat(c); }
static SkPMFloat FromARGB(float a, float r, float g, float b) { return SkPMFloat(a,r,g,b); }
+ // May be more efficient than one at a time. No special alignment assumed for SkPMColors.
+ static void From4PMColors(SkPMFloat floats[4], const SkPMColor colors[4]) {
+ // TODO: specialize
+ for (int i = 0; i < 4; i++) { floats[i] = FromPMColor(colors[i]); }
+ }
+
explicit SkPMFloat(SkPMColor);
SkPMFloat(float a, float r, float g, float b) {
// TODO: faster when specialized?
@@ -44,6 +50,16 @@ public:
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().
+ // 4-at-a-time versions of get() and clamped(). Like From4PMColors(), no alignment assumed.
+ static void To4PMColors(SkPMColor colors[4], const SkPMFloat floats[4]) {
+ // TODO: specialize
+ for (int i = 0; i < 4; i++) { colors[i] = floats[i].get(); }
+ }
+ static void ClampTo4PMColors(SkPMColor colors[4], const SkPMFloat floats[4]) {
+ // TODO: specialize
+ for (int i = 0; i < 4; i++) { colors[i] = floats[i].clamped(); }
+ }
+
bool isValid() const {
return this->a() >= 0 && this->a() <= 255
&& this->r() >= 0 && this->r() <= this->a()