Flutter Engine
The Flutter Engine
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
10#include "flutter/common/graphics/texture.h"
11#include "flutter/display_list/display_list.h"
16
17namespace flutter {
18
19class DlImage;
20
22 public:
23 //----------------------------------------------------------------------------
24 /// @brief A data structure used by the Skia implementation of deferred
25 /// GPU based images.
28 sk_sp<GrDirectContext> p_context,
29 sk_sp<SkImage> p_image = nullptr,
30 const std::string& p_error = "")
31 : texture(p_texture),
32 context(std::move(p_context)),
33 image(std::move(p_image)),
34 error(p_error) {}
35
37 // If texture.isValid() == true, this is a pointer to a GrDirectContext that
38 // can be used to create an image from the texture.
40 // If MakeGpuImage could not create a GPU resident image, a raster copy
41 // is available in this member and texture.isValid() is false.
43
44 // A non-empty string containing an error message if neither a GPU backed
45 // texture nor a raster backed image could be created.
46 const std::string error;
47 };
48
49 //----------------------------------------------------------------------------
50 /// @brief Attempts to create a GrBackendTexture for the specified
51 /// DisplayList. May result in a raster bitmap if no GPU context
52 /// is available.
53 virtual std::unique_ptr<GpuImageResult> MakeSkiaGpuImage(
54 sk_sp<DisplayList> display_list,
55 const SkImageInfo& image_info) = 0;
56
57 //----------------------------------------------------------------------------
58 /// @brief Gets the registry of external textures currently in use by the
59 /// rasterizer. These textures may be updated at a cadence
60 /// different from that of the Flutter application. When an
61 /// external texture is referenced in the Flutter layer tree, that
62 /// texture is composited within the Flutter layer tree.
63 ///
64 /// @return A pointer to the external texture registry.
65 ///
66 virtual std::shared_ptr<TextureRegistry> GetTextureRegistry() = 0;
67
69
71 SkISize picture_size) = 0;
72
74
75 /// Load and compile and initial PSO for the provided [runtime_stage].
76 ///
77 /// Impeller only.
78 virtual void CacheRuntimeStage(
79 const std::shared_ptr<impeller::RuntimeStage>& runtime_stage) = 0;
80};
81
82} // namespace flutter
83
84#endif // FLUTTER_LIB_UI_SNAPSHOT_DELEGATE_H_
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 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 sk_sp< DlImage > MakeRasterSnapshot(sk_sp< DisplayList > display_list, SkISize picture_size)=0
virtual void CacheRuntimeStage(const std::shared_ptr< impeller::RuntimeStage > &runtime_stage)=0
sk_sp< SkImage > image
Definition examples.cpp:29
Definition ref_ptr.h:256
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="")