7#import <CoreMedia/CoreMedia.h>
25- (IOSurfaceRef)ioSurface {
34 return reinterpret_cast<int64_t
>(
_texture);
38 return _isInUseOverride || IOSurfaceIsInUse(_ioSurface);
45- (
BOOL)isInUseOverride {
46 return _isInUseOverride;
49- (void)setIsInUseOverride:(
BOOL)isInUseOverride {
53- (instancetype)initWithSize:(CGSize)size
54 device:(
id<MTLDevice>)device
55 enableWideGamut:(
BOOL)enableWideGamut {
56 if (
self = [super init]) {
58 self->_isWideGamut = enableWideGamut;
60 enableWideGamut:enableWideGamut]);
61 MTLPixelFormat pixelFormat =
62 enableWideGamut ? MTLPixelFormatBGRA10_XR : MTLPixelFormatBGRA8Unorm;
66 pixelFormat:pixelFormat];
78 .user_data = (__bridge_retained
void*)
self,
79 .destruction_callback =
92+ (IOSurfaceRef)createIOSurfaceWithSize:(CGSize)size enableWideGamut:(
BOOL)enableWideGamut {
94 unsigned bytesPerElement;
95 if (enableWideGamut) {
97 pixelFormat = kCVPixelFormatType_40ARGBLEWideGamut;
100 pixelFormat = kCVPixelFormatType_32BGRA;
104 size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow,
size.width * bytesPerElement);
105 size_t totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize,
size.height * bytesPerRow);
106 NSDictionary* options = @{
109 (
id)kIOSurfacePixelFormat : @(pixelFormat),
110 (
id)kIOSurfaceBytesPerElement : @(bytesPerElement),
111 (
id)kIOSurfaceBytesPerRow : @(bytesPerRow),
112 (
id)kIOSurfaceAllocSize : @(totalBytes),
115 IOSurfaceRef res = IOSurfaceCreate((CFDictionaryRef)options);
116 if (enableWideGamut) {
117 IOSurfaceSetValue(res, kIOSurfaceColorSpace, kCGColorSpaceExtendedSRGB);
119 IOSurfaceSetValue(res, kIOSurfaceColorSpace, kCGColorSpaceSRGB);
124+ (
id<MTLTexture>)createTextureForIOSurface:(IOSurfaceRef)surface
126 device:(
id<MTLDevice>)device
127 pixelFormat:(MTLPixelFormat)pixelFormat {
128 MTLTextureDescriptor* textureDescriptor =
129 [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pixelFormat
133 textureDescriptor.usage =
134 MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget | MTLTextureUsageShaderWrite;
136 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).