Flutter Engine
The Flutter Engine
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 "flutter/common/graphics/texture.h"
9#include "flutter/display_list/image/dl_image.h"
10#include "flutter/flow/layers/layer_tree.h"
11#include "flutter/fml/macros.h"
12#include "flutter/fml/memory/weak_ptr.h"
13#include "flutter/fml/task_runner.h"
14#include "flutter/lib/ui/snapshot_delegate.h"
16
17namespace flutter {
18
19class DlDeferredImageGPUImpeller final : public DlImage {
20 public:
22 std::unique_ptr<LayerTree> layer_tree,
24 fml::RefPtr<fml::TaskRunner> raster_task_runner);
25
27 sk_sp<DisplayList> display_list,
28 const SkISize& size,
30 fml::RefPtr<fml::TaskRunner> raster_task_runner);
31
32 // |DlImage|
34
35 // |DlImage|
36 sk_sp<SkImage> skia_image() const override;
37
38 // |DlImage|
39 std::shared_ptr<impeller::Texture> impeller_texture() const override;
40
41 // |DlImage|
42 bool isOpaque() const override;
43
44 // |DlImage|
45 bool isTextureBacked() const override;
46
47 // |DlImage|
48 bool isUIThreadSafe() const override;
49
50 // |DlImage|
51 SkISize dimensions() const override;
52
53 // |DlImage|
54 size_t GetApproximateByteSize() const override;
55
56 // |DlImage|
57 OwningContext owning_context() const override {
59 }
60
61 private:
62 class ImageWrapper final : public std::enable_shared_from_this<ImageWrapper>,
63 public ContextListener {
64 public:
65 ~ImageWrapper();
66
67 static std::shared_ptr<ImageWrapper> Make(
68 sk_sp<DisplayList> display_list,
69 const SkISize& size,
71 fml::RefPtr<fml::TaskRunner> raster_task_runner);
72
73 static std::shared_ptr<ImageWrapper> Make(
74 std::unique_ptr<LayerTree> layer_tree,
76 fml::RefPtr<fml::TaskRunner> raster_task_runner);
77
78 bool isTextureBacked() const;
79
80 const std::shared_ptr<impeller::Texture> texture() const {
81 return texture_;
82 }
83
84 const SkISize size() const { return size_; }
85
86 std::optional<std::string> get_error();
87
88 private:
89 SkISize size_;
90 sk_sp<DisplayList> display_list_;
91 std::shared_ptr<impeller::Texture> texture_;
93 fml::RefPtr<fml::TaskRunner> raster_task_runner_;
94 std::shared_ptr<TextureRegistry> texture_registry_;
95
96 mutable std::mutex error_mutex_;
97 std::optional<std::string> error_;
98
99 ImageWrapper(
100 sk_sp<DisplayList> display_list,
101 const SkISize& size,
103 fml::RefPtr<fml::TaskRunner> raster_task_runner);
104
105 // If a layer tree is provided, it will be flattened during the raster
106 // thread task spawned by this method. After being flattened into a display
107 // list, the image wrapper will be updated to hold this display list and the
108 // layer tree can be dropped.
109 void SnapshotDisplayList(std::unique_ptr<LayerTree> layer_tree = nullptr);
110
111 // |ContextListener|
112 void OnGrContextCreated() override;
113
114 // |ContextListener|
115 void OnGrContextDestroyed() override;
116
117 FML_DISALLOW_COPY_AND_ASSIGN(ImageWrapper);
118 };
119
120 const std::shared_ptr<ImageWrapper> wrapper_;
121
122 explicit DlDeferredImageGPUImpeller(std::shared_ptr<ImageWrapper> wrapper);
123
124 FML_DISALLOW_COPY_AND_ASSIGN(DlDeferredImageGPUImpeller);
125};
126
127} // namespace flutter
128
129#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:30
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate_
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
FlTexture * texture
it will be possible to load the file into Perfetto s trace viewer 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
Definition switches.h:259