DEF_TEST(HalfToFloat_01, r) { for (uint16_t h = 0; h < 0x8000; h++) { float f = SkHalfToFloat(h); if (f >= 0 && f <= 1) { float got = SkHalfToFloat_01(h)[0]; if (got != f) { SkDebugf("0x%04x -> 0x%08x (%g), want 0x%08x (%g)\n", h, u(got), got, u(f), f); } REPORTER_ASSERT(r, SkHalfToFloat_01(h)[0] == f); REPORTER_ASSERT(r, SkFloatToHalf_01(SkHalfToFloat_01(h)) == h); } } }
// Returns dst in its "natural" bias (either unit-float or 16bit int) // template <DstType D> Sk4f load_from_dst(uint64_t dst) { return (D == kU16_Dst) ? load_from_u16(dst) : SkHalfToFloat_01(dst); }