aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-02 19:33:08 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-02 19:33:08 +0000
commitc98a0aadc4416f3eef1505c49bbdd8dcb304569e (patch)
treed1a1cd71fa9d93e64836f342f1ecf4c3759d95a0
parent177f65cb897cc3299cbfbaf5642607483af37f8f (diff)
rearrange functions to group clamp, repeat, mirror helpers together.
git-svn-id: http://skia.googlecode.com/svn/trunk@3135 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/effects/SkGradientShader.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/effects/SkGradientShader.cpp b/src/effects/SkGradientShader.cpp
index cfae9aa6d2..ef3edc04f0 100644
--- a/src/effects/SkGradientShader.cpp
+++ b/src/effects/SkGradientShader.cpp
@@ -49,33 +49,31 @@ static SkPoint unflatten_point(SkReader32& buffer) {
return retval;
}
-///////////////////////////////////////////////////////////////////////////////
-
-typedef SkFixed (*TileProc)(SkFixed);
+// Clamp
static SkFixed clamp_tileproc(SkFixed x) {
return SkClampMax(x, 0xFFFF);
}
+// Repeat
+
static SkFixed repeat_tileproc(SkFixed x) {
return x & 0xFFFF;
}
-static inline SkFixed mirror_tileproc(SkFixed x) {
- int s = x << 15 >> 31;
- return (x ^ s) & 0xFFFF;
+static inline int repeat_bits(int x, const int bits) {
+ return x & ((1 << bits) - 1);
}
-static const TileProc gTileProcs[] = {
- clamp_tileproc,
- repeat_tileproc,
- mirror_tileproc
-};
+static inline int repeat_8bits(int x) {
+ return x & 0xFF;
+}
-///////////////////////////////////////////////////////////////////////////////
+// Mirror
-static inline int repeat_bits(int x, const int bits) {
- return x & ((1 << bits) - 1);
+static inline SkFixed mirror_tileproc(SkFixed x) {
+ int s = x << 15 >> 31;
+ return (x ^ s) & 0xFFFF;
}
static inline int mirror_bits(int x, const int bits) {
@@ -89,10 +87,6 @@ static inline int mirror_bits(int x, const int bits) {
#endif
}
-static inline int repeat_8bits(int x) {
- return x & 0xFF;
-}
-
static inline int mirror_8bits(int x) {
#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
if (x & 256) {
@@ -107,6 +101,17 @@ static inline int mirror_8bits(int x) {
///////////////////////////////////////////////////////////////////////////////
+typedef SkFixed (*TileProc)(SkFixed);
+
+static const TileProc gTileProcs[] = {
+ clamp_tileproc,
+ repeat_tileproc,
+ mirror_tileproc
+};
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
class Gradient_Shader : public SkShader {
public:
Gradient_Shader(const SkColor colors[], const SkScalar pos[],