aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/exp/shiny
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/exp/shiny')
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/driver_darwin.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/driver_fallback.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/driver_x11.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.go5
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.m1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/gldriver/context.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/gldriver/other.go3
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/gldriver/win32.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/gldriver/x11.c2
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/gldriver/x11.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/internal/swizzle/swizzle_other.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/internal/win32/key.go5
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/internal/win32/win32.go8
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/buffer.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.go13
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.h4
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/appkit/appkit.m2
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.go13
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.h3
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/internal/coreanim/coreanim.m2
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/mtldriver.go15
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/screen.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/texture.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver/window.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/mtldriver_darwin.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/windriver/buffer.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/windriver/other.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/windriver/screen.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/windriver/texture.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/windriver/window.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/windriver/windraw.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/windriver/windriver.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/buffer.go5
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/buffer_fallback.go123
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/screen.go22
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/shm_linux_ipc.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/shm_openbsd_syscall.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/shm_other.go5
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/shm_shmopen_syscall.go1
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/texture.go2
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/window.go2
-rw-r--r--vendor/golang.org/x/exp/shiny/driver/x11driver/x11driver.go6
42 files changed, 209 insertions, 54 deletions
diff --git a/vendor/golang.org/x/exp/shiny/driver/driver_darwin.go b/vendor/golang.org/x/exp/shiny/driver/driver_darwin.go
index ee59ac6..3eebcf7 100644
--- a/vendor/golang.org/x/exp/shiny/driver/driver_darwin.go
+++ b/vendor/golang.org/x/exp/shiny/driver/driver_darwin.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 && !metal
// +build darwin,!metal
package driver
diff --git a/vendor/golang.org/x/exp/shiny/driver/driver_fallback.go b/vendor/golang.org/x/exp/shiny/driver/driver_fallback.go
index 450aef8..e36fbc5 100644
--- a/vendor/golang.org/x/exp/shiny/driver/driver_fallback.go
+++ b/vendor/golang.org/x/exp/shiny/driver/driver_fallback.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 && (!linux || android) && !windows && !dragonfly && !openbsd
// +build !darwin
// +build !linux android
// +build !windows
diff --git a/vendor/golang.org/x/exp/shiny/driver/driver_x11.go b/vendor/golang.org/x/exp/shiny/driver/driver_x11.go
index cd91d38..bc24238 100644
--- a/vendor/golang.org/x/exp/shiny/driver/driver_x11.go
+++ b/vendor/golang.org/x/exp/shiny/driver/driver_x11.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 (linux && !android) || dragonfly || openbsd
// +build linux,!android dragonfly openbsd
package driver
diff --git a/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.go b/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.go
index b258bdc..e13ac80 100644
--- a/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.go
+++ b/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.go
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin
-// +build 386 amd64
-// +build !ios
+//go:build darwin && !ios
+// +build darwin,!ios
package gldriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.m b/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.m
index a013764..2c8fd83 100644
--- a/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.m
+++ b/vendor/golang.org/x/exp/shiny/driver/gldriver/cocoa.m
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
// +build darwin
-// +build 386 amd64
// +build !ios
#include "_cgo_export.h"
diff --git a/vendor/golang.org/x/exp/shiny/driver/gldriver/context.go b/vendor/golang.org/x/exp/shiny/driver/gldriver/context.go
index 197be35..274d799 100644
--- a/vendor/golang.org/x/exp/shiny/driver/gldriver/context.go
+++ b/vendor/golang.org/x/exp/shiny/driver/gldriver/context.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 !android
// +build !android
package gldriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/gldriver/other.go b/vendor/golang.org/x/exp/shiny/driver/gldriver/other.go
index c1d92ea..0a04425 100644
--- a/vendor/golang.org/x/exp/shiny/driver/gldriver/other.go
+++ b/vendor/golang.org/x/exp/shiny/driver/gldriver/other.go
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !darwin !386,!amd64 ios !cgo
+//go:build (!darwin || ios || !cgo) && (!linux || android || !cgo) && (!openbsd || !cgo) && !windows
+// +build !darwin ios !cgo
// +build !linux android !cgo
// +build !openbsd !cgo
// +build !windows
diff --git a/vendor/golang.org/x/exp/shiny/driver/gldriver/win32.go b/vendor/golang.org/x/exp/shiny/driver/gldriver/win32.go
index 343fb45..8ece242 100644
--- a/vendor/golang.org/x/exp/shiny/driver/gldriver/win32.go
+++ b/vendor/golang.org/x/exp/shiny/driver/gldriver/win32.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 windows
// +build windows
package gldriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.c b/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.c
index dff6d2d..e7fb289 100644
--- a/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.c
+++ b/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.c
@@ -6,6 +6,8 @@
#include "_cgo_export.h"
#include <EGL/egl.h>
+#include <X11/Xlib.h> // for Atom, Colormap, Display, Window
+#include <X11/Xutil.h> // for XVisualInfo
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.go b/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.go
index 7aaeaff..4847e85 100644
--- a/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.go
+++ b/vendor/golang.org/x/exp/shiny/driver/gldriver/x11.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 (linux && !android) || openbsd
// +build linux,!android openbsd
package gldriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/internal/swizzle/swizzle_other.go b/vendor/golang.org/x/exp/shiny/driver/internal/swizzle/swizzle_other.go
index 5f3264d..f1c2726 100644
--- a/vendor/golang.org/x/exp/shiny/driver/internal/swizzle/swizzle_other.go
+++ b/vendor/golang.org/x/exp/shiny/driver/internal/swizzle/swizzle_other.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 !amd64
// +build !amd64
package swizzle
diff --git a/vendor/golang.org/x/exp/shiny/driver/internal/win32/key.go b/vendor/golang.org/x/exp/shiny/driver/internal/win32/key.go
index c7b9e38..a5748c3 100644
--- a/vendor/golang.org/x/exp/shiny/driver/internal/win32/key.go
+++ b/vendor/golang.org/x/exp/shiny/driver/internal/win32/key.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 windows
// +build windows
package win32
@@ -332,14 +333,14 @@ func sendKeyEvent(hwnd syscall.Handle, uMsg uint32, wParam, lParam uintptr) (lRe
Modifiers: keyModifiers(),
}
switch uMsg {
- case _WM_KEYDOWN:
+ case _WM_KEYDOWN, _WM_SYSKEYDOWN:
const prevMask = 1 << 30
if repeat := lParam&prevMask == prevMask; repeat {
e.Direction = key.DirNone
} else {
e.Direction = key.DirPress
}
- case _WM_KEYUP:
+ case _WM_KEYUP, _WM_SYSKEYUP:
e.Direction = key.DirRelease
default:
panic(fmt.Sprintf("win32: unexpected key message: %d", uMsg))
diff --git a/vendor/golang.org/x/exp/shiny/driver/internal/win32/win32.go b/vendor/golang.org/x/exp/shiny/driver/internal/win32/win32.go
index 6925085..22a6013 100644
--- a/vendor/golang.org/x/exp/shiny/driver/internal/win32/win32.go
+++ b/vendor/golang.org/x/exp/shiny/driver/internal/win32/win32.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 windows
// +build windows
// Package win32 implements a partial shiny screen driver using the Win32 API.
@@ -331,9 +332,10 @@ var windowMsgs = map[uint32]func(hwnd syscall.Handle, uMsg uint32, wParam, lPara
_WM_MOUSEMOVE: sendMouseEvent,
_WM_MOUSEWHEEL: sendMouseEvent,
- _WM_KEYDOWN: sendKeyEvent,
- _WM_KEYUP: sendKeyEvent,
- // TODO case _WM_SYSKEYDOWN, _WM_SYSKEYUP:
+ _WM_KEYDOWN: sendKeyEvent,
+ _WM_KEYUP: sendKeyEvent,
+ _WM_SYSKEYDOWN: sendKeyEvent,
+ _WM_SYSKEYUP: sendKeyEvent,
}
func AddWindowMsg(fn func(hwnd syscall.Handle, uMsg uint32, wParam, lParam uintptr)) uint32 {
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
diff --git a/vendor/golang.org/x/exp/shiny/driver/mtldriver_darwin.go b/vendor/golang.org/x/exp/shiny/driver/mtldriver_darwin.go
index d94e633..a30cd27 100644
--- a/vendor/golang.org/x/exp/shiny/driver/mtldriver_darwin.go
+++ b/vendor/golang.org/x/exp/shiny/driver/mtldriver_darwin.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 && metal
// +build darwin,metal
package driver
diff --git a/vendor/golang.org/x/exp/shiny/driver/windriver/buffer.go b/vendor/golang.org/x/exp/shiny/driver/windriver/buffer.go
index a55fd38..eeff378 100644
--- a/vendor/golang.org/x/exp/shiny/driver/windriver/buffer.go
+++ b/vendor/golang.org/x/exp/shiny/driver/windriver/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 windows
// +build windows
package windriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/windriver/other.go b/vendor/golang.org/x/exp/shiny/driver/windriver/other.go
index ebc09a6..2da4c44 100644
--- a/vendor/golang.org/x/exp/shiny/driver/windriver/other.go
+++ b/vendor/golang.org/x/exp/shiny/driver/windriver/other.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 !windows
// +build !windows
package windriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/windriver/screen.go b/vendor/golang.org/x/exp/shiny/driver/windriver/screen.go
index 3e84345..148b4ef 100644
--- a/vendor/golang.org/x/exp/shiny/driver/windriver/screen.go
+++ b/vendor/golang.org/x/exp/shiny/driver/windriver/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 windows
// +build windows
package windriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/windriver/texture.go b/vendor/golang.org/x/exp/shiny/driver/windriver/texture.go
index 0155a66..6fbfff5 100644
--- a/vendor/golang.org/x/exp/shiny/driver/windriver/texture.go
+++ b/vendor/golang.org/x/exp/shiny/driver/windriver/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 windows
// +build windows
package windriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/windriver/window.go b/vendor/golang.org/x/exp/shiny/driver/windriver/window.go
index c66cd47..9577f2c 100644
--- a/vendor/golang.org/x/exp/shiny/driver/windriver/window.go
+++ b/vendor/golang.org/x/exp/shiny/driver/windriver/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 windows
// +build windows
package windriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/windriver/windraw.go b/vendor/golang.org/x/exp/shiny/driver/windriver/windraw.go
index 363b733..b5e6b15 100644
--- a/vendor/golang.org/x/exp/shiny/driver/windriver/windraw.go
+++ b/vendor/golang.org/x/exp/shiny/driver/windriver/windraw.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 windows
// +build windows
package windriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/windriver/windriver.go b/vendor/golang.org/x/exp/shiny/driver/windriver/windriver.go
index 9f3bfa3..73a5420 100644
--- a/vendor/golang.org/x/exp/shiny/driver/windriver/windriver.go
+++ b/vendor/golang.org/x/exp/shiny/driver/windriver/windriver.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 windows
// +build windows
package windriver
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/buffer.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/buffer.go
index c479639..a905928 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/buffer.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/buffer.go
@@ -16,10 +16,13 @@ import (
"github.com/BurntSushi/xgb/render"
"github.com/BurntSushi/xgb/shm"
"github.com/BurntSushi/xgb/xproto"
-
"golang.org/x/exp/shiny/driver/internal/swizzle"
)
+type bufferUploader interface {
+ upload(xd xproto.Drawable, xg xproto.Gcontext, depth uint8, dp image.Point, sr image.Rectangle)
+}
+
type bufferImpl struct {
s *screenImpl
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/buffer_fallback.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/buffer_fallback.go
new file mode 100644
index 0000000..bfdd9c7
--- /dev/null
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/buffer_fallback.go
@@ -0,0 +1,123 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package x11driver
+
+import (
+ "image"
+ "sync"
+
+ "github.com/BurntSushi/xgb"
+ "github.com/BurntSushi/xgb/xproto"
+ "golang.org/x/exp/shiny/driver/internal/swizzle"
+)
+
+const (
+ xPutImageReqSizeMax = (1 << 16) * 4
+ xPutImageReqSizeFixed = 28
+ xPutImageReqDataSize = xPutImageReqSizeMax - xPutImageReqSizeFixed
+)
+
+type bufferFallbackImpl struct {
+ xc *xgb.Conn
+
+ buf []byte
+ rgba image.RGBA
+ size image.Point
+
+ mu sync.Mutex
+ nUpload uint32
+ released bool
+}
+
+func (b *bufferFallbackImpl) Size() image.Point { return b.size }
+func (b *bufferFallbackImpl) Bounds() image.Rectangle { return image.Rectangle{Max: b.size} }
+func (b *bufferFallbackImpl) RGBA() *image.RGBA { return &b.rgba }
+
+func (b *bufferFallbackImpl) preUpload() {
+ // Check that the program hasn't tried to modify the rgba field via the
+ // pointer returned by the bufferFallbackImpl.RGBA method. This check doesn't catch
+ // 100% of all cases; it simply tries to detect some invalid uses of a
+ // screen.Buffer such as:
+ // *buffer.RGBA() = anotherImageRGBA
+ if len(b.buf) != 0 && len(b.rgba.Pix) != 0 && &b.buf[0] != &b.rgba.Pix[0] {
+ panic("x11driver: invalid Buffer.RGBA modification")
+ }
+
+ b.mu.Lock()
+ defer b.mu.Unlock()
+
+ if b.released {
+ panic("x11driver: Buffer.Upload called after Buffer.Release")
+ }
+ if b.nUpload == 0 {
+ swizzle.BGRA(b.buf)
+ }
+ b.nUpload++
+}
+
+func (b *bufferFallbackImpl) postUpload() {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+
+ b.nUpload--
+ if b.nUpload != 0 {
+ return
+ }
+
+ if !b.released {
+ swizzle.BGRA(b.buf)
+ }
+}
+
+func (b *bufferFallbackImpl) Release() {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+
+ b.released = true
+}
+
+func (b *bufferFallbackImpl) upload(xd xproto.Drawable, xg xproto.Gcontext, depth uint8, dp image.Point, sr image.Rectangle) {
+ originalSRMin := sr.Min
+ sr = sr.Intersect(b.Bounds())
+ if sr.Empty() {
+ return
+ }
+ dp = dp.Add(sr.Min.Sub(originalSRMin))
+ b.preUpload()
+
+ b.putImage(xd, xg, depth, dp, sr)
+
+ b.postUpload()
+}
+
+// putImage issues xproto.PutImage requests in batches.
+func (b *bufferFallbackImpl) putImage(xd xproto.Drawable, xg xproto.Gcontext, depth uint8, dp image.Point, sr image.Rectangle) {
+ widthPerReq := b.size.X
+ rowPerReq := xPutImageReqDataSize / (widthPerReq * 4)
+ dataPerReq := rowPerReq * widthPerReq * 4
+ dstX := dp.X
+ dstY := dp.Y
+ start := 0
+ end := 0
+
+ for end < len(b.buf) {
+ end = start + dataPerReq
+ if end > len(b.buf) {
+ end = len(b.buf)
+ }
+
+ data := b.buf[start:end]
+ heightPerReq := len(data) / (widthPerReq * 4)
+
+ xproto.PutImage(
+ b.xc, xproto.ImageFormatZPixmap, xd, xg,
+ uint16(widthPerReq), uint16(heightPerReq),
+ int16(dstX), int16(dstY),
+ 0, depth, data)
+
+ start = end
+ dstY += rowPerReq
+ }
+}
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/screen.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/screen.go
index 7e0d3bb..0d0374b 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/screen.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/screen.go
@@ -51,6 +51,7 @@ type screenImpl struct {
// opaqueP is a fully opaque, solid fill picture.
opaqueP render.Picture
+ useShm bool
uniformMu sync.Mutex
uniformC render.Color
@@ -64,13 +65,14 @@ type screenImpl struct {
completionKeys []uint16
}
-func newScreenImpl(xc *xgb.Conn) (*screenImpl, error) {
+func newScreenImpl(xc *xgb.Conn, useShm bool) (*screenImpl, error) {
s := &screenImpl{
xc: xc,
xsi: xproto.Setup(xc).DefaultScreen(xc),
buffers: map[shm.Seg]*bufferImpl{},
uploads: map[uint16]chan struct{}{},
windows: map[xproto.Window]*windowImpl{},
+ useShm: useShm,
}
if err := s.initAtoms(); err != nil {
return nil, err
@@ -282,14 +284,28 @@ const (
)
func (s *screenImpl) NewBuffer(size image.Point) (retBuf screen.Buffer, retErr error) {
- // TODO: detect if the X11 server or connection cannot support SHM pixmaps,
- // and fall back to regular pixmaps.
w, h := int64(size.X), int64(size.Y)
if w < 0 || maxShmSide < w || h < 0 || maxShmSide < h || maxShmSize < 4*w*h {
return nil, fmt.Errorf("x11driver: invalid buffer size %v", size)
}
+ // If the X11 server or connection cannot support SHM pixmaps,
+ // fall back to regular pixmaps.
+ if !s.useShm {
+ b := &bufferFallbackImpl{
+ xc: s.xc,
+ size: size,
+ rgba: image.RGBA{
+ Stride: 4 * size.X,
+ Rect: image.Rectangle{Max: size},
+ Pix: make([]uint8, 4*size.X*size.Y),
+ },
+ }
+ b.buf = b.rgba.Pix
+ return b, nil
+ }
+
b := &bufferImpl{
s: s,
rgba: image.RGBA{
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_linux_ipc.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_linux_ipc.go
index 025f3ff..23fe9a4 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_linux_ipc.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_linux_ipc.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 linux && (386 || ppc64 || ppc64le || s390x)
// +build linux
// +build 386 ppc64 ppc64le s390x
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_openbsd_syscall.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_openbsd_syscall.go
index 573c78b..d42cb4c 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_openbsd_syscall.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_openbsd_syscall.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 openbsd && (i386 || amd64)
// +build openbsd
// +build i386 amd64
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_other.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_other.go
index d09994f..fa071c3 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_other.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_other.go
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !linux
-// +build !dragonfly
-// +build !openbsd
+//go:build !linux && !dragonfly && !openbsd
+// +build !linux,!dragonfly,!openbsd
package x11driver
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_shmopen_syscall.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_shmopen_syscall.go
index 23f9026..45d7373 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_shmopen_syscall.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/shm_shmopen_syscall.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 (linux || dragonfly) && (amd64 || arm || arm64 || mips64 || mips64le)
// +build linux dragonfly
// +build amd64 arm arm64 mips64 mips64le
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/texture.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/texture.go
index da6fc86..8ca4759 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/texture.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/texture.go
@@ -59,7 +59,7 @@ func (t *textureImpl) Upload(dp image.Point, src screen.Buffer, sr image.Rectang
if t.degenerate() {
return
}
- src.(*bufferImpl).upload(xproto.Drawable(t.xm), t.s.gcontext32, textureDepth, dp, sr)
+ src.(bufferUploader).upload(xproto.Drawable(t.xm), t.s.gcontext32, textureDepth, dp, sr)
}
func (t *textureImpl) Fill(dr image.Rectangle, src color.Color, op draw.Op) {
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/window.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/window.go
index 5ebdbcd..f77b876 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/window.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/window.go
@@ -67,7 +67,7 @@ func (w *windowImpl) Release() {
}
func (w *windowImpl) Upload(dp image.Point, src screen.Buffer, sr image.Rectangle) {
- src.(*bufferImpl).upload(xproto.Drawable(w.xw), w.xg, w.s.xsi.RootDepth, dp, sr)
+ src.(bufferUploader).upload(xproto.Drawable(w.xw), w.xg, w.s.xsi.RootDepth, dp, sr)
}
func (w *windowImpl) Fill(dr image.Rectangle, src color.Color, op draw.Op) {
diff --git a/vendor/golang.org/x/exp/shiny/driver/x11driver/x11driver.go b/vendor/golang.org/x/exp/shiny/driver/x11driver/x11driver.go
index 29d2b0d..1ba227e 100644
--- a/vendor/golang.org/x/exp/shiny/driver/x11driver/x11driver.go
+++ b/vendor/golang.org/x/exp/shiny/driver/x11driver/x11driver.go
@@ -47,11 +47,13 @@ func main(f func(screen.Screen)) (retErr error) {
if err := render.Init(xc); err != nil {
return fmt.Errorf("x11driver: render.Init failed: %v", err)
}
+
+ useShm := true
if err := shm.Init(xc); err != nil {
- return fmt.Errorf("x11driver: shm.Init failed: %v", err)
+ useShm = false
}
- s, err := newScreenImpl(xc)
+ s, err := newScreenImpl(xc, useShm)
if err != nil {
return err
}