@@ -42,9 +42,9 @@ public final class SDLRenderer {
42
42
return ( red, green, blue, alpha)
43
43
}
44
44
45
- public func setDrawColor( _ newValue : ( red: UInt8 , green: UInt8 , blue: UInt8 , alpha: UInt8 ) ) throws {
45
+ public func setDrawColor( red: UInt8 , green: UInt8 , blue: UInt8 , alpha: UInt8 ) throws {
46
46
47
- try SDL_SetRenderDrawColor ( internalPointer, newValue . red, newValue . green, newValue . blue, newValue . alpha) . sdlThrow ( )
47
+ try SDL_SetRenderDrawColor ( internalPointer, red, green, blue, alpha) . sdlThrow ( )
48
48
}
49
49
50
50
/// Current rendering target texture.
@@ -90,35 +90,21 @@ public final class SDLRenderer {
90
90
}
91
91
92
92
/// Copy a portion of the texture to the current rendering target.
93
- public func copy( _ texture: SDLTexture , source: SDL_Rect ? = nil , destination: SDL_Rect ? = nil ) throws {
94
-
95
- let sourcePointer : UnsafeMutablePointer < SDL_Rect > ?
96
-
97
- defer { sourcePointer? . deallocate ( ) }
93
+ public func copy( _ texture: SDLTexture ,
94
+ source: SDL_Rect ? = nil ,
95
+ destination: SDL_Rect ? = nil ) throws {
98
96
97
+ let sourcePointer : UnsafePointer < SDL_Rect > ?
99
98
if let rect = source {
100
-
101
- sourcePointer = UnsafeMutablePointer . allocate ( capacity: 1 )
102
-
103
- sourcePointer? . pointee = rect
104
-
99
+ sourcePointer = withUnsafePointer ( to: rect) { $0 }
105
100
} else {
106
-
107
101
sourcePointer = nil
108
102
}
109
103
110
- let destinationPointer : UnsafeMutablePointer < SDL_Rect > ?
111
-
112
- defer { destinationPointer? . deallocate ( ) }
113
-
104
+ let destinationPointer : UnsafePointer < SDL_Rect > ?
114
105
if let rect = destination {
115
-
116
- destinationPointer = UnsafeMutablePointer . allocate ( capacity: 1 )
117
-
118
- destinationPointer? . pointee = rect
119
-
106
+ destinationPointer = withUnsafePointer ( to: rect) { $0 }
120
107
} else {
121
-
122
108
destinationPointer = nil
123
109
}
124
110
0 commit comments