5#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurface.h"
29 return reinterpret_cast<int64_t
>(
_texture);
40- (void)setIsInUseOverride:(
BOOL)isInUseOverride {
44- (instancetype)initWithSize:(CGSize)size device:(
id<MTLDevice>)device {
45 if (
self = [super init]) {
75 CFRelease(_ioSurface);
78+ (IOSurfaceRef)createIOSurfaceWithSize:(CGSize)size {
79 unsigned pixelFormat =
'BGRA';
80 unsigned bytesPerElement = 4;
82 size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow,
size.width * bytesPerElement);
83 size_t totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize,
size.height * bytesPerRow);
87 (
id)kIOSurfacePixelFormat : @(pixelFormat),
88 (
id)kIOSurfaceBytesPerElement : @(bytesPerElement),
89 (
id)kIOSurfaceBytesPerRow : @(bytesPerRow),
90 (
id)kIOSurfaceAllocSize : @(totalBytes),
93 IOSurfaceRef res = IOSurfaceCreate((CFDictionaryRef)
options);
94 IOSurfaceSetValue(res, CFSTR(
"IOSurfaceColorSpace"), kCGColorSpaceSRGB);
98+ (
id<MTLTexture>)createTextureForIOSurface:(IOSurfaceRef)surface
100 device:(
id<MTLDevice>)device {
101 MTLTextureDescriptor* textureDescriptor =
102 [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
106 textureDescriptor.usage =
107 MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget | MTLTextureUsageShaderWrite;
109 return [device newTextureWithDescriptor:textureDescriptor iosurface:surface plane:0];
id< FlutterTexture > _texture
static void ReleaseSurface(void *surface)
FlutterMetalTexture asFlutterMetalTexture()
IOSurfaceRef createIOSurfaceWithSize:(CGSize size)
id< MTLTexture > _texture
id< MTLTexture > createTextureForIOSurface:size:device:(IOSurfaceRef surface, [size] CGSize size, [device] id< MTLDevice > device)
FlutterMetalTextureHandle texture
size_t struct_size
The size of this struct. Must be sizeof(FlutterMetalTexture).
VoidCallback destruction_callback