DEF_TEST(SpecialImage_Pixmap, reporter) { SkAutoPixmapStorage pixmap; const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType); pixmap.alloc(info); pixmap.erase(SK_ColorGREEN); const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); pixmap.erase(SK_ColorRED, subset); { sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(subset, pixmap, nullptr, nullptr)); test_image(img, reporter, nullptr, false, kPad, kFullSize); } }
DEF_TEST(color_half_float, reporter) { const int w = 100; const int h = 100; SkImageInfo info = SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType); SkAutoPixmapStorage pm; pm.alloc(info); REPORTER_ASSERT(reporter, pm.getSafeSize() == SkToSizeT(w * h * sizeof(uint64_t))); SkColor4f c4 { 1, 0.5f, 0.25f, 0.5f }; pm.erase(c4); SkPM4f origpm4 = c4.premul(); for (int y = 0; y < pm.height(); ++y) { for (int x = 0; x < pm.width(); ++x) { SkPM4f pm4 = SkPM4f::FromF16(pm.addrF16(x, y)); REPORTER_ASSERT(reporter, eq_within_half_float(origpm4, pm4)); } } }