5#include "flutter/lib/ui/painting/image_descriptor.h"
7#include "flutter/fml/build_config.h"
8#include "flutter/fml/logging.h"
9#include "flutter/fml/trace_event.h"
10#include "flutter/lib/ui/painting/multi_frame_codec.h"
11#include "flutter/lib/ui/painting/single_frame_codec.h"
12#include "flutter/lib/ui/ui_dart_state.h"
20const SkImageInfo ImageDescriptor::CreateImageInfo()
const {
22 return generator_->GetInfo();
27 std::optional<size_t> row_bytes)
30 image_info_(image_info),
31 row_bytes_(row_bytes) {}
34 std::shared_ptr<ImageGenerator> generator)
36 generator_(
std::move(generator)),
37 image_info_(CreateImageInfo()),
38 row_bytes_(
std::nullopt) {}
47 if (!immutable_buffer) {
52 auto dart_state = UIDartState::Current();
53 auto registry = dart_state->GetImageGeneratorRegistry();
57 "Failed to access the internal image decoder "
58 "registry on this isolate. Please file a bug on "
59 "https://github.com/flutter/flutter/issues.");
63 registry->CreateCompatibleGenerator(immutable_buffer->
data());
70 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
71 immutable_buffer->
data(), std::move(generator));
75 descriptor->AssociateWithDartWrapper(descriptor_handle);
89 switch (pixel_format) {
90 case PixelFormat::kRGBA8888:
93 case PixelFormat::kBGRA8888:
96 case PixelFormat::kRGBAFloat32:
104 auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
105 data->data(), std::move(image_info),
106 row_bytes == -1 ? std::nullopt : std::optional<size_t>(row_bytes));
107 descriptor->AssociateWithDartWrapper(descriptor_handle);
114 if (!generator_ || generator_->GetFrameCount() == 1) {
115 ui_codec = fml::MakeRefCounted<SingleFrameCodec>(
119 ui_codec = fml::MakeRefCounted<MultiFrameCodec>(generator_);
121 ui_codec->AssociateWithDartWrapper(codec_handle);
125 return generator_->GetImage();
128bool ImageDescriptor::get_pixels(
const SkPixmap& pixmap)
const {
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kUnknown_SkColorType
uninitialized
const SkImageInfo & info() const
void * writable_addr() const
Creates an image descriptor for encoded or decoded image data, describing the width,...
sk_sp< SkData > data() const
Callers should not modify the returned data. This is not exposed to Dart.
DART_EXPORT Dart_Handle Dart_TypeVoid(void)
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
#define FML_DCHECK(condition)
sk_sp< const SkImage > image
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, FlutterGpuTestClass)
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 vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Dart_Handle ToDart(const T &object)
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data