Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
surface.h File Reference
#include <atomic>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "dart_api.h"
#include "flutter/display_list/image/dl_image.h"
#include "flutter/lib/gpu/command_buffer.h"
#include "flutter/lib/gpu/context.h"
#include "flutter/lib/gpu/export.h"
#include "flutter/lib/gpu/texture.h"
#include "flutter/lib/ui/dart_wrapper.h"
#include "impeller/core/formats.h"
#include "impeller/core/texture.h"
#include "impeller/geometry/size.h"
#include "impeller/renderer/context.h"

Go to the source code of this file.

Classes

class  flutter::gpu::Surface
 

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_Initialize (Dart_Handle wrapper, flutter::gpu::Context *gpu_context, int width, int height, int format)
 
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Surface_AcquireNextFrame (flutter::gpu::Surface *wrapper, Dart_Handle texture_wrapper)
 
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_PresentFrame (flutter::gpu::Surface *wrapper, int texture_index, flutter::gpu::CommandBuffer *command_buffer)
 
FLUTTER_GPU_EXPORT void InternalFlutterGpu_Surface_DiscardFrame (flutter::gpu::Surface *wrapper, int texture_index)
 
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_GetCurrentImage (flutter::gpu::Surface *wrapper)
 
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_Resize (flutter::gpu::Surface *wrapper, int width, int height)
 
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Surface_GetBackingTextureCount (flutter::gpu::Surface *wrapper)
 

Function Documentation

◆ InternalFlutterGpu_Surface_AcquireNextFrame()

FLUTTER_GPU_EXPORT int InternalFlutterGpu_Surface_AcquireNextFrame ( flutter::gpu::Surface wrapper,
Dart_Handle  texture_wrapper 
)
extern

Definition at line 276 of file surface.cc.

277 {
278 return wrapper->AcquireNextFrame(texture_wrapper);
279}
int AcquireNextFrame(Dart_Handle texture_wrapper)
Definition surface.cc:124

References flutter::gpu::Surface::AcquireNextFrame().

◆ InternalFlutterGpu_Surface_DiscardFrame()

FLUTTER_GPU_EXPORT void InternalFlutterGpu_Surface_DiscardFrame ( flutter::gpu::Surface wrapper,
int  texture_index 
)
extern

Definition at line 292 of file surface.cc.

293 {
294 if (texture_index < 0) {
295 return;
296 }
297 wrapper->DiscardFrame(static_cast<size_t>(texture_index));
298}
void DiscardFrame(size_t texture_index)
Definition surface.cc:199

References flutter::gpu::Surface::DiscardFrame().

◆ InternalFlutterGpu_Surface_GetBackingTextureCount()

FLUTTER_GPU_EXPORT int InternalFlutterGpu_Surface_GetBackingTextureCount ( flutter::gpu::Surface wrapper)
extern

Definition at line 318 of file surface.cc.

319 {
320 return static_cast<int>(wrapper->GetBackingTextureCount());
321}
size_t GetBackingTextureCount() const
Definition surface.cc:233

References flutter::gpu::Surface::GetBackingTextureCount().

◆ InternalFlutterGpu_Surface_GetCurrentImage()

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_GetCurrentImage ( flutter::gpu::Surface wrapper)
extern

Definition at line 300 of file surface.cc.

301 {
302 return wrapper->GetCurrentImage();
303}
Dart_Handle GetCurrentImage() const
Definition surface.cc:209

References flutter::gpu::Surface::GetCurrentImage().

◆ InternalFlutterGpu_Surface_Initialize()

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_Initialize ( Dart_Handle  wrapper,
flutter::gpu::Context gpu_context,
int  width,
int  height,
int  format 
)
extern

Exports

Definition at line 250 of file surface.cc.

255 {
256 if (width <= 0 || height <= 0) {
257 return tonic::ToDart("GpuSurface dimensions must be greater than zero.");
258 }
259
260#if !IMPELLER_SUPPORTS_RENDERING
261 return tonic::ToDart("GpuSurface requires Impeller rendering support.");
262#else
263 auto pixel_format = flutter::gpu::ToImpellerPixelFormat(format);
264 if (pixel_format == impeller::PixelFormat::kUnknown) {
265 return tonic::ToDart("Unsupported GpuSurface pixel format.");
266 }
267
268 auto res = fml::MakeRefCounted<flutter::gpu::Surface>(
269 gpu_context->GetContextShared(), impeller::ISize{width, height},
270 pixel_format);
271 res->AssociateWithDartWrapper(wrapper);
272 return Dart_Null();
273#endif
274}
std::shared_ptr< impeller::Context > & GetContextShared()
Definition context.cc:91
constexpr impeller::PixelFormat ToImpellerPixelFormat(FlutterGPUPixelFormat value)
Definition formats.h:104
Dart_Handle ToDart(const T &object)
int32_t height
int32_t width

References format, height, impeller::kUnknown, tonic::ToDart(), flutter::gpu::ToImpellerPixelFormat(), and width.

◆ InternalFlutterGpu_Surface_PresentFrame()

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_PresentFrame ( flutter::gpu::Surface wrapper,
int  texture_index,
flutter::gpu::CommandBuffer command_buffer 
)
extern

Definition at line 281 of file surface.cc.

284 {
285 if (texture_index < 0) {
286 return tonic::ToDart("Invalid SurfaceFrame texture index.");
287 }
288 return wrapper->PresentFrame(static_cast<size_t>(texture_index),
290}
Dart_Handle PresentFrame(size_t texture_index, CommandBuffer &command_buffer)
Definition surface.cc:168
std::shared_ptr< CommandBuffer > command_buffer

References command_buffer, flutter::gpu::Surface::PresentFrame(), and tonic::ToDart().

◆ InternalFlutterGpu_Surface_Resize()

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_Surface_Resize ( flutter::gpu::Surface wrapper,
int  width,
int  height 
)
extern

Definition at line 305 of file surface.cc.

307 {
308 if (width <= 0 || height <= 0) {
309 return tonic::ToDart("GpuSurface dimensions must be greater than zero.");
310 }
311 auto error = wrapper->Resize(impeller::ISize{width, height});
312 if (error.has_value()) {
313 return tonic::ToDart(error.value());
314 }
315 return Dart_Null();
316}
std::optional< std::string > Resize(impeller::ISize size)
Definition surface.cc:221
const uint8_t uint32_t uint32_t GError ** error

References error, height, flutter::gpu::Surface::Resize(), tonic::ToDart(), and width.