Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
flutter::ImageGeneratorRegistry Class Reference

Keeps a priority-ordered registry of image generator builders to be used when decoding images. This object must be created, accessed, and collected on the UI thread (typically the engine or its runtime controller). More...

#include <image_generator_registry.h>

Public Member Functions

 ImageGeneratorRegistry ()
 
 ~ImageGeneratorRegistry ()
 
void AddFactory (ImageGeneratorFactory factory, int32_t priority)
 Install a new factory for image generators.
 
std::shared_ptr< ImageGeneratorCreateCompatibleGenerator (const sk_sp< SkData > &buffer)
 Walks the list of image generator builders in descending priority order until a compatible ImageGenerator is able to be built. This method is safe to perform on the UI thread, as checking for ImageGenerator compatibility is expected to be a lightweight operation. The returned ImageGenerator can then be used to fully decode the image on e.g. the IO thread.
 
fml::WeakPtr< ImageGeneratorRegistryGetWeakPtr () const
 

Detailed Description

Keeps a priority-ordered registry of image generator builders to be used when decoding images. This object must be created, accessed, and collected on the UI thread (typically the engine or its runtime controller).

Definition at line 28 of file image_generator_registry.h.

Constructor & Destructor Documentation

◆ ImageGeneratorRegistry()

flutter::ImageGeneratorRegistry::ImageGeneratorRegistry ( )

Definition at line 21 of file image_generator_registry.cc.

21 : weak_factory_(this) {
25 },
26 0);
27
31 },
32 0);
33
34 // todo(bdero): https://github.com/flutter/flutter/issues/82603
35#ifdef FML_OS_MACOSX
38 auto generator =
39 SkImageGeneratorCG::MakeFromEncodedCG(std::move(buffer));
41 std::move(generator));
42 },
43 0);
44#elif FML_OS_WIN
47 auto generator = SkImageGeneratorWIC::MakeFromEncodedWIC(buffer);
49 std::move(generator));
50 },
51 0);
52#endif
53}
static std::unique_ptr< ImageGenerator > MakeFromData(sk_sp< SkData > data)
static std::unique_ptr< ImageGenerator > MakeFromData(sk_sp< SkData > data)
static std::unique_ptr< ImageGenerator > MakeFromGenerator(std::unique_ptr< SkImageGenerator > generator)
void AddFactory(ImageGeneratorFactory factory, int32_t priority)
Install a new factory for image generators.
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
Definition switches.h:126

◆ ~ImageGeneratorRegistry()

flutter::ImageGeneratorRegistry::~ImageGeneratorRegistry ( )
default

Member Function Documentation

◆ AddFactory()

void flutter::ImageGeneratorRegistry::AddFactory ( ImageGeneratorFactory  factory,
int32_t  priority 
)

Install a new factory for image generators.

Parameters
[in]factoryCallback that produces ImageGenerators for compatible input data.
[in]priorityThe priority used to determine the order in which factories are tried. Higher values mean higher priority. The built-in Skia decoders are installed at priority 0, and so a priority > 0 takes precedent over the builtin decoders. When multiple decoders are added with the same priority, those which are added earlier take precedent.
See also
CreateCompatibleGenerator

Definition at line 57 of file image_generator_registry.cc.

58 {
59 image_generator_factories_.insert({std::move(factory), priority, ++nonce_});
60}

◆ CreateCompatibleGenerator()

std::shared_ptr< ImageGenerator > flutter::ImageGeneratorRegistry::CreateCompatibleGenerator ( const sk_sp< SkData > &  buffer)

Walks the list of image generator builders in descending priority order until a compatible ImageGenerator is able to be built. This method is safe to perform on the UI thread, as checking for ImageGenerator compatibility is expected to be a lightweight operation. The returned ImageGenerator can then be used to fully decode the image on e.g. the IO thread.

Parameters
[in]bufferThe raw encoded image data.
Returns
An ImageGenerator that is compatible with the input buffer. If no compatible ImageGenerator type was found, then std::shared_ptr<ImageGenerator>(nullptr) is returned.
See also
ImageGenerator

Definition at line 63 of file image_generator_registry.cc.

63 {
64 if (!image_generator_factories_.size()) {
65 FML_LOG(WARNING)
66 << "There are currently no image decoders installed. If you're writing "
67 "your own platform embedding, you can register new image decoders "
68 "via `ImageGeneratorRegistry::AddFactory` on the "
69 "`ImageGeneratorRegistry` provided by the engine. Otherwise, please "
70 "file a bug on https://github.com/flutter/flutter/issues.";
71 }
72
73 for (auto& factory : image_generator_factories_) {
74 std::shared_ptr<ImageGenerator> result = factory.callback(buffer);
75 if (result) {
76 return result;
77 }
78 }
79 return nullptr;
80}
GAsyncResult * result
#define FML_LOG(severity)
Definition logging.h:82

◆ GetWeakPtr()

fml::WeakPtr< ImageGeneratorRegistry > flutter::ImageGeneratorRegistry::GetWeakPtr ( ) const

Definition at line 82 of file image_generator_registry.cc.

83 {
84 return weak_factory_.GetWeakPtr();
85}

The documentation for this class was generated from the following files: