diff options
Diffstat (limited to 'vendor/golang.org/x/exp/shiny/driver/mtldriver')
11 files changed, 23 insertions, 33 deletions
diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/buffer.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver/buffer.go index c9a10ed..987d75a 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/buffer.go +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/buffer.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin package mtldriver diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.go index f6f6d5d..7140f6f 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.go +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin // Package appkit provides access to Apple's AppKit API @@ -11,7 +12,7 @@ // It's a minimal implementation with scope limited to // supporting mtldriver. // -// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/ns. +// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/appkit. package appkit import ( @@ -21,6 +22,7 @@ import ( ) /* +#include <stdbool.h> #include "appkit.h" */ import "C" @@ -63,12 +65,5 @@ func (v View) SetLayer(l coreanim.Layer) { // // Reference: https://developer.apple.com/documentation/appkit/nsview/1483695-wantslayer. func (v View) SetWantsLayer(wantsLayer bool) { - C.View_SetWantsLayer(v.view, toCBool(wantsLayer)) -} - -func toCBool(b bool) C.BOOL { - if b { - return 1 - } - return 0 + C.View_SetWantsLayer(v.view, C.bool(wantsLayer)) } diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.h b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.h index eb3a92c..3a3e705 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.h +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.h @@ -4,9 +4,7 @@ // +build darwin -typedef signed char BOOL; - void * Window_ContentView(void * window); void View_SetLayer(void * view, void * layer); -void View_SetWantsLayer(void * view, BOOL wantsLayer); +void View_SetWantsLayer(void * view, bool wantsLayer); diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.m b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.m index 8bb74e3..4dec9db 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.m +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.m @@ -15,6 +15,6 @@ void View_SetLayer(void * view, void * layer) { ((NSView *)view).layer = (CALayer *)layer; } -void View_SetWantsLayer(void * view, BOOL wantsLayer) { +void View_SetWantsLayer(void * view, bool wantsLayer) { ((NSView *)view).wantsLayer = wantsLayer; } diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.go index 857c5e1..257b783 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.go +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin // Package coreanim provides access to Apple's Core Animation API @@ -11,7 +12,7 @@ // It's a minimal implementation with scope limited to // supporting mtldriver. // -// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/ca. +// It was copied from dmitri.shuralyov.com/gpu/mtl/example/movingtriangle/internal/coreanim. package coreanim import ( @@ -23,6 +24,7 @@ import ( /* #cgo LDFLAGS: -framework QuartzCore -framework Foundation +#include <stdbool.h> #include "coreanim.h" */ import "C" @@ -99,7 +101,7 @@ func (ml MetalLayer) SetMaximumDrawableCount(count int) { // // Reference: https://developer.apple.com/documentation/quartzcore/cametallayer/2887087-displaysyncenabled. func (ml MetalLayer) SetDisplaySyncEnabled(enabled bool) { - C.MetalLayer_SetDisplaySyncEnabled(ml.metalLayer, toCBool(enabled)) + C.MetalLayer_SetDisplaySyncEnabled(ml.metalLayer, C.bool(enabled)) } // SetDrawableSize sets the size, in pixels, of textures for rendering layer content. @@ -137,10 +139,3 @@ func (md MetalDrawable) Drawable() unsafe.Pointer { return md.metalDrawable } func (md MetalDrawable) Texture() mtl.Texture { return mtl.NewTexture(C.MetalDrawable_Texture(md.metalDrawable)) } - -func toCBool(b bool) C.BOOL { - if b { - return 1 - } - return 0 -} diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.h b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.h index 36cd06c..6e1ee2b 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.h +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.h @@ -4,7 +4,6 @@ // +build darwin -typedef signed char BOOL; typedef unsigned long uint_t; typedef unsigned short uint16_t; @@ -14,7 +13,7 @@ uint16_t MetalLayer_PixelFormat(void * metalLayer); void MetalLayer_SetDevice(void * metalLayer, void * device); const char * MetalLayer_SetPixelFormat(void * metalLayer, uint16_t pixelFormat); const char * MetalLayer_SetMaximumDrawableCount(void * metalLayer, uint_t maximumDrawableCount); -void MetalLayer_SetDisplaySyncEnabled(void * metalLayer, BOOL displaySyncEnabled); +void MetalLayer_SetDisplaySyncEnabled(void * metalLayer, bool displaySyncEnabled); void MetalLayer_SetDrawableSize(void * metalLayer, double width, double height); void * MetalLayer_NextDrawable(void * metalLayer); diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.m b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.m index 7aecf83..7848a84 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.m +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.m @@ -41,7 +41,7 @@ const char * MetalLayer_SetMaximumDrawableCount(void * metalLayer, uint_t maximu return NULL; } -void MetalLayer_SetDisplaySyncEnabled(void * metalLayer, BOOL displaySyncEnabled) { +void MetalLayer_SetDisplaySyncEnabled(void * metalLayer, bool displaySyncEnabled) { ((CAMetalLayer *)metalLayer).displaySyncEnabled = displaySyncEnabled; } diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/mtldriver.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver/mtldriver.go index 2c0e3c4..a926b92 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/mtldriver.go +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/mtldriver.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin // Package mtldriver provides a Metal driver for accessing a screen. @@ -55,6 +56,12 @@ func main(f func(screen.Screen)) error { } defer glfw.Terminate() glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI) + { + // TODO(dmitshur): Delete this when https://github.com/go-gl/glfw/issues/272 is resolved. + // Post an empty event from the main thread before it can happen in a non-main thread, + // to work around https://github.com/glfw/glfw/issues/1649. + glfw.PostEmptyEvent() + } var ( done = make(chan struct{}) newWindowCh = make(chan newWindowReq, 1) @@ -67,14 +74,6 @@ func main(f func(screen.Screen)) error { close(done) glfw.PostEmptyEvent() // Break main loop out of glfw.WaitEvents so it can receive on done. }() - select { - // TODO(dmitshur): Delete this when https://github.com/go-gl/glfw/issues/262 is resolved. - // Wait for first window request (or done) before entering main - // loop to work around https://github.com/glfw/glfw/issues/1543. - case w := <-newWindowCh: - newWindowCh <- w - case <-done: - } for { select { case <-done: diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/screen.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver/screen.go index 1828a4c..544de7c 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/screen.go +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/screen.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin package mtldriver diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/texture.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver/texture.go index 6a60dfd..60185ee 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/texture.go +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/texture.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin package mtldriver diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver/window.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver/window.go index 55f5a42..7bbb837 100644 --- a/vendor/golang.org/x/exp/shiny/driver/mtldriver/window.go +++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver/window.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin package mtldriver |