fold SK_CPU_HAS_CONDITION_INSTR through as always defined
BUG=
R=reed@google.com
Author: mtklein@google.com
Review URL: https://chromiumcodereview.appspot.com/21122005
git-svn-id: http://skia.googlecode.com/svn/trunk@10432 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index a59ead1..1664cf2 100644
--- a/include/core/SkPreConfig.h
+++ b/include/core/SkPreConfig.h
@@ -195,11 +195,6 @@
//////////////////////////////////////////////////////////////////////
-// TODO(mtklein): propagate this through the codebase and remove
-#define SK_CPU_HAS_CONDITIONAL_INSTR
-
-//////////////////////////////////////////////////////////////////////
-
#if !defined(SKIA_IMPLEMENTATION)
#define SKIA_IMPLEMENTATION 0
#endif
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 9b3233a..48a6de8 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -285,14 +285,10 @@
}
static inline int32_t SkAbs32(int32_t value) {
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
- if (value < 0)
+ if (value < 0) {
value = -value;
+ }
return value;
-#else
- int32_t mask = value >> 31;
- return (value ^ mask) - mask;
-#endif
}
template <typename T> inline T SkTAbs(T value) {
@@ -327,32 +323,21 @@
}
static inline int32_t SkFastMin32(int32_t value, int32_t max) {
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
- if (value > max)
+ if (value > max) {
value = max;
+ }
return value;
-#else
- int diff = max - value;
- // clear diff if it is negative (clear if value > max)
- diff &= (diff >> 31);
- return value + diff;
-#endif
}
/** Returns signed 32 bit value pinned between min and max, inclusively
*/
static inline int32_t SkPin32(int32_t value, int32_t min, int32_t max) {
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
- if (value < min)
+ if (value < min) {
value = min;
- if (value > max)
+ }
+ if (value > max) {
value = max;
-#else
- if (value < min)
- value = min;
- else if (value > max)
- value = max;
-#endif
+ }
return value;
}
diff --git a/src/core/Sk64.cpp b/src/core/Sk64.cpp
index c530ed8..7c195ce 100644
--- a/src/core/Sk64.cpp
+++ b/src/core/Sk64.cpp
@@ -253,17 +253,11 @@
do {
shift_left(rhi, rlo);
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
if ((uint32_t)denom <= (uint32_t)hi)
{
hi -= denom;
rlo |= 1;
}
-#else
- int32_t diff = (denom - hi - 1) >> 31;
- hi -= denom & diff;
- rlo -= diff;
-#endif
shift_left(hi, lo);
} while (--bits >= 0);
SkASSERT(rhi >= 0);
diff --git a/src/core/SkBitmapProcState_matrixProcs.cpp b/src/core/SkBitmapProcState_matrixProcs.cpp
index a3d2b08..70d367b 100644
--- a/src/core/SkBitmapProcState_matrixProcs.cpp
+++ b/src/core/SkBitmapProcState_matrixProcs.cpp
@@ -112,24 +112,12 @@
static inline U16CPU fixed_clamp(SkFixed x)
{
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
- if (x < 0)
+ if (x < 0) {
x = 0;
- if (x >> 16)
- x = 0xFFFF;
-#else
- if (x >> 16)
- {
-#if 0 // is this faster?
- x = (~x >> 31) & 0xFFFF;
-#else
- if (x < 0)
- x = 0;
- else
- x = 0xFFFF;
-#endif
}
-#endif
+ if (x >> 16) {
+ x = 0xFFFF;
+ }
return x;
}
@@ -185,20 +173,12 @@
}
static inline U16CPU int_clamp(int x, int n) {
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
- if (x >= n)
+ if (x >= n) {
x = n - 1;
- if (x < 0)
- x = 0;
-#else
- if ((unsigned)x >= (unsigned)n) {
- if (x < 0) {
- x = 0;
- } else {
- x = n - 1;
- }
}
-#endif
+ if (x < 0) {
+ x = 0;
+ }
return x;
}
diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp
index 0efedd7..2693e5c 100644
--- a/src/core/SkMath.cpp
+++ b/src/core/SkMath.cpp
@@ -27,7 +27,6 @@
return 32;
}
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
int zeros = 31;
if (x & 0xFFFF0000) {
sub_shift(zeros, x, 16);
@@ -44,24 +43,6 @@
if (x & 0x2) {
sub_shift(zeros, x, 1);
}
-#else
- int zeros = ((x >> 16) - 1) >> 31 << 4;
- x <<= zeros;
-
- int nonzero = ((x >> 24) - 1) >> 31 << 3;
- zeros += nonzero;
- x <<= nonzero;
-
- nonzero = ((x >> 28) - 1) >> 31 << 2;
- zeros += nonzero;
- x <<= nonzero;
-
- nonzero = ((x >> 30) - 1) >> 31 << 1;
- zeros += nonzero;
- x <<= nonzero;
-
- zeros += (~x) >> 31;
-#endif
return zeros;
}
diff --git a/src/core/SkMathPriv.h b/src/core/SkMathPriv.h
index 53cf430..4eaad8b 100644
--- a/src/core/SkMathPriv.h
+++ b/src/core/SkMathPriv.h
@@ -33,18 +33,10 @@
@return max if value >= max, else value
*/
static inline unsigned SkClampUMax(unsigned value, unsigned max) {
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
if (value > max) {
value = max;
}
return value;
-#else
- int diff = max - value;
- // clear diff if diff is positive
- diff &= diff >> 31;
-
- return value + diff;
-#endif
}
/** Computes the 64bit product of a * b, and then shifts the answer down by
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 4bc697d..2f56cb4 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -23,26 +23,17 @@
#endif
static inline int mirror_bits(int x, const int bits) {
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
- if (x & (1 << bits))
+ if (x & (1 << bits)) {
x = ~x;
+ }
return x & ((1 << bits) - 1);
-#else
- int s = x << (31 - bits) >> 31;
- return (x ^ s) & ((1 << bits) - 1);
-#endif
}
static inline int mirror_8bits(int x) {
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
if (x & 256) {
x = ~x;
}
return x & 255;
-#else
- int s = x << 23 >> 31;
- return (x ^ s) & 0xFF;
-#endif
}
#if defined(_MSC_VER) && (_MSC_VER >= 1600)