5#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_IMPELLER_H_
6#define FLUTTER_LIB_UI_PAINTING_IMAGE_DECODER_IMPELLER_H_
15#include "include/core/SkImageInfo.h"
16#include "third_party/abseil-cpp/absl/status/statusor.h"
17#include "third_party/skia/include/core/SkBitmap.h"
39 std::shared_ptr<impeller::Allocator> allocator_;
40 std::shared_ptr<impeller::DeviceBuffer> buffer_;
47 std::shared_ptr<fml::ConcurrentTaskRunner> concurrent_task_runner,
49 bool supports_wide_gamut,
50 const std::shared_ptr<fml::SyncSwitch>& gpu_disabled_switch);
76 bool supports_wide_gamut,
77 const std::shared_ptr<const impeller::Capabilities>& capabilities,
78 const std::shared_ptr<impeller::Allocator>&
allocator);
91 const std::shared_ptr<impeller::Context>& context,
92 const std::shared_ptr<impeller::DeviceBuffer>& buffer,
94 const std::optional<SkImageInfo>& resize_info,
95 const std::shared_ptr<const fml::SyncSwitch>& gpu_disabled_switch);
102 const std::shared_ptr<impeller::Context>& context,
103 std::shared_ptr<SkBitmap>
bitmap);
106 using FutureContext = std::shared_future<std::shared_ptr<impeller::Context>>;
107 FutureContext context_;
111 const bool wide_gamut_enabled_;
112 std::shared_ptr<fml::SyncSwitch> gpu_disabled_switch_;
115 static std::pair<sk_sp<DlImage>, std::string> UnsafeUploadTextureToPrivate(
116 const std::shared_ptr<impeller::Context>& context,
117 const std::shared_ptr<impeller::DeviceBuffer>& buffer,
119 const std::optional<SkImageInfo>& resize_info);
std::function< void(sk_sp< DlImage >, std::string)> ImageResult
static absl::StatusOr< DecompressResult > DecompressTexture(ImageDescriptor *descriptor, const ImageDecoder::Options &options, impeller::ISize max_texture_size, bool supports_wide_gamut, const std::shared_ptr< const impeller::Capabilities > &capabilities, const std::shared_ptr< impeller::Allocator > &allocator)
static std::optional< impeller::PixelFormat > ToPixelFormat(SkColorType type)
static void UploadTextureToPrivate(ImageResult result, const std::shared_ptr< impeller::Context > &context, const std::shared_ptr< impeller::DeviceBuffer > &buffer, const ImageInfo &image_info, const std::optional< SkImageInfo > &resize_info, const std::shared_ptr< const fml::SyncSwitch > &gpu_disabled_switch)
Create a device private texture from the provided host buffer.
static std::pair< sk_sp< DlImage >, std::string > UploadTextureToStorage(const std::shared_ptr< impeller::Context > &context, std::shared_ptr< SkBitmap > bitmap)
Create a texture from the provided bitmap.
~ImageDecoderImpeller() override
void Decode(fml::RefPtr< ImageDescriptor > descriptor, const Options &options, const ImageResult &result) override
Creates an image descriptor for encoded or decoded image data, describing the width,...
bool allocPixelRef(SkBitmap *bitmap) override
~ImpellerAllocator()=default
std::shared_ptr< impeller::DeviceBuffer > GetDeviceBuffer() const
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
std::shared_ptr< SkBitmap > bitmap
std::shared_ptr< ImpellerAllocator > allocator
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
std::optional< SkImageInfo > resize_info
std::shared_ptr< impeller::DeviceBuffer > device_buffer
impeller::PixelFormat format