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
18#include "third_party/skia/include/core/SkImage.h"
19
20namespace flutter {
21
22/// A deferred image that is created from pixels.
23/// @see DisplayListDeferredImageGPUImpeller for another example of a deferred
24/// image.
25/// @see dart:ui `decodeImageFromPixelsSync` for the user of this class.
27 public:
28 static sk_sp<PixelDeferredImageGPUImpeller> Make(
29 sk_sp<SkImage> image,
31 fml::RefPtr<fml::TaskRunner> raster_task_runner);
32
33 // |DlImage|
35
36 // |DlImage|
37 sk_sp<SkImage> skia_image() const override;
38
39 // |DlImage|
40 std::shared_ptr<impeller::Texture> impeller_texture() const override;
41
42 // |DlImage|
43 bool isOpaque() const override;
44
45 // |DlImage|
46 bool isTextureBacked() const override;
47
48 // |DlImage|
49 bool isUIThreadSafe() const override;
50
51 // |DlImage|
52 DlISize GetSize() const override;
53
54 // |DlImage|
55 size_t GetApproximateByteSize() const override;
56
57 // |DlImage|
58 std::optional<std::string> get_error() const override;
59
60 private:
61 class ImageWrapper : public std::enable_shared_from_this<ImageWrapper> {
62 public:
63 static std::shared_ptr<ImageWrapper> Make(
64 sk_sp<SkImage> image,
66 fml::RefPtr<fml::TaskRunner> raster_task_runner);
67
68 ImageWrapper(
69 const sk_sp<SkImage>& image,
71 fml::RefPtr<fml::TaskRunner> raster_task_runner);
72
73 ~ImageWrapper();
74
75 std::shared_ptr<impeller::Texture> texture() const { return texture_; }
76
77 const DlISize& size() const { return size_; }
78
79 bool isTextureBacked() const;
80
81 std::optional<std::string> get_error() const;
82
83 private:
84 void SnapshotImage(sk_sp<SkImage> image);
85
86 DlISize size_;
88 fml::RefPtr<fml::TaskRunner> raster_task_runner_;
89 std::shared_ptr<impeller::Texture> texture_;
90 mutable std::mutex error_mutex_;
91 std::optional<std::string> error_;
92
93 FML_DISALLOW_COPY_AND_ASSIGN(ImageWrapper);
94 };
95
96 explicit PixelDeferredImageGPUImpeller(std::shared_ptr<ImageWrapper> wrapper);
97
98 std::shared_ptr<ImageWrapper> wrapper_;
99
100 FML_DISALLOW_COPY_AND_ASSIGN(PixelDeferredImageGPUImpeller);
101};
102
103} // namespace flutter
104
105#endif // FLUTTER_LIB_UI_PAINTING_PIXEL_DEFERRED_IMAGE_GPU_IMPELLER_H_
Represents an image whose allocation is (usually) resident on device memory.
Definition dl_image.h:32
std::shared_ptr< impeller::Texture > impeller_texture() const override
If this display list image is meant to be used by the Impeller backend, an Impeller texture instance....
sk_sp< SkImage > skia_image() const override
If this display list image is meant to be used by the Skia backend, an SkImage instance....
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