Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
snapshot_delegate.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_SNAPSHOT_DELEGATE_H_
6#define FLUTTER_LIB_UI_SNAPSHOT_DELEGATE_H_
7
8#include <functional>
9#include <string>
10
14#include "third_party/skia/include/core/SkImage.h"
15#include "third_party/skia/include/gpu/ganesh/GrBackendSurface.h"
16#include "third_party/skia/include/gpu/ganesh/GrContextThreadSafeProxy.h"
17#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
18
19namespace impeller {
20class Texture;
21class RuntimeStage;
22} // namespace impeller
23
24namespace flutter {
25
26class DlImage;
27
29 public:
30 //----------------------------------------------------------------------------
31 /// @brief A data structure used by the Skia implementation of deferred
32 /// GPU based images.
35#if !SLIMPELLER
36 const GrBackendTexture& p_texture,
37#endif // !SLIMPELLER
38 sk_sp<GrDirectContext> p_context,
39 sk_sp<SkImage> p_image = nullptr,
40 const std::string& p_error = "")
41 :
42#if !SLIMPELLER
43 texture(p_texture),
44#endif // !SLIMPELLER
45 context(std::move(p_context)),
46 image(std::move(p_image)),
47 error(p_error) {
48 }
49
50#if !SLIMPELLER
51 const GrBackendTexture texture;
52#endif // !SLIMPELLER
53 // If texture.isValid() == true, this is a pointer to a GrDirectContext that
54 // can be used to create an image from the texture.
55 sk_sp<GrDirectContext> context;
56 // If MakeGpuImage could not create a GPU resident image, a raster copy
57 // is available in this member and texture.isValid() is false.
58 sk_sp<SkImage> image;
59
60 // A non-empty string containing an error message if neither a GPU backed
61 // texture nor a raster backed image could be created.
62 const std::string error;
63 };
64
65 //----------------------------------------------------------------------------
66 /// @brief Attempts to create a GrBackendTexture for the specified
67 /// DisplayList. May result in a raster bitmap if no GPU context
68 /// is available.
69 virtual std::unique_ptr<GpuImageResult> MakeSkiaGpuImage(
70 sk_sp<DisplayList> display_list,
71 const SkImageInfo& image_info) = 0;
72
73 //----------------------------------------------------------------------------
74 /// @brief Gets the registry of external textures currently in use by the
75 /// rasterizer. These textures may be updated at a cadence
76 /// different from that of the Flutter application. When an
77 /// external texture is referenced in the Flutter layer tree, that
78 /// texture is composited within the Flutter layer tree.
79 ///
80 /// @return A pointer to the external texture registry.
81 ///
82 virtual std::shared_ptr<TextureRegistry> GetTextureRegistry() = 0;
83
84 virtual GrDirectContext* GetGrContext() = 0;
85
86 virtual void MakeSkiaSnapshot(sk_sp<DisplayList> display_list,
87 DlISize picture_size,
88 std::function<void(sk_sp<SkImage>)> callback,
89 SnapshotPixelFormat pixel_format) = 0;
90
91 virtual sk_sp<SkImage> MakeSkiaSnapshotSync(
92 sk_sp<DisplayList> display_list,
93 DlISize picture_size,
94 SnapshotPixelFormat pixel_format) = 0;
95
97 sk_sp<DisplayList> display_list,
98 DlISize picture_size,
99 std::function<void(std::shared_ptr<impeller::Texture>)> callback,
100 SnapshotPixelFormat pixel_format) = 0;
101
102 virtual std::shared_ptr<impeller::Texture> MakeImpellerSnapshotSync(
103 sk_sp<DisplayList> display_list,
104 DlISize picture_size,
105 SnapshotPixelFormat pixel_format) = 0;
106
107 virtual sk_sp<SkImage> MakeSkiaTextureImage(
108 sk_sp<SkImage> image,
109 SnapshotPixelFormat pixel_format) = 0;
110
111 virtual std::shared_ptr<impeller::Texture> MakeImpellerTextureImage(
112 sk_sp<SkImage> image,
113 SnapshotPixelFormat pixel_format) = 0;
114
115 virtual sk_sp<SkImage> ConvertToRasterImage(sk_sp<SkImage> image) = 0;
116
117 /// Load and compile and initial PSO for the provided [runtime_stage].
118 ///
119 /// Impeller only.
120 virtual void CacheRuntimeStage(
121 const std::shared_ptr<impeller::RuntimeStage>& runtime_stage) = 0;
122
123 /// Bind a context to the current thread that can execute rendering commands.
124 ///
125 /// Impeller only.
126 virtual bool MakeRenderContextCurrent() = 0;
127};
128
129} // namespace flutter
130
131#endif // FLUTTER_LIB_UI_SNAPSHOT_DELEGATE_H_
virtual bool MakeRenderContextCurrent()=0
virtual sk_sp< SkImage > MakeSkiaTextureImage(sk_sp< SkImage > image, SnapshotPixelFormat pixel_format)=0
virtual std::shared_ptr< TextureRegistry > GetTextureRegistry()=0
Gets the registry of external textures currently in use by the rasterizer. These textures may be upda...
virtual void MakeSkiaSnapshot(sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(sk_sp< SkImage >)> callback, SnapshotPixelFormat pixel_format)=0
virtual std::shared_ptr< impeller::Texture > MakeImpellerTextureImage(sk_sp< SkImage > image, SnapshotPixelFormat pixel_format)=0
virtual std::shared_ptr< impeller::Texture > MakeImpellerSnapshotSync(sk_sp< DisplayList > display_list, DlISize picture_size, SnapshotPixelFormat pixel_format)=0
virtual sk_sp< SkImage > ConvertToRasterImage(sk_sp< SkImage > image)=0
virtual GrDirectContext * GetGrContext()=0
virtual void MakeImpellerSnapshot(sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(std::shared_ptr< impeller::Texture >)> callback, SnapshotPixelFormat pixel_format)=0
virtual sk_sp< SkImage > MakeSkiaSnapshotSync(sk_sp< DisplayList > display_list, DlISize picture_size, SnapshotPixelFormat pixel_format)=0
virtual std::unique_ptr< GpuImageResult > MakeSkiaGpuImage(sk_sp< DisplayList > display_list, const SkImageInfo &image_info)=0
Attempts to create a GrBackendTexture for the specified DisplayList. May result in a raster bitmap if...
virtual void CacheRuntimeStage(const std::shared_ptr< impeller::RuntimeStage > &runtime_stage)=0
FlutterVulkanImage * image
if(engine==nullptr)
FlutterDesktopBinaryReply callback
Definition ref_ptr.h:261
flutter::DlImage DlImage
A data structure used by the Skia implementation of deferred GPU based images.
GpuImageResult(const GrBackendTexture &p_texture, sk_sp< GrDirectContext > p_context, sk_sp< SkImage > p_image=nullptr, const std::string &p_error="")