static void test_pictures(skiatest::Reporter* reporter, sk_sp<SkPicture> p0, int count, bool skipRoot) { Context ctx; if (skipRoot) { ctx.fSkipMe = p0.get(); } SkSerialProcs sprocs = makes(array_serial_proc, &ctx); auto d0 = p0->serialize(&sprocs); REPORTER_ASSERT(reporter, ctx.fArray.count() == count); SkDeserialProcs dprocs = maked(array_deserial_proc, &ctx); p0 = SkPicture::MakeFromData(d0.get(), &dprocs); REPORTER_ASSERT(reporter, ctx.fArray.count() == 0); }
static void test_serialize(skiatest::Reporter* r, sk_sp<SkColorSpace> space, bool isNamed) { sk_sp<SkData> data1 = space->serialize(); size_t bytes = space->writeToMemory(nullptr); sk_sp<SkData> data2 = SkData::MakeUninitialized(bytes); space->writeToMemory(data2->writable_data()); sk_sp<SkColorSpace> newSpace1 = SkColorSpace::Deserialize(data1->data(), data1->size()); sk_sp<SkColorSpace> newSpace2 = SkColorSpace::Deserialize(data2->data(), data2->size()); if (isNamed) { REPORTER_ASSERT(r, space.get() == newSpace1.get()); REPORTER_ASSERT(r, space.get() == newSpace2.get()); } else { REPORTER_ASSERT(r, SkColorSpace::Equals(space.get(), newSpace1.get())); REPORTER_ASSERT(r, SkColorSpace::Equals(space.get(), newSpace2.get())); } }