aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkPreConfig.h5
-rw-r--r--include/core/SkTypes.h31
-rw-r--r--src/core/Sk64.cpp6
-rw-r--r--src/core/SkBitmapProcState_matrixProcs.cpp32
-rw-r--r--src/core/SkMath.cpp19
-rw-r--r--src/core/SkMathPriv.h8
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp13
7 files changed, 16 insertions, 98 deletions
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index a59ead1efb..1664cf263c 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 9b3233a87e..48a6de80dd 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -285,14 +285,10 @@ template <typename T> inline void SkTSwap(T& a, T& b) {
}
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 SkSign32(int32_t a) {
}
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)
- value = max;
-#else
- if (value < min)
- value = min;
- else if (value > max)
+ }
+ if (value > max) {
value = max;
-#endif
+ }
return value;
}
diff --git a/src/core/Sk64.cpp b/src/core/Sk64.cpp
index c530ed866f..7c195ce4fe 100644
--- a/src/core/Sk64.cpp
+++ b/src/core/Sk64.cpp
@@ -253,17 +253,11 @@ void Sk64::div(int32_t denom, DivOptions option)
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 a3d2b08665..70d367b870 100644
--- a/src/core/SkBitmapProcState_matrixProcs.cpp
+++ b/src/core/SkBitmapProcState_matrixProcs.cpp
@@ -112,24 +112,12 @@ extern const SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs_neon[];
static inline U16CPU fixed_clamp(SkFixed x)
{
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
- if (x < 0)
+ if (x < 0) {
x = 0;
- if (x >> 16)
+ }
+ 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
return x;
}
@@ -185,20 +173,12 @@ static SkBitmapProcState::FixedTileLowBitsProc choose_tile_lowbits_proc(unsigned
}
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)
+ }
+ if (x < 0) {
x = 0;
-#else
- if ((unsigned)x >= (unsigned)n) {
- if (x < 0) {
- x = 0;
- } else {
- x = n - 1;
- }
}
-#endif
return x;
}
diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp
index 0efedd727b..2693e5c13c 100644
--- a/src/core/SkMath.cpp
+++ b/src/core/SkMath.cpp
@@ -27,7 +27,6 @@ int SkCLZ_portable(uint32_t x) {
return 32;
}
-#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
int zeros = 31;
if (x & 0xFFFF0000) {
sub_shift(zeros, x, 16);
@@ -44,24 +43,6 @@ int SkCLZ_portable(uint32_t x) {
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 53cf43063d..4eaad8b9b1 100644
--- a/src/core/SkMathPriv.h
+++ b/src/core/SkMathPriv.h
@@ -33,18 +33,10 @@ static inline int32_t SkCopySign32(int32_t x, int32_t y) {
@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 4bc697d904..2f56cb49ca 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -23,26 +23,17 @@ static inline int repeat_8bits(int x) {
#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)