7#import <CoreMedia/CoreMedia.h>
23- (IOSurfaceRef)ioSurface {
32 return reinterpret_cast<int64_t
>(
_texture);
36 return _isInUseOverride || IOSurfaceIsInUse(_ioSurface);
39- (
BOOL)isInUseOverride {
40 return _isInUseOverride;
43- (void)setIsInUseOverride:(
BOOL)isInUseOverride {
47- (instancetype)initWithSize:(CGSize)size device:(
id<MTLDevice>)device {
48 if (
self = [super init]) {
51 self->_texture = [
FlutterSurface createTextureForIOSurface:_ioSurface size:size device:device];
63 .user_data = (__bridge_retained
void*)
self,
64 .destruction_callback =
77+ (IOSurfaceRef)createIOSurfaceWithSize:(CGSize)size {
78 unsigned pixelFormat = kCVPixelFormatType_32BGRA;
79 unsigned bytesPerElement = 4;
81 size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow,
size.width * bytesPerElement);
82 size_t totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize,
size.height * bytesPerRow);
83 NSDictionary* options = @{
86 (
id)kIOSurfacePixelFormat : @(pixelFormat),
87 (
id)kIOSurfaceBytesPerElement : @(bytesPerElement),
88 (
id)kIOSurfaceBytesPerRow : @(bytesPerRow),
89 (
id)kIOSurfaceAllocSize : @(totalBytes),
92 IOSurfaceRef res = IOSurfaceCreate((CFDictionaryRef)options);
93 IOSurfaceSetValue(res, kIOSurfaceColorSpace, kCGColorSpaceSRGB);
97+ (
id<MTLTexture>)createTextureForIOSurface:(IOSurfaceRef)surface
99 device:(
id<MTLDevice>)device {
100 MTLTextureDescriptor* textureDescriptor =
101 [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
105 textureDescriptor.usage =
106 MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget | MTLTextureUsageShaderWrite;
108 return [device newTextureWithDescriptor:textureDescriptor iosurface:surface plane:0];
id< FlutterTexture > _texture
fml::CFRef< IOSurfaceRef > _ioSurface
id< MTLTexture > _texture
FlutterMetalTexture asFlutterMetalTexture()
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
size_t struct_size
The size of this struct. Must be sizeof(FlutterMetalTexture).