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

Unified Diff: src/core/SkPMFloat.h

Issue 1201343004: Convert SkPMFloat to [0,1] range and prune its API. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 6 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 | « bench/PMFloatBench.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('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 ce7b75e705f002c91c224e53f077e72e16d0b7c3..f1d302458d0fe121e0950b8b08628c60283bb893 100644
--- a/src/core/SkPMFloat.h
+++ b/src/core/SkPMFloat.h
@@ -21,15 +21,12 @@
namespace {
// A pre-multiplied color storing each component in the same order as SkPMColor,
-// but as a float in the range [0, 255].
+// but as a float in the range [0, 1].
class SkPMFloat : public Sk4f {
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(const SkPMColor[4], SkPMFloat*, SkPMFloat*, SkPMFloat*, SkPMFloat*);
-
// Uninitialized.
SkPMFloat() {}
explicit SkPMFloat(SkPMColor);
@@ -47,24 +44,10 @@ public:
float g() const { return this->kth<SK_G32_SHIFT / 8>(); }
float b() const { return this->kth<SK_B32_SHIFT / 8>(); }
- // N.B. All methods returning an SkPMColor call SkPMColorAssert on that result before returning.
-
- // round() and roundClamp() round component values to the nearest integer.
- SkPMColor round() const; // Assumes all values in [0, 255]. Some implementations may clamp.
- SkPMColor roundClamp() const; // Will clamp all values to [0, 255].
-
- // Like round(), but truncates instead of rounding.
- // The domain of this function is (-1.0f, 256.0f). Values in (-1.0f, 0.0f] trunc to a zero.
- SkPMColor trunc() const;
-
- // 4-at-a-time versions of round() and roundClamp(). Like From4PMColors(), no alignment assumed.
- static void RoundTo4PMColors(
- const SkPMFloat&, const SkPMFloat&, const SkPMFloat&, const SkPMFloat&, SkPMColor[4]);
- static void RoundClampTo4PMColors(
- const SkPMFloat&, const SkPMFloat&, const SkPMFloat&, const SkPMFloat&, SkPMColor[4]);
+ SkPMColor round() const; // Rounds from [0.0f, 1.0f] to [0, 255], clamping if out of range.
bool isValid() const {
- return this->a() >= 0 && this->a() <= 255
+ return this->a() >= 0 && this->a() <= 1
&& this->r() >= 0 && this->r() <= this->a()
&& this->g() >= 0 && this->g() <= this->a()
&& this->b() >= 0 && this->b() <= this->a();
@@ -80,10 +63,8 @@ private:
// Platform implementations of SkPMFloat assume Sk4f uses SSE or NEON. _none is generic.
#include "../opts/SkPMFloat_none.h"
#else
- #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
- #include "../opts/SkPMFloat_SSSE3.h"
- #elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
- #include "../opts/SkPMFloat_SSE2.h"
+ #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+ #include "../opts/SkPMFloat_sse.h"
#elif defined(SK_ARM_HAS_NEON)
#include "../opts/SkPMFloat_neon.h"
#else
« no previous file with comments | « bench/PMFloatBench.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698