Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
surface.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_GPU_SURFACE_H_
6#define FLUTTER_LIB_GPU_SURFACE_H_
7
8#include <atomic>
9#include <memory>
10#include <optional>
11#include <string>
12#include <vector>
13
14#include "dart_api.h"
25
26namespace flutter {
27namespace gpu {
28
29class Surface : public RefCountedDartWrappable<Surface> {
30 DEFINE_WRAPPERTYPEINFO();
32
33 public:
34 Surface(std::shared_ptr<impeller::Context> context,
37
38 ~Surface() override;
39
40 int AcquireNextFrame(Dart_Handle texture_wrapper);
41
42 Dart_Handle PresentFrame(size_t texture_index, CommandBuffer& command_buffer);
43
44 void DiscardFrame(size_t texture_index);
45
46 Dart_Handle GetCurrentImage() const;
47
48 std::optional<std::string> Resize(impeller::ISize size);
49
50 size_t GetBackingTextureCount() const;
51
52 private:
53 struct TextureRecord {
54 TextureRecord(std::shared_ptr<impeller::Texture> texture,
55 sk_sp<DlImage> image,
56 impeller::ISize size,
58
59 std::shared_ptr<impeller::Texture> texture;
60 sk_sp<DlImage> image;
63 bool acquired = false;
64 std::atomic_bool producer_pending = false;
65 };
66
67 std::shared_ptr<TextureRecord> CreateTextureRecord() const;
68
69 bool IsReusable(const std::shared_ptr<TextureRecord>& record,
70 size_t index) const;
71
72 void PruneTextureRecords();
73
74 Dart_Handle CreateImage(const sk_sp<DlImage>& image) const;
75
76 std::shared_ptr<impeller::Context> context_;
77 impeller::ISize size_;
79 std::vector<std::shared_ptr<TextureRecord>> records_;
80 std::optional<size_t> current_index_;
81
83};
84
85} // namespace gpu
86} // namespace flutter
87
88//----------------------------------------------------------------------------
89/// Exports
90///
91
92extern "C" {
93
96 Dart_Handle wrapper,
97 flutter::gpu::Context* gpu_context,
98 int width,
99 int height,
100 int format);
101
104 flutter::gpu::Surface* wrapper,
105 Dart_Handle texture_wrapper);
106
109 flutter::gpu::Surface* wrapper,
110 int texture_index,
112
115 flutter::gpu::Surface* wrapper,
116 int texture_index);
117
120 flutter::gpu::Surface* wrapper);
121
123extern Dart_Handle InternalFlutterGpu_Surface_Resize(
124 flutter::gpu::Surface* wrapper,
125 int width,
126 int height);
127
130 flutter::gpu::Surface* wrapper);
131
132} // extern "C"
133
134#endif // FLUTTER_LIB_GPU_SURFACE_H_
int AcquireNextFrame(Dart_Handle texture_wrapper)
Definition surface.cc:124
Dart_Handle GetCurrentImage() const
Definition surface.cc:209
size_t GetBackingTextureCount() const
Definition surface.cc:233
Dart_Handle PresentFrame(size_t texture_index, CommandBuffer &command_buffer)
Definition surface.cc:168
std::optional< std::string > Resize(impeller::ISize size)
Definition surface.cc:221
void DiscardFrame(size_t texture_index)
Definition surface.cc:199
FlutterVulkanImage * image
uint32_t uint32_t * format
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
#define FLUTTER_GPU_EXPORT
Definition export.h:13
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_PresentFrame(flutter::gpu::Surface *wrapper, int texture_index, flutter::gpu::CommandBuffer *command_buffer)
Definition surface.cc:281
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_Resize(flutter::gpu::Surface *wrapper, int width, int height)
Definition surface.cc:305
FLUTTER_GPU_EXPORT void InternalFlutterGpu_Surface_DiscardFrame(flutter::gpu::Surface *wrapper, int texture_index)
Definition surface.cc:292
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_GetCurrentImage(flutter::gpu::Surface *wrapper)
Definition surface.cc:300
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Surface_AcquireNextFrame(flutter::gpu::Surface *wrapper, Dart_Handle texture_wrapper)
Definition surface.cc:276
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Surface_GetBackingTextureCount(flutter::gpu::Surface *wrapper)
Definition surface.cc:318
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_Initialize(Dart_Handle wrapper, flutter::gpu::Context *gpu_context, int width, int height, int format)
Definition surface.cc:250
FlTexture * texture
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
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
#define FML_FRIEND_MAKE_REF_COUNTED(T)
std::shared_ptr< ContextGLES > context
std::shared_ptr< CommandBuffer > command_buffer
int32_t height
int32_t width