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/SkData.h"
17#include "third_party/skia/include/core/SkImage.h"
18#include "third_party/skia/include/core/SkImageInfo.h"
19#include "third_party/skia/include/core/SkPixmap.h"
20#include "third_party/skia/include/core/SkSize.h"
49 static Dart_Handle
initEncoded(Dart_Handle descriptor_handle,
51 Dart_Handle callback_handle);
55 static void initRaw(Dart_Handle descriptor_handle,
63 void instantiateCodec(Dart_Handle codec,
int target_width,
int target_height);
66 int width()
const {
return image_info_.width(); }
69 int height()
const {
return image_info_.height(); }
77 return row_bytes_.value_or(
78 static_cast<size_t>(image_info_.width() * image_info_.bytesPerPixel()));
84 return target_width !=
width() || target_height !=
height();
88 sk_sp<SkData>
data()
const {
return buffer_; }
90 sk_sp<SkImage>
image()
const;
97 const SkImageInfo&
image_info()
const {
return image_info_; }
104 return generator_->GetScaledDimensions(scale);
106 return image_info_.dimensions();
111 bool get_pixels(
const SkPixmap& pixmap)
const;
124 std::shared_ptr<ImageGenerator> generator);
126 sk_sp<SkData> buffer_;
127 std::shared_ptr<ImageGenerator> generator_;
128 const SkImageInfo image_info_;
129 std::optional<size_t> row_bytes_;
131 const SkImageInfo CreateImageInfo()
const;
133 DEFINE_WRAPPERTYPEINFO();
Creates an image descriptor for encoded or decoded image data, describing the width,...
sk_sp< SkImage > image() const
const SkImageInfo & image_info() const
The orientation corrected image info for this image.
~ImageDescriptor() override=default
void instantiateCodec(Dart_Handle codec, int target_width, int target_height)
Associates a flutter::Codec object with the dart.ui Codec handle.
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...
friend class ImageDecoderFixtureTest
int row_bytes() const
The byte length of the first row of the image. Defaults to width() * 4.
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...
static void initRaw(Dart_Handle descriptor_handle, const fml::RefPtr< ImmutableBuffer > &data, int width, int height, int row_bytes, PixelFormat pixel_format)
Synchronously initializes an ImageDescriptor for decompressed image data as specified by the PixelFor...
bool is_compressed() const
Whether this descriptor represents compressed (encoded) data or not.
sk_sp< SkData > data() const
The underlying buffer for this image.
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
#define FML_FRIEND_MAKE_REF_COUNTED(T)