Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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 381 of file gpu_surface_metal_impeller.mm.

381 {
382 if (!(last_texture_ && [last_texture_ conformsToProtocol:@protocol(MTLTexture)])) {
383 return {};
384 }
385 id<MTLTexture> texture = last_texture_;
386 int bytesPerPixel = 0;
387 std::string pixel_format;
388 switch (texture.pixelFormat) {
389 case MTLPixelFormatBGR10_XR:
390 bytesPerPixel = 4;
391 pixel_format = "MTLPixelFormatBGR10_XR";
392 break;
393 case MTLPixelFormatBGRA10_XR:
394 bytesPerPixel = 8;
395 pixel_format = "MTLPixelFormatBGRA10_XR";
396 break;
397 case MTLPixelFormatBGRA8Unorm:
398 bytesPerPixel = 4;
399 pixel_format = "MTLPixelFormatBGRA8Unorm";
400 break;
401 case MTLPixelFormatRGBA16Float:
402 bytesPerPixel = 8;
403 pixel_format = "MTLPixelFormatRGBA16Float";
404 break;
405 default:
406 return {};
407 }
408
409 // Zero initialized so that errors are easier to find at the cost of
410 // performance.
411 sk_sp<SkData> result =
412 SkData::MakeZeroInitialized(texture.width * texture.height * bytesPerPixel);
413 [texture getBytes:result->writable_data()
414 bytesPerRow:texture.width * bytesPerPixel
415 fromRegion:MTLRegionMake2D(0, 0, texture.width, texture.height)
416 mipmapLevel:0];
417 return {
418 .pixel_format = pixel_format,
419 .data = result,
420 };
421}
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: