Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
image_generator_registry.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <algorithm>
6#include <utility>
7
8#include "flutter/lib/ui/painting/image_generator_registry.h"
11#ifdef FML_OS_MACOSX
13#elif FML_OS_WIN
15#endif
16
18
19namespace flutter {
20
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}
54
56
58 int32_t priority) {
59 image_generator_factories_.insert({std::move(factory), priority, ++nonce_});
60}
61
62std::shared_ptr<ImageGenerator>
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}
81
83 const {
84 return weak_factory_.GetWeakPtr();
85}
86
87} // namespace flutter
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)
std::shared_ptr< ImageGenerator > CreateCompatibleGenerator(const sk_sp< SkData > &buffer)
Walks the list of image generator builders in descending priority order until a compatible ImageGener...
fml::WeakPtr< ImageGeneratorRegistry > GetWeakPtr() const
void AddFactory(ImageGeneratorFactory factory, int32_t priority)
Install a new factory for image generators.
GAsyncResult * result
#define FML_LOG(severity)
Definition logging.h:82
std::function< std::shared_ptr< ImageGenerator >(sk_sp< SkData > buffer)> ImageGeneratorFactory
ImageGeneratorFactory is the top level primitive for specifying an image decoder in Flutter....
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