internal/cocoa, internal/graphicsdriver/mtl: remove usages of NSInvocations to directly call ID.Send (#2464)

purego now supports using floats as arguments.
We can remove these instances of NSInvocation that
only existed to circumvent that feature.

Updates #1162
This commit is contained in:
TotallyGamerJet 2022-11-20 06:48:22 -08:00 committed by GitHub
parent 9a75e266d4
commit fb612ab443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 18 deletions

View File

@ -108,16 +108,7 @@ type NSColor struct {
} }
func NSColor_colorWithSRGBRedGreenBlueAlpha(red, green, blue, alpha CGFloat) (color NSColor) { func NSColor_colorWithSRGBRedGreenBlueAlpha(red, green, blue, alpha CGFloat) (color NSColor) {
sig := NSMethodSignature_signatureWithObjCTypes("@@:ffff") return NSColor{objc.ID(class_NSColor).Send(sel_colorWithSRGBRedGreenBlueAlpha, red, green, blue, alpha)}
inv := NSInvocation_invocationWithMethodSignature(sig)
inv.SetSelector(sel_colorWithSRGBRedGreenBlueAlpha)
inv.SetArgumentAtIndex(unsafe.Pointer(&red), 2)
inv.SetArgumentAtIndex(unsafe.Pointer(&green), 3)
inv.SetArgumentAtIndex(unsafe.Pointer(&blue), 4)
inv.SetArgumentAtIndex(unsafe.Pointer(&alpha), 5)
inv.InvokeWithTarget(objc.ID(class_NSColor))
inv.GetReturnValue(unsafe.Pointer(&color))
return color
} }
type NSOperatingSystemVersion struct { type NSOperatingSystemVersion struct {

View File

@ -910,14 +910,7 @@ func (rce RenderCommandEncoder) SetFragmentTexture(texture Texture, index int) {
} }
func (rce RenderCommandEncoder) SetBlendColor(red, green, blue, alpha float32) { func (rce RenderCommandEncoder) SetBlendColor(red, green, blue, alpha float32) {
inv := cocoa.NSInvocation_invocationWithMethodSignature(cocoa.NSMethodSignature_signatureWithObjCTypes("v@:ffff")) rce.commandEncoder.Send(sel_setBlendColorRedGreenBlueAlpha, red, green, blue, alpha)
inv.SetTarget(rce.commandEncoder)
inv.SetSelector(sel_setBlendColorRedGreenBlueAlpha)
inv.SetArgumentAtIndex(unsafe.Pointer(&red), 2)
inv.SetArgumentAtIndex(unsafe.Pointer(&green), 3)
inv.SetArgumentAtIndex(unsafe.Pointer(&blue), 4)
inv.SetArgumentAtIndex(unsafe.Pointer(&alpha), 5)
inv.Invoke()
} }
// SetDepthStencilState sets the depth and stencil test state. // SetDepthStencilState sets the depth and stencil test state.