/* * TODO: clean this guy up and possibly add to SkScalar.h */ static inline SkScalar SkScalarDecULP(SkScalar value) { #if SK_SCALAR_IS_FLOAT return SkBits2Float(SkFloat2Bits(value) - 1); #else #error "need impl for doubles" #endif }
void SkAppendScalar(SkString* str, SkScalar value, SkScalarAsStringType asType) { switch (asType) { case kHex_SkScalarAsStringType: str->appendf("SkBits2Float(0x%08x)", SkFloat2Bits(value)); break; case kDec_SkScalarAsStringType: { SkString tmp; tmp.printf("%g", value); if (tmp.contains('.')) { tmp.appendUnichar('f'); } str->append(tmp); break; } } }
static bool isFinite_int(float x) { uint32_t bits = SkFloat2Bits(x); // need unsigned for our shifts int exponent = bits << 1 >> 24; return exponent != 0xFF; }