5#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_DESCRIPTOR_H_
6#define FLUTTER_LIB_UI_PAINTING_IMAGE_DESCRIPTOR_H_
16#include "third_party/skia/include/core/SkColorSpace.h"
17#include "third_party/skia/include/core/SkData.h"
18#include "third_party/skia/include/core/SkImage.h"
19#include "third_party/skia/include/core/SkImageInfo.h"
20#include "third_party/skia/include/core/SkPixmap.h"
21#include "third_party/skia/include/core/SkSize.h"
62 static Dart_Handle
initEncoded(Dart_Handle descriptor_handle,
64 Dart_Handle callback_handle);
68 static void initRaw(Dart_Handle descriptor_handle,
78 int32_t target_height,
79 int32_t destination_format);
93 return row_bytes_.value_or(
100 return target_width !=
width() || target_height !=
height();
104 sk_sp<SkData>
data()
const {
return buffer_; }
106 sk_sp<SkImage>
image()
const;
120 return generator_->GetScaledDimensions(scale);
122 return SkISize::Make(image_info_.
width, image_info_.
height);
127 bool get_pixels(
const SkPixmap& pixmap)
const;
143 std::shared_ptr<ImageGenerator> generator);
145 sk_sp<SkData> buffer_;
146 const ImageInfo image_info_;
147 std::shared_ptr<ImageGenerator> generator_;
148 std::optional<size_t> row_bytes_;
150 DEFINE_WRAPPERTYPEINFO();
Creates an image descriptor for encoded or decoded image data, describing the width,...
sk_sp< SkImage > image() const
~ImageDescriptor() override=default
int width() const
The width of this image, EXIF oriented if applicable.
SkISize get_scaled_dimensions(float scale)
Gets the scaled dimensions of this image, if backed by an ImageGenerator that can perform efficient s...
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)
friend class ImageDecoderFixtureTest
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 should_resize(int target_width, int target_height) const
Whether the given target_width or target_height differ from width() and height() respectively.
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...
bool is_compressed() const
Whether this descriptor represents compressed (encoded) data or not.
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.
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
#define FML_FRIEND_MAKE_REF_COUNTED(T)
const SkAlphaType alpha_type
const sk_sp< SkColorSpace > color_space