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

#include <ios_surface_metal_impeller.h>

Inheritance diagram for flutter::IOSSurfaceMetalImpeller:
flutter::IOSSurface flutter::GPUSurfaceMetalDelegate

Public Member Functions

 IOSSurfaceMetalImpeller (const fml::scoped_nsobject< CAMetalLayer > &layer, const std::shared_ptr< IOSContext > &context)
 
 ~IOSSurfaceMetalImpeller ()
 
- Public Member Functions inherited from flutter::IOSSurface
std::shared_ptr< IOSContextGetContext () const
 
virtual ~IOSSurface ()
 
- Public Member Functions inherited from flutter::GPUSurfaceMetalDelegate
 GPUSurfaceMetalDelegate (MTLRenderTargetType render_target)
 Construct a new GPUSurfaceMetalDelegate object with the specified render_target type.
 
virtual ~GPUSurfaceMetalDelegate ()
 
MTLRenderTargetType GetRenderTargetType ()
 

Private Member Functions

bool IsValid () const override
 
void UpdateStorageSizeIfNecessary () override
 
std::unique_ptr< SurfaceCreateGPUSurface (GrDirectContext *gr_context) override
 
GPUCAMetalLayerHandle GetCAMetalLayer (const SkISize &frame_info) const override __attribute__((cf_audited_transfer))
 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 __attribute__((cf_audited_transfer))
 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_info) const override __attribute__((cf_audited_transfer))
 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 __attribute__((cf_audited_transfer))
 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.
 
bool AllowsDrawingWhenGpuDisabled () const override
 Whether to allow drawing to the surface when the GPU is disabled.
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::IOSSurface
static std::unique_ptr< IOSSurfaceCreate (std::shared_ptr< IOSContext > context, const fml::scoped_nsobject< CALayer > &layer)
 
- Protected Member Functions inherited from flutter::IOSSurface
 IOSSurface (std::shared_ptr< IOSContext > ios_context)
 

Detailed Description

Definition at line 20 of file ios_surface_metal_impeller.h.

Constructor & Destructor Documentation

◆ IOSSurfaceMetalImpeller()

flutter::IOSSurfaceMetalImpeller::IOSSurfaceMetalImpeller ( const fml::scoped_nsobject< CAMetalLayer > &  layer,
const std::shared_ptr< IOSContext > &  context 
)

Definition at line 15 of file ios_surface_metal_impeller.mm.

17 : IOSSurface(context),
19 layer_(layer),
20 impeller_context_(context ? context->GetImpellerContext() : nullptr) {
21 if (!impeller_context_) {
22 return;
23 }
24 is_valid_ = true;
25}
GPUSurfaceMetalDelegate(MTLRenderTargetType render_target)
Construct a new GPUSurfaceMetalDelegate object with the specified render_target type.
IOSSurface(std::shared_ptr< IOSContext > ios_context)

◆ ~IOSSurfaceMetalImpeller()

flutter::IOSSurfaceMetalImpeller::~IOSSurfaceMetalImpeller ( )
default

Member Function Documentation

◆ AllowsDrawingWhenGpuDisabled()

bool flutter::IOSSurfaceMetalImpeller::AllowsDrawingWhenGpuDisabled ( ) const
overrideprivatevirtual

Whether to allow drawing to the surface when the GPU is disabled.

Reimplemented from flutter::GPUSurfaceMetalDelegate.

Definition at line 94 of file ios_surface_metal_impeller.mm.

94 {
95 return false;
96}

◆ CreateGPUSurface()

std::unique_ptr< Surface > flutter::IOSSurfaceMetalImpeller::CreateGPUSurface ( GrDirectContext gr_context)
overrideprivatevirtual

Implements flutter::IOSSurface.

Definition at line 41 of file ios_surface_metal_impeller.mm.

41 {
42 impeller_context_->UpdateOffscreenLayerPixelFormat(
43 impeller::FromMTLPixelFormat(layer_.get().pixelFormat));
44 return std::make_unique<GPUSurfaceMetalImpeller>(this, //
45 impeller_context_ //
46 );
47}
T get() const __attribute((ns_returns_not_retained))
constexpr PixelFormat FromMTLPixelFormat(MTLPixelFormat format)
Definition formats_mtl.h:23

◆ GetCAMetalLayer()

GPUCAMetalLayerHandle flutter::IOSSurfaceMetalImpeller::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 50 of file ios_surface_metal_impeller.mm.

50 {
51 CAMetalLayer* layer = layer_.get();
52 const auto drawable_size = CGSizeMake(frame_info.width(), frame_info.height());
53 if (!CGSizeEqualToSize(drawable_size, layer.drawableSize)) {
54 layer.drawableSize = drawable_size;
55 }
56
57 // Flutter needs to read from the color attachment in cases where there are effects such as
58 // backdrop filters. Flutter plugins that create platform views may also read from the layer.
59 layer.framebufferOnly = NO;
60
61 // When there are platform views in the scene, the drawable needs to be presented in the same
62 // transaction as the one created for platform views. When the drawable are being presented from
63 // the raster thread, we may not be able to use a transaction as it will dirty the UIViews being
64 // presented. If there is a non-Flutter UIView active, such as in add2app or a
65 // presentViewController page transition, then this will cause CoreAnimation assertion errors and
66 // exit the app.
67 layer.presentsWithTransaction = [[NSThread currentThread] isMainThread];
68
69 return (__bridge GPUCAMetalLayerHandle)layer;
70}
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ GetMTLTexture()

GPUMTLTextureInfo flutter::IOSSurfaceMetalImpeller::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 79 of file ios_surface_metal_impeller.mm.

79 {
80 FML_CHECK(false);
81 return GPUMTLTextureInfo{
82 .texture_id = -1, //
83 .texture = nullptr //
84 };
85}
#define FML_CHECK(condition)
Definition logging.h:85

◆ IsValid()

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

Implements flutter::IOSSurface.

Definition at line 31 of file ios_surface_metal_impeller.mm.

31 {
32 return is_valid_;
33}

◆ PresentDrawable()

bool flutter::IOSSurfaceMetalImpeller::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 73 of file ios_surface_metal_impeller.mm.

73 {
74 FML_DCHECK(false);
75 return false;
76}
#define FML_DCHECK(condition)
Definition logging.h:103

◆ PresentTexture()

bool flutter::IOSSurfaceMetalImpeller::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 88 of file ios_surface_metal_impeller.mm.

88 {
89 FML_CHECK(false);
90 return false;
91}

◆ UpdateStorageSizeIfNecessary()

void flutter::IOSSurfaceMetalImpeller::UpdateStorageSizeIfNecessary ( )
overrideprivatevirtual

Implements flutter::IOSSurface.

Definition at line 36 of file ios_surface_metal_impeller.mm.

36 {
37 // Nothing to do.
38}

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