22 const auto image_info = SkImageInfo::MakeN32Premul(
size.width,
size.height,
23 SkColorSpace::MakeSRGB());
24 if (surface_context) {
27 return SkSurfaces::RenderTarget(surface_context, skgpu::Budgeted::kNo,
33 return SkSurfaces::Raster(image_info);
39static sk_sp<SkData>
GetRasterData(
const sk_sp<SkSurface>& offscreen_surface,
42 auto potentially_gpu_snapshot = offscreen_surface->makeImageSnapshot();
43 if (!potentially_gpu_snapshot) {
44 FML_LOG(ERROR) <<
"Screenshot: unable to make image screenshot";
50 auto cpu_snapshot = potentially_gpu_snapshot->makeRasterImage(
nullptr);
52 FML_LOG(ERROR) <<
"Screenshot: unable to make raster image";
59 return SkPngEncoder::Encode(
nullptr, cpu_snapshot.get(), {});
64 if (!cpu_snapshot->peekPixels(&pixmap)) {
65 FML_LOG(ERROR) <<
"Screenshot: unable to obtain bitmap pixels";
68 return SkData::MakeWithCopy(pixmap.addr32(), pixmap.computeByteSize());