Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::gpu::Surface Class Reference

#include <surface.h>

Inheritance diagram for flutter::gpu::Surface:
flutter::RefCountedDartWrappable< Surface > fml::RefCountedThreadSafe< T > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 Surface (std::shared_ptr< impeller::Context > context, impeller::ISize size, impeller::PixelFormat format)
 
 ~Surface () override
 
int AcquireNextFrame (Dart_Handle texture_wrapper)
 
Dart_Handle PresentFrame (size_t texture_index, CommandBuffer &command_buffer)
 
void DiscardFrame (size_t texture_index)
 
Dart_Handle GetCurrentImage () const
 
std::optional< std::string > Resize (impeller::ISize size)
 
size_t GetBackingTextureCount () const
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Surface >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< T >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex ,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< T >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 29 of file surface.h.

Constructor & Destructor Documentation

◆ Surface()

flutter::gpu::Surface::Surface ( std::shared_ptr< impeller::Context context,
impeller::ISize  size,
impeller::PixelFormat  format 
)

Definition at line 40 of file surface.cc.

43 : context_(std::move(context)), size_(size), format_(format) {}
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
std::shared_ptr< ContextGLES > context

References format.

◆ ~Surface()

flutter::gpu::Surface::~Surface ( )
overridedefault

References format, image, flutter::size, and texture.

Member Function Documentation

◆ AcquireNextFrame()

int flutter::gpu::Surface::AcquireNextFrame ( Dart_Handle  texture_wrapper)

Definition at line 124 of file surface.cc.

124 {
125 std::optional<size_t> available_index;
126 size_t index = 0;
127 for (const auto& record : records_) {
128 if (!record && !available_index.has_value()) {
129 available_index = index;
130 }
131 if (IsReusable(record, index)) {
132 record->acquired = true;
133 auto texture = fml::MakeRefCounted<Texture>(record->texture);
134 texture->AssociateWithDartWrapper(texture_wrapper);
135 return static_cast<int>(index);
136 }
137 index++;
138 }
139
140 auto record = CreateTextureRecord();
141 if (!record) {
142 return -1;
143 }
144 record->acquired = true;
145
146 if (available_index.has_value()) {
147 records_[available_index.value()] = record;
148 index = available_index.value();
149 } else {
150 records_.push_back(record);
151 index = records_.size() - 1u;
152 }
153
154 auto texture = fml::MakeRefCounted<Texture>(record->texture);
155 texture->AssociateWithDartWrapper(texture_wrapper);
156 return static_cast<int>(index);
157}
FlTexture * texture

References texture.

Referenced by InternalFlutterGpu_Surface_AcquireNextFrame().

◆ DiscardFrame()

void flutter::gpu::Surface::DiscardFrame ( size_t  texture_index)

Definition at line 199 of file surface.cc.

199 {
200 if (texture_index >= records_.size()) {
201 return;
202 }
203 auto record = records_[texture_index];
204 if (record) {
205 record->acquired = false;
206 }
207}

Referenced by InternalFlutterGpu_Surface_DiscardFrame().

◆ GetBackingTextureCount()

size_t flutter::gpu::Surface::GetBackingTextureCount ( ) const

Definition at line 233 of file surface.cc.

233 {
234 size_t count = 0;
235 for (const auto& record : records_) {
236 if (record) {
237 count++;
238 }
239 }
240 return count;
241}

Referenced by InternalFlutterGpu_Surface_GetBackingTextureCount().

◆ GetCurrentImage()

Dart_Handle flutter::gpu::Surface::GetCurrentImage ( ) const

Definition at line 209 of file surface.cc.

209 {
210 if (!current_index_.has_value() ||
211 current_index_.value() >= records_.size()) {
212 return Dart_Null();
213 }
214 auto record = records_[current_index_.value()];
215 if (!record) {
216 return Dart_Null();
217 }
218 return CreateImage(record->image);
219}

Referenced by InternalFlutterGpu_Surface_GetCurrentImage().

◆ PresentFrame()

Dart_Handle flutter::gpu::Surface::PresentFrame ( size_t  texture_index,
CommandBuffer command_buffer 
)

Definition at line 168 of file surface.cc.

169 {
170 if (texture_index >= records_.size()) {
171 return tonic::ToDart("SurfaceFrame does not belong to this GpuSurface.");
172 }
173
174 auto record = records_[texture_index];
175 if (!record || !record->acquired) {
176 return tonic::ToDart(
177 "SurfaceFrame has already been presented or discarded.");
178 }
179
180 record->producer_pending.store(true);
181 if (!command_buffer.AddCompletionCallback(
182 [record]([[maybe_unused]] impeller::CommandBuffer::Status status) {
183 record->producer_pending.store(false);
184 })) {
185 record->producer_pending.store(false);
186 return tonic::ToDart(
187 "SurfaceFrame.present must be called before submitting the command "
188 "buffer.");
189 }
190
191 record->acquired = false;
192 current_index_ = texture_index;
193 PruneTextureRecords();
194 // The presented image is read separately via GetCurrentImage, so avoid
195 // allocating an image wrapper here on every presented frame.
196 return Dart_Null();
197}
Dart_Handle ToDart(const T &object)
std::shared_ptr< CommandBuffer > command_buffer

References command_buffer, and tonic::ToDart().

Referenced by InternalFlutterGpu_Surface_PresentFrame().

◆ Resize()

std::optional< std::string > flutter::gpu::Surface::Resize ( impeller::ISize  size)

Definition at line 221 of file surface.cc.

221 {
222 for (const auto& record : records_) {
223 if (record && record->acquired) {
224 return "GpuSurface.resize cannot be called while a SurfaceFrame is "
225 "acquired.";
226 }
227 }
228 size_ = size;
229 PruneTextureRecords();
230 return std::nullopt;
231}

References flutter::size.

Referenced by InternalFlutterGpu_Surface_Resize().


The documentation for this class was generated from the following files: