17 PixelDeferredImageGPUImpeller::ImageWrapper::Make(
18 std::move(
image), std::move(snapshot_delegate),
19 std::move(raster_task_runner))));
22PixelDeferredImageGPUImpeller::PixelDeferredImageGPUImpeller(
23 std::shared_ptr<ImageWrapper> wrapper)
24 : wrapper_(
std::move(wrapper)) {}
28std::shared_ptr<impeller::Texture>
30 const std::shared_ptr<impeller::Context>& context)
const {
34 return wrapper_->texture();
46 return wrapper_ ? wrapper_->size() :
DlISize();
52 if (wrapper_->texture()) {
53 size += wrapper_->texture()
54 ->GetTextureDescriptor()
55 .GetByteSizeOfBaseMipLevel();
57 size += wrapper_->size().Area() * 4;
67 std::shared_ptr<impeller::Texture>
texture = wrapper_->texture();
71 switch (
texture->GetTextureDescriptor().format) {
81 return wrapper_ ? wrapper_->get_error() : std::nullopt;
84std::shared_ptr<PixelDeferredImageGPUImpeller::ImageWrapper>
85PixelDeferredImageGPUImpeller::ImageWrapper::Make(
89 auto wrapper = std::shared_ptr<ImageWrapper>(
new ImageWrapper(
90 image, std::move(snapshot_delegate), std::move(raster_task_runner)));
91 wrapper->SnapshotImage(std::move(
image));
95PixelDeferredImageGPUImpeller::ImageWrapper::ImageWrapper(
96 const sk_sp<SkImage>&
image,
101 raster_task_runner_(
std::move(raster_task_runner)) {}
103PixelDeferredImageGPUImpeller::ImageWrapper::~ImageWrapper() =
default;
105void PixelDeferredImageGPUImpeller::ImageWrapper::SnapshotImage(
106 sk_sp<SkImage>
image) {
110 [weak_this = weak_from_this(),
image = std::move(
image)]()
mutable {
112 auto wrapper = weak_this.lock();
116 FML_DCHECK(!wrapper->texture_) <<
"should only execute once.";
117 auto snapshot_delegate = wrapper->snapshot_delegate_;
118 if (!snapshot_delegate) {
123 auto snapshot_texture = snapshot_delegate->MakeImpellerTextureImage(
125 if (!snapshot_texture) {
126 std::scoped_lock lock(wrapper->error_mutex_);
127 wrapper->error_ =
"Failed to create snapshot.";
130 wrapper->texture_ = snapshot_texture;
134std::optional<std::string>
135PixelDeferredImageGPUImpeller::ImageWrapper::get_error()
const {
136 std::scoped_lock lock(error_mutex_);
DlISize GetSize() const override
std::shared_ptr< impeller::Texture > GetImpellerTexture(const std::shared_ptr< impeller::Context > &context) const override
DlColorSpace GetColorSpace() const override
Gets the color space of the image.
size_t GetApproximateByteSize() const override
bool isOpaque() const override
If the pixel format of this image ignores alpha, this returns true. This method might conservatively ...
static sk_sp< PixelDeferredImageGPUImpeller > Make(sk_sp< SkImage > image, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate, fml::RefPtr< fml::TaskRunner > raster_task_runner)
bool isUIThreadSafe() const override
If the underlying platform image held by this object has no threading requirements for the release of...
~PixelDeferredImageGPUImpeller() override
std::optional< std::string > get_error() const override
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
FlutterVulkanImage * image
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate_
#define FML_DCHECK(condition)
impeller::ISize32 DlISize
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
internal::CopyableLambda< T > MakeCopyable(T lambda)
#define TRACE_EVENT0(category_group, name)