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

#include <embedder_surface_metal_impeller.h>

Inheritance diagram for flutter::EmbedderSurfaceMetalImpeller:
flutter::EmbedderSurface flutter::GPUSurfaceMetalDelegate

Classes

struct  MetalDispatchTable
 

Public Member Functions

 EmbedderSurfaceMetalImpeller (GPUMTLDeviceHandle device, GPUMTLCommandQueueHandle command_queue, MetalDispatchTable dispatch_table, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
 
 ~EmbedderSurfaceMetalImpeller () override
 
- Public Member Functions inherited from flutter::EmbedderSurface
 EmbedderSurface ()
 
virtual ~EmbedderSurface ()
 
virtual sk_sp< GrDirectContextCreateResourceContext () 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
 
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.
 
std::shared_ptr< impeller::ContextCreateImpellerContext () const override
 

Detailed Description

Definition at line 22 of file embedder_surface_metal_impeller.h.

Constructor & Destructor Documentation

◆ EmbedderSurfaceMetalImpeller()

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

Definition at line 28 of file embedder_surface_metal_impeller.mm.

34 metal_dispatch_table_(std::move(metal_dispatch_table)),
35 external_view_embedder_(std::move(external_view_embedder)) {
36 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
37 std::make_shared<fml::NonOwnedMapping>(impeller_entity_shaders_data,
38 impeller_entity_shaders_length),
39#if IMPELLER_ENABLE_3D
40 std::make_shared<fml::NonOwnedMapping>(impeller_scene_shaders_data,
41 impeller_scene_shaders_length),
42#endif // IMPELLER_ENABLE_3D
43 std::make_shared<fml::NonOwnedMapping>(impeller_modern_shaders_data,
44 impeller_modern_shaders_length),
45 std::make_shared<fml::NonOwnedMapping>(impeller_framebuffer_blend_shaders_data,
46 impeller_framebuffer_blend_shaders_length),
47 };
49 (id<MTLDevice>)device, // device
50 (id<MTLCommandQueue>)command_queue, // command_queue
51 shader_mappings, // shader_libraries_data
52 std::make_shared<fml::SyncSwitch>(false), // is_gpu_disabled_sync_switch
53 "Impeller Library" // library_label
54 );
55 FML_LOG(IMPORTANT) << "Using the Impeller rendering backend (Metal).";
56
57 valid_ = !!context_;
58}
GPUSurfaceMetalDelegate(MTLRenderTargetType render_target)
Construct a new GPUSurfaceMetalDelegate object with the specified render_target type.
static std::shared_ptr< ContextMTL > Create(const std::vector< std::string > &shader_library_paths, std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)
VkDevice device
Definition main.cc:53
#define FML_LOG(severity)
Definition logging.h:82

◆ ~EmbedderSurfaceMetalImpeller()

flutter::EmbedderSurfaceMetalImpeller::~EmbedderSurfaceMetalImpeller ( )
overridedefault

Member Function Documentation

◆ CreateGPUSurface()

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

Implements flutter::EmbedderSurface.

Definition at line 66 of file embedder_surface_metal_impeller.mm.

67 {
68 if (!IsValid()) {
69 return nullptr;
70 }
71
72 const bool render_to_surface = !external_view_embedder_;
73 auto surface = std::make_unique<GPUSurfaceMetalImpeller>(this, context_, render_to_surface);
74
75 if (!surface->IsValid()) {
76 return nullptr;
77 }
78
79 return surface;
80}
VkSurfaceKHR surface
Definition main.cc:49

◆ CreateImpellerContext()

std::shared_ptr< impeller::Context > flutter::EmbedderSurfaceMetalImpeller::CreateImpellerContext ( ) const
overrideprivatevirtual

Reimplemented from flutter::EmbedderSurface.

Definition at line 82 of file embedder_surface_metal_impeller.mm.

82 {
83 return context_;
84}

◆ GetCAMetalLayer()

GPUCAMetalLayerHandle flutter::EmbedderSurfaceMetalImpeller::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 86 of file embedder_surface_metal_impeller.mm.

87 {
88 FML_CHECK(false) << "Only rendering to MTLTexture is supported.";
89 return nullptr;
90}
#define FML_CHECK(condition)
Definition logging.h:85

◆ GetMTLTexture()

GPUMTLTextureInfo flutter::EmbedderSurfaceMetalImpeller::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 97 of file embedder_surface_metal_impeller.mm.

97 {
98 return metal_dispatch_table_.get_texture(frame_info);
99}
std::function< GPUMTLTextureInfo(const SkISize &frame_size)> get_texture

◆ IsValid()

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

Implements flutter::EmbedderSurface.

Definition at line 62 of file embedder_surface_metal_impeller.mm.

62 {
63 return valid_;
64}

◆ PresentDrawable()

bool flutter::EmbedderSurfaceMetalImpeller::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 92 of file embedder_surface_metal_impeller.mm.

92 {
93 FML_CHECK(false) << "Only rendering to MTLTexture is supported.";
94 return false;
95}

◆ PresentTexture()

bool flutter::EmbedderSurfaceMetalImpeller::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 101 of file embedder_surface_metal_impeller.mm.

101 {
102 return metal_dispatch_table_.present(texture);
103}
FlTexture * texture

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