/** Returns -1 if n < 0, else returns 0
*/ #define SkExtractSign(n) ((int32_t)(n) >> 31)
/** If sign == -1, returns -n, else sign must be 0, and returns n. TypicallyusedinconjunctionwithSkExtractSign().
*/ staticinline int32_t SkApplySign(int32_t n, int32_t sign) {
SkASSERT(sign == 0 || sign == -1); return (n ^ sign) - sign;
}
/** Return x with the sign of y */ staticinline int32_t SkCopySign32(int32_t x, int32_t y) { return SkApplySign(x, SkExtractSign(x ^ y));
}
/** Given a positive value and a positive max, return the value pinnedagainstmax. Note:onlyworksaslongasmax-valuedoesn'twraparound @returnmaxifvalue>=max,elsevalue
*/ staticinlineunsigned SkClampUMax(unsigned value, unsigned max) { if (value > max) {
value = max;
} return value;
}
// If a signed int holds min_int (e.g. 0x80000000) it is undefined what happens when // we negate it (even though we *know* we're 2's complement and we'll get the same // value back). So we create this helper function that casts to size_t (unsigned) first, // to avoid the complaint. staticinline size_t sk_negate_to_size_t(int32_t value) { #ifdefined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 4146) // Thanks MSVC, we know what we're negating an unsigned #endif return -static_cast<size_t>(value); #ifdefined(_MSC_VER) #pragma warning(pop) #endif
}
n--;
uint32_t shift = 1; while (shift < kNumSizeTBits) {
n |= n >> shift;
shift <<= 1;
} return n + 1;
}
// conservative check. will return false for very large values that "could" fit template <typename T> staticinlinebool SkFitsInFixed(T x) { return SkTAbs(x) <= 32767.0f;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.