Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
display_list_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_DISPLAY_LIST_DEFERRED_IMAGE_GPU_IMPELLER_H_
6#define FLUTTER_LIB_UI_PAINTING_DISPLAY_LIST_DEFERRED_IMAGE_GPU_IMPELLER_H_
7
8#include <variant>
12#include "flutter/fml/macros.h"
18
19namespace flutter {
20
21namespace testing {
23} // namespace testing
24
25class DlDeferredImageGPUImpeller final : public DlImage {
26 public:
27 static sk_sp<DlDeferredImageGPUImpeller> Make(
28 std::unique_ptr<LayerTree> layer_tree,
30 fml::RefPtr<fml::TaskRunner> raster_task_runner);
31
32 static sk_sp<DlDeferredImageGPUImpeller> Make(
33 sk_sp<DisplayList> display_list,
34 const DlISize& size,
35 SnapshotPixelFormat pixel_format,
37 fml::RefPtr<fml::TaskRunner> raster_task_runner);
38
39 // |DlImage|
41
42 // |DlImage|
43 sk_sp<SkImage> skia_image() const override;
44
45 // |DlImage|
46 std::shared_ptr<impeller::Texture> impeller_texture() const override;
47
48 // |DlImage|
49 bool isOpaque() const override;
50
51 // |DlImage|
52 bool isTextureBacked() const override;
53
54 // |DlImage|
55 bool isUIThreadSafe() const override;
56
57 // |DlImage|
58 DlISize GetSize() const override;
59
60 // |DlImage|
61 size_t GetApproximateByteSize() const override;
62
63 // |DlImage|
64 OwningContext owning_context() const override {
66 }
67
68 private:
69 FML_FRIEND_TEST(testing::DlDeferredImageGPUImpeller, TrashesDisplayList);
70
71 class ImageWrapper final : public std::enable_shared_from_this<ImageWrapper>,
72 public ContextListener {
73 public:
74 ~ImageWrapper();
75
76 static std::shared_ptr<ImageWrapper> Make(
77 sk_sp<DisplayList> display_list,
78 const DlISize& size,
79 SnapshotPixelFormat pixel_format,
81 fml::RefPtr<fml::TaskRunner> raster_task_runner);
82
83 static std::shared_ptr<ImageWrapper> Make(
84 std::unique_ptr<LayerTree> layer_tree,
86 fml::RefPtr<fml::TaskRunner> raster_task_runner);
87
88 bool isTextureBacked() const;
89
90 const std::shared_ptr<impeller::Texture> texture() const {
91 FML_DCHECK(raster_task_runner_->RunsTasksOnCurrentThread());
92 return texture_;
93 }
94
95 const DlISize size() const { return size_; }
96
97 std::optional<std::string> get_error();
98
99 private:
100 FML_FRIEND_TEST(testing::DlDeferredImageGPUImpeller, TrashesDisplayList);
101 DlISize size_;
102 SnapshotPixelFormat pixel_format_;
103 std::shared_ptr<impeller::Texture> texture_;
105 fml::RefPtr<fml::TaskRunner> raster_task_runner_;
106
107 mutable std::mutex error_mutex_;
108 std::optional<std::string> error_;
109
110 ImageWrapper(
111 const DlISize& size,
112 SnapshotPixelFormat pixel_format,
114 fml::RefPtr<fml::TaskRunner> raster_task_runner);
115
116 // If a layer tree is provided, it will be flattened into a display list
117 // during the raster thread task spawned by this method.
118 void SnapshotDisplayList(
119 std::variant<sk_sp<DisplayList>, std::unique_ptr<LayerTree>> content);
120
121 // |ContextListener|
122 void OnGrContextCreated() override;
123
124 // |ContextListener|
125 void OnGrContextDestroyed() override;
126
127 FML_DISALLOW_COPY_AND_ASSIGN(ImageWrapper);
128 };
129
130 const std::shared_ptr<ImageWrapper> wrapper_;
131
132 explicit DlDeferredImageGPUImpeller(std::shared_ptr<ImageWrapper> wrapper);
133
134 FML_DISALLOW_COPY_AND_ASSIGN(DlDeferredImageGPUImpeller);
135};
136
137} // namespace flutter
138
139#endif // FLUTTER_LIB_UI_PAINTING_DISPLAY_LIST_DEFERRED_IMAGE_GPU_IMPELLER_H_
bool isUIThreadSafe() const override
If the underlying platform image held by this object has no threading requirements for the release of...
bool isOpaque() const override
If the pixel format of this image ignores alpha, this returns true. This method might conservatively ...
sk_sp< SkImage > skia_image() const override
If this display list image is meant to be used by the Skia backend, an SkImage instance....
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....
static sk_sp< DlDeferredImageGPUImpeller > Make(std::unique_ptr< LayerTree > layer_tree, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate, fml::RefPtr< fml::TaskRunner > raster_task_runner)
Represents an image whose allocation is (usually) resident on device memory.
Definition dl_image.h:32
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate_
#define FML_DCHECK(condition)
Definition logging.h:122
#define FML_FRIEND_TEST(test_case_name, test_name)
Definition macros.h:47
#define FML_TEST_CLASS(test_case_name, test_name)
Definition macros.h:44
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
union flutter::testing::@2832::KeyboardChange::@77 content
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