mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
gpu,app: [Metal] don't store CFTypeRef values in pointer types
CFTypeRefs may not always contain valid pointers, so they must not be stored in pointer types lest the Go runtime treats them as such. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+3
-4
@@ -7,7 +7,6 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"gioui.org/gpu"
|
"gioui.org/gpu"
|
||||||
)
|
)
|
||||||
@@ -123,14 +122,14 @@ func (c *mtlContext) RenderTarget() (gpu.RenderTarget, error) {
|
|||||||
return nil, errors.New("metal: CADrawable.texture is nil")
|
return nil, errors.New("metal: CADrawable.texture is nil")
|
||||||
}
|
}
|
||||||
return gpu.MetalRenderTarget{
|
return gpu.MetalRenderTarget{
|
||||||
Texture: unsafe.Pointer(c.texture),
|
Texture: uintptr(c.texture),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *mtlContext) API() gpu.API {
|
func (c *mtlContext) API() gpu.API {
|
||||||
return gpu.Metal{
|
return gpu.Metal{
|
||||||
Device: unsafe.Pointer(c.dev),
|
Device: uintptr(c.dev),
|
||||||
Queue: unsafe.Pointer(c.queue),
|
Queue: uintptr(c.queue),
|
||||||
PixelFormat: int(C.MTLPixelFormatBGRA8Unorm_sRGB),
|
PixelFormat: int(C.MTLPixelFormatBGRA8Unorm_sRGB),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package headless
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"gioui.org/gpu"
|
"gioui.org/gpu"
|
||||||
_ "gioui.org/internal/cocoainit"
|
_ "gioui.org/internal/cocoainit"
|
||||||
@@ -54,8 +53,8 @@ func init() {
|
|||||||
|
|
||||||
func (c *mtlContext) API() gpu.API {
|
func (c *mtlContext) API() gpu.API {
|
||||||
return gpu.Metal{
|
return gpu.Metal{
|
||||||
Device: unsafe.Pointer(c.dev),
|
Device: uintptr(c.dev),
|
||||||
Queue: unsafe.Pointer(c.queue),
|
Queue: uintptr(c.queue),
|
||||||
PixelFormat: int(C.MTLPixelFormatRGBA8Unorm_sRGB),
|
PixelFormat: int(C.MTLPixelFormatRGBA8Unorm_sRGB),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ type Direct3D11RenderTarget struct {
|
|||||||
|
|
||||||
type MetalRenderTarget struct {
|
type MetalRenderTarget struct {
|
||||||
// Texture is a MTLTexture.
|
// Texture is a MTLTexture.
|
||||||
Texture unsafe.Pointer
|
Texture uintptr
|
||||||
}
|
}
|
||||||
|
|
||||||
type VulkanRenderTarget struct {
|
type VulkanRenderTarget struct {
|
||||||
@@ -59,9 +59,9 @@ type Direct3D11 struct {
|
|||||||
|
|
||||||
type Metal struct {
|
type Metal struct {
|
||||||
// Device is an MTLDevice.
|
// Device is an MTLDevice.
|
||||||
Device unsafe.Pointer
|
Device uintptr
|
||||||
// Queue is a MTLCommandQueue.
|
// Queue is a MTLCommandQueue.
|
||||||
Queue unsafe.Pointer
|
Queue uintptr
|
||||||
// PixelFormat is the MTLPixelFormat of the default framebuffer.
|
// PixelFormat is the MTLPixelFormat of the default framebuffer.
|
||||||
PixelFormat int
|
PixelFormat int
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user