Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions shell/platform/darwin/macos/framework/Source/FlutterSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ - (instancetype)initWithSize:(CGSize)size device:(id<MTLDevice>)device {
return self;
}

static void ReleaseSurface(void* surface) {
if (surface != nullptr) {
CFBridgingRelease(surface);
}
}

- (FlutterMetalTexture)asFlutterMetalTexture {
FlutterMetalTexture res;
memset(&res, 0, sizeof(FlutterMetalTexture));
res.struct_size = sizeof(FlutterMetalTexture);
res.texture = (__bridge void*)_texture;
res.texture_id = self.textureId;
res.user_data = (void*)CFBridgingRetain(self);
res.destruction_callback = ReleaseSurface;
return res;
return FlutterMetalTexture{
.struct_size = sizeof(FlutterMetalTexture),
.texture_id = self.textureId,
.texture = (__bridge void*)_texture,
// Retain for use in [FlutterSurface fromFlutterMetalTexture]. Released in
// destruction_callback.
.user_data = (__bridge_retained void*)self,
.destruction_callback =
[](void* user_data) {
// Balancing release for the retain when setting user_data above.
FlutterSurface* surface = (__bridge_transfer FlutterSurface*)user_data;
surface = nil;
},
};
}

+ (FlutterSurface*)fromFlutterMetalTexture:(const FlutterMetalTexture*)texture {
Expand Down