34 {
36 return {};
37 }
39 return {};
40 }
41
42 auto src =
new std::shared_ptr<const fml::Mapping>(
source_);
43 auto sk_data = SkData::MakeWithProc(
45 [](const void* ptr, void* context) {
46 delete reinterpret_cast<decltype(src)>(context);
47 },
48 src);
49
50 auto image = SkImages::DeferredFromEncodedData(sk_data);
52 return {};
53 }
54
55 const auto dims =
image->imageInfo().dimensions();
56 auto info = SkImageInfo::Make(dims.width(), dims.height(),
57 kRGBA_8888_SkColorType, kPremul_SkAlphaType);
58
59 auto bitmap = std::make_shared<SkBitmap>();
60 if (!bitmap->tryAllocPixels(info)) {
61 VALIDATION_LOG <<
"Could not allocate arena for decompressing image.";
62 return {};
63 }
64
65 if (!
image->readPixels(
nullptr, bitmap->pixmap(), 0, 0)) {
67 return {};
68 }
69
70 auto mapping = std::make_shared<fml::NonOwnedMapping>(
71 reinterpret_cast<const uint8_t*>(bitmap->pixmap().addr()),
72 bitmap->pixmap().rowBytes() * bitmap->pixmap().height(),
73 [bitmap](
const uint8_t*
data,
size_t size)
mutable {
74 bitmap.reset();
75 }
76 );
77
78 return {
79 {bitmap->pixmap().dimensions().fWidth,
80 bitmap->pixmap().dimensions().fHeight},
82 mapping
83 };
84}
const std::shared_ptr< const fml::Mapping > source_
FlutterVulkanImage * image
std::shared_ptr< const fml::Mapping > data