diff --git a/thermion_flutter/thermion_flutter/macos/Classes/ThermionFlutterTexture.swift b/thermion_flutter/thermion_flutter/macos/Classes/ThermionFlutterTexture.swift index 1a2f4c1d..57eea716 100644 --- a/thermion_flutter/thermion_flutter/macos/Classes/ThermionFlutterTexture.swift +++ b/thermion_flutter/thermion_flutter/macos/Classes/ThermionFlutterTexture.swift @@ -2,20 +2,24 @@ import Foundation import GLKit import FlutterMacOS -public class ThermionFlutterTexture : ThermionDartTexture, FlutterTexture { +public class ThermionFlutterTexture : NSObject, FlutterTexture { var flutterTextureId: Int64 = -1 var registry: FlutterTextureRegistry + var texture: ThermionDartTexture init(registry:FlutterTextureRegistry, width:Int64, height:Int64) { self.registry = registry - super.init(width:width, height:height) + self.texture = ThermionDartTexture(width:width, height: height) + super.init() self.flutterTextureId = registry.register(self) - } public func copyPixelBuffer() -> Unmanaged? { - return Unmanaged.passRetained(pixelBuffer!); + if(self.texture.pixelBuffer == nil) { + return nil + } + return Unmanaged.passRetained(self.texture.pixelBuffer!); } public func onTextureUnregistered(_ texture:FlutterTexture) { @@ -24,7 +28,7 @@ public class ThermionFlutterTexture : ThermionDartTexture, FlutterTexture { public func destroy() { self.registry.unregisterTexture(self.flutterTextureId) - self.destroyTexture() + self.texture.destroyTexture() } -} \ No newline at end of file +}