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
This commit is contained in:
commit-bot@chromium.org 2013-07-30 13:16:29 +00:00
parent 5abacf6720
commit 38bad32cf5
7 changed files with 18 additions and 100 deletions

View File

@ -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

View File

@ -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)
}
if (value > max) {
value = max;
#else
if (value < min)
value = min;
else if (value > max)
value = max;
#endif
}
return value;
}

View File

@ -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);

View File

@ -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)
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 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)
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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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)