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

#include <gpu_surface_metal_skia.h>

Inheritance diagram for flutter::GPUSurfaceMetalSkia:
flutter::Surface

Public Member Functions

 GPUSurfaceMetalSkia (GPUSurfaceMetalDelegate *delegate, sk_sp< GrDirectContext > context, MsaaSampleCount msaa_samples, bool render_to_surface=true)
 
 ~GPUSurfaceMetalSkia ()
 
bool IsValid () override
 
- Public Member Functions inherited from flutter::Surface
 Surface ()
 
virtual ~Surface ()
 
virtual bool ClearRenderContext ()
 
virtual bool EnableRasterCache () const
 
virtual std::shared_ptr< impeller::AiksContextGetAiksContext () const
 
virtual SurfaceData GetSurfaceData () const
 

Private Member Functions

std::unique_ptr< SurfaceFrameAcquireFrame (const SkISize &size) override
 
SkMatrix GetRootTransformation () const override
 
GrDirectContextGetContext () override
 
std::unique_ptr< GLContextResultMakeRenderContextCurrent () override
 
bool AllowsDrawingWhenGpuDisabled () const override
 

Detailed Description

Definition at line 16 of file gpu_surface_metal_skia.h.

Constructor & Destructor Documentation

◆ GPUSurfaceMetalSkia()

flutter::GPUSurfaceMetalSkia::GPUSurfaceMetalSkia ( GPUSurfaceMetalDelegate delegate,
sk_sp< GrDirectContext context,
MsaaSampleCount  msaa_samples,
bool  render_to_surface = true 
)

Definition at line 58 of file gpu_surface_metal_skia.mm.

62 : delegate_(delegate),
63 render_target_type_(delegate->GetRenderTargetType()),
64 context_(std::move(context)),
65 msaa_samples_(msaa_samples),
66 render_to_surface_(render_to_surface) {
67 // If this preference is explicitly set, we allow for disabling partial repaint.
68 NSNumber* disablePartialRepaint =
69 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTDisablePartialRepaint"];
70 if (disablePartialRepaint != nil) {
71 disable_partial_repaint_ = disablePartialRepaint.boolValue;
72 }
73}

◆ ~GPUSurfaceMetalSkia()

flutter::GPUSurfaceMetalSkia::~GPUSurfaceMetalSkia ( )
default

Member Function Documentation

◆ AcquireFrame()

std::unique_ptr< SurfaceFrame > flutter::GPUSurfaceMetalSkia::AcquireFrame ( const SkISize size)
overrideprivatevirtual

Implements flutter::Surface.

Definition at line 93 of file gpu_surface_metal_skia.mm.

93 {
94 if (!IsValid()) {
95 FML_LOG(ERROR) << "Metal surface was invalid.";
96 return nullptr;
97 }
98
99 if (frame_size.isEmpty()) {
100 FML_LOG(ERROR) << "Metal surface was asked for an empty frame.";
101 return nullptr;
102 }
103
104 if (!render_to_surface_) {
105 return std::make_unique<SurfaceFrame>(
106 nullptr, SurfaceFrame::FramebufferInfo(),
107 [](const SurfaceFrame& surface_frame, DlCanvas* canvas) { return true; }, frame_size);
108 }
109
110 PrecompileKnownSkSLsIfNecessary();
111
112 switch (render_target_type_) {
114 return AcquireFrameFromCAMetalLayer(frame_size);
116 return AcquireFrameFromMTLTexture(frame_size);
117 default:
118 FML_CHECK(false) << "Unknown MTLRenderTargetType type.";
119 }
120
121 return nullptr;
122}
#define FML_LOG(severity)
Definition logging.h:82
#define FML_CHECK(condition)
Definition logging.h:85
#define ERROR(message)

◆ AllowsDrawingWhenGpuDisabled()

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

Reimplemented from flutter::Surface.

Definition at line 270 of file gpu_surface_metal_skia.mm.

270 {
271 return delegate_->AllowsDrawingWhenGpuDisabled();
272}
virtual bool AllowsDrawingWhenGpuDisabled() const
Whether to allow drawing to the surface when the GPU is disabled.

◆ GetContext()

GrDirectContext * flutter::GPUSurfaceMetalSkia::GetContext ( )
overrideprivatevirtual

Implements flutter::Surface.

Definition at line 256 of file gpu_surface_metal_skia.mm.

256 {
257 return context_.get();
258}
T * get() const
Definition SkRefCnt.h:303

◆ GetRootTransformation()

SkMatrix flutter::GPUSurfaceMetalSkia::GetRootTransformation ( ) const
overrideprivatevirtual

Implements flutter::Surface.

Definition at line 249 of file gpu_surface_metal_skia.mm.

249 {
250 // This backend does not currently support root surface transformations. Just
251 // return identity.
252 return {};
253}

◆ IsValid()

bool flutter::GPUSurfaceMetalSkia::IsValid ( )
overridevirtual

Implements flutter::Surface.

Definition at line 78 of file gpu_surface_metal_skia.mm.

78 {
79 return context_ != nullptr;
80}

◆ MakeRenderContextCurrent()

std::unique_ptr< GLContextResult > flutter::GPUSurfaceMetalSkia::MakeRenderContextCurrent ( )
overrideprivatevirtual

Reimplemented from flutter::Surface.

Definition at line 261 of file gpu_surface_metal_skia.mm.

261 {
262 // A context may either be necessary to render to the surface or to snapshot an offscreen
263 // surface. Either way, SkSL precompilation must be attempted.
264 PrecompileKnownSkSLsIfNecessary();
265
266 // This backend has no such concept.
267 return std::make_unique<GLContextDefaultResult>(true);
268}

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