File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Sources/FlutterSwift/Client Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -43,23 +43,28 @@ private func _releaseAnyObject(_ anyObjectPtr: UnsafeMutableRawPointer?) {
43
43
}
44
44
45
45
public class FlutterPixelBuffer {
46
- public var buffer : [ UInt8 ]
46
+ public var buffer : UnsafeMutablePointer < UInt8 >
47
47
public var width : Int
48
48
public var height : Int
49
49
50
50
private var _desktopPixelBuffer = FlutterDesktopPixelBuffer ( )
51
51
52
52
public init ( width: Int , height: Int ) {
53
- buffer = [ UInt8] ( repeating: 0 , count: width * height)
53
+ buffer = UnsafeMutablePointer< UInt8> . allocate( capacity: width * height)
54
+ buffer. initialize ( repeating: 0 , count: width * height)
54
55
self . width = width
55
56
self . height = height
56
57
}
57
58
59
+ deinit {
60
+ buffer. deallocate ( )
61
+ }
62
+
58
63
fileprivate func getDesktopPixelBufferTextureConfig(
59
64
width: Int ,
60
65
height: Int
61
66
) -> UnsafePointer < FlutterDesktopPixelBuffer > {
62
- buffer . withUnsafeBufferPointer { _desktopPixelBuffer. buffer = $0 . baseAddress! }
67
+ _desktopPixelBuffer. buffer = UnsafePointer ( buffer )
63
68
_desktopPixelBuffer. width = self . width
64
69
_desktopPixelBuffer. height = self . height
65
70
_desktopPixelBuffer. release_context = _retainAnyObject ( self )
You can’t perform that action at this time.
0 commit comments