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