Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
pixel_deferred_image_gpu_impeller.h
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#ifndef FLUTTER_LIB_UI_PAINTING_PIXEL_DEFERRED_IMAGE_GPU_IMPELLER_H_
6#define FLUTTER_LIB_UI_PAINTING_PIXEL_DEFERRED_IMAGE_GPU_IMPELLER_H_
7
8#include <memory>
9#include <mutex>
10#include <optional>
11#include <string>
12
19#include "third_party/skia/include/core/SkImage.h"
20
21namespace flutter {
22
23/// A deferred image that is created from pixels.
24/// @see DisplayListDeferredImageGPUImpeller for another example of a deferred
25/// image.
26/// @see dart:ui `decodeImageFromPixelsSync` for the user of this class.
28 public:
29 static sk_sp<PixelDeferredImageGPUImpeller> Make(
30 sk_sp<SkImage> image,
32 fml::RefPtr<fml::TaskRunner> raster_task_runner);
33
34 // |DlImage|
36
37 // |DlImageImpeller|
38 std::shared_ptr<impeller::Texture> GetImpellerTexture(
39 const std::shared_ptr<impeller::Context>& context) const override;
40
41 // |DlImage|
42 bool isOpaque() const override;
43
44 // |DlImage|
45 bool isUIThreadSafe() const override;
46
47 // |DlImage|
48 DlISize GetSize() const override;
49
50 // |DlImage|
51 size_t GetApproximateByteSize() const override;
52
53 // |DlImage|
54 DlColorSpace GetColorSpace() const override;
55
56 // |DlImage|
57 std::optional<std::string> get_error() const override;
58
59 private:
60 class ImageWrapper : public std::enable_shared_from_this<ImageWrapper> {
61 public:
62 static std::shared_ptr<ImageWrapper> Make(
63 sk_sp<SkImage> image,
65 fml::RefPtr<fml::TaskRunner> raster_task_runner);
66
67 ImageWrapper(
68 const sk_sp<SkImage>& image,
70 fml::RefPtr<fml::TaskRunner> raster_task_runner);
71
72 ~ImageWrapper();
73
74 std::shared_ptr<impeller::Texture> texture() const { return texture_; }
75
76 const DlISize& size() const { return size_; }
77
78 std::optional<std::string> get_error() const;
79
80 private:
81 void SnapshotImage(sk_sp<SkImage> image);
82
83 DlISize size_;
85 fml::RefPtr<fml::TaskRunner> raster_task_runner_;
86 std::shared_ptr<impeller::Texture> texture_;
87 mutable std::mutex error_mutex_;
88 std::optional<std::string> error_;
89
90 FML_DISALLOW_COPY_AND_ASSIGN(ImageWrapper);
91 };
92
93 explicit PixelDeferredImageGPUImpeller(std::shared_ptr<ImageWrapper> wrapper);
94
95 std::shared_ptr<ImageWrapper> wrapper_;
96
97 FML_DISALLOW_COPY_AND_ASSIGN(PixelDeferredImageGPUImpeller);
98};
99
100} // namespace flutter
101
102#endif // FLUTTER_LIB_UI_PAINTING_PIXEL_DEFERRED_IMAGE_GPU_IMPELLER_H_
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.
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...
std::optional< std::string > get_error() const override
FlutterVulkanImage * image
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate_
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
FlTexture * texture
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
DlColorSpace
Definition dl_color.h:13