21 const SkImageInfo& sk_image_info) {
23 switch (sk_image_info.colorType()) {
24 case kUnknown_SkColorType:
27 case kRGBA_8888_SkColorType:
30 case kBGRA_8888_SkColorType:
33 case kRGBA_F32_SkColorType:
36 case kGray_8_SkColorType:
40 FML_DCHECK(
false) <<
"Unsupported pixel format: "
41 << sk_image_info.colorType();
45 .
width =
static_cast<uint32_t
>(sk_image_info.width()),
46 .
height =
static_cast<uint32_t
>(sk_image_info.height()),
49 .color_space = sk_image_info.refColorSpace(),
72 FML_DCHECK(
false) <<
"not a supported skia format";
79ImageDescriptor::ImageDescriptor(sk_sp<SkData> buffer,
80 const ImageInfo& image_info,
81 std::optional<size_t> row_bytes)
83 image_info_(image_info),
85 row_bytes_(row_bytes) {}
87ImageDescriptor::ImageDescriptor(sk_sp<SkData> buffer,
88 std::shared_ptr<ImageGenerator> generator)
89 : buffer_(
std::move(buffer)),
90 image_info_(CreateImageInfo(generator->GetInfo())),
91 generator_(
std::move(generator)),
92 row_bytes_(
std::nullopt) {}
96 Dart_Handle callback_handle) {
97 if (!Dart_IsClosure(callback_handle)) {
101 if (!immutable_buffer) {
107 auto registry = dart_state->GetImageGeneratorRegistry();
111 "Failed to access the internal image decoder "
112 "registry on this isolate. Please file a bug on "
113 "https://github.com/flutter/flutter/issues.");
117 registry->CreateCompatibleGenerator(immutable_buffer->
data());
124 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
125 immutable_buffer->
data(), std::move(generator));
129 descriptor->AssociateWithDartWrapper(descriptor_handle);
161 toImageDescriptorPixelFormat(pixel_format);
165 .format = image_descriptor_pixel_format,
167 ? kUnpremul_SkAlphaType
168 : kPremul_SkAlphaType,
169 .color_space = SkColorSpace::MakeSRGB(),
172 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
175 descriptor->AssociateWithDartWrapper(descriptor_handle);
195 int32_t target_width,
196 int32_t target_height,
197 int32_t destination_format) {
199 if (!generator_ || generator_->GetFrameCount() == 1) {
200 ui_codec = fml::MakeRefCounted<SingleFrameCodec>(
206 ui_codec = fml::MakeRefCounted<MultiFrameCodec>(generator_);
208 ui_codec->AssociateWithDartWrapper(codec_handle);
212 return generator_->GetImage();
217 return generator_->GetPixels(pixmap.info(), pixmap.writable_addr(),
222 switch (image_info_.
format) {
@ kDontCare
Explicitly declare the target pixel is left for the engine to decide.
@ kUnknown
An unknown pixel format, reserved for error cases.
Creates an image descriptor for encoded or decoded image data, describing the width,...
sk_sp< SkImage > image() const
int width() const
The width of this image, EXIF oriented if applicable.
void instantiateCodec(Dart_Handle codec, int32_t target_width, int32_t target_height, int32_t destination_format)
Associates a flutter::Codec object with the dart.ui Codec handle.
static SkImageInfo ToSkImageInfo(const ImageInfo &image_info)
int row_bytes() const
The byte length of the first row of the image. Defaults to width() * 4.
static ImageInfo CreateImageInfo(const SkImageInfo &sk_image_info)
int height() const
The height of this image. EXIF oriented if applicable.
bool get_pixels(const SkPixmap &pixmap) const
Gets pixels for this image transformed based on the EXIF orientation tag, if applicable.
int bytesPerPixel() const
The bytes per pixel of the image.
static Dart_Handle initEncoded(Dart_Handle descriptor_handle, ImmutableBuffer *immutable_buffer, Dart_Handle callback_handle)
Asynchronously initializes an ImageDescriptor for an encoded image, as long as the format is recogniz...
static void initRaw(Dart_Handle descriptor_handle, const fml::RefPtr< ImmutableBuffer > &data, int width, int height, int row_bytes, int pixel_format)
Synchronously initializes an ImageDescriptor for decompressed image data as specified by the PixelFor...
const ImageInfo & image_info() const
The orientation corrected image info for this image.
sk_sp< SkData > data() const
The underlying buffer for this image.
sk_sp< SkData > data() const
Callers should not modify the returned data. This is not exposed to Dart.
static UIDartState * Current()
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
uint32_t uint32_t * format
#define FML_DCHECK(condition)
ImageDecoder::TargetPixelFormat ToImageDecoderTargetPixelFormat(int32_t value)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Dart_Handle ToDart(const T &object)
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
const SkAlphaType alpha_type
const sk_sp< SkColorSpace > color_space