Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | List of all members
flutter::EmbedderSurfaceMetal Class Referencefinal

#include <embedder_surface_metal.h>

Inheritance diagram for flutter::EmbedderSurfaceMetal:
flutter::EmbedderSurface flutter::GPUSurfaceMetalDelegate

Classes

struct  MetalDispatchTable
 

Public Member Functions

 EmbedderSurfaceMetal (GPUMTLDeviceHandle device, GPUMTLCommandQueueHandle command_queue, MetalDispatchTable dispatch_table, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
 
 ~EmbedderSurfaceMetal () override
 
- Public Member Functions inherited from flutter::EmbedderSurface
 EmbedderSurface ()
 
virtual ~EmbedderSurface ()
 
virtual std::shared_ptr< impeller::ContextCreateImpellerContext () const
 
- Public Member Functions inherited from flutter::GPUSurfaceMetalDelegate
 GPUSurfaceMetalDelegate (MTLRenderTargetType render_target)
 Construct a new GPUSurfaceMetalDelegate object with the specified render_target type.
 
virtual ~GPUSurfaceMetalDelegate ()
 
virtual bool AllowsDrawingWhenGpuDisabled () const
 Whether to allow drawing to the surface when the GPU is disabled.
 
MTLRenderTargetType GetRenderTargetType ()
 

Private Member Functions

bool IsValid () const override
 
std::unique_ptr< SurfaceCreateGPUSurface () override
 
sk_sp< GrDirectContextCreateResourceContext () const override
 
GPUCAMetalLayerHandle GetCAMetalLayer (const SkISize &frame_size) const override
 Returns the handle to the CAMetalLayer to render to. This is only called when the specified render target type is kCAMetalLayer.
 
bool PresentDrawable (GrMTLHandle drawable) const override
 Presents the drawable to the "screen". The drawable is obtained from the CAMetalLayer that given by GetCAMetalLayer call. This is only called when the specified render target type in kCAMetalLayer.
 
GPUMTLTextureInfo GetMTLTexture (const SkISize &frame_size) const override
 Returns the handle to the MTLTexture to render to. This is only called when the specified render target type is kMTLTexture.
 
bool PresentTexture (GPUMTLTextureInfo texture) const override
 Presents the texture with texture_id to the "screen". texture_id corresponds to a texture that has been obtained by an earlier call to GetMTLTexture. This is only called when the specified render target type is kMTLTexture.
 

Detailed Description

Definition at line 18 of file embedder_surface_metal.h.

Constructor & Destructor Documentation

◆ EmbedderSurfaceMetal()

flutter::EmbedderSurfaceMetal::EmbedderSurfaceMetal ( GPUMTLDeviceHandle  device,
GPUMTLCommandQueueHandle  command_queue,
MetalDispatchTable  dispatch_table,
std::shared_ptr< EmbedderExternalViewEmbedder external_view_embedder 
)

Definition at line 17 of file embedder_surface_metal.mm.

23 metal_dispatch_table_(std::move(metal_dispatch_table)),
24 external_view_embedder_(std::move(external_view_embedder)) {
25 main_context_ =
26 [FlutterDarwinContextMetalSkia createGrContext:(id<MTLDevice>)device
27 commandQueue:(id<MTLCommandQueue>)command_queue];
28 resource_context_ =
29 [FlutterDarwinContextMetalSkia createGrContext:(id<MTLDevice>)device
30 commandQueue:(id<MTLCommandQueue>)command_queue];
31 valid_ = main_context_ && resource_context_;
32}
GPUSurfaceMetalDelegate(MTLRenderTargetType render_target)
Construct a new GPUSurfaceMetalDelegate object with the specified render_target type.
VkDevice device
Definition main.cc:53
const uintptr_t id

◆ ~EmbedderSurfaceMetal()

flutter::EmbedderSurfaceMetal::~EmbedderSurfaceMetal ( )
overridedefault

Member Function Documentation

◆ CreateGPUSurface()

std::unique_ptr< Surface > flutter::EmbedderSurfaceMetal::CreateGPUSurface ( )
overrideprivatevirtual

Implements flutter::EmbedderSurface.

Definition at line 40 of file embedder_surface_metal.mm.

40 {
41 if (@available(iOS 13.0, *)) {
42 } else {
43 return nullptr;
44 }
45 if (!IsValid()) {
46 return nullptr;
47 }
48
49 const bool render_to_surface = !external_view_embedder_;
50 auto surface = std::make_unique<GPUSurfaceMetalSkia>(this, main_context_, MsaaSampleCount::kNone,
51 render_to_surface);
52
53 if (!surface->IsValid()) {
54 return nullptr;
55 }
56
57 return surface;
58}
VkSurfaceKHR surface
Definition main.cc:49

◆ CreateResourceContext()

sk_sp< GrDirectContext > flutter::EmbedderSurfaceMetal::CreateResourceContext ( ) const
overrideprivatevirtual

Reimplemented from flutter::EmbedderSurface.

Definition at line 60 of file embedder_surface_metal.mm.

60 {
61 return resource_context_;
62}

◆ GetCAMetalLayer()

GPUCAMetalLayerHandle flutter::EmbedderSurfaceMetal::GetCAMetalLayer ( const SkISize frame_info) const
overrideprivatevirtual

Returns the handle to the CAMetalLayer to render to. This is only called when the specified render target type is kCAMetalLayer.

Implements flutter::GPUSurfaceMetalDelegate.

Definition at line 64 of file embedder_surface_metal.mm.

64 {
65 FML_CHECK(false) << "Only rendering to MTLTexture is supported.";
66 return nullptr;
67}
#define FML_CHECK(condition)
Definition logging.h:85

◆ GetMTLTexture()

GPUMTLTextureInfo flutter::EmbedderSurfaceMetal::GetMTLTexture ( const SkISize frame_info) const
overrideprivatevirtual

Returns the handle to the MTLTexture to render to. This is only called when the specified render target type is kMTLTexture.

Implements flutter::GPUSurfaceMetalDelegate.

Definition at line 74 of file embedder_surface_metal.mm.

74 {
75 return metal_dispatch_table_.get_texture(frame_info);
76}
std::function< GPUMTLTextureInfo(const SkISize &frame_size)> get_texture

◆ IsValid()

bool flutter::EmbedderSurfaceMetal::IsValid ( ) const
overrideprivatevirtual

Implements flutter::EmbedderSurface.

Definition at line 36 of file embedder_surface_metal.mm.

36 {
37 return valid_;
38}

◆ PresentDrawable()

bool flutter::EmbedderSurfaceMetal::PresentDrawable ( GrMTLHandle  drawable) const
overrideprivatevirtual

Presents the drawable to the "screen". The drawable is obtained from the CAMetalLayer that given by GetCAMetalLayer call. This is only called when the specified render target type in kCAMetalLayer.

See also
|GPUSurfaceMetalDelegateGetCAMetalLayer|

Implements flutter::GPUSurfaceMetalDelegate.

Definition at line 69 of file embedder_surface_metal.mm.

69 {
70 FML_CHECK(false) << "Only rendering to MTLTexture is supported.";
71 return false;
72}

◆ PresentTexture()

bool flutter::EmbedderSurfaceMetal::PresentTexture ( GPUMTLTextureInfo  texture) const
overrideprivatevirtual

Presents the texture with texture_id to the "screen". texture_id corresponds to a texture that has been obtained by an earlier call to GetMTLTexture. This is only called when the specified render target type is kMTLTexture.

See also
|GPUSurfaceMetalDelegateGetMTLTexture|

Implements flutter::GPUSurfaceMetalDelegate.

Definition at line 78 of file embedder_surface_metal.mm.

78 {
79 return metal_dispatch_table_.present(texture);
80}
FlTexture * texture
std::function< bool(GPUMTLTextureInfo texture)> present

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