fix iOS
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
import Foundation
|
||||
import Foundation
|
||||
import GLKit
|
||||
|
||||
@objc public class DartFilamentTexture : NSObject {
|
||||
|
||||
var pixelBuffer: CVPixelBuffer?
|
||||
public var pixelBuffer: CVPixelBuffer?
|
||||
|
||||
var pixelBufferAttrs = [
|
||||
kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_32ABGR ),
|
||||
// kCVPixelBufferOpenGLCompatibilityKey: kCFBooleanTrue!,
|
||||
kCVPixelBufferIOSurfacePropertiesKey: [:] as CFDictionary
|
||||
] as CFDictionary
|
||||
kCVPixelBufferOpenGLCompatibilityKey: kCFBooleanFalse!,
|
||||
// kCVPixelBufferIOSurfacePropertiesKey: [Any:Any] as CFDictionary
|
||||
] as [CFString : Any] as CFDictionary
|
||||
|
||||
@objc public var cvMetalTextureCache:CVMetalTextureCache?
|
||||
@objc public var cvMetalTexture:CVMetalTexture?
|
||||
@@ -19,7 +18,7 @@ import GLKit
|
||||
@objc public var metalTextureAddress:Int = -1
|
||||
|
||||
@objc override public init() {
|
||||
print("VAnilla init")
|
||||
|
||||
}
|
||||
|
||||
@objc public init(width:Int64, height:Int64) {
|
||||
|
||||
33
flutter_filament/macos/Classes/FlutterFilamentTexture.swift
Normal file
33
flutter_filament/macos/Classes/FlutterFilamentTexture.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
import Foundation
|
||||
import GLKit
|
||||
import FlutterMacOS
|
||||
|
||||
public class FlutterFilamentTexture : NSObject, FlutterTexture {
|
||||
|
||||
var texture:DartFilamentTexture
|
||||
var flutterTextureId: Int64 = -1
|
||||
var registry: FlutterTextureRegistry
|
||||
|
||||
init(registry:FlutterTextureRegistry, texture:DartFilamentTexture) {
|
||||
self.texture = texture
|
||||
self.registry = registry
|
||||
super.init()
|
||||
|
||||
self.flutterTextureId = registry.register(self)
|
||||
|
||||
}
|
||||
|
||||
public func copyPixelBuffer() -> Unmanaged<CVPixelBuffer>? {
|
||||
return Unmanaged.passRetained(texture.pixelBuffer!);
|
||||
}
|
||||
|
||||
public func onTextureUnregistered(_ texture:FlutterTexture) {
|
||||
print("Texture unregistered")
|
||||
}
|
||||
|
||||
public func destroy() {
|
||||
self.registry.unregisterTexture(self.flutterTextureId)
|
||||
self.texture.destroyTexture()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +1,6 @@
|
||||
import FlutterMacOS
|
||||
import GLKit
|
||||
|
||||
public class FlutterFilamentTexture : NSObject, FlutterTexture {
|
||||
|
||||
var texture:DartFilamentTexture
|
||||
var flutterTextureId: Int64 = -1
|
||||
var registry: FlutterTextureRegistry
|
||||
|
||||
init(registry:FlutterTextureRegistry, texture:DartFilamentTexture) {
|
||||
self.texture = texture
|
||||
self.registry = registry
|
||||
super.init()
|
||||
|
||||
self.flutterTextureId = registry.register(self)
|
||||
|
||||
}
|
||||
|
||||
public func copyPixelBuffer() -> Unmanaged<CVPixelBuffer>? {
|
||||
return Unmanaged.passRetained(texture.pixelBuffer!);
|
||||
}
|
||||
|
||||
public func onTextureUnregistered(_ texture:FlutterTexture) {
|
||||
print("Texture unregistered")
|
||||
}
|
||||
|
||||
public func destroy() {
|
||||
self.registry.unregisterTexture(self.flutterTextureId)
|
||||
self.texture.destroyTexture()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class SwiftFlutterFilamentPlugin: NSObject, FlutterPlugin {
|
||||
|
||||
var registrar : FlutterPluginRegistrar
|
||||
@@ -121,8 +91,6 @@ public class SwiftFlutterFilamentPlugin: NSObject, FlutterPlugin {
|
||||
result(nil)
|
||||
case "getSharedContext":
|
||||
result(nil)
|
||||
case "getWindow":
|
||||
result(nil)
|
||||
case "createTexture":
|
||||
let args = call.arguments as! [Any]
|
||||
let width = args[0] as! Int64
|
||||
@@ -131,7 +99,7 @@ public class SwiftFlutterFilamentPlugin: NSObject, FlutterPlugin {
|
||||
let texture = DartFilamentTexture(width: width, height: height)
|
||||
self.texture = FlutterFilamentTexture(registry: registry, texture: texture)
|
||||
|
||||
result([self.texture!.flutterTextureId as Any, texture.metalTextureAddress])
|
||||
result([self.texture!.flutterTextureId as Any, texture.metalTextureAddress, nil])
|
||||
case "destroyTexture":
|
||||
self.texture?.destroy()
|
||||
self.texture = nil
|
||||
|
||||
Reference in New Issue
Block a user