Flutter Engine
 
Loading...
Searching...
No Matches
flutter::GPUSurfaceMetalImpeller Class Reference

#include <gpu_surface_metal_impeller.h>

Inheritance diagram for flutter::GPUSurfaceMetalImpeller:
flutter::Surface

Public Member Functions

 GPUSurfaceMetalImpeller (GPUSurfaceMetalDelegate *delegate, const std::shared_ptr< impeller::AiksContext > &context, bool render_to_surface=true)
 
 ~GPUSurfaceMetalImpeller ()
 
bool IsValid () override
 
virtual Surface::SurfaceData GetSurfaceData () const override
 
- Public Member Functions inherited from flutter::Surface
 Surface ()
 
virtual ~Surface ()
 
virtual bool ClearRenderContext ()
 

Detailed Description

Definition at line 20 of file gpu_surface_metal_impeller.h.

Constructor & Destructor Documentation

◆ GPUSurfaceMetalImpeller()

flutter::GPUSurfaceMetalImpeller::GPUSurfaceMetalImpeller ( GPUSurfaceMetalDelegate delegate,
const std::shared_ptr< impeller::AiksContext > &  context,
bool  render_to_surface = true 
)

Definition at line 26 of file gpu_surface_metal_impeller.mm.

30 : delegate_(delegate),
31 render_target_type_(delegate->GetRenderTargetType()),
32 aiks_context_(context),
33 render_to_surface_(render_to_surface) {
34 // If this preference is explicitly set, we allow for disabling partial repaint.
35 NSNumber* disablePartialRepaint =
36 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTDisablePartialRepaint"];
37 if (disablePartialRepaint != nil) {
38 disable_partial_repaint_ = disablePartialRepaint.boolValue;
39 }
40 if (aiks_context_) {
41 swapchain_transients_ = std::make_shared<impeller::SwapchainTransientsMTL>(
42 aiks_context_->GetContext()->GetResourceAllocator());
43 }
44}

◆ ~GPUSurfaceMetalImpeller()

flutter::GPUSurfaceMetalImpeller::~GPUSurfaceMetalImpeller ( )
default

Member Function Documentation

◆ GetSurfaceData()

Surface::SurfaceData flutter::GPUSurfaceMetalImpeller::GetSurfaceData ( ) const
overridevirtual

Capture the SurfaceData currently present in the surface.

Not guaranteed to work on all setups and not intended to be used in production. The data field will be null if it was unable to work.

Reimplemented from flutter::Surface.

Definition at line 370 of file gpu_surface_metal_impeller.mm.

370 {
371 if (!(last_texture_ && [last_texture_ conformsToProtocol:@protocol(MTLTexture)])) {
372 return {};
373 }
374 id<MTLTexture> texture = last_texture_;
375 int bytesPerPixel = 0;
376 std::string pixel_format;
377 switch (texture.pixelFormat) {
378 case MTLPixelFormatBGR10_XR:
379 bytesPerPixel = 4;
380 pixel_format = "MTLPixelFormatBGR10_XR";
381 break;
382 case MTLPixelFormatBGRA10_XR:
383 bytesPerPixel = 8;
384 pixel_format = "MTLPixelFormatBGRA10_XR";
385 break;
386 case MTLPixelFormatBGRA8Unorm:
387 bytesPerPixel = 4;
388 pixel_format = "MTLPixelFormatBGRA8Unorm";
389 break;
390 case MTLPixelFormatRGBA16Float:
391 bytesPerPixel = 8;
392 pixel_format = "MTLPixelFormatRGBA16Float";
393 break;
394 default:
395 return {};
396 }
397
398 // Zero initialized so that errors are easier to find at the cost of
399 // performance.
400 sk_sp<SkData> result =
401 SkData::MakeZeroInitialized(texture.width * texture.height * bytesPerPixel);
402 [texture getBytes:result->writable_data()
403 bytesPerRow:texture.width * bytesPerPixel
404 fromRegion:MTLRegionMake2D(0, 0, texture.width, texture.height)
405 mipmapLevel:0];
406 return {
407 .pixel_format = pixel_format,
408 .data = result,
409 };
410}
FlTexture * texture

References texture.

◆ IsValid()

bool flutter::GPUSurfaceMetalImpeller::IsValid ( )
overridevirtual

Implements flutter::Surface.

Definition at line 49 of file gpu_surface_metal_impeller.mm.

49 {
50 return !!aiks_context_ && aiks_context_->IsValid();
51}

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