forked from joejulian/gio
Compare commits
361 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 718be79d9e | |||
| 0073e1a167 | |||
| 32ecec5538 | |||
| 6eb33b8a56 | |||
| 4617526e12 | |||
| dbc7a900bd | |||
| fb3ae95b28 | |||
| c458eb30f0 | |||
| d96c954769 | |||
| f39245df99 | |||
| 8097df9930 | |||
| fc6e51deba | |||
| 5fa94ff67b | |||
| 23b6f06e3e | |||
| c8801fe233 | |||
| 3fde0c0061 | |||
| 9d89f7c8b1 | |||
| 48bd5952b1 | |||
| df8a8789a3 | |||
| 62edabe137 | |||
| 49296bd0ca | |||
| d078bf0ed7 | |||
| ea58aacde2 | |||
| ae2b1f42b2 | |||
| 63fea3d2bd | |||
| ce8475a0b9 | |||
| 37717d0df9 | |||
| 7550d85447 | |||
| c756986d9e | |||
| dc170033cd | |||
| d42dae73f0 | |||
| 23e44292bb | |||
| fe85136f99 | |||
| b9837def5c | |||
| dc97871122 | |||
| 4a4fe5a69b | |||
| 1686874d07 | |||
| 650ccea28d | |||
| e1b3928819 | |||
| b66dcc436c | |||
| 526db27c75 | |||
| 27193ae8e8 | |||
| 313c488ec3 | |||
| f30e936d9a | |||
| ae3bd2a1e1 | |||
| ae43d18ced | |||
| b4d93379c4 | |||
| b9654eb4eb | |||
| 89d20c7d99 | |||
| 14bab8efae | |||
| f437aaf359 | |||
| cf5ae4aad9 | |||
| 8679f49fff | |||
| 83202263b9 | |||
| 7fde80e805 | |||
| e9d0619641 | |||
| 2e524200ab | |||
| cc477e9ca6 | |||
| 290b5fe821 | |||
| e9cb0b326d | |||
| 0e77a2b521 | |||
| 63550cc81e | |||
| 03c21dc1b5 | |||
| 05f0dc2513 | |||
| c1d975cced | |||
| 32f15ede7b | |||
| d414116990 | |||
| 341978dbcd | |||
| 80da4d6b02 | |||
| edbf872b44 | |||
| c7c49c3258 | |||
| fdd102aaf9 | |||
| 8dc03ed655 | |||
| 1d8b54892a | |||
| 7966832536 | |||
| 36a39f7d38 | |||
| d62057a62e | |||
| ddf770b9d5 | |||
| acab582487 | |||
| 6384ab6087 | |||
| 43c47f0883 | |||
| babe7a292b | |||
| 92bc52c25c | |||
| df782ea7c5 | |||
| 74a87b1092 | |||
| 6ea4119a3c | |||
| 15031d0b52 | |||
| 5606a961f2 | |||
| 6d925a12ff | |||
| cc2d2c0abf | |||
| e5fe3a0732 | |||
| 55404aec91 | |||
| 0edc00a721 | |||
| b183774063 | |||
| 90e57c2b18 | |||
| 49bb767048 | |||
| 2327604f58 | |||
| 3bb6cca157 | |||
| c6e4eecf21 | |||
| a252394356 | |||
| e3ef98dda3 | |||
| 4677b72a4c | |||
| 8571b25ff7 | |||
| febadd3145 | |||
| 59695984e5 | |||
| 0e5ec18a82 | |||
| 2a5f8950fd | |||
| bcb123a05e | |||
| 816bda7ac7 | |||
| bba91263b0 | |||
| 880cd27f59 | |||
| 0dfd8c3da6 | |||
| ccf24c0bd2 | |||
| a7c9ca99f3 | |||
| f77bf9a42c | |||
| cda73efa6a | |||
| b6e0376ad2 | |||
| 6937a5dd1f | |||
| 73787b8478 | |||
| c0d3f67b04 | |||
| ad3db5212d | |||
| e768fe347a | |||
| e0ceb9f335 | |||
| d71f170c29 | |||
| 7e8c10927b | |||
| 9d0a53fc9f | |||
| 5e6e1217da | |||
| 959f5889a1 | |||
| 5c54268d40 | |||
| 36e768e716 | |||
| 25171df66a | |||
| 3bdbcab874 | |||
| 6ab3ff40a6 | |||
| 47d25c1394 | |||
| d7b1c7c33b | |||
| 51b11486c5 | |||
| fa34121f00 | |||
| b09ef80d9f | |||
| 107401cf07 | |||
| dc9a4a4009 | |||
| 4a1962e5e8 | |||
| 35a8231963 | |||
| 39b1158410 | |||
| 1210bbb34a | |||
| 5f818bc5e7 | |||
| 8af4472672 | |||
| bb12508a8a | |||
| 0dba85f52e | |||
| 32c6a9b10d | |||
| bce4153640 | |||
| 14a33f3cb7 | |||
| db6b4de0f7 | |||
| 22aa00f476 | |||
| ac2c284d16 | |||
| e0cf570339 | |||
| af7afea5a3 | |||
| 1eb5c7dbcd | |||
| 940f0f6021 | |||
| 1c49532447 | |||
| 044390c9df | |||
| f6d56dba89 | |||
| f8221bb2ab | |||
| 1a84517b12 | |||
| 827e20d84d | |||
| 8bc6737dea | |||
| c81a1f9671 | |||
| e9bce02b24 | |||
| aa2a948b86 | |||
| dc6fbf07f0 | |||
| e98c8955bb | |||
| f99aff96ee | |||
| 5d6cc2892d | |||
| 0b456579a9 | |||
| c455f0f342 | |||
| fe5878bc63 | |||
| 5d1d1df206 | |||
| 12da71821a | |||
| 5b40d3cd47 | |||
| b0483975b7 | |||
| bfb47538aa | |||
| 2db1a7bfb9 | |||
| 719278bb36 | |||
| b7d126e24c | |||
| 513250122c | |||
| 98f098f53f | |||
| eccc94dceb | |||
| a22e0f527a | |||
| 42b2174dec | |||
| dee53b3645 | |||
| 5c84cf7e90 | |||
| 4f5a6b3212 | |||
| b1942f64b0 | |||
| c67d8cde4b | |||
| 5c896eabbb | |||
| 9f62230c38 | |||
| f7c14e9964 | |||
| 2340664570 | |||
| dee3cc44f9 | |||
| 64db3720fc | |||
| b67b322978 | |||
| 1be58a2bc4 | |||
| b46c0f5907 | |||
| bebc73db37 | |||
| e69ef4f0b4 | |||
| b707b199b3 | |||
| dead6e007f | |||
| 80196f3c3e | |||
| 24eb1a4fc5 | |||
| 90688fdd17 | |||
| b1dba5f27d | |||
| 83cb383523 | |||
| e37deed8bb | |||
| dbf6429026 | |||
| 276b7eefdd | |||
| 020eb27ff5 | |||
| 911b526dc1 | |||
| 3b2f2efac7 | |||
| 8425d2a6aa | |||
| a55065af9c | |||
| 5fc9312f46 | |||
| 96d6fd2791 | |||
| 65a4366e44 | |||
| 61b2e37691 | |||
| 3e9d4d966c | |||
| dbbae0519e | |||
| 5326ca5fbe | |||
| f7bc744a24 | |||
| 0f51cb9084 | |||
| fc5689ea44 | |||
| 26e71011f5 | |||
| b67bef3e0d | |||
| b9416c7c9c | |||
| 28c206fc78 | |||
| 2993ba1838 | |||
| 63d2353864 | |||
| e711cbc004 | |||
| c73125e1c3 | |||
| 41de0048db | |||
| 1d9ab65313 | |||
| 48e9cdaffd | |||
| 53da73de35 | |||
| 162250392b | |||
| b4acc239cd | |||
| 0777afb85f | |||
| 0057e871d0 | |||
| 6bf5d4dc2d | |||
| f8f68a4e9f | |||
| 17f604fb50 | |||
| e7dd180447 | |||
| f8efc9c2a6 | |||
| d3d2c51717 | |||
| 9de13e37e9 | |||
| 3670f70c01 | |||
| 2adf4efcbd | |||
| 2957d007a2 | |||
| cab1184818 | |||
| a5f8aa35e1 | |||
| 992f568ac7 | |||
| 6981a88720 | |||
| f229601e2d | |||
| aea376fbaf | |||
| 8f990a6fdc | |||
| ea37124686 | |||
| d8766f6d2d | |||
| fa3978e18e | |||
| 78d1eab950 | |||
| e21c665e70 | |||
| 4d593927ae | |||
| 5dc8e0e39d | |||
| 29f4a1d07b | |||
| b82b9b258a | |||
| dab796808a | |||
| fa538f219f | |||
| 546d971e49 | |||
| 9151009b2a | |||
| 414a91c49e | |||
| 3f38e67ce0 | |||
| b53cdfef8d | |||
| b34dc63531 | |||
| fd3a3eb1b9 | |||
| 45443a2c3a | |||
| 5bdf5950b2 | |||
| 2973c7fa5a | |||
| 5e7bf1716e | |||
| 8ef0ad43cb | |||
| df43ba8be0 | |||
| 5cf657065e | |||
| 59480066b4 | |||
| 69e4a3cff3 | |||
| c5e07ba01f | |||
| 8457df2d1f | |||
| 8a9382940a | |||
| 6a5d3f996a | |||
| 9f91fecdb3 | |||
| 3ca4c98596 | |||
| 371de3462b | |||
| 43116400d0 | |||
| e31aa35622 | |||
| 6a6ddc3f19 | |||
| 55c96adb91 | |||
| 72669e19bc | |||
| bf6371c8e9 | |||
| 5ff316ed6d | |||
| 916efb4612 | |||
| 11192a5142 | |||
| 9bf68963da | |||
| a10a8a816a | |||
| 4872bd3cd6 | |||
| 44ec48d325 | |||
| a896a467ec | |||
| b5f12c5f26 | |||
| fc79ec5c94 | |||
| 3d37491342 | |||
| 48a8540a68 | |||
| a63e0cb44a | |||
| 14805af367 | |||
| 87be31cbec | |||
| 99d0332067 | |||
| cbbb5865e5 | |||
| 2a0a196d1a | |||
| 28acb79b82 | |||
| 79f037f983 | |||
| 0e2e02a662 | |||
| 7fc594fa4b | |||
| 7ced0d29ab | |||
| c68417aaf9 | |||
| 4996337d26 | |||
| c97f976e7d | |||
| 45e8c781e2 | |||
| a9a9a7c02f | |||
| aa14056350 | |||
| 4e6a9c0909 | |||
| 1071f56119 | |||
| d22ec125ea | |||
| 1a833ab0a4 | |||
| 6ede60d84e | |||
| 8630fee623 | |||
| 3c45a6d420 | |||
| 2381c5ad70 | |||
| 0273203743 | |||
| f3265e56b9 | |||
| 30fa85f518 | |||
| 6ddc13ce66 | |||
| 7629874237 | |||
| 3a4b8b81ec | |||
| 6c76fa6dec | |||
| ad7c1eb78d | |||
| d37197f45b | |||
| 380f96b3fc | |||
| bec0283e54 | |||
| 9c59612e08 | |||
| ed8d3e8566 | |||
| dc25afda07 | |||
| 6a14269682 | |||
| 43865ddabd | |||
| 405215f862 | |||
| 6e66203881 | |||
| 38ff78df5d | |||
| 25fae8de30 | |||
| 49bd5787e4 | |||
| 4e488f4c70 |
+17
-17
@@ -8,23 +8,28 @@ packages:
|
||||
- libxml2-dev
|
||||
- libssl-dev
|
||||
- libz-dev
|
||||
- llvm-dev # for cctools
|
||||
- uuid-dev ## for cctools
|
||||
- llvm-dev # cctools
|
||||
- uuid-dev # cctools
|
||||
- ninja-build # cctools
|
||||
- systemtap-sdt-dev # cctools
|
||||
- libbsd-dev # cctools
|
||||
- linux-libc-dev # cctools
|
||||
- libplist-utils # for gogio
|
||||
sources:
|
||||
- https://git.sr.ht/~eliasnaur/applesdks
|
||||
- https://git.sr.ht/~eliasnaur/gio
|
||||
- https://git.sr.ht/~eliasnaur/giouiorg
|
||||
- https://github.com/tpoechtrager/cctools-port.git
|
||||
- https://github.com/tpoechtrager/apple-libtapi.git
|
||||
- https://github.com/mackyle/xar.git
|
||||
- https://github.com/tpoechtrager/cctools-port
|
||||
- https://github.com/tpoechtrager/apple-libtapi
|
||||
- https://github.com/tpoechtrager/apple-libdispatch
|
||||
- https://github.com/mackyle/xar
|
||||
environment:
|
||||
APPLE_TOOLCHAIN_ROOT: /home/build/appletools
|
||||
PATH: /home/build/sdk/go/bin:/home/build/go/bin:/usr/bin
|
||||
tasks:
|
||||
- install_go: |
|
||||
mkdir -p /home/build/sdk
|
||||
curl -s https://dl.google.com/go/go1.17.7.linux-amd64.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
curl -s https://dl.google.com/go/go1.19.11.linux-amd64.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
- prepare_toolchain: |
|
||||
mkdir -p $APPLE_TOOLCHAIN_ROOT
|
||||
cd $APPLE_TOOLCHAIN_ROOT
|
||||
@@ -42,6 +47,11 @@ tasks:
|
||||
- install_appletoolchain: |
|
||||
cd giouiorg
|
||||
go build -o $APPLE_TOOLCHAIN_ROOT/tools ./cmd/appletoolchain
|
||||
- build_libdispatch: |
|
||||
cd apple-libdispatch
|
||||
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_INSTALL_PREFIX=$APPLE_TOOLCHAIN_ROOT/libdispatch .
|
||||
ninja
|
||||
ninja install
|
||||
- build_xar: |
|
||||
cd xar/xar
|
||||
ac_cv_lib_crypto_OpenSSL_add_all_ciphers=yes CC=clang ./autogen.sh --prefix=/usr
|
||||
@@ -53,7 +63,7 @@ tasks:
|
||||
./install.sh
|
||||
- build_cctools: |
|
||||
cd cctools-port/cctools
|
||||
./configure --prefix $APPLE_TOOLCHAIN_ROOT/toolchain --with-libtapi=$APPLE_TOOLCHAIN_ROOT/libtapi --target=x86_64-apple-darwin19
|
||||
./configure --target=x86_64-apple-darwin19 --prefix $APPLE_TOOLCHAIN_ROOT/toolchain --with-libtapi=$APPLE_TOOLCHAIN_ROOT/libtapi --with-libdispatch=$APPLE_TOOLCHAIN_ROOT/libdispatch --with-libblocksruntime=$APPLE_TOOLCHAIN_ROOT/libdispatch
|
||||
make install
|
||||
- test_macos: |
|
||||
cd gio
|
||||
@@ -62,13 +72,3 @@ tasks:
|
||||
- test_ios: |
|
||||
cd gio
|
||||
CC=$APPLE_TOOLCHAIN_ROOT/tools/clang-ios GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -tags ios ./...
|
||||
- install_gogio: |
|
||||
cd gio/cmd
|
||||
go install ./gogio
|
||||
- test_ios_gogio: |
|
||||
mkdir tmp
|
||||
cd tmp
|
||||
go mod init example.com
|
||||
go get -d gioui.org/example/kitchen
|
||||
export PATH=/home/build/appletools/bin:$PATH
|
||||
gogio -target ios -o app.app gioui.org/example/kitchen
|
||||
|
||||
+1
-4
@@ -16,10 +16,7 @@ environment:
|
||||
tasks:
|
||||
- install_go: |
|
||||
mkdir -p /home/build/sdk
|
||||
curl https://dl.google.com/go/go1.17.7.freebsd-amd64.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
curl https://dl.google.com/go/go1.19.11.freebsd-amd64.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
- test_gio: |
|
||||
cd gio
|
||||
go test ./...
|
||||
- test_cmd: |
|
||||
cd gio/cmd
|
||||
go test ./...
|
||||
|
||||
+11
-24
@@ -3,6 +3,7 @@ image: debian/testing
|
||||
packages:
|
||||
- curl
|
||||
- pkg-config
|
||||
- gcc-multilib
|
||||
- libwayland-dev
|
||||
- libx11-dev
|
||||
- libx11-xcb-dev
|
||||
@@ -24,12 +25,11 @@ packages:
|
||||
- scrot
|
||||
- sway
|
||||
- grim
|
||||
- wine
|
||||
- unzip
|
||||
sources:
|
||||
- https://git.sr.ht/~eliasnaur/gio
|
||||
environment:
|
||||
GOFLAGS: -mod=readonly
|
||||
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig/:/usr/lib/i386-linux-gnu/pkgconfig/
|
||||
PATH: /home/build/sdk/go/bin:/usr/bin:/home/build/go/bin:/home/build/android/tools/bin
|
||||
ANDROID_SDK_ROOT: /home/build/android
|
||||
android_sdk_tools_zip: sdk-tools-linux-3859397.zip
|
||||
@@ -40,7 +40,7 @@ secrets:
|
||||
tasks:
|
||||
- install_go: |
|
||||
mkdir -p /home/build/sdk
|
||||
curl -s https://dl.google.com/go/go1.17.7.linux-amd64.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
curl -s https://dl.google.com/go/go1.19.11.linux-amd64.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
- check_gofmt: |
|
||||
cd gio
|
||||
test -z "$(gofmt -s -l .)"
|
||||
@@ -54,20 +54,19 @@ tasks:
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
- mirror: |
|
||||
# mirror to github
|
||||
ssh-keyscan github.com > "$HOME"/.ssh/known_hosts && cd gio && git push --mirror "$github_mirror" || echo "failed mirroring"
|
||||
- add_32bit_arch: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y "libwayland-dev:i386" "libx11-dev:i386" "libx11-xcb-dev:i386" "libxkbcommon-dev:i386" "libxkbcommon-x11-dev:i386" "libgles2-mesa-dev:i386" "libegl1-mesa-dev:i386" "libffi-dev:i386" "libvulkan-dev:i386" "libxcursor-dev:i386"
|
||||
- test_gio: |
|
||||
cd gio
|
||||
go test -race ./...
|
||||
CGO_ENABLED=1 GOARCH=386 go test ./...
|
||||
GOOS=windows go test -exec=wine ./...
|
||||
GOOS=js GOARCH=wasm go build -o /dev/null ./...
|
||||
- install_chrome: |
|
||||
curl -s https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
|
||||
sudo sh -c 'echo "deb [arch=amd64] https://dl-ssl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
|
||||
sudo apt-get -qq update
|
||||
sudo apt-get -qq install -y google-chrome-stable
|
||||
- test_cmd: |
|
||||
cd gio/cmd
|
||||
go test ./...
|
||||
go test -race ./...
|
||||
- install_jdk8: |
|
||||
curl -so jdk.deb "https://cdn.azul.com/zulu/bin/zulu8.42.0.21-ca-jdk8.0.232-linux_amd64.deb"
|
||||
sudo apt-get -qq install -y -f ./jdk.deb
|
||||
@@ -87,15 +86,3 @@ tasks:
|
||||
cd gio
|
||||
CC=$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang GOOS=android GOARCH=arm64 CGO_ENABLED=1 go build ./...
|
||||
CC=$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang GOOS=android GOARCH=arm CGO_ENABLED=1 go build ./...
|
||||
- install_gogio: |
|
||||
cd gio/cmd
|
||||
go install ./gogio
|
||||
- test_android_gogio: |
|
||||
mkdir tmp
|
||||
cd tmp
|
||||
go mod init example.com
|
||||
go get -d gioui.org/example/kitchen
|
||||
gogio -target android gioui.org/example/kitchen
|
||||
- mirror: |
|
||||
# mirror to github
|
||||
ssh-keyscan github.com > "$HOME"/.ssh/known_hosts && cd gio && git push --mirror "$github_mirror" || echo "failed mirroring"
|
||||
|
||||
+1
-4
@@ -10,12 +10,9 @@ environment:
|
||||
tasks:
|
||||
- install_go: |
|
||||
mkdir -p /home/build/sdk
|
||||
curl https://dl.google.com/go/go1.17.7.src.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
curl https://dl.google.com/go/go1.19.11.src.tar.gz | tar -C /home/build/sdk -xzf -
|
||||
cd /home/build/sdk/go/src
|
||||
./make.bash
|
||||
- test_gio: |
|
||||
cd gio
|
||||
go test ./...
|
||||
- test_cmd: |
|
||||
cd gio/cmd
|
||||
go test ./...
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
.gradle
|
||||
**/android/build
|
||||
@@ -24,3 +24,12 @@ account is required and you can post without being subscribed.
|
||||
See the [contribution guide](https://gioui.org/doc/contribute) for more details.
|
||||
|
||||
An [official GitHub mirror](https://github.com/gioui/gio) is available.
|
||||
|
||||
## Tags
|
||||
|
||||
Pre-1.0 tags are provided for reference only, and do not designate releases with ongoing support. Bugfixes will not be backported to older tags.
|
||||
|
||||
Tags follow semantic versioning. In particular, as the major version is zero:
|
||||
|
||||
- breaking API or behavior changes will increment the *minor* version component.
|
||||
- non-breaking changes will increment the *patch* version component.
|
||||
|
||||
+17
-3
@@ -5,16 +5,30 @@ package org.gioui;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.res.Configuration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public final class GioActivity extends Activity {
|
||||
private GioView view;
|
||||
public FrameLayout layer;
|
||||
|
||||
@Override public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
super.onCreate(state);
|
||||
|
||||
this.view = new GioView(this);
|
||||
layer = new FrameLayout(this);
|
||||
view = new GioView(this);
|
||||
|
||||
setContentView(view);
|
||||
view.setLayoutParams(new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT
|
||||
));
|
||||
view.setFocusable(true);
|
||||
view.setFocusableInTouchMode(true);
|
||||
|
||||
layer.addView(view);
|
||||
setContentView(layer);
|
||||
}
|
||||
|
||||
@Override public void onDestroy() {
|
||||
|
||||
+61
-1
@@ -26,6 +26,7 @@ import android.text.SpannableStringBuilder;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Choreographer;
|
||||
import android.view.Display;
|
||||
import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
@@ -105,6 +106,8 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
|
||||
scrollYScale = px;
|
||||
}
|
||||
|
||||
setHighRefreshRate();
|
||||
|
||||
accessManager = (AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
nhandle = onCreateView(this);
|
||||
@@ -255,6 +258,59 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
|
||||
this.setBarColor(Bar.NAVIGATION, color, luminance);
|
||||
}
|
||||
|
||||
private void setHighRefreshRate() {
|
||||
Context context = getContext();
|
||||
Display display = context.getDisplay();
|
||||
Display.Mode[] supportedModes = display.getSupportedModes();
|
||||
if (supportedModes.length <= 1) {
|
||||
// Nothing to set
|
||||
return;
|
||||
}
|
||||
|
||||
Display.Mode currentMode = display.getMode();
|
||||
int currentWidth = currentMode.getPhysicalWidth();
|
||||
int currentHeight = currentMode.getPhysicalHeight();
|
||||
|
||||
float minRefreshRate = -1;
|
||||
float maxRefreshRate = -1;
|
||||
float bestRefreshRate = -1;
|
||||
int bestModeId = -1;
|
||||
for (Display.Mode mode : supportedModes) {
|
||||
float refreshRate = mode.getRefreshRate();
|
||||
float width = mode.getPhysicalWidth();
|
||||
float height = mode.getPhysicalHeight();
|
||||
|
||||
if (minRefreshRate == -1 || refreshRate < minRefreshRate) {
|
||||
minRefreshRate = refreshRate;
|
||||
}
|
||||
if (maxRefreshRate == -1 || refreshRate > maxRefreshRate) {
|
||||
maxRefreshRate = refreshRate;
|
||||
}
|
||||
|
||||
boolean refreshRateIsBetter = bestRefreshRate == -1 || refreshRate > bestRefreshRate;
|
||||
if (width == currentWidth && height == currentHeight && refreshRateIsBetter) {
|
||||
int modeId = mode.getModeId();
|
||||
bestRefreshRate = refreshRate;
|
||||
bestModeId = modeId;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestModeId == -1) {
|
||||
// Not expecting this but just in case
|
||||
return;
|
||||
}
|
||||
|
||||
if (minRefreshRate == maxRefreshRate) {
|
||||
// Can't improve the refresh rate
|
||||
return;
|
||||
}
|
||||
|
||||
Window window = ((Activity) context).getWindow();
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.preferredDisplayModeId = bestModeId;
|
||||
window.setAttributes(layoutParams);
|
||||
}
|
||||
|
||||
@Override protected boolean dispatchHoverEvent(MotionEvent event) {
|
||||
if (!accessManager.isTouchExplorationEnabled()) {
|
||||
return super.dispatchHoverEvent(event);
|
||||
@@ -555,7 +611,11 @@ public final class GioView extends SurfaceView implements Choreographer.FrameCal
|
||||
@Override public int getCursorCapsMode(int reqModes) {
|
||||
Snippet snip = getSnippet();
|
||||
int selStart = imeSelectionStart(nhandle);
|
||||
return TextUtils.getCapsMode(snip.snippet, imeToUTF16(nhandle, selStart), reqModes);
|
||||
int off = imeToUTF16(nhandle, selStart - snip.offset);
|
||||
if (off < 0 || off > snip.snippet.length()) {
|
||||
return 0;
|
||||
}
|
||||
return TextUtils.getCapsMode(snip.snippet, off, reqModes);
|
||||
}
|
||||
|
||||
@Override public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
|
||||
|
||||
+19
@@ -4,6 +4,7 @@ package app
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -14,11 +15,29 @@ import (
|
||||
// Set with the go linker flag -X.
|
||||
var extraArgs string
|
||||
|
||||
// ID is the app id exposed to the platform.
|
||||
//
|
||||
// On Android ID is the package property of AndroidManifest.xml,
|
||||
// on iOS ID is the CFBundleIdentifier of the app Info.plist,
|
||||
// on Wayland it is the toplevel app_id,
|
||||
// on X11 it is the X11 XClassHint
|
||||
//
|
||||
// ID is set by the gogio tool or manually with the -X linker flag. For example,
|
||||
//
|
||||
// go build -ldflags="-X 'gioui.org/app.ID=org.gioui.example.Kitchen'" .
|
||||
//
|
||||
// Note that ID is treated as a constant, and that changing it at runtime
|
||||
// is not supported. Default value of ID is filepath.Base(os.Args[0]).
|
||||
var ID = ""
|
||||
|
||||
func init() {
|
||||
if extraArgs != "" {
|
||||
args := strings.Split(extraArgs, "|")
|
||||
os.Args = append(os.Args, args...)
|
||||
}
|
||||
if ID == "" {
|
||||
ID = filepath.Base(os.Args[0])
|
||||
}
|
||||
}
|
||||
|
||||
// DataDir returns a path to use for application-specific
|
||||
|
||||
@@ -20,7 +20,7 @@ type d3d11Context struct {
|
||||
width, height int
|
||||
}
|
||||
|
||||
const debug = false
|
||||
const debugDirectX = false
|
||||
|
||||
func init() {
|
||||
drivers = append(drivers, gpuAPI{
|
||||
@@ -28,7 +28,7 @@ func init() {
|
||||
initializer: func(w *window) (context, error) {
|
||||
hwnd, _, _ := w.HWND()
|
||||
var flags uint32
|
||||
if debug {
|
||||
if debugDirectX {
|
||||
flags |= d3d11.CREATE_DEVICE_DEBUG
|
||||
}
|
||||
dev, ctx, _, err := d3d11.CreateDevice(
|
||||
@@ -60,10 +60,10 @@ func (c *d3d11Context) RenderTarget() (gpu.RenderTarget, error) {
|
||||
}
|
||||
|
||||
func (c *d3d11Context) Present() error {
|
||||
err := c.swchain.Present(1, 0)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return wrapErr(c.swchain.Present(1, 0))
|
||||
}
|
||||
|
||||
func wrapErr(err error) error {
|
||||
if err, ok := err.(d3d11.ErrorCode); ok {
|
||||
switch err.Code {
|
||||
case d3d11.DXGI_STATUS_OCCLUDED:
|
||||
@@ -84,7 +84,7 @@ func (c *d3d11Context) Refresh() error {
|
||||
}
|
||||
c.releaseFBO()
|
||||
if err := c.swchain.ResizeBuffers(0, 0, 0, d3d11.DXGI_FORMAT_UNKNOWN, 0); err != nil {
|
||||
return err
|
||||
return wrapErr(err)
|
||||
}
|
||||
c.width = width
|
||||
c.height = height
|
||||
@@ -122,7 +122,7 @@ func (c *d3d11Context) Release() {
|
||||
d3d11.IUnknownRelease(unsafe.Pointer(c.dev), c.dev.Vtbl.Release)
|
||||
}
|
||||
*c = d3d11Context{}
|
||||
if debug {
|
||||
if debugDirectX {
|
||||
d3d11.ReportLiveObjects()
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -6,22 +6,22 @@ functionality for running graphical user interfaces.
|
||||
|
||||
See https://gioui.org for instructions to set up and run Gio programs.
|
||||
|
||||
Windows
|
||||
# Windows
|
||||
|
||||
Create a new Window by calling NewWindow. On mobile platforms or when Gio
|
||||
is embedded in another project, NewWindow merely connects with a previously
|
||||
created window.
|
||||
|
||||
A Window is run by receiving events from its Events channel. The most
|
||||
important event is FrameEvent that prompts an update of the window
|
||||
contents and state.
|
||||
A Window is run by calling NextEvent in a loop. The most important event is
|
||||
FrameEvent that prompts an update of the window contents.
|
||||
|
||||
For example:
|
||||
|
||||
import "gioui.org/unit"
|
||||
|
||||
w := app.NewWindow()
|
||||
for e := range w.Events() {
|
||||
for {
|
||||
e := w.NextEvent()
|
||||
if e, ok := e.(system.FrameEvent); ok {
|
||||
ops.Reset()
|
||||
// Add operations to ops.
|
||||
@@ -34,7 +34,7 @@ For example:
|
||||
A program must keep receiving events from the event channel until
|
||||
DestroyEvent is received.
|
||||
|
||||
Main
|
||||
# Main
|
||||
|
||||
The Main function must be called from a program's main function, to hand over
|
||||
control of the main thread to operating systems that need it.
|
||||
@@ -50,20 +50,20 @@ For example, to display a blank but otherwise functional window:
|
||||
func main() {
|
||||
go func() {
|
||||
w := app.NewWindow()
|
||||
for range w.Events() {
|
||||
for {
|
||||
w.NextEvent()
|
||||
}
|
||||
}()
|
||||
app.Main()
|
||||
}
|
||||
|
||||
|
||||
Event queue
|
||||
# Event queue
|
||||
|
||||
A FrameEvent's Queue method returns an event.Queue implementation that distributes
|
||||
incoming events to the event handlers declared in the last frame.
|
||||
See the gioui.org/io/event package for more information about event handlers.
|
||||
|
||||
Permissions
|
||||
# Permissions
|
||||
|
||||
The packages under gioui.org/app/permission should be imported
|
||||
by a Gio program or by one of its dependencies to indicate that specific
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
//go:build !noopengl
|
||||
|
||||
package app
|
||||
|
||||
/*
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
//go:build ((linux && !android) || freebsd) && !nowayland
|
||||
//go:build ((linux && !android) || freebsd) && !nowayland && !noopengl
|
||||
// +build linux,!android freebsd
|
||||
// +build !nowayland
|
||||
// +build !noopengl
|
||||
|
||||
package app
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
//go:build !noopengl
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
//go:build ((linux && !android) || freebsd || openbsd) && !nox11
|
||||
//go:build ((linux && !android) || freebsd || openbsd) && !nox11 && !noopengl
|
||||
// +build linux,!android freebsd openbsd
|
||||
// +build !nox11
|
||||
// +build !noopengl
|
||||
|
||||
package app
|
||||
|
||||
|
||||
+14
-4
@@ -13,6 +13,7 @@ import (
|
||||
type glContext struct {
|
||||
ctx js.Value
|
||||
cnv js.Value
|
||||
w *window
|
||||
}
|
||||
|
||||
func newContext(w *window) (*glContext, error) {
|
||||
@@ -32,11 +33,15 @@ func newContext(w *window) (*glContext, error) {
|
||||
c := &glContext{
|
||||
ctx: ctx,
|
||||
cnv: w.cnv,
|
||||
w: w,
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *glContext) RenderTarget() (gpu.RenderTarget, error) {
|
||||
if c.w.contextStatus != contextStatusOkay {
|
||||
return nil, gpu.ErrDeviceLost
|
||||
}
|
||||
return gpu.OpenGLRenderTarget{}, nil
|
||||
}
|
||||
|
||||
@@ -48,9 +53,6 @@ func (c *glContext) Release() {
|
||||
}
|
||||
|
||||
func (c *glContext) Present() error {
|
||||
if c.ctx.Call("isContextLost").Bool() {
|
||||
return errors.New("context lost")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -61,7 +63,15 @@ func (c *glContext) Lock() error {
|
||||
func (c *glContext) Unlock() {}
|
||||
|
||||
func (c *glContext) Refresh() error {
|
||||
return nil
|
||||
switch c.w.contextStatus {
|
||||
case contextStatusLost:
|
||||
return errOutOfDate
|
||||
case contextStatusRestored:
|
||||
c.w.contextStatus = contextStatusOkay
|
||||
return gpu.ErrDeviceLost
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w *window) NewContext() (context, error) {
|
||||
|
||||
@@ -16,6 +16,9 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -xobjective-c -fobjc-arc
|
||||
#cgo LDFLAGS: -framework OpenGL
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
+1
-2
@@ -2,8 +2,7 @@
|
||||
|
||||
// +build darwin,!ios,nometal
|
||||
|
||||
@import AppKit;
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include "_cgo_export.h"
|
||||
|
||||
+25
-3
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
|
||||
"gioui.org/font"
|
||||
"gioui.org/font/gofont"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/router"
|
||||
@@ -28,14 +29,14 @@ func FuzzIME(f *testing.F) {
|
||||
f.Add([]byte("20007800002\x02000"))
|
||||
f.Add([]byte("200A02000990\x19002\x17\x0200"))
|
||||
f.Fuzz(func(t *testing.T, cmds []byte) {
|
||||
cache := text.NewCache(gofont.Collection())
|
||||
cache := text.NewShaper(text.WithCollection(gofont.Collection()))
|
||||
e := new(widget.Editor)
|
||||
e.Focus()
|
||||
|
||||
var r router.Router
|
||||
gtx := layout.Context{Ops: new(op.Ops), Queue: &r}
|
||||
// Layout once to register focus.
|
||||
e.Layout(gtx, cache, text.Font{}, unit.Px(10), nil)
|
||||
e.Layout(gtx, cache, font.Font{}, unit.Sp(10), op.CallOp{}, op.CallOp{})
|
||||
r.Frame(gtx.Ops)
|
||||
|
||||
var state editorState
|
||||
@@ -103,11 +104,32 @@ func FuzzIME(f *testing.F) {
|
||||
}
|
||||
}
|
||||
cmds = cmds[cmdLen:]
|
||||
e.Layout(gtx, cache, text.Font{}, unit.Px(10), nil)
|
||||
e.Layout(gtx, cache, font.Font{}, unit.Sp(10), op.CallOp{}, op.CallOp{})
|
||||
r.Frame(gtx.Ops)
|
||||
newState := r.EditorState()
|
||||
// We don't track caret position.
|
||||
state.Selection.Caret = newState.Selection.Caret
|
||||
// Expanded snippets are ok.
|
||||
their, our := newState.Snippet, state.EditorState.Snippet
|
||||
beforeLen := 0
|
||||
for before := our.Start - their.Start; before > 0; before-- {
|
||||
_, n := utf8.DecodeRuneInString(their.Text[beforeLen:])
|
||||
beforeLen += n
|
||||
}
|
||||
afterLen := 0
|
||||
for after := their.End - our.End; after > 0; after-- {
|
||||
_, n := utf8.DecodeLastRuneInString(their.Text[:len(their.Text)-afterLen])
|
||||
afterLen += n
|
||||
}
|
||||
if beforeLen > 0 {
|
||||
our.Text = their.Text[:beforeLen] + our.Text
|
||||
our.Start = their.Start
|
||||
}
|
||||
if afterLen > 0 {
|
||||
our.Text = our.Text + their.Text[len(their.Text)-afterLen:]
|
||||
our.End = their.End
|
||||
}
|
||||
state.EditorState.Snippet = our
|
||||
if newState != state.EditorState {
|
||||
t.Errorf("IME state: %+v\neditor state: %+v", state.EditorState, newState)
|
||||
}
|
||||
|
||||
@@ -47,6 +47,13 @@ type WndClassEx struct {
|
||||
HIconSm syscall.Handle
|
||||
}
|
||||
|
||||
type Margins struct {
|
||||
CxLeftWidth int32
|
||||
CxRightWidth int32
|
||||
CyTopHeight int32
|
||||
CyBottomHeight int32
|
||||
}
|
||||
|
||||
type Msg struct {
|
||||
Hwnd syscall.Handle
|
||||
Message uint32
|
||||
@@ -69,6 +76,21 @@ type MinMaxInfo struct {
|
||||
PtMaxTrackSize Point
|
||||
}
|
||||
|
||||
type NCCalcSizeParams struct {
|
||||
Rgrc [3]Rect
|
||||
LpPos *WindowPos
|
||||
}
|
||||
|
||||
type WindowPos struct {
|
||||
HWND syscall.Handle
|
||||
HWNDInsertAfter syscall.Handle
|
||||
x int32
|
||||
y int32
|
||||
cx int32
|
||||
cy int32
|
||||
flags uint32
|
||||
}
|
||||
|
||||
type WindowPlacement struct {
|
||||
length uint32
|
||||
flags uint32
|
||||
@@ -113,7 +135,16 @@ const (
|
||||
|
||||
HWND_TOPMOST = ^(uint32(1) - 1) // -1
|
||||
|
||||
HTCLIENT = 1
|
||||
HTCAPTION = 2
|
||||
HTCLIENT = 1
|
||||
HTLEFT = 10
|
||||
HTRIGHT = 11
|
||||
HTTOP = 12
|
||||
HTTOPLEFT = 13
|
||||
HTTOPRIGHT = 14
|
||||
HTBOTTOM = 15
|
||||
HTBOTTOMLEFT = 16
|
||||
HTBOTTOMRIGHT = 17
|
||||
|
||||
IDC_APPSTARTING = 32650 // Standard arrow and small hourglass
|
||||
IDC_ARROW = 32512 // Standard arrow
|
||||
@@ -146,13 +177,16 @@ const (
|
||||
|
||||
SCS_SETSTR = GCS_COMPREADSTR | GCS_COMPSTR
|
||||
|
||||
SM_CXSIZEFRAME = 32
|
||||
SM_CYSIZEFRAME = 33
|
||||
|
||||
SW_SHOWDEFAULT = 10
|
||||
SW_SHOWMINIMIZED = 2
|
||||
SW_SHOWMAXIMIZED = 3
|
||||
SW_SHOWNORMAL = 1
|
||||
SW_SHOW = 5
|
||||
SWP_FRAMECHANGED = 0x0020
|
||||
|
||||
SWP_FRAMECHANGED = 0x0020
|
||||
SWP_NOMOVE = 0x0002
|
||||
SWP_NOOWNERZORDER = 0x0200
|
||||
SWP_NOSIZE = 0x0001
|
||||
@@ -231,6 +265,9 @@ const (
|
||||
WM_MOUSEMOVE = 0x0200
|
||||
WM_MOUSEWHEEL = 0x020A
|
||||
WM_MOUSEHWHEEL = 0x020E
|
||||
WM_NCACTIVATE = 0x0086
|
||||
WM_NCHITTEST = 0x0084
|
||||
WM_NCCALCSIZE = 0x0083
|
||||
WM_PAINT = 0x000F
|
||||
WM_QUIT = 0x0012
|
||||
WM_SETCURSOR = 0x0020
|
||||
@@ -246,7 +283,7 @@ const (
|
||||
WM_USER = 0x0400
|
||||
WM_WINDOWPOSCHANGED = 0x0047
|
||||
|
||||
WS_CLIPCHILDREN = 0x00010000
|
||||
WS_CLIPCHILDREN = 0x02000000
|
||||
WS_CLIPSIBLINGS = 0x04000000
|
||||
WS_MAXIMIZE = 0x01000000
|
||||
WS_ICONIC = 0x20000000
|
||||
@@ -309,6 +346,7 @@ var (
|
||||
_DispatchMessage = user32.NewProc("DispatchMessageW")
|
||||
_EmptyClipboard = user32.NewProc("EmptyClipboard")
|
||||
_GetWindowRect = user32.NewProc("GetWindowRect")
|
||||
_GetClientRect = user32.NewProc("GetClientRect")
|
||||
_GetClipboardData = user32.NewProc("GetClipboardData")
|
||||
_GetDC = user32.NewProc("GetDC")
|
||||
_GetDpiForWindow = user32.NewProc("GetDpiForWindow")
|
||||
@@ -316,6 +354,7 @@ var (
|
||||
_GetMessage = user32.NewProc("GetMessageW")
|
||||
_GetMessageTime = user32.NewProc("GetMessageTime")
|
||||
_GetMonitorInfo = user32.NewProc("GetMonitorInfoW")
|
||||
_GetSystemMetrics = user32.NewProc("GetSystemMetrics")
|
||||
_GetWindowLong = user32.NewProc("GetWindowLongPtrW")
|
||||
_GetWindowLong32 = user32.NewProc("GetWindowLongW")
|
||||
_GetWindowPlacement = user32.NewProc("GetWindowPlacement")
|
||||
@@ -364,6 +403,9 @@ var (
|
||||
_ImmReleaseContext = imm32.NewProc("ImmReleaseContext")
|
||||
_ImmSetCandidateWindow = imm32.NewProc("ImmSetCandidateWindow")
|
||||
_ImmSetCompositionWindow = imm32.NewProc("ImmSetCompositionWindow")
|
||||
|
||||
dwmapi = syscall.NewLazySystemDLL("dwmapi")
|
||||
_DwmExtendFrameIntoClientArea = dwmapi.NewProc("DwmExtendFrameIntoClientArea")
|
||||
)
|
||||
|
||||
func AdjustWindowRectEx(r *Rect, dwStyle uint32, bMenu int, dwExStyle uint32) {
|
||||
@@ -415,6 +457,14 @@ func DispatchMessage(m *Msg) {
|
||||
_DispatchMessage.Call(uintptr(unsafe.Pointer(m)))
|
||||
}
|
||||
|
||||
func DwmExtendFrameIntoClientArea(hwnd syscall.Handle, margins Margins) error {
|
||||
r, _, _ := _DwmExtendFrameIntoClientArea.Call(uintptr(hwnd), uintptr(unsafe.Pointer(&margins)))
|
||||
if r != 0 {
|
||||
return fmt.Errorf("DwmExtendFrameIntoClientArea: %#x", r)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func EmptyClipboard() error {
|
||||
r, _, err := _EmptyClipboard.Call()
|
||||
if r == 0 {
|
||||
@@ -429,6 +479,12 @@ func GetWindowRect(hwnd syscall.Handle) Rect {
|
||||
return r
|
||||
}
|
||||
|
||||
func GetClientRect(hwnd syscall.Handle) Rect {
|
||||
var r Rect
|
||||
_GetClientRect.Call(uintptr(hwnd), uintptr(unsafe.Pointer(&r)))
|
||||
return r
|
||||
}
|
||||
|
||||
func GetClipboardData(format uint32) (syscall.Handle, error) {
|
||||
r, _, err := _GetClipboardData.Call(uintptr(format))
|
||||
if r == 0 {
|
||||
@@ -499,6 +555,11 @@ func GetMessageTime() time.Duration {
|
||||
return time.Duration(r) * time.Millisecond
|
||||
}
|
||||
|
||||
func GetSystemMetrics(nIndex int) int {
|
||||
r, _, _ := _GetSystemMetrics.Call(uintptr(nIndex))
|
||||
return int(r)
|
||||
}
|
||||
|
||||
// GetWindowDPI returns the effective DPI of the window.
|
||||
func GetWindowDPI(hwnd syscall.Handle) int {
|
||||
// Check for GetDpiForWindow, introduced in Windows 10.
|
||||
|
||||
@@ -136,6 +136,10 @@ func (x *Context) LoadKeymap(format int, fd int, size int) error {
|
||||
|
||||
func (x *Context) Modifiers() key.Modifiers {
|
||||
var mods key.Modifiers
|
||||
if x.state == nil {
|
||||
return mods
|
||||
}
|
||||
|
||||
if C.xkb_state_mod_name_is_active(x.state, (*C.char)(unsafe.Pointer(&_XKB_MOD_NAME_CTRL[0])), C.XKB_STATE_MODS_EFFECTIVE) == 1 {
|
||||
mods |= key.ModCtrl
|
||||
}
|
||||
@@ -219,6 +223,9 @@ func (x *Context) charsForKeycode(keyCode C.xkb_keycode_t) []byte {
|
||||
}
|
||||
|
||||
func (x *Context) IsRepeatKey(keyCode uint32) bool {
|
||||
if x.state == nil {
|
||||
return false
|
||||
}
|
||||
kc := C.xkb_keycode_t(keyCode)
|
||||
return C.xkb_keymap_key_repeats(x.keyMap, kc) == 1
|
||||
}
|
||||
@@ -235,6 +242,9 @@ func convertKeysym(s C.xkb_keysym_t) (string, bool) {
|
||||
if 'a' <= s && s <= 'z' {
|
||||
return string(rune(s - 'a' + 'A')), true
|
||||
}
|
||||
if C.XKB_KEY_KP_0 <= s && s <= C.XKB_KEY_KP_9 {
|
||||
return string(rune(s - C.XKB_KEY_KP_0 + '0')), true
|
||||
}
|
||||
if ' ' < s && s <= '~' {
|
||||
return string(rune(s)), true
|
||||
}
|
||||
@@ -248,8 +258,6 @@ func convertKeysym(s C.xkb_keysym_t) (string, bool) {
|
||||
n = key.NameRightArrow
|
||||
case C.XKB_KEY_Return:
|
||||
n = key.NameReturn
|
||||
case C.XKB_KEY_KP_Enter:
|
||||
n = key.NameEnter
|
||||
case C.XKB_KEY_Up:
|
||||
n = key.NameUpArrow
|
||||
case C.XKB_KEY_Down:
|
||||
@@ -290,9 +298,9 @@ func convertKeysym(s C.xkb_keysym_t) (string, bool) {
|
||||
n = key.NameF11
|
||||
case C.XKB_KEY_F12:
|
||||
n = key.NameF12
|
||||
case C.XKB_KEY_Tab, C.XKB_KEY_KP_Tab, C.XKB_KEY_ISO_Left_Tab:
|
||||
case C.XKB_KEY_Tab, C.XKB_KEY_ISO_Left_Tab:
|
||||
n = key.NameTab
|
||||
case 0x20, C.XKB_KEY_KP_Space:
|
||||
case 0x20:
|
||||
n = key.NameSpace
|
||||
case C.XKB_KEY_Control_L, C.XKB_KEY_Control_R:
|
||||
n = key.NameCtrl
|
||||
@@ -302,6 +310,64 @@ func convertKeysym(s C.xkb_keysym_t) (string, bool) {
|
||||
n = key.NameAlt
|
||||
case C.XKB_KEY_Super_L, C.XKB_KEY_Super_R:
|
||||
n = key.NameSuper
|
||||
|
||||
case C.XKB_KEY_KP_Space:
|
||||
n = key.NameSpace
|
||||
case C.XKB_KEY_KP_Tab:
|
||||
n = key.NameTab
|
||||
case C.XKB_KEY_KP_Enter:
|
||||
n = key.NameEnter
|
||||
case C.XKB_KEY_KP_F1:
|
||||
n = key.NameF1
|
||||
case C.XKB_KEY_KP_F2:
|
||||
n = key.NameF2
|
||||
case C.XKB_KEY_KP_F3:
|
||||
n = key.NameF3
|
||||
case C.XKB_KEY_KP_F4:
|
||||
n = key.NameF4
|
||||
case C.XKB_KEY_KP_Home:
|
||||
n = key.NameHome
|
||||
case C.XKB_KEY_KP_Left:
|
||||
n = key.NameLeftArrow
|
||||
case C.XKB_KEY_KP_Up:
|
||||
n = key.NameUpArrow
|
||||
case C.XKB_KEY_KP_Right:
|
||||
n = key.NameRightArrow
|
||||
case C.XKB_KEY_KP_Down:
|
||||
n = key.NameDownArrow
|
||||
case C.XKB_KEY_KP_Prior:
|
||||
// not supported
|
||||
return "", false
|
||||
case C.XKB_KEY_KP_Next:
|
||||
// not supported
|
||||
return "", false
|
||||
case C.XKB_KEY_KP_End:
|
||||
n = key.NameEnd
|
||||
case C.XKB_KEY_KP_Begin:
|
||||
n = key.NameHome
|
||||
case C.XKB_KEY_KP_Insert:
|
||||
// not supported
|
||||
return "", false
|
||||
case C.XKB_KEY_KP_Delete:
|
||||
n = key.NameDeleteForward
|
||||
case C.XKB_KEY_KP_Multiply:
|
||||
n = "*"
|
||||
case C.XKB_KEY_KP_Add:
|
||||
n = "+"
|
||||
case C.XKB_KEY_KP_Separator:
|
||||
// not supported
|
||||
return "", false
|
||||
case C.XKB_KEY_KP_Subtract:
|
||||
n = "-"
|
||||
case C.XKB_KEY_KP_Decimal:
|
||||
// TODO(dh): does a German keyboard layout also translate the numpad key to XKB_KEY_KP_DECIMAL? Because in
|
||||
// German, the decimal is a comma, not a period.
|
||||
n = "."
|
||||
case C.XKB_KEY_KP_Divide:
|
||||
n = "/"
|
||||
case C.XKB_KEY_KP_Equal:
|
||||
n = "="
|
||||
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
|
||||
+4
-3
@@ -12,10 +12,11 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -Werror -xobjective-c -fmodules -fobjc-arc
|
||||
#cgo CFLAGS: -Werror -xobjective-c -fobjc-arc
|
||||
#cgo LDFLAGS: -framework QuartzCore -framework Metal
|
||||
|
||||
@import Metal;
|
||||
@import QuartzCore.CAMetalLayer;
|
||||
#import <Metal/Metal.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
|
||||
+3
-5
@@ -6,12 +6,10 @@
|
||||
package app
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -Werror -xobjective-c -fmodules -fobjc-arc
|
||||
|
||||
@import AppKit;
|
||||
|
||||
@import QuartzCore.CAMetalLayer;
|
||||
#cgo CFLAGS: -Werror -xobjective-c -fobjc-arc
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
CALayer *gio_layerFactory(void) {
|
||||
|
||||
@@ -41,10 +41,11 @@ type Config struct {
|
||||
// CustomRenderer is true when the window content is rendered by the
|
||||
// client.
|
||||
CustomRenderer bool
|
||||
// center is a flag used to center the window. Set by option.
|
||||
center bool
|
||||
// Decorated reports whether window decorations are provided automatically.
|
||||
Decorated bool
|
||||
// decoHeight is the height of the fallback decoration for platforms such
|
||||
// as Wayland that may need fallback client-side decorations.
|
||||
decoHeight unit.Dp
|
||||
}
|
||||
|
||||
// ConfigEvent is sent whenever the configuration of a Window changes.
|
||||
@@ -164,10 +165,6 @@ type driver interface {
|
||||
Configure([]Option)
|
||||
// SetCursor updates the current cursor to name.
|
||||
SetCursor(cursor pointer.Cursor)
|
||||
// Raise the window at the top.
|
||||
Raise()
|
||||
// Close the window.
|
||||
Close()
|
||||
// Wakeup wakes up the event loop and sends a WakeupEvent.
|
||||
Wakeup()
|
||||
// Perform actions on the window.
|
||||
|
||||
+88
-65
@@ -154,7 +154,7 @@ type window struct {
|
||||
|
||||
dpi int
|
||||
fontScale float32
|
||||
insets system.Insets
|
||||
insets pixelInsets
|
||||
|
||||
stage system.Stage
|
||||
started bool
|
||||
@@ -195,6 +195,10 @@ var gioView struct {
|
||||
updateCaret C.jmethodID
|
||||
}
|
||||
|
||||
type pixelInsets struct {
|
||||
top, bottom, left, right int
|
||||
}
|
||||
|
||||
// ViewEvent is sent whenever the Window's underlying Android view
|
||||
// changes.
|
||||
type ViewEvent struct {
|
||||
@@ -310,7 +314,7 @@ const (
|
||||
)
|
||||
|
||||
func (w *window) NewContext() (context, error) {
|
||||
funcs := []func(w *window) (context, error){newAndroidVulkanContext, newAndroidGLESContext}
|
||||
funcs := []func(w *window) (context, error){newAndroidGLESContext, newAndroidVulkanContext}
|
||||
var firstErr error
|
||||
for _, f := range funcs {
|
||||
if f == nil {
|
||||
@@ -334,20 +338,6 @@ func (w *window) NewContext() (context, error) {
|
||||
func dataDir() (string, error) {
|
||||
dataDirOnce.Do(func() {
|
||||
dataPath = <-dataDirChan
|
||||
// Set XDG_CACHE_HOME to make os.UserCacheDir work.
|
||||
if _, exists := os.LookupEnv("XDG_CACHE_HOME"); !exists {
|
||||
cachePath := filepath.Join(dataPath, "cache")
|
||||
os.Setenv("XDG_CACHE_HOME", cachePath)
|
||||
}
|
||||
// Set XDG_CONFIG_HOME to make os.UserConfigDir work.
|
||||
if _, exists := os.LookupEnv("XDG_CONFIG_HOME"); !exists {
|
||||
cfgPath := filepath.Join(dataPath, "config")
|
||||
os.Setenv("XDG_CONFIG_HOME", cfgPath)
|
||||
}
|
||||
// Set HOME to make os.UserHomeDir work.
|
||||
if _, exists := os.LookupEnv("HOME"); !exists {
|
||||
os.Setenv("HOME", dataPath)
|
||||
}
|
||||
})
|
||||
return dataPath, nil
|
||||
}
|
||||
@@ -385,6 +375,22 @@ func Java_org_gioui_Gio_runGoMain(env *C.JNIEnv, class C.jclass, jdataDir C.jbyt
|
||||
}
|
||||
n := C.jni_GetArrayLength(env, jdataDir)
|
||||
dataDir := C.GoStringN((*C.char)(unsafe.Pointer(dirBytes)), n)
|
||||
|
||||
// Set XDG_CACHE_HOME to make os.UserCacheDir work.
|
||||
if _, exists := os.LookupEnv("XDG_CACHE_HOME"); !exists {
|
||||
cachePath := filepath.Join(dataDir, "cache")
|
||||
os.Setenv("XDG_CACHE_HOME", cachePath)
|
||||
}
|
||||
// Set XDG_CONFIG_HOME to make os.UserConfigDir work.
|
||||
if _, exists := os.LookupEnv("XDG_CONFIG_HOME"); !exists {
|
||||
cfgPath := filepath.Join(dataDir, "config")
|
||||
os.Setenv("XDG_CONFIG_HOME", cfgPath)
|
||||
}
|
||||
// Set HOME to make os.UserHomeDir work.
|
||||
if _, exists := os.LookupEnv("HOME"); !exists {
|
||||
os.Setenv("HOME", dataDir)
|
||||
}
|
||||
|
||||
dataDirChan <- dataDir
|
||||
C.jni_ReleaseByteArrayElements(env, jdataDir, dirBytes)
|
||||
|
||||
@@ -548,7 +554,7 @@ func Java_org_gioui_GioView_onLowMemory(env *C.JNIEnv, class C.jclass) {
|
||||
func Java_org_gioui_GioView_onConfigurationChanged(env *C.JNIEnv, class C.jclass, view C.jlong) {
|
||||
w := cgo.Handle(view).Value().(*window)
|
||||
w.loadConfig(env, class)
|
||||
if w.stage >= system.StageRunning {
|
||||
if w.stage >= system.StageInactive {
|
||||
w.draw(env, true)
|
||||
}
|
||||
}
|
||||
@@ -559,7 +565,7 @@ func Java_org_gioui_GioView_onFrameCallback(env *C.JNIEnv, class C.jclass, view
|
||||
if !exist {
|
||||
return
|
||||
}
|
||||
if w.stage < system.StageRunning {
|
||||
if w.stage < system.StageInactive {
|
||||
return
|
||||
}
|
||||
if w.animating {
|
||||
@@ -571,9 +577,7 @@ func Java_org_gioui_GioView_onFrameCallback(env *C.JNIEnv, class C.jclass, view
|
||||
//export Java_org_gioui_GioView_onBack
|
||||
func Java_org_gioui_GioView_onBack(env *C.JNIEnv, class C.jclass, view C.jlong) C.jboolean {
|
||||
w := cgo.Handle(view).Value().(*window)
|
||||
ev := &system.CommandEvent{Type: system.CommandBack}
|
||||
w.callbacks.Event(ev)
|
||||
if ev.Cancel {
|
||||
if w.callbacks.Event(key.Event{Name: key.NameBack}) {
|
||||
return C.JNI_TRUE
|
||||
}
|
||||
return C.JNI_FALSE
|
||||
@@ -588,13 +592,13 @@ func Java_org_gioui_GioView_onFocusChange(env *C.JNIEnv, class C.jclass, view C.
|
||||
//export Java_org_gioui_GioView_onWindowInsets
|
||||
func Java_org_gioui_GioView_onWindowInsets(env *C.JNIEnv, class C.jclass, view C.jlong, top, right, bottom, left C.jint) {
|
||||
w := cgo.Handle(view).Value().(*window)
|
||||
w.insets = system.Insets{
|
||||
Top: unit.Px(float32(top)),
|
||||
Bottom: unit.Px(float32(bottom)),
|
||||
Left: unit.Px(float32(left)),
|
||||
Right: unit.Px(float32(right)),
|
||||
w.insets = pixelInsets{
|
||||
top: int(top),
|
||||
bottom: int(bottom),
|
||||
left: int(left),
|
||||
right: int(right),
|
||||
}
|
||||
if w.stage >= system.StageRunning {
|
||||
if w.stage >= system.StageInactive {
|
||||
w.draw(env, true)
|
||||
}
|
||||
}
|
||||
@@ -832,11 +836,18 @@ func (w *window) draw(env *C.JNIEnv, sync bool) {
|
||||
}
|
||||
const inchPrDp = 1.0 / 160
|
||||
ppdp := float32(w.dpi) * inchPrDp
|
||||
dppp := unit.Dp(1.0 / ppdp)
|
||||
insets := system.Insets{
|
||||
Top: unit.Dp(w.insets.top) * dppp,
|
||||
Bottom: unit.Dp(w.insets.bottom) * dppp,
|
||||
Left: unit.Dp(w.insets.left) * dppp,
|
||||
Right: unit.Dp(w.insets.right) * dppp,
|
||||
}
|
||||
w.callbacks.Event(frameEvent{
|
||||
FrameEvent: system.FrameEvent{
|
||||
Now: time.Now(),
|
||||
Size: w.config.Size,
|
||||
Insets: w.insets,
|
||||
Insets: insets,
|
||||
Metric: unit.Metric{
|
||||
PxPerDp: ppdp,
|
||||
PxPerSp: w.fontScale * ppdp,
|
||||
@@ -867,8 +878,6 @@ func (w *window) draw(env *C.JNIEnv, sync bool) {
|
||||
}
|
||||
}
|
||||
|
||||
type keyMapper func(devId, keyCode C.int32_t) rune
|
||||
|
||||
func runInJVM(jvm *C.JavaVM, f func(env *C.JNIEnv)) {
|
||||
if jvm == nil {
|
||||
panic("nil JVM")
|
||||
@@ -908,6 +917,14 @@ func convertKeyCode(code C.jint) (string, bool) {
|
||||
n = key.NameAlt
|
||||
case C.AKEYCODE_META_LEFT, C.AKEYCODE_META_RIGHT:
|
||||
n = key.NameSuper
|
||||
case C.AKEYCODE_DPAD_UP:
|
||||
n = key.NameUpArrow
|
||||
case C.AKEYCODE_DPAD_DOWN:
|
||||
n = key.NameDownArrow
|
||||
case C.AKEYCODE_DPAD_LEFT:
|
||||
n = key.NameLeftArrow
|
||||
case C.AKEYCODE_DPAD_RIGHT:
|
||||
n = key.NameRightArrow
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
@@ -917,19 +934,9 @@ func convertKeyCode(code C.jint) (string, bool) {
|
||||
//export Java_org_gioui_GioView_onKeyEvent
|
||||
func Java_org_gioui_GioView_onKeyEvent(env *C.JNIEnv, class C.jclass, handle C.jlong, keyCode, r C.jint, pressed C.jboolean, t C.jlong) {
|
||||
w := cgo.Handle(handle).Value().(*window)
|
||||
if pressed == C.JNI_TRUE {
|
||||
switch keyCode {
|
||||
case C.AKEYCODE_DPAD_UP:
|
||||
w.callbacks.MoveFocus(router.FocusUp)
|
||||
case C.AKEYCODE_DPAD_DOWN:
|
||||
w.callbacks.MoveFocus(router.FocusDown)
|
||||
case C.AKEYCODE_DPAD_LEFT:
|
||||
w.callbacks.MoveFocus(router.FocusLeft)
|
||||
case C.AKEYCODE_DPAD_RIGHT:
|
||||
w.callbacks.MoveFocus(router.FocusRight)
|
||||
case C.AKEYCODE_DPAD_CENTER:
|
||||
w.callbacks.ClickFocus()
|
||||
}
|
||||
if pressed == C.JNI_TRUE && keyCode == C.AKEYCODE_DPAD_CENTER {
|
||||
w.callbacks.ClickFocus()
|
||||
return
|
||||
}
|
||||
if n, ok := convertKeyCode(keyCode); ok {
|
||||
state := key.Release
|
||||
@@ -946,18 +953,18 @@ func Java_org_gioui_GioView_onKeyEvent(env *C.JNIEnv, class C.jclass, handle C.j
|
||||
//export Java_org_gioui_GioView_onTouchEvent
|
||||
func Java_org_gioui_GioView_onTouchEvent(env *C.JNIEnv, class C.jclass, handle C.jlong, action, pointerID, tool C.jint, x, y, scrollX, scrollY C.jfloat, jbtns C.jint, t C.jlong) {
|
||||
w := cgo.Handle(handle).Value().(*window)
|
||||
var typ pointer.Type
|
||||
var kind pointer.Kind
|
||||
switch action {
|
||||
case C.AMOTION_EVENT_ACTION_DOWN, C.AMOTION_EVENT_ACTION_POINTER_DOWN:
|
||||
typ = pointer.Press
|
||||
kind = pointer.Press
|
||||
case C.AMOTION_EVENT_ACTION_UP, C.AMOTION_EVENT_ACTION_POINTER_UP:
|
||||
typ = pointer.Release
|
||||
kind = pointer.Release
|
||||
case C.AMOTION_EVENT_ACTION_CANCEL:
|
||||
typ = pointer.Cancel
|
||||
kind = pointer.Cancel
|
||||
case C.AMOTION_EVENT_ACTION_MOVE:
|
||||
typ = pointer.Move
|
||||
kind = pointer.Move
|
||||
case C.AMOTION_EVENT_ACTION_SCROLL:
|
||||
typ = pointer.Scroll
|
||||
kind = pointer.Scroll
|
||||
default:
|
||||
return
|
||||
}
|
||||
@@ -987,7 +994,7 @@ func Java_org_gioui_GioView_onTouchEvent(env *C.JNIEnv, class C.jclass, handle C
|
||||
return
|
||||
}
|
||||
w.callbacks.Event(pointer.Event{
|
||||
Type: typ,
|
||||
Kind: kind,
|
||||
Source: src,
|
||||
Buttons: btns,
|
||||
PointerID: pointer.ID(pointerID),
|
||||
@@ -1057,6 +1064,12 @@ func Java_org_gioui_GioView_imeSnippetStart(env *C.JNIEnv, class C.jclass, handl
|
||||
//export Java_org_gioui_GioView_imeSetSnippet
|
||||
func Java_org_gioui_GioView_imeSetSnippet(env *C.JNIEnv, class C.jclass, handle C.jlong, start, end C.jint) {
|
||||
w := cgo.Handle(handle).Value().(*window)
|
||||
if start < 0 {
|
||||
start = 0
|
||||
}
|
||||
if end < start {
|
||||
end = start
|
||||
}
|
||||
r := key.Range{Start: int(start), End: int(end)}
|
||||
w.callbacks.SetEditorSnippet(r)
|
||||
}
|
||||
@@ -1134,20 +1147,37 @@ func (w *window) ShowTextInput(show bool) {
|
||||
func (w *window) SetInputHint(mode key.InputHint) {
|
||||
// Constants defined at https://developer.android.com/reference/android/text/InputType.
|
||||
const (
|
||||
TYPE_NULL = 0
|
||||
TYPE_CLASS_TEXT = 1
|
||||
TYPE_CLASS_NUMBER = 2
|
||||
TYPE_NUMBER_FLAG_DECIMAL = 8192
|
||||
TYPE_NUMBER_FLAG_SIGNED = 4096
|
||||
TYPE_TEXT_FLAG_NO_SUGGESTIONS = 524288
|
||||
TYPE_TEXT_VARIATION_VISIBLE_PASSWORD = 144
|
||||
TYPE_NULL = 0
|
||||
|
||||
TYPE_CLASS_TEXT = 1
|
||||
TYPE_TEXT_VARIATION_EMAIL_ADDRESS = 32
|
||||
TYPE_TEXT_VARIATION_URI = 16
|
||||
TYPE_TEXT_VARIATION_PASSWORD = 128
|
||||
TYPE_TEXT_FLAG_CAP_SENTENCES = 16384
|
||||
TYPE_TEXT_FLAG_AUTO_CORRECT = 32768
|
||||
|
||||
TYPE_CLASS_NUMBER = 2
|
||||
TYPE_NUMBER_FLAG_DECIMAL = 8192
|
||||
TYPE_NUMBER_FLAG_SIGNED = 4096
|
||||
|
||||
TYPE_CLASS_PHONE = 3
|
||||
)
|
||||
|
||||
runInJVM(javaVM(), func(env *C.JNIEnv) {
|
||||
var m jvalue
|
||||
switch mode {
|
||||
case key.HintText:
|
||||
m = TYPE_CLASS_TEXT | TYPE_TEXT_FLAG_AUTO_CORRECT | TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||
case key.HintNumeric:
|
||||
m = TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_DECIMAL | TYPE_NUMBER_FLAG_SIGNED
|
||||
case key.HintEmail:
|
||||
m = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||
case key.HintURL:
|
||||
m = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_URI
|
||||
case key.HintTelephone:
|
||||
m = TYPE_CLASS_PHONE
|
||||
case key.HintPassword:
|
||||
m = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD
|
||||
default:
|
||||
m = TYPE_CLASS_TEXT
|
||||
}
|
||||
@@ -1319,16 +1349,12 @@ func (w *window) Configure(options []Option) {
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
}
|
||||
if w.config != prev {
|
||||
w.callbacks.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.callbacks.Event(ConfigEvent{Config: w.config})
|
||||
})
|
||||
}
|
||||
|
||||
func (w *window) Perform(system.Action) {}
|
||||
|
||||
func (w *window) Raise() {}
|
||||
|
||||
func (w *window) SetCursor(cursor pointer.Cursor) {
|
||||
runInJVM(javaVM(), func(env *C.JNIEnv) {
|
||||
setCursor(env, w.view, cursor)
|
||||
@@ -1406,9 +1432,6 @@ func setNavigationColor(env *C.JNIEnv, view C.jobject, color color.NRGBA) {
|
||||
)
|
||||
}
|
||||
|
||||
// Close the window. Not implemented for Android.
|
||||
func (w *window) Close() {}
|
||||
|
||||
// runOnMain runs a function on the Java main thread.
|
||||
func runOnMain(f func(env *C.JNIEnv)) {
|
||||
go func() {
|
||||
|
||||
+19
-12
@@ -6,7 +6,7 @@ package app
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
__attribute__ ((visibility ("hidden"))) void gio_wakeupMainThread(void);
|
||||
__attribute__ ((visibility ("hidden"))) CFTypeRef gio_createDisplayLink(uintptr_t handle);
|
||||
__attribute__ ((visibility ("hidden"))) CFTypeRef gio_createDisplayLink(void);
|
||||
__attribute__ ((visibility ("hidden"))) void gio_releaseDisplayLink(CFTypeRef dl);
|
||||
__attribute__ ((visibility ("hidden"))) int gio_startDisplayLink(CFTypeRef dl);
|
||||
__attribute__ ((visibility ("hidden"))) int gio_stopDisplayLink(CFTypeRef dl);
|
||||
@@ -42,7 +42,7 @@ static CFTypeRef newNSString(unichar *chars, NSUInteger length) {
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"runtime/cgo"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unicode/utf16"
|
||||
@@ -70,6 +70,9 @@ type displayLink struct {
|
||||
running uint32
|
||||
}
|
||||
|
||||
// displayLinks maps CFTypeRefs to *displayLinks.
|
||||
var displayLinks sync.Map
|
||||
|
||||
var mainFuncs = make(chan func(), 1)
|
||||
|
||||
// runOnMain runs the function on the main thread.
|
||||
@@ -121,25 +124,25 @@ func stringToNSString(str string) C.CFTypeRef {
|
||||
return C.newNSString(chars, C.NSUInteger(len(u16)))
|
||||
}
|
||||
|
||||
func NewDisplayLink(callback func()) (*displayLink, error) {
|
||||
func newDisplayLink(callback func()) (*displayLink, error) {
|
||||
d := &displayLink{
|
||||
callback: callback,
|
||||
done: make(chan struct{}),
|
||||
states: make(chan bool),
|
||||
dids: make(chan uint64),
|
||||
}
|
||||
h := cgo.NewHandle(d)
|
||||
dl := C.gio_createDisplayLink(C.uintptr_t(h))
|
||||
dl := C.gio_createDisplayLink()
|
||||
if dl == 0 {
|
||||
return nil, errors.New("app: failed to create display link")
|
||||
}
|
||||
go d.run(dl, h)
|
||||
go d.run(dl)
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (d *displayLink) run(dl C.CFTypeRef, h cgo.Handle) {
|
||||
func (d *displayLink) run(dl C.CFTypeRef) {
|
||||
defer C.gio_releaseDisplayLink(dl)
|
||||
defer h.Delete()
|
||||
displayLinks.Store(dl, d)
|
||||
defer displayLinks.Delete(dl)
|
||||
var stopTimer *time.Timer
|
||||
var tchan <-chan time.Time
|
||||
started := false
|
||||
@@ -200,10 +203,14 @@ func (d *displayLink) SetDisplayID(did uint64) {
|
||||
}
|
||||
|
||||
//export gio_onFrameCallback
|
||||
func gio_onFrameCallback(dl C.CFTypeRef, handle C.uintptr_t) {
|
||||
d := cgo.Handle(handle).Value().(*displayLink)
|
||||
if atomic.LoadUint32(&d.running) != 0 {
|
||||
d.callback()
|
||||
func gio_onFrameCallback(ref C.CFTypeRef) {
|
||||
d, exists := displayLinks.Load(ref)
|
||||
if !exists {
|
||||
return
|
||||
}
|
||||
dl := d.(*displayLink)
|
||||
if atomic.LoadUint32(&dl.running) != 0 {
|
||||
dl.callback()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
@import Dispatch;
|
||||
@import Foundation;
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include "_cgo_export.h"
|
||||
|
||||
|
||||
+18
-24
@@ -117,7 +117,7 @@ func onCreate(view, controller C.CFTypeRef) {
|
||||
w := &window{
|
||||
view: view,
|
||||
}
|
||||
dl, err := NewDisplayLink(func() {
|
||||
dl, err := newDisplayLink(func() {
|
||||
w.draw(false)
|
||||
})
|
||||
if err != nil {
|
||||
@@ -150,6 +150,11 @@ func (w *window) draw(sync bool) {
|
||||
w.w.Event(system.StageEvent{Stage: system.StageRunning})
|
||||
}
|
||||
const inchPrDp = 1.0 / 163
|
||||
m := unit.Metric{
|
||||
PxPerDp: float32(params.dpi) * inchPrDp,
|
||||
PxPerSp: float32(params.sdpi) * inchPrDp,
|
||||
}
|
||||
dppp := unit.Dp(1. / m.PxPerDp)
|
||||
w.w.Event(frameEvent{
|
||||
FrameEvent: system.FrameEvent{
|
||||
Now: time.Now(),
|
||||
@@ -158,15 +163,12 @@ func (w *window) draw(sync bool) {
|
||||
Y: int(params.height + .5),
|
||||
},
|
||||
Insets: system.Insets{
|
||||
Top: unit.Px(float32(params.top)),
|
||||
Bottom: unit.Px(float32(params.bottom)),
|
||||
Left: unit.Px(float32(params.left)),
|
||||
Right: unit.Px(float32(params.right)),
|
||||
},
|
||||
Metric: unit.Metric{
|
||||
PxPerDp: float32(params.dpi) * inchPrDp,
|
||||
PxPerSp: float32(params.sdpi) * inchPrDp,
|
||||
Top: unit.Dp(params.top) * dppp,
|
||||
Bottom: unit.Dp(params.bottom) * dppp,
|
||||
Left: unit.Dp(params.left) * dppp,
|
||||
Right: unit.Dp(params.right) * dppp,
|
||||
},
|
||||
Metric: m,
|
||||
},
|
||||
Sync: sync,
|
||||
})
|
||||
@@ -234,16 +236,16 @@ func onText(view, str C.CFTypeRef) {
|
||||
|
||||
//export onTouch
|
||||
func onTouch(last C.int, view, touchRef C.CFTypeRef, phase C.NSInteger, x, y C.CGFloat, ti C.double) {
|
||||
var typ pointer.Type
|
||||
var kind pointer.Kind
|
||||
switch phase {
|
||||
case C.UITouchPhaseBegan:
|
||||
typ = pointer.Press
|
||||
kind = pointer.Press
|
||||
case C.UITouchPhaseMoved:
|
||||
typ = pointer.Move
|
||||
kind = pointer.Move
|
||||
case C.UITouchPhaseEnded:
|
||||
typ = pointer.Release
|
||||
kind = pointer.Release
|
||||
case C.UITouchPhaseCancelled:
|
||||
typ = pointer.Cancel
|
||||
kind = pointer.Cancel
|
||||
default:
|
||||
return
|
||||
}
|
||||
@@ -251,7 +253,7 @@ func onTouch(last C.int, view, touchRef C.CFTypeRef, phase C.NSInteger, x, y C.C
|
||||
t := time.Duration(float64(ti) * float64(time.Second))
|
||||
p := f32.Point{X: float32(x), Y: float32(y)}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: typ,
|
||||
Kind: kind,
|
||||
Source: pointer.Touch,
|
||||
PointerID: w.lookupTouch(last != 0, touchRef),
|
||||
Position: p,
|
||||
@@ -276,20 +278,15 @@ func (w *window) WriteClipboard(s string) {
|
||||
}
|
||||
|
||||
func (w *window) Configure([]Option) {
|
||||
prev := w.config
|
||||
// Decorations are never disabled.
|
||||
w.config.Decorated = true
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *window) EditorStateChanged(old, new editorState) {}
|
||||
|
||||
func (w *window) Perform(system.Action) {}
|
||||
|
||||
func (w *window) Raise() {}
|
||||
|
||||
func (w *window) SetAnimating(anim bool) {
|
||||
v := w.view
|
||||
if v == 0 {
|
||||
@@ -346,9 +343,6 @@ func (w *window) ShowTextInput(show bool) {
|
||||
|
||||
func (w *window) SetInputHint(_ key.InputHint) {}
|
||||
|
||||
// Close the window. Not implemented for iOS.
|
||||
func (w *window) Close() {}
|
||||
|
||||
func newWindow(win *callbacks, options []Option) error {
|
||||
mainWindow.in <- windowAndConfig{win, options}
|
||||
return <-mainWindow.errs
|
||||
|
||||
+5
-17
@@ -123,6 +123,9 @@ static void handleTouches(int last, UIView *view, NSSet<UITouch *> *touches, UIE
|
||||
|
||||
@implementation GioView
|
||||
NSArray<UIKeyCommand *> *_keyCommands;
|
||||
+ (void)onFrameCallback:(CADisplayLink *)link {
|
||||
gio_onFrameCallback((__bridge CFTypeRef)link);
|
||||
}
|
||||
+ (Class)layerClass {
|
||||
return gio_layerClass();
|
||||
}
|
||||
@@ -227,23 +230,8 @@ NSArray<UIKeyCommand *> *_keyCommands;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DisplayLinkHandle : NSObject {
|
||||
}
|
||||
@property uintptr_t handle;
|
||||
@end
|
||||
|
||||
@implementation DisplayLinkHandle {
|
||||
}
|
||||
|
||||
- (void)onFrameCallback:(CADisplayLink *)link {
|
||||
gio_onFrameCallback((__bridge CFTypeRef)link, _handle);
|
||||
}
|
||||
@end
|
||||
|
||||
CFTypeRef gio_createDisplayLink(uintptr_t handle) {
|
||||
DisplayLinkHandle *h = [DisplayLinkHandle alloc];
|
||||
h.handle = handle;
|
||||
CADisplayLink *dl = [CADisplayLink displayLinkWithTarget:h selector:@selector(onFrameCallback:)];
|
||||
CFTypeRef gio_createDisplayLink(void) {
|
||||
CADisplayLink *dl = [CADisplayLink displayLinkWithTarget:[GioView class] selector:@selector(onFrameCallback:)];
|
||||
dl.paused = YES;
|
||||
NSRunLoop *runLoop = [NSRunLoop mainRunLoop];
|
||||
[dl addToRunLoop:runLoop forMode:[runLoop currentMode]];
|
||||
|
||||
+58
-21
@@ -22,7 +22,17 @@ import (
|
||||
"gioui.org/unit"
|
||||
)
|
||||
|
||||
type ViewEvent struct{}
|
||||
type ViewEvent struct {
|
||||
Element js.Value
|
||||
}
|
||||
|
||||
type contextStatus int
|
||||
|
||||
const (
|
||||
contextStatusOkay contextStatus = iota
|
||||
contextStatusLost
|
||||
contextStatusRestored
|
||||
)
|
||||
|
||||
type window struct {
|
||||
window js.Value
|
||||
@@ -54,6 +64,8 @@ type window struct {
|
||||
// is pending.
|
||||
animRequested bool
|
||||
wakeups chan struct{}
|
||||
|
||||
contextStatus contextStatus
|
||||
}
|
||||
|
||||
func newWindow(win *callbacks, options []Option) error {
|
||||
@@ -101,6 +113,7 @@ func newWindow(win *callbacks, options []Option) error {
|
||||
w.w.SetDriver(w)
|
||||
w.Configure(options)
|
||||
w.blur()
|
||||
w.w.Event(ViewEvent{Element: cont})
|
||||
w.w.Event(system.StageEvent{Stage: system.StageRunning})
|
||||
w.resize()
|
||||
w.draw(true)
|
||||
@@ -162,9 +175,25 @@ func (w *window) cleanup() {
|
||||
}
|
||||
|
||||
func (w *window) addEventListeners() {
|
||||
w.addEventListener(w.cnv, "webglcontextlost", func(this js.Value, args []js.Value) interface{} {
|
||||
args[0].Call("preventDefault")
|
||||
w.contextStatus = contextStatusLost
|
||||
return nil
|
||||
})
|
||||
w.addEventListener(w.cnv, "webglcontextrestored", func(this js.Value, args []js.Value) interface{} {
|
||||
args[0].Call("preventDefault")
|
||||
w.contextStatus = contextStatusRestored
|
||||
|
||||
// Resize is required to force update the canvas content when restored.
|
||||
w.cnv.Set("width", 0)
|
||||
w.cnv.Set("height", 0)
|
||||
w.resize()
|
||||
w.requestRedraw()
|
||||
return nil
|
||||
})
|
||||
w.addEventListener(w.visualViewport, "resize", func(this js.Value, args []js.Value) interface{} {
|
||||
w.resize()
|
||||
w.chanRedraw <- struct{}{}
|
||||
w.requestRedraw()
|
||||
return nil
|
||||
})
|
||||
w.addEventListener(w.window, "contextmenu", func(this js.Value, args []js.Value) interface{} {
|
||||
@@ -172,12 +201,9 @@ func (w *window) addEventListeners() {
|
||||
return nil
|
||||
})
|
||||
w.addEventListener(w.window, "popstate", func(this js.Value, args []js.Value) interface{} {
|
||||
ev := &system.CommandEvent{Type: system.CommandBack}
|
||||
w.w.Event(ev)
|
||||
if ev.Cancel {
|
||||
if w.w.Event(key.Event{Name: key.NameBack}) {
|
||||
return w.browserHistory.Call("forward")
|
||||
}
|
||||
|
||||
return w.browserHistory.Call("back")
|
||||
})
|
||||
w.addEventListener(w.document, "visibilitychange", func(this js.Value, args []js.Value) interface{} {
|
||||
@@ -210,6 +236,10 @@ func (w *window) addEventListeners() {
|
||||
w.addEventListener(w.cnv, "wheel", func(this js.Value, args []js.Value) interface{} {
|
||||
e := args[0]
|
||||
dx, dy := e.Get("deltaX").Float(), e.Get("deltaY").Float()
|
||||
// horizontal scroll if shift is pressed.
|
||||
if e.Get("shiftKey").Bool() {
|
||||
dx, dy = dy, dx
|
||||
}
|
||||
mode := e.Get("deltaMode").Int()
|
||||
switch mode {
|
||||
case 0x01: // DOM_DELTA_LINE
|
||||
@@ -245,7 +275,7 @@ func (w *window) addEventListeners() {
|
||||
}
|
||||
w.touches = w.touches[:0]
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Cancel,
|
||||
Kind: pointer.Cancel,
|
||||
Source: pointer.Touch,
|
||||
})
|
||||
return nil
|
||||
@@ -328,6 +358,8 @@ func (w *window) keyboard(hint key.InputHint) {
|
||||
m = "url"
|
||||
case key.HintTelephone:
|
||||
m = "tel"
|
||||
case key.HintPassword:
|
||||
m = "password"
|
||||
default:
|
||||
m = "text"
|
||||
}
|
||||
@@ -366,7 +398,7 @@ func modifiersFor(e js.Value) key.Modifiers {
|
||||
return mods
|
||||
}
|
||||
|
||||
func (w *window) touchEvent(typ pointer.Type, e js.Value) {
|
||||
func (w *window) touchEvent(kind pointer.Kind, e js.Value) {
|
||||
e.Call("preventDefault")
|
||||
t := time.Duration(e.Get("timeStamp").Int()) * time.Millisecond
|
||||
changedTouches := e.Get("changedTouches")
|
||||
@@ -394,7 +426,7 @@ func (w *window) touchEvent(typ pointer.Type, e js.Value) {
|
||||
Y: float32(y) * scale,
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: typ,
|
||||
Kind: kind,
|
||||
Source: pointer.Touch,
|
||||
Position: pos,
|
||||
PointerID: pid,
|
||||
@@ -416,7 +448,7 @@ func (w *window) touchIDFor(touch js.Value) pointer.ID {
|
||||
return pid
|
||||
}
|
||||
|
||||
func (w *window) pointerEvent(typ pointer.Type, dx, dy float32, e js.Value) {
|
||||
func (w *window) pointerEvent(kind pointer.Kind, dx, dy float32, e js.Value) {
|
||||
e.Call("preventDefault")
|
||||
x, y := e.Get("clientX").Float(), e.Get("clientY").Float()
|
||||
rect := w.cnv.Call("getBoundingClientRect")
|
||||
@@ -444,7 +476,7 @@ func (w *window) pointerEvent(typ pointer.Type, dx, dy float32, e js.Value) {
|
||||
btns |= pointer.ButtonTertiary
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: typ,
|
||||
Kind: kind,
|
||||
Source: pointer.Mouse,
|
||||
Buttons: btns,
|
||||
Position: pos,
|
||||
@@ -536,15 +568,11 @@ func (w *window) Configure(options []Option) {
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
}
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *window) Perform(system.Action) {}
|
||||
|
||||
func (w *window) Raise() {}
|
||||
|
||||
var webCursor = [...]string{
|
||||
pointer.CursorDefault: "default",
|
||||
pointer.CursorNone: "none",
|
||||
@@ -602,9 +630,6 @@ func (w *window) SetInputHint(mode key.InputHint) {
|
||||
w.keyboard(mode)
|
||||
}
|
||||
|
||||
// Close the window. Not implemented for js.
|
||||
func (w *window) Close() {}
|
||||
|
||||
func (w *window) resize() {
|
||||
w.scale = float32(w.window.Get("devicePixelRatio").Float())
|
||||
|
||||
@@ -632,10 +657,14 @@ func (w *window) resize() {
|
||||
}
|
||||
|
||||
func (w *window) draw(sync bool) {
|
||||
if w.contextStatus == contextStatusLost {
|
||||
return
|
||||
}
|
||||
size, insets, metric := w.getConfig()
|
||||
if metric == (unit.Metric{}) || size.X == 0 || size.Y == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
w.w.Event(frameEvent{
|
||||
FrameEvent: system.FrameEvent{
|
||||
Now: time.Now(),
|
||||
@@ -648,10 +677,11 @@ func (w *window) draw(sync bool) {
|
||||
}
|
||||
|
||||
func (w *window) getConfig() (image.Point, system.Insets, unit.Metric) {
|
||||
invscale := unit.Dp(1. / w.scale)
|
||||
return image.Pt(w.config.Size.X, w.config.Size.Y),
|
||||
system.Insets{
|
||||
Bottom: unit.Px(w.inset.Y),
|
||||
Right: unit.Px(w.inset.X),
|
||||
Bottom: unit.Dp(w.inset.Y) * invscale,
|
||||
Right: unit.Dp(w.inset.X) * invscale,
|
||||
}, unit.Metric{
|
||||
PxPerDp: w.scale,
|
||||
PxPerSp: w.scale,
|
||||
@@ -705,6 +735,13 @@ func (w *window) navigationColor(c color.NRGBA) {
|
||||
theme.Set("content", fmt.Sprintf("#%06X", []uint8{rgba.R, rgba.G, rgba.B}))
|
||||
}
|
||||
|
||||
func (w *window) requestRedraw() {
|
||||
select {
|
||||
case w.chanRedraw <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func osMain() {
|
||||
select {}
|
||||
}
|
||||
|
||||
+162
-75
@@ -13,7 +13,7 @@ import (
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/internal/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
@@ -24,7 +24,8 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
|
||||
#cgo CFLAGS: -Werror -Wno-deprecated-declarations -fobjc-arc -x objective-c
|
||||
#cgo LDFLAGS: -framework AppKit -framework QuartzCore
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@@ -98,6 +99,31 @@ static NSWindowStyleMask getWindowStyleMask(CFTypeRef windowRef) {
|
||||
return [window styleMask];
|
||||
}
|
||||
|
||||
static void setWindowStyleMask(CFTypeRef windowRef, NSWindowStyleMask mask) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
window.styleMask = mask;
|
||||
}
|
||||
|
||||
static void setWindowTitleVisibility(CFTypeRef windowRef, NSWindowTitleVisibility state) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
window.titleVisibility = state;
|
||||
}
|
||||
|
||||
static void setWindowTitlebarAppearsTransparent(CFTypeRef windowRef, int transparent) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
window.titlebarAppearsTransparent = (BOOL)transparent;
|
||||
}
|
||||
|
||||
static void setWindowStandardButtonHidden(CFTypeRef windowRef, NSWindowButton btn, int hide) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
[window standardWindowButton:btn].hidden = (BOOL)hide;
|
||||
}
|
||||
|
||||
static void performWindowDragWithEvent(CFTypeRef windowRef, CFTypeRef evt) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
[window performWindowDragWithEvent:(__bridge NSEvent*)evt];
|
||||
}
|
||||
|
||||
static void closeWindow(CFTypeRef windowRef) {
|
||||
NSWindow* window = (__bridge NSWindow *)windowRef;
|
||||
[window performClose:nil];
|
||||
@@ -145,12 +171,31 @@ static void setTitle(CFTypeRef windowRef, CFTypeRef titleRef) {
|
||||
window.title = (__bridge NSString *)titleRef;
|
||||
}
|
||||
|
||||
static int isWindowZoomed(CFTypeRef windowRef) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
return window.zoomed ? 1 : 0;
|
||||
}
|
||||
|
||||
static void zoomWindow(CFTypeRef windowRef) {
|
||||
NSWindow *window = (__bridge NSWindow *)windowRef;
|
||||
[window zoom:nil];
|
||||
}
|
||||
|
||||
static CFTypeRef layerForView(CFTypeRef viewRef) {
|
||||
NSView *view = (__bridge NSView *)viewRef;
|
||||
return (__bridge CFTypeRef)view.layer;
|
||||
}
|
||||
|
||||
static CFTypeRef windowForView(CFTypeRef viewRef) {
|
||||
NSView *view = (__bridge NSView *)viewRef;
|
||||
return (__bridge CFTypeRef)view.window;
|
||||
}
|
||||
|
||||
static void raiseWindow(CFTypeRef windowRef) {
|
||||
NSRunningApplication *currentApp = [NSRunningApplication currentApplication];
|
||||
if (![currentApp isActive]) {
|
||||
[currentApp activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
|
||||
}
|
||||
NSWindow* window = (__bridge NSWindow *)windowRef;
|
||||
[window makeKeyAndOrderFront:nil];
|
||||
}
|
||||
@@ -201,14 +246,14 @@ type ViewEvent struct {
|
||||
|
||||
type window struct {
|
||||
view C.CFTypeRef
|
||||
window C.CFTypeRef
|
||||
w *callbacks
|
||||
stage system.Stage
|
||||
displayLink *displayLink
|
||||
// redraw is a single entry channel for making sure only one
|
||||
// display link redraw request is in flight.
|
||||
redraw chan struct{}
|
||||
cursor pointer.Cursor
|
||||
redraw chan struct{}
|
||||
cursor pointer.Cursor
|
||||
pointerBtns pointer.Buttons
|
||||
|
||||
scale float32
|
||||
config Config
|
||||
@@ -256,7 +301,9 @@ func (w *window) contextView() C.CFTypeRef {
|
||||
|
||||
func (w *window) ReadClipboard() {
|
||||
cstr := C.readClipboard()
|
||||
defer C.CFRelease(cstr)
|
||||
if cstr != 0 {
|
||||
defer C.CFRelease(cstr)
|
||||
}
|
||||
content := nsstringToString(cstr)
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
}
|
||||
@@ -268,12 +315,13 @@ func (w *window) WriteClipboard(s string) {
|
||||
}
|
||||
|
||||
func (w *window) updateWindowMode() {
|
||||
style := int(C.getWindowStyleMask(w.window))
|
||||
if style&C.NSWindowStyleMaskFullScreen > 0 {
|
||||
style := int(C.getWindowStyleMask(C.windowForView(w.view)))
|
||||
if style&C.NSWindowStyleMaskFullScreen != 0 {
|
||||
w.config.Mode = Fullscreen
|
||||
} else {
|
||||
w.config.Mode = Windowed
|
||||
}
|
||||
w.config.Decorated = style&C.NSWindowStyleMaskFullSizeContentView == 0
|
||||
}
|
||||
|
||||
func (w *window) Configure(options []Option) {
|
||||
@@ -283,81 +331,89 @@ func (w *window) Configure(options []Option) {
|
||||
w.updateWindowMode()
|
||||
cnf := w.config
|
||||
cnf.apply(cfg, options)
|
||||
// Decorations are never disabled.
|
||||
cnf.Decorated = true
|
||||
window := C.windowForView(w.view)
|
||||
|
||||
switch cnf.Mode {
|
||||
case Fullscreen:
|
||||
switch prev.Mode {
|
||||
case Fullscreen:
|
||||
case Minimized:
|
||||
C.unhideWindow(w.window)
|
||||
C.unhideWindow(window)
|
||||
fallthrough
|
||||
default:
|
||||
w.config.Mode = Fullscreen
|
||||
C.toggleFullScreen(w.window)
|
||||
C.toggleFullScreen(window)
|
||||
}
|
||||
case Minimized:
|
||||
switch prev.Mode {
|
||||
case Minimized, Fullscreen:
|
||||
default:
|
||||
w.config.Mode = Minimized
|
||||
C.hideWindow(w.window)
|
||||
C.hideWindow(window)
|
||||
}
|
||||
case Maximized:
|
||||
switch prev.Mode {
|
||||
case Fullscreen:
|
||||
case Minimized:
|
||||
C.unhideWindow(w.window)
|
||||
C.unhideWindow(window)
|
||||
fallthrough
|
||||
default:
|
||||
w.config.Mode = Maximized
|
||||
r := C.getScreenFrame(w.window) // the screen size of the window
|
||||
C.setScreenFrame(w.window, C.CGFloat(0), C.CGFloat(0), r.size.width, r.size.height)
|
||||
w.config.Size = image.Pt(int(r.size.width), int(r.size.height))
|
||||
w.setTitle(prev, cnf)
|
||||
if C.isWindowZoomed(window) == 0 {
|
||||
C.zoomWindow(window)
|
||||
}
|
||||
}
|
||||
case Windowed:
|
||||
switch prev.Mode {
|
||||
case Fullscreen:
|
||||
w.config.Mode = Windowed
|
||||
C.toggleFullScreen(w.window)
|
||||
C.toggleFullScreen(window)
|
||||
case Minimized:
|
||||
w.config.Mode = Windowed
|
||||
C.unhideWindow(w.window)
|
||||
C.unhideWindow(window)
|
||||
case Maximized:
|
||||
w.config.Mode = Windowed
|
||||
if C.isWindowZoomed(window) != 0 {
|
||||
C.zoomWindow(window)
|
||||
}
|
||||
}
|
||||
w.config.Mode = Windowed
|
||||
w.setTitle(prev, cnf)
|
||||
if prev.Size != cnf.Size {
|
||||
w.config.Size = cnf.Size
|
||||
cnf.Size = cnf.Size.Div(int(screenScale))
|
||||
C.setSize(w.window, C.CGFloat(cnf.Size.X), C.CGFloat(cnf.Size.Y))
|
||||
C.setSize(window, C.CGFloat(cnf.Size.X), C.CGFloat(cnf.Size.Y))
|
||||
}
|
||||
if prev.MinSize != cnf.MinSize {
|
||||
w.config.MinSize = cnf.MinSize
|
||||
cnf.MinSize = cnf.MinSize.Div(int(screenScale))
|
||||
C.setMinSize(w.window, C.CGFloat(cnf.MinSize.X), C.CGFloat(cnf.MinSize.Y))
|
||||
C.setMinSize(window, C.CGFloat(cnf.MinSize.X), C.CGFloat(cnf.MinSize.Y))
|
||||
}
|
||||
if prev.MaxSize != cnf.MaxSize {
|
||||
w.config.MaxSize = cnf.MaxSize
|
||||
cnf.MaxSize = cnf.MaxSize.Div(int(screenScale))
|
||||
C.setMaxSize(w.window, C.CGFloat(cnf.MaxSize.X), C.CGFloat(cnf.MaxSize.Y))
|
||||
}
|
||||
if cnf.center {
|
||||
r := C.getScreenFrame(w.window) // the screen size of the window
|
||||
sz := w.config.Size
|
||||
x := (int(r.size.width) - sz.X) / 2
|
||||
y := (int(r.size.height) - sz.Y) / 2
|
||||
C.setScreenFrame(w.window, C.CGFloat(x), C.CGFloat(y), C.CGFloat(sz.X), C.CGFloat(sz.Y))
|
||||
C.setMaxSize(window, C.CGFloat(cnf.MaxSize.X), C.CGFloat(cnf.MaxSize.Y))
|
||||
}
|
||||
}
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
mask := C.getWindowStyleMask(window)
|
||||
style := C.NSWindowStyleMask(C.NSWindowStyleMaskTitled | C.NSWindowStyleMaskResizable | C.NSWindowStyleMaskMiniaturizable | C.NSWindowStyleMaskClosable)
|
||||
style = C.NSWindowStyleMaskFullSizeContentView
|
||||
mask &^= style
|
||||
barTrans := C.int(C.NO)
|
||||
titleVis := C.NSWindowTitleVisibility(C.NSWindowTitleVisible)
|
||||
if !cnf.Decorated {
|
||||
mask |= style
|
||||
barTrans = C.YES
|
||||
titleVis = C.NSWindowTitleHidden
|
||||
}
|
||||
C.setWindowTitlebarAppearsTransparent(window, barTrans)
|
||||
C.setWindowTitleVisibility(window, titleVis)
|
||||
C.setWindowStyleMask(window, mask)
|
||||
C.setWindowStandardButtonHidden(window, C.NSWindowCloseButton, barTrans)
|
||||
C.setWindowStandardButtonHidden(window, C.NSWindowMiniaturizeButton, barTrans)
|
||||
C.setWindowStandardButtonHidden(window, C.NSWindowZoomButton, barTrans)
|
||||
}
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *window) setTitle(prev, cnf Config) {
|
||||
@@ -365,11 +421,29 @@ func (w *window) setTitle(prev, cnf Config) {
|
||||
w.config.Title = cnf.Title
|
||||
title := stringToNSString(cnf.Title)
|
||||
defer C.CFRelease(title)
|
||||
C.setTitle(w.window, title)
|
||||
C.setTitle(C.windowForView(w.view), title)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *window) Perform(system.Action) {}
|
||||
func (w *window) Perform(acts system.Action) {
|
||||
window := C.windowForView(w.view)
|
||||
walkActions(acts, func(a system.Action) {
|
||||
switch a {
|
||||
case system.ActionCenter:
|
||||
r := C.getScreenFrame(window) // the screen size of the window
|
||||
screenScale := float32(C.getScreenBackingScale())
|
||||
sz := w.config.Size.Div(int(screenScale))
|
||||
x := (int(r.size.width) - sz.X) / 2
|
||||
y := (int(r.size.height) - sz.Y) / 2
|
||||
C.setScreenFrame(window, C.CGFloat(x), C.CGFloat(y), C.CGFloat(sz.X), C.CGFloat(sz.Y))
|
||||
case system.ActionRaise:
|
||||
C.raiseWindow(window)
|
||||
}
|
||||
})
|
||||
if acts&system.ActionClose != 0 {
|
||||
C.closeWindow(window)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *window) SetCursor(cursor pointer.Cursor) {
|
||||
w.cursor = windowSetCursor(w.cursor, cursor)
|
||||
@@ -397,10 +471,6 @@ func (w *window) SetAnimating(anim bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *window) Raise() {
|
||||
C.raiseWindow(w.window)
|
||||
}
|
||||
|
||||
func (w *window) runOnMain(f func()) {
|
||||
runOnMain(func() {
|
||||
// Make sure the view is still valid. The window might've been closed
|
||||
@@ -411,10 +481,6 @@ func (w *window) runOnMain(f func()) {
|
||||
})
|
||||
}
|
||||
|
||||
func (w *window) Close() {
|
||||
C.closeWindow(w.window)
|
||||
}
|
||||
|
||||
func (w *window) setStage(stage system.Stage) {
|
||||
if stage == w.stage {
|
||||
return
|
||||
@@ -451,40 +517,50 @@ func gio_onText(view, cstr C.CFTypeRef) {
|
||||
}
|
||||
|
||||
//export gio_onMouse
|
||||
func gio_onMouse(view C.CFTypeRef, cdir C.int, cbtns C.NSUInteger, x, y, dx, dy C.CGFloat, ti C.double, mods C.NSUInteger) {
|
||||
var typ pointer.Type
|
||||
func gio_onMouse(view, evt C.CFTypeRef, cdir C.int, cbtn C.NSInteger, x, y, dx, dy C.CGFloat, ti C.double, mods C.NSUInteger) {
|
||||
w := mustView(view)
|
||||
t := time.Duration(float64(ti)*float64(time.Second) + .5)
|
||||
xf, yf := float32(x)*w.scale, float32(y)*w.scale
|
||||
dxf, dyf := float32(dx)*w.scale, float32(dy)*w.scale
|
||||
pos := f32.Point{X: xf, Y: yf}
|
||||
var btn pointer.Buttons
|
||||
switch cbtn {
|
||||
case 0:
|
||||
btn = pointer.ButtonPrimary
|
||||
case 1:
|
||||
btn = pointer.ButtonSecondary
|
||||
case 2:
|
||||
btn = pointer.ButtonTertiary
|
||||
}
|
||||
var typ pointer.Kind
|
||||
switch cdir {
|
||||
case C.MOUSE_MOVE:
|
||||
typ = pointer.Move
|
||||
case C.MOUSE_UP:
|
||||
typ = pointer.Release
|
||||
w.pointerBtns &^= btn
|
||||
case C.MOUSE_DOWN:
|
||||
typ = pointer.Press
|
||||
w.pointerBtns |= btn
|
||||
act, ok := w.w.ActionAt(pos)
|
||||
if ok && w.config.Mode != Fullscreen {
|
||||
switch act {
|
||||
case system.ActionMove:
|
||||
C.performWindowDragWithEvent(C.windowForView(w.view), evt)
|
||||
return
|
||||
}
|
||||
}
|
||||
case C.MOUSE_SCROLL:
|
||||
typ = pointer.Scroll
|
||||
default:
|
||||
panic("invalid direction")
|
||||
}
|
||||
var btns pointer.Buttons
|
||||
if cbtns&(1<<0) != 0 {
|
||||
btns |= pointer.ButtonPrimary
|
||||
}
|
||||
if cbtns&(1<<1) != 0 {
|
||||
btns |= pointer.ButtonSecondary
|
||||
}
|
||||
if cbtns&(1<<2) != 0 {
|
||||
btns |= pointer.ButtonTertiary
|
||||
}
|
||||
t := time.Duration(float64(ti)*float64(time.Second) + .5)
|
||||
w := mustView(view)
|
||||
xf, yf := float32(x)*w.scale, float32(y)*w.scale
|
||||
dxf, dyf := float32(dx)*w.scale, float32(dy)*w.scale
|
||||
w.w.Event(pointer.Event{
|
||||
Type: typ,
|
||||
Kind: typ,
|
||||
Source: pointer.Mouse,
|
||||
Time: t,
|
||||
Buttons: btns,
|
||||
Position: f32.Point{X: xf, Y: yf},
|
||||
Buttons: w.pointerBtns,
|
||||
Position: pos,
|
||||
Scroll: f32.Point{X: dxf, Y: dyf},
|
||||
Modifiers: convertMods(mods),
|
||||
})
|
||||
@@ -500,6 +576,13 @@ func gio_onDraw(view C.CFTypeRef) {
|
||||
func gio_onFocus(view C.CFTypeRef, focus C.int) {
|
||||
w := mustView(view)
|
||||
w.w.Event(key.FocusEvent{Focus: focus == 1})
|
||||
if w.stage >= system.StageInactive {
|
||||
if focus == 0 {
|
||||
w.setStage(system.StageInactive)
|
||||
} else {
|
||||
w.setStage(system.StageRunning)
|
||||
}
|
||||
}
|
||||
w.SetCursor(w.cursor)
|
||||
}
|
||||
|
||||
@@ -636,7 +719,11 @@ func gio_insertText(view, cstr C.CFTypeRef, crng C.NSRange) {
|
||||
str := nsstringToString(cstr)
|
||||
w.w.EditorReplace(rng, str)
|
||||
w.w.SetComposingRegion(key.Range{Start: -1, End: -1})
|
||||
pos := rng.Start + utf8.RuneCountInString(str)
|
||||
start := rng.Start
|
||||
if rng.End < start {
|
||||
start = rng.End
|
||||
}
|
||||
pos := start + utf8.RuneCountInString(str)
|
||||
w.w.SetEditorSelection(key.Range{Start: pos, End: pos})
|
||||
}
|
||||
|
||||
@@ -710,14 +797,12 @@ func configFor(scale float32) unit.Metric {
|
||||
func gio_onClose(view C.CFTypeRef) {
|
||||
w := mustView(view)
|
||||
w.w.Event(ViewEvent{})
|
||||
deleteView(view)
|
||||
w.w.Event(system.DestroyEvent{})
|
||||
w.displayLink.Close()
|
||||
C.CFRelease(w.view)
|
||||
C.CFRelease(w.window)
|
||||
w.view = 0
|
||||
w.window = 0
|
||||
w.displayLink = nil
|
||||
deleteView(view)
|
||||
C.CFRelease(w.view)
|
||||
w.view = 0
|
||||
}
|
||||
|
||||
//export gio_onHide
|
||||
@@ -776,16 +861,18 @@ func newWindow(win *callbacks, options []Option) error {
|
||||
}
|
||||
errch <- nil
|
||||
w.w = win
|
||||
w.window = C.gio_createWindow(w.view, 0, 0, 0, 0, 0, 0)
|
||||
window := C.gio_createWindow(w.view, 0, 0, 0, 0, 0, 0)
|
||||
w.updateWindowMode()
|
||||
win.SetDriver(w)
|
||||
w.Configure(options)
|
||||
if nextTopLeft.x == 0 && nextTopLeft.y == 0 {
|
||||
// cascadeTopLeftFromPoint treats (0, 0) as a no-op,
|
||||
// and just returns the offset we need for the first window.
|
||||
nextTopLeft = C.cascadeTopLeftFromPoint(w.window, nextTopLeft)
|
||||
nextTopLeft = C.cascadeTopLeftFromPoint(window, nextTopLeft)
|
||||
}
|
||||
nextTopLeft = C.cascadeTopLeftFromPoint(w.window, nextTopLeft)
|
||||
C.makeKeyAndOrderFront(w.window)
|
||||
nextTopLeft = C.cascadeTopLeftFromPoint(window, nextTopLeft)
|
||||
// makeKeyAndOrderFront assumes ownership of our window reference.
|
||||
C.makeKeyAndOrderFront(window)
|
||||
layer := C.layerForView(w.view)
|
||||
w.w.Event(ViewEvent{View: uintptr(w.view), Layer: uintptr(layer)})
|
||||
})
|
||||
@@ -803,7 +890,7 @@ func newOSWindow() (*window, error) {
|
||||
scale: scale,
|
||||
redraw: make(chan struct{}, 1),
|
||||
}
|
||||
dl, err := NewDisplayLink(func() {
|
||||
dl, err := newDisplayLink(func() {
|
||||
select {
|
||||
case w.redraw <- struct{}{}:
|
||||
default:
|
||||
|
||||
+22
-17
@@ -2,7 +2,7 @@
|
||||
|
||||
// +build darwin,!ios
|
||||
|
||||
@import AppKit;
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "_cgo_export.h"
|
||||
|
||||
@@ -45,11 +45,6 @@ __attribute__ ((visibility ("hidden"))) CALayer *gio_layerFactory(void);
|
||||
NSWindow *window = (NSWindow *)[notification object];
|
||||
gio_onFocus((__bridge CFTypeRef)window.contentView, 0);
|
||||
}
|
||||
- (void)windowWillClose:(NSNotification *)notification {
|
||||
NSWindow *window = (NSWindow *)[notification object];
|
||||
window.delegate = nil;
|
||||
gio_onClose((__bridge CFTypeRef)window.contentView);
|
||||
}
|
||||
@end
|
||||
|
||||
static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFloat dy) {
|
||||
@@ -61,7 +56,7 @@ static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFlo
|
||||
}
|
||||
// Origin is in the lower left corner. Convert to upper left.
|
||||
CGFloat height = view.bounds.size.height;
|
||||
gio_onMouse((__bridge CFTypeRef)view, typ, [NSEvent pressedMouseButtons], p.x, height - p.y, dx, dy, [event timestamp], [event modifierFlags]);
|
||||
gio_onMouse((__bridge CFTypeRef)view, (__bridge CFTypeRef)event, typ, event.buttonNumber, p.x, height - p.y, dx, dy, [event timestamp], [event modifierFlags]);
|
||||
}
|
||||
|
||||
@interface GioView : NSView <CALayerDelegate,NSTextInputClient>
|
||||
@@ -86,30 +81,41 @@ static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFlo
|
||||
layer.delegate = self;
|
||||
return layer;
|
||||
}
|
||||
- (void)viewDidMoveToWindow {
|
||||
if (self.window == nil) {
|
||||
gio_onClose((__bridge CFTypeRef)self);
|
||||
}
|
||||
}
|
||||
- (void)mouseDown:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_DOWN, 0, 0);
|
||||
}
|
||||
- (void)mouseUp:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_UP, 0, 0);
|
||||
}
|
||||
- (void)middleMouseDown:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_DOWN, 0, 0);
|
||||
}
|
||||
- (void)middletMouseUp:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_UP, 0, 0);
|
||||
}
|
||||
- (void)rightMouseDown:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_DOWN, 0, 0);
|
||||
}
|
||||
- (void)rightMouseUp:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_UP, 0, 0);
|
||||
}
|
||||
- (void)otherMouseDown:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_DOWN, 0, 0);
|
||||
}
|
||||
- (void)otherMouseUp:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_UP, 0, 0);
|
||||
}
|
||||
- (void)mouseMoved:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_MOVE, 0, 0);
|
||||
}
|
||||
- (void)mouseDragged:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_MOVE, 0, 0);
|
||||
}
|
||||
- (void)rightMouseDragged:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_MOVE, 0, 0);
|
||||
}
|
||||
- (void)otherMouseDragged:(NSEvent *)event {
|
||||
handleMouse(self, event, MOUSE_MOVE, 0, 0);
|
||||
}
|
||||
- (void)scrollWheel:(NSEvent *)event {
|
||||
CGFloat dx = -event.scrollingDeltaX;
|
||||
CGFloat dy = -event.scrollingDeltaY;
|
||||
@@ -193,14 +199,14 @@ static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFlo
|
||||
static GioWindowDelegate *globalWindowDel;
|
||||
|
||||
static CVReturn displayLinkCallback(CVDisplayLinkRef dl, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *handle) {
|
||||
gio_onFrameCallback(dl, (uintptr_t)handle);
|
||||
gio_onFrameCallback(dl);
|
||||
return kCVReturnSuccess;
|
||||
}
|
||||
|
||||
CFTypeRef gio_createDisplayLink(uintptr_t handle) {
|
||||
CFTypeRef gio_createDisplayLink(void) {
|
||||
CVDisplayLinkRef dl;
|
||||
CVDisplayLinkCreateWithActiveCGDisplays(&dl);
|
||||
CVDisplayLinkSetOutputCallback(dl, displayLinkCallback, (void *)(handle));
|
||||
CVDisplayLinkSetOutputCallback(dl, displayLinkCallback, nil);
|
||||
return dl;
|
||||
}
|
||||
|
||||
@@ -357,7 +363,6 @@ CFTypeRef gio_createWindow(CFTypeRef viewRef, CGFloat width, CGFloat height, CGF
|
||||
NSView *view = (__bridge NSView *)viewRef;
|
||||
[window setContentView:view];
|
||||
[window makeFirstResponder:view];
|
||||
window.releasedWhenClosed = NO;
|
||||
window.delegate = globalWindowDel;
|
||||
return (__bridge_retained CFTypeRef)window;
|
||||
}
|
||||
|
||||
+220
-103
@@ -12,7 +12,6 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -168,7 +167,23 @@ type window struct {
|
||||
cursor struct {
|
||||
theme *C.struct_wl_cursor_theme
|
||||
cursor *C.struct_wl_cursor
|
||||
surf *C.struct_wl_surface
|
||||
// system is the active cursor for system gestures
|
||||
// such as border resizes and window moves. It
|
||||
// is nil if the pointer is not in a system gesture
|
||||
// area.
|
||||
system *C.struct_wl_cursor
|
||||
surf *C.struct_wl_surface
|
||||
cursors struct {
|
||||
pointer *C.struct_wl_cursor
|
||||
resizeNorth *C.struct_wl_cursor
|
||||
resizeSouth *C.struct_wl_cursor
|
||||
resizeWest *C.struct_wl_cursor
|
||||
resizeEast *C.struct_wl_cursor
|
||||
resizeNorthWest *C.struct_wl_cursor
|
||||
resizeNorthEast *C.struct_wl_cursor
|
||||
resizeSouthWest *C.struct_wl_cursor
|
||||
resizeSouthEast *C.struct_wl_cursor
|
||||
}
|
||||
}
|
||||
|
||||
fling struct {
|
||||
@@ -358,14 +373,28 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
|
||||
w.destroy()
|
||||
return nil, errors.New("wayland: xdg_surface_get_toplevel failed")
|
||||
}
|
||||
w.cursor.theme = C.wl_cursor_theme_load(nil, 32, d.shm)
|
||||
|
||||
id := C.CString(ID)
|
||||
defer C.free(unsafe.Pointer(id))
|
||||
C.xdg_toplevel_set_app_id(w.topLvl, id)
|
||||
|
||||
cursorTheme := C.CString(os.Getenv("XCURSOR_THEME"))
|
||||
defer C.free(unsafe.Pointer(cursorTheme))
|
||||
cursorSize := 32
|
||||
if envSize, ok := os.LookupEnv("XCURSOR_SIZE"); ok && envSize != "" {
|
||||
size, err := strconv.Atoi(envSize)
|
||||
if err == nil {
|
||||
cursorSize = size
|
||||
}
|
||||
}
|
||||
|
||||
w.cursor.theme = C.wl_cursor_theme_load(cursorTheme, C.int(cursorSize*w.scale), d.shm)
|
||||
if w.cursor.theme == nil {
|
||||
w.destroy()
|
||||
return nil, errors.New("wayland: wl_cursor_theme_load failed")
|
||||
}
|
||||
cname := C.CString("left_ptr")
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
w.cursor.cursor = C.wl_cursor_theme_get_cursor(w.cursor.theme, cname)
|
||||
w.loadCursors()
|
||||
w.cursor.cursor = w.cursor.cursors.pointer
|
||||
if w.cursor.cursor == nil {
|
||||
w.destroy()
|
||||
return nil, errors.New("wayland: wl_cursor_theme_get_cursor failed")
|
||||
@@ -375,6 +404,7 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
|
||||
w.destroy()
|
||||
return nil, errors.New("wayland: wl_compositor_create_surface failed")
|
||||
}
|
||||
C.wl_surface_set_buffer_scale(w.cursor.surf, C.int32_t(w.scale))
|
||||
C.xdg_wm_base_add_listener(d.wm, &C.gio_xdg_wm_base_listener, unsafe.Pointer(w.surf))
|
||||
C.wl_surface_add_listener(w.surf, &C.gio_surface_listener, unsafe.Pointer(w.surf))
|
||||
C.xdg_surface_add_listener(w.wmSurf, &C.gio_xdg_surface_listener, unsafe.Pointer(w.surf))
|
||||
@@ -388,6 +418,33 @@ func (d *wlDisplay) createNativeWindow(options []Option) (*window, error) {
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func (w *window) loadCursors() {
|
||||
w.cursor.cursors.pointer = w.loadCursor(pointer.CursorDefault)
|
||||
w.cursor.cursors.resizeNorth = w.loadCursor(pointer.CursorNorthResize)
|
||||
w.cursor.cursors.resizeSouth = w.loadCursor(pointer.CursorSouthResize)
|
||||
w.cursor.cursors.resizeWest = w.loadCursor(pointer.CursorWestResize)
|
||||
w.cursor.cursors.resizeEast = w.loadCursor(pointer.CursorEastResize)
|
||||
w.cursor.cursors.resizeSouthWest = w.loadCursor(pointer.CursorSouthWestResize)
|
||||
w.cursor.cursors.resizeSouthEast = w.loadCursor(pointer.CursorSouthEastResize)
|
||||
w.cursor.cursors.resizeNorthWest = w.loadCursor(pointer.CursorNorthWestResize)
|
||||
w.cursor.cursors.resizeNorthEast = w.loadCursor(pointer.CursorNorthEastResize)
|
||||
}
|
||||
|
||||
func (w *window) loadCursor(name pointer.Cursor) *C.struct_wl_cursor {
|
||||
if name == pointer.CursorNone {
|
||||
return nil
|
||||
}
|
||||
xcursor := xCursor[name]
|
||||
cname := C.CString(xcursor)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
c := C.wl_cursor_theme_get_cursor(w.cursor.theme, cname)
|
||||
if c == nil {
|
||||
// Fall back to default cursor.
|
||||
c = w.cursor.cursors.pointer
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func callbackDelete(k unsafe.Pointer) {
|
||||
callbackMap.Delete(k)
|
||||
}
|
||||
@@ -523,6 +580,12 @@ func gio_onToplevelDecorationConfigure(data unsafe.Pointer, deco *C.struct_zxdg_
|
||||
w.config.Decorated = true
|
||||
}
|
||||
if decorated != w.config.Decorated {
|
||||
w.setWindowConstraints()
|
||||
if w.config.Decorated {
|
||||
w.size.Y -= int(w.config.decoHeight)
|
||||
} else {
|
||||
w.size.Y += int(w.config.decoHeight)
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
w.redraw = true
|
||||
}
|
||||
@@ -560,7 +623,7 @@ func gio_onOutputDone(data unsafe.Pointer, output *C.struct_wl_output) {
|
||||
d := callbackLoad(data).(*wlDisplay)
|
||||
conf := d.outputConfig[output]
|
||||
for _, w := range conf.windows {
|
||||
w.redraw = true
|
||||
w.updateOutputs()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,15 +691,7 @@ func gio_onRegistryGlobal(data unsafe.Pointer, reg *C.struct_wl_registry, name C
|
||||
}
|
||||
callbackStore(unsafe.Pointer(s), d.seat)
|
||||
C.wl_seat_add_listener(s, &C.gio_seat_listener, unsafe.Pointer(s))
|
||||
if d.dataDeviceManager == nil {
|
||||
break
|
||||
}
|
||||
d.seat.dataDev = C.wl_data_device_manager_get_data_device(d.dataDeviceManager, s)
|
||||
if d.seat.dataDev == nil {
|
||||
break
|
||||
}
|
||||
callbackStore(unsafe.Pointer(d.seat.dataDev), d.seat)
|
||||
C.wl_data_device_add_listener(d.seat.dataDev, &C.gio_data_device_listener, unsafe.Pointer(d.seat.dataDev))
|
||||
d.bindDataDevice()
|
||||
case "wl_shm":
|
||||
d.shm = (*C.struct_wl_shm)(C.wl_registry_bind(reg, name, &C.wl_shm_interface, 1))
|
||||
case "xdg_wm_base":
|
||||
@@ -648,6 +703,7 @@ func gio_onRegistryGlobal(data unsafe.Pointer, reg *C.struct_wl_registry, name C
|
||||
d.imm = (*C.struct_zwp_text_input_manager_v3)(C.wl_registry_bind(reg, name, &C.zwp_text_input_manager_v3_interface, 1))*/
|
||||
case "wl_data_device_manager":
|
||||
d.dataDeviceManager = (*C.struct_wl_data_device_manager)(C.wl_registry_bind(reg, name, &C.wl_data_device_manager_interface, 3))
|
||||
d.bindDataDevice()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,7 +791,7 @@ func gio_onTouchDown(data unsafe.Pointer, touch *C.struct_wl_touch, serial, t C.
|
||||
Y: fromFixed(y) * float32(w.scale),
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Press,
|
||||
Kind: pointer.Press,
|
||||
Source: pointer.Touch,
|
||||
Position: w.lastTouch,
|
||||
PointerID: pointer.ID(id),
|
||||
@@ -751,7 +807,7 @@ func gio_onTouchUp(data unsafe.Pointer, touch *C.struct_wl_touch, serial, t C.ui
|
||||
w := s.touchFoci[id]
|
||||
delete(s.touchFoci, id)
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Release,
|
||||
Kind: pointer.Release,
|
||||
Source: pointer.Touch,
|
||||
Position: w.lastTouch,
|
||||
PointerID: pointer.ID(id),
|
||||
@@ -769,7 +825,7 @@ func gio_onTouchMotion(data unsafe.Pointer, touch *C.struct_wl_touch, t C.uint32
|
||||
Y: fromFixed(y) * float32(w.scale),
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Move,
|
||||
Kind: pointer.Move,
|
||||
Position: w.lastTouch,
|
||||
Source: pointer.Touch,
|
||||
PointerID: pointer.ID(id),
|
||||
@@ -788,7 +844,7 @@ func gio_onTouchCancel(data unsafe.Pointer, touch *C.struct_wl_touch) {
|
||||
for id, w := range s.touchFoci {
|
||||
delete(s.touchFoci, id)
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Cancel,
|
||||
Kind: pointer.Cancel,
|
||||
Source: pointer.Touch,
|
||||
})
|
||||
}
|
||||
@@ -813,7 +869,7 @@ func gio_onPointerLeave(data unsafe.Pointer, p *C.struct_wl_pointer, serial C.ui
|
||||
s.serial = serial
|
||||
if w.inCompositor {
|
||||
w.inCompositor = false
|
||||
w.w.Event(pointer.Event{Type: pointer.Cancel})
|
||||
w.w.Event(pointer.Event{Kind: pointer.Cancel})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,21 +903,35 @@ func gio_onPointerButton(data unsafe.Pointer, p *C.struct_wl_pointer, serial, t,
|
||||
default:
|
||||
return
|
||||
}
|
||||
var typ pointer.Type
|
||||
if state == 1 && btn == pointer.ButtonPrimary {
|
||||
if _, edge := w.systemGesture(); edge != 0 {
|
||||
w.resize(serial, edge)
|
||||
return
|
||||
}
|
||||
act, ok := w.w.ActionAt(w.lastPos)
|
||||
if ok && w.config.Mode == Windowed {
|
||||
switch act {
|
||||
case system.ActionMove:
|
||||
w.move(serial)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
var kind pointer.Kind
|
||||
switch state {
|
||||
case 0:
|
||||
w.pointerBtns &^= btn
|
||||
typ = pointer.Release
|
||||
kind = pointer.Release
|
||||
// Move or resize gestures no longer applies.
|
||||
w.inCompositor = false
|
||||
case 1:
|
||||
w.pointerBtns |= btn
|
||||
typ = pointer.Press
|
||||
kind = pointer.Press
|
||||
}
|
||||
w.flushScroll()
|
||||
w.resetFling()
|
||||
w.w.Event(pointer.Event{
|
||||
Type: typ,
|
||||
Kind: kind,
|
||||
Source: pointer.Mouse,
|
||||
Buttons: w.pointerBtns,
|
||||
Position: w.lastPos,
|
||||
@@ -883,7 +953,12 @@ func gio_onPointerAxis(data unsafe.Pointer, p *C.struct_wl_pointer, t, axis C.ui
|
||||
case C.WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||
w.scroll.dist.X += v
|
||||
case C.WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||
w.scroll.dist.Y += v
|
||||
// horizontal scroll if shift + mousewheel(up/down) pressed.
|
||||
if w.disp.xkb.Modifiers() == key.ModShift {
|
||||
w.scroll.dist.X += v
|
||||
} else {
|
||||
w.scroll.dist.Y += v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,7 +1008,12 @@ func gio_onPointerAxisDiscrete(data unsafe.Pointer, p *C.struct_wl_pointer, axis
|
||||
case C.WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||
w.scroll.steps.X += int(discrete)
|
||||
case C.WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||
w.scroll.steps.Y += int(discrete)
|
||||
// horizontal scroll if shift + mousewheel(up/down) pressed.
|
||||
if w.disp.xkb.Modifiers() == key.ModShift {
|
||||
w.scroll.steps.X += int(discrete)
|
||||
} else {
|
||||
w.scroll.steps.Y += int(discrete)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,7 +1027,7 @@ func (w *window) ReadClipboard() {
|
||||
// Don't let slow clipboard transfers block event loop.
|
||||
go func() {
|
||||
defer r.Close()
|
||||
data, _ := ioutil.ReadAll(r)
|
||||
data, _ := io.ReadAll(r)
|
||||
w.clipReads <- clipboard.Event{Text: string(data)}
|
||||
w.Wakeup()
|
||||
}()
|
||||
@@ -962,6 +1042,7 @@ func (w *window) Configure(options []Option) {
|
||||
prev := w.config
|
||||
cnf := w.config
|
||||
cnf.apply(cfg, options)
|
||||
w.config.decoHeight = cnf.decoHeight
|
||||
|
||||
switch cnf.Mode {
|
||||
case Fullscreen:
|
||||
@@ -1004,25 +1085,36 @@ func (w *window) Configure(options []Option) {
|
||||
w.setTitle(prev, cnf)
|
||||
if prev.Size != cnf.Size {
|
||||
w.config.Size = cnf.Size
|
||||
w.size = cnf.Size.Div(w.scale)
|
||||
}
|
||||
if prev.MinSize != cnf.MinSize {
|
||||
w.config.MinSize = cnf.MinSize
|
||||
C.xdg_toplevel_set_min_size(w.topLvl, C.int32_t(cnf.MinSize.X), C.int32_t(cnf.MinSize.Y))
|
||||
}
|
||||
if prev.MaxSize != cnf.MaxSize {
|
||||
w.config.MaxSize = cnf.MaxSize
|
||||
C.xdg_toplevel_set_max_size(w.topLvl, C.int32_t(cnf.MaxSize.X), C.int32_t(cnf.MaxSize.Y))
|
||||
w.config.Size.Y += int(w.decoHeight()) * w.scale
|
||||
w.size = w.config.Size.Div(w.scale)
|
||||
}
|
||||
w.config.MinSize = cnf.MinSize
|
||||
w.config.MaxSize = cnf.MaxSize
|
||||
w.setWindowConstraints()
|
||||
}
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
w.redraw = true
|
||||
}
|
||||
|
||||
func (w *window) setWindowConstraints() {
|
||||
decoHeight := w.decoHeight()
|
||||
if scaled := w.config.MinSize.Div(w.scale); scaled != (image.Point{}) {
|
||||
C.xdg_toplevel_set_min_size(w.topLvl, C.int32_t(scaled.X), C.int32_t(scaled.Y+decoHeight))
|
||||
}
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
if scaled := w.config.MaxSize.Div(w.scale); scaled != (image.Point{}) {
|
||||
C.xdg_toplevel_set_max_size(w.topLvl, C.int32_t(scaled.X), C.int32_t(scaled.Y+decoHeight))
|
||||
}
|
||||
}
|
||||
|
||||
// decoHeight returns the adjustment for client-side decorations, if applicable.
|
||||
// The unit is in surface-local coordinates.
|
||||
func (w *window) decoHeight() int {
|
||||
if !w.config.Decorated {
|
||||
return int(w.config.decoHeight)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (w *window) setTitle(prev, cnf Config) {
|
||||
if prev.Title != cnf.Title {
|
||||
w.config.Title = cnf.Title
|
||||
@@ -1033,88 +1125,62 @@ func (w *window) setTitle(prev, cnf Config) {
|
||||
}
|
||||
|
||||
func (w *window) Perform(actions system.Action) {
|
||||
// NB. there is no way for a minimized window to be unminimized.
|
||||
// https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_minimized
|
||||
walkActions(actions, func(action system.Action) {
|
||||
switch action {
|
||||
case system.ActionMove:
|
||||
w.move()
|
||||
default:
|
||||
w.resize(action)
|
||||
case system.ActionClose:
|
||||
w.dead = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (w *window) move() {
|
||||
if !w.inCompositor && w.seat != nil {
|
||||
func (w *window) move(serial C.uint32_t) {
|
||||
s := w.seat
|
||||
if !w.inCompositor && s != nil {
|
||||
w.inCompositor = true
|
||||
s := w.seat
|
||||
C.xdg_toplevel_move(w.topLvl, s.seat, s.serial)
|
||||
C.xdg_toplevel_move(w.topLvl, s.seat, serial)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *window) resize(a system.Action) {
|
||||
if w.inCompositor || w.seat == nil {
|
||||
return
|
||||
}
|
||||
var edge int
|
||||
switch a {
|
||||
case system.ActionResizeNorth:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_TOP
|
||||
case system.ActionResizeSouth:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM
|
||||
case system.ActionResizeEast:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_LEFT
|
||||
case system.ActionResizeWest:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_RIGHT
|
||||
case system.ActionResizeNorthWest:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT
|
||||
case system.ActionResizeNorthEast:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT
|
||||
case system.ActionResizeSouthEast:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT
|
||||
case system.ActionResizeSouthWest:
|
||||
edge = C.XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT
|
||||
default:
|
||||
func (w *window) resize(serial, edge C.uint32_t) {
|
||||
s := w.seat
|
||||
if w.inCompositor || s == nil {
|
||||
return
|
||||
}
|
||||
w.inCompositor = true
|
||||
s := w.seat
|
||||
C.xdg_toplevel_resize(w.topLvl, s.seat, s.serial, C.uint32_t(edge))
|
||||
}
|
||||
|
||||
func (w *window) Raise() {
|
||||
// NB. there is no way for a minimized window to be unminimized.
|
||||
// https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_minimized
|
||||
C.xdg_toplevel_resize(w.topLvl, s.seat, serial, edge)
|
||||
}
|
||||
|
||||
func (w *window) SetCursor(cursor pointer.Cursor) {
|
||||
w.cursor.cursor = w.loadCursor(cursor)
|
||||
w.updateCursor()
|
||||
}
|
||||
|
||||
func (w *window) updateCursor() {
|
||||
ptr := w.disp.seat.pointer
|
||||
if ptr == nil {
|
||||
return
|
||||
}
|
||||
if cursor == pointer.CursorNone {
|
||||
C.wl_pointer_set_cursor(ptr, w.serial, nil, 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
xcursor := xCursor[cursor]
|
||||
cname := C.CString(xcursor)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
c := C.wl_cursor_theme_get_cursor(w.cursor.theme, cname)
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
w.cursor.cursor = c
|
||||
w.setCursor(ptr, w.serial)
|
||||
}
|
||||
|
||||
func (w *window) setCursor(pointer *C.struct_wl_pointer, serial C.uint32_t) {
|
||||
c := w.cursor.system
|
||||
if c == nil {
|
||||
c = w.cursor.cursor
|
||||
}
|
||||
if c == nil {
|
||||
C.wl_pointer_set_cursor(pointer, w.serial, nil, 0, 0)
|
||||
return
|
||||
}
|
||||
// Get images[0].
|
||||
img := *w.cursor.cursor.images
|
||||
img := *c.images
|
||||
buf := C.wl_cursor_image_get_buffer(img)
|
||||
if buf == nil {
|
||||
return
|
||||
}
|
||||
C.wl_pointer_set_cursor(pointer, serial, w.cursor.surf, C.int32_t(img.hotspot_x), C.int32_t(img.hotspot_y))
|
||||
C.wl_pointer_set_cursor(pointer, serial, w.cursor.surf, C.int32_t(img.hotspot_x/C.uint(w.scale)), C.int32_t(img.hotspot_y/C.uint(w.scale)))
|
||||
C.wl_surface_attach(w.cursor.surf, buf, 0, 0)
|
||||
C.wl_surface_damage(w.cursor.surf, 0, 0, C.int32_t(img.width), C.int32_t(img.height))
|
||||
C.wl_surface_commit(w.cursor.surf)
|
||||
@@ -1306,6 +1372,19 @@ func (w *window) loop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindDataDevice initializes the dataDev field if and only if both
|
||||
// the seat and dataDeviceManager fields are initialized.
|
||||
func (d *wlDisplay) bindDataDevice() {
|
||||
if d.seat != nil && d.dataDeviceManager != nil {
|
||||
d.seat.dataDev = C.wl_data_device_manager_get_data_device(d.dataDeviceManager, d.seat.seat)
|
||||
if d.seat.dataDev == nil {
|
||||
return
|
||||
}
|
||||
callbackStore(unsafe.Pointer(d.seat.dataDev), d.seat)
|
||||
C.wl_data_device_add_listener(d.seat.dataDev, &C.gio_data_device_listener, unsafe.Pointer(d.seat.dataDev))
|
||||
}
|
||||
}
|
||||
|
||||
func (d *wlDisplay) dispatch(p *poller) error {
|
||||
dispfd := C.wl_display_get_fd(d.disp)
|
||||
// Poll for events and notifications.
|
||||
@@ -1494,7 +1573,7 @@ func (w *window) flushScroll() {
|
||||
return
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Scroll,
|
||||
Kind: pointer.Scroll,
|
||||
Source: pointer.Mouse,
|
||||
Buttons: w.pointerBtns,
|
||||
Position: w.lastPos,
|
||||
@@ -1517,13 +1596,55 @@ func (w *window) onPointerMotion(x, y C.wl_fixed_t, t C.uint32_t) {
|
||||
Y: fromFixed(y) * float32(w.scale),
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Move,
|
||||
Kind: pointer.Move,
|
||||
Position: w.lastPos,
|
||||
Buttons: w.pointerBtns,
|
||||
Source: pointer.Mouse,
|
||||
Time: time.Duration(t) * time.Millisecond,
|
||||
Modifiers: w.disp.xkb.Modifiers(),
|
||||
})
|
||||
c, _ := w.systemGesture()
|
||||
if c != w.cursor.system {
|
||||
w.cursor.system = c
|
||||
w.updateCursor()
|
||||
}
|
||||
}
|
||||
|
||||
// updateCursor updates the system gesture cursor according to the pointer
|
||||
// position.
|
||||
func (w *window) systemGesture() (*C.struct_wl_cursor, C.uint32_t) {
|
||||
if w.config.Mode != Windowed || w.config.Decorated {
|
||||
return nil, 0
|
||||
}
|
||||
border := w.w.w.metric.Dp(3)
|
||||
x, y, size := int(w.lastPos.X), int(w.lastPos.Y), w.config.Size
|
||||
north := y <= border
|
||||
south := y >= size.Y-border
|
||||
west := x <= border
|
||||
east := x >= size.X-border
|
||||
|
||||
switch {
|
||||
default:
|
||||
fallthrough
|
||||
case !north && !south && !west && !east:
|
||||
return nil, 0
|
||||
case north && west:
|
||||
return w.cursor.cursors.resizeNorthWest, C.XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT
|
||||
case north && east:
|
||||
return w.cursor.cursors.resizeNorthEast, C.XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT
|
||||
case south && west:
|
||||
return w.cursor.cursors.resizeSouthWest, C.XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT
|
||||
case south && east:
|
||||
return w.cursor.cursors.resizeSouthEast, C.XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT
|
||||
case north:
|
||||
return w.cursor.cursors.resizeNorth, C.XDG_TOPLEVEL_RESIZE_EDGE_TOP
|
||||
case south:
|
||||
return w.cursor.cursors.resizeSouth, C.XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM
|
||||
case west:
|
||||
return w.cursor.cursors.resizeWest, C.XDG_TOPLEVEL_RESIZE_EDGE_LEFT
|
||||
case east:
|
||||
return w.cursor.cursors.resizeEast, C.XDG_TOPLEVEL_RESIZE_EDGE_RIGHT
|
||||
}
|
||||
}
|
||||
|
||||
func (w *window) updateOpaqueRegion() {
|
||||
@@ -1549,6 +1670,7 @@ func (w *window) updateOutputs() {
|
||||
if found && scale != w.scale {
|
||||
w.scale = scale
|
||||
C.wl_surface_set_buffer_scale(w.surf, C.int32_t(w.scale))
|
||||
w.redraw = true
|
||||
}
|
||||
if !found {
|
||||
w.setStage(system.StagePaused)
|
||||
@@ -1622,21 +1744,16 @@ func (w *window) SetInputHint(_ key.InputHint) {}
|
||||
|
||||
func (w *window) EditorStateChanged(old, new editorState) {}
|
||||
|
||||
// Close the window.
|
||||
func (w *window) Close() {
|
||||
w.dead = true
|
||||
}
|
||||
|
||||
func (w *window) NewContext() (context, error) {
|
||||
var firstErr error
|
||||
if f := newWaylandVulkanContext; f != nil {
|
||||
if f := newWaylandEGLContext; f != nil {
|
||||
c, err := f(w)
|
||||
if err == nil {
|
||||
return c, nil
|
||||
}
|
||||
firstErr = err
|
||||
}
|
||||
if f := newWaylandEGLContext; f != nil {
|
||||
if f := newWaylandVulkanContext; f != nil {
|
||||
c, err := f(w)
|
||||
if err == nil {
|
||||
return c, nil
|
||||
|
||||
+220
-129
@@ -32,11 +32,6 @@ type ViewEvent struct {
|
||||
HWND uintptr
|
||||
}
|
||||
|
||||
type winDeltas struct {
|
||||
width int32
|
||||
height int32
|
||||
}
|
||||
|
||||
type window struct {
|
||||
hwnd syscall.Handle
|
||||
hdc syscall.Handle
|
||||
@@ -53,9 +48,10 @@ type window struct {
|
||||
placement *windows.WindowPlacement
|
||||
|
||||
animating bool
|
||||
focused bool
|
||||
|
||||
deltas winDeltas
|
||||
config Config
|
||||
borderSize image.Point
|
||||
config Config
|
||||
}
|
||||
|
||||
const _WM_WAKEUP = windows.WM_USER + iota
|
||||
@@ -150,6 +146,8 @@ func initResources() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
const dwExStyle = windows.WS_EX_APPWINDOW | windows.WS_EX_WINDOWEDGE
|
||||
|
||||
func createNativeWindow() (*window, error) {
|
||||
var resErr error
|
||||
resources.once.Do(func() {
|
||||
@@ -158,10 +156,10 @@ func createNativeWindow() (*window, error) {
|
||||
if resErr != nil {
|
||||
return nil, resErr
|
||||
}
|
||||
dwStyle := uint32(windows.WS_OVERLAPPEDWINDOW)
|
||||
dwExStyle := uint32(windows.WS_EX_APPWINDOW | windows.WS_EX_WINDOWEDGE)
|
||||
const dwStyle = windows.WS_OVERLAPPEDWINDOW
|
||||
|
||||
hwnd, err := windows.CreateWindowEx(dwExStyle,
|
||||
hwnd, err := windows.CreateWindowEx(
|
||||
dwExStyle,
|
||||
resources.class,
|
||||
"",
|
||||
dwStyle|windows.WS_CLIPSIBLINGS|windows.WS_CLIPCHILDREN,
|
||||
@@ -188,39 +186,17 @@ func createNativeWindow() (*window, error) {
|
||||
// It reads the window style and size/position and updates w.config.
|
||||
// If anything has changed it emits a ConfigEvent to notify the application.
|
||||
func (w *window) update() {
|
||||
var triggerEvent bool
|
||||
r := windows.GetWindowRect(w.hwnd)
|
||||
size := image.Point{
|
||||
X: int(r.Right - r.Left - w.deltas.width),
|
||||
Y: int(r.Bottom - r.Top - w.deltas.height),
|
||||
cr := windows.GetClientRect(w.hwnd)
|
||||
w.config.Size = image.Point{
|
||||
X: int(cr.Right - cr.Left),
|
||||
Y: int(cr.Bottom - cr.Top),
|
||||
}
|
||||
|
||||
// Check the window mode.
|
||||
mode := w.config.Mode
|
||||
p := windows.GetWindowPlacement(w.hwnd)
|
||||
style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE)
|
||||
if style&windows.WS_OVERLAPPEDWINDOW == 0 {
|
||||
mode = Fullscreen
|
||||
mi := windows.GetMonitorInfo(w.hwnd).Monitor
|
||||
size = image.Point{X: int(mi.Right - mi.Left), Y: int(mi.Bottom - mi.Top)}
|
||||
} else if p.IsMinimized() {
|
||||
mode = Minimized
|
||||
} else if p.IsMaximized() {
|
||||
mode = Maximized
|
||||
} else {
|
||||
mode = Windowed
|
||||
}
|
||||
if size != w.config.Size {
|
||||
w.config.Size = size
|
||||
triggerEvent = true
|
||||
}
|
||||
if mode != w.config.Mode {
|
||||
w.config.Mode = mode
|
||||
triggerEvent = true
|
||||
}
|
||||
if triggerEvent {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.borderSize = image.Pt(
|
||||
windows.GetSystemMetrics(windows.SM_CXSIZEFRAME),
|
||||
windows.GetSystemMetrics(windows.SM_CYSIZEFRAME),
|
||||
)
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr {
|
||||
@@ -283,26 +259,46 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
||||
w.pointerButton(pointer.ButtonTertiary, false, lParam, getModifiers())
|
||||
case windows.WM_CANCELMODE:
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Cancel,
|
||||
Kind: pointer.Cancel,
|
||||
})
|
||||
case windows.WM_SETFOCUS:
|
||||
w.focused = true
|
||||
w.w.Event(key.FocusEvent{Focus: true})
|
||||
case windows.WM_KILLFOCUS:
|
||||
w.focused = false
|
||||
w.w.Event(key.FocusEvent{Focus: false})
|
||||
case windows.WM_NCACTIVATE:
|
||||
if w.stage >= system.StageInactive {
|
||||
if wParam == windows.TRUE {
|
||||
w.setStage(system.StageRunning)
|
||||
} else {
|
||||
w.setStage(system.StageInactive)
|
||||
}
|
||||
}
|
||||
case windows.WM_NCHITTEST:
|
||||
if w.config.Decorated {
|
||||
// Let the system handle it.
|
||||
break
|
||||
}
|
||||
x, y := coordsFromlParam(lParam)
|
||||
np := windows.Point{X: int32(x), Y: int32(y)}
|
||||
windows.ScreenToClient(w.hwnd, &np)
|
||||
return w.hitTest(int(np.X), int(np.Y))
|
||||
case windows.WM_MOUSEMOVE:
|
||||
x, y := coordsFromlParam(lParam)
|
||||
p := f32.Point{X: float32(x), Y: float32(y)}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Move,
|
||||
Source: pointer.Mouse,
|
||||
Position: p,
|
||||
Buttons: w.pointerBtns,
|
||||
Time: windows.GetMessageTime(),
|
||||
Kind: pointer.Move,
|
||||
Source: pointer.Mouse,
|
||||
Position: p,
|
||||
Buttons: w.pointerBtns,
|
||||
Time: windows.GetMessageTime(),
|
||||
Modifiers: getModifiers(),
|
||||
})
|
||||
case windows.WM_MOUSEWHEEL:
|
||||
w.scrollEvent(wParam, lParam, false)
|
||||
w.scrollEvent(wParam, lParam, false, getModifiers())
|
||||
case windows.WM_MOUSEHWHEEL:
|
||||
w.scrollEvent(wParam, lParam, true)
|
||||
w.scrollEvent(wParam, lParam, true, getModifiers())
|
||||
case windows.WM_DESTROY:
|
||||
w.w.Event(ViewEvent{})
|
||||
w.w.Event(system.DestroyEvent{})
|
||||
@@ -313,31 +309,67 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
||||
// The system destroys the HWND for us.
|
||||
w.hwnd = 0
|
||||
windows.PostQuitMessage(0)
|
||||
case windows.WM_NCCALCSIZE:
|
||||
if w.config.Decorated {
|
||||
// Let Windows handle decorations.
|
||||
break
|
||||
}
|
||||
// No client areas; we draw decorations ourselves.
|
||||
if wParam != 1 {
|
||||
return 0
|
||||
}
|
||||
// lParam contains an NCCALCSIZE_PARAMS for us to adjust.
|
||||
place := windows.GetWindowPlacement(w.hwnd)
|
||||
if !place.IsMaximized() {
|
||||
// Nothing do adjust.
|
||||
return 0
|
||||
}
|
||||
// Adjust window position to avoid the extra padding in maximized
|
||||
// state. See https://devblogs.microsoft.com/oldnewthing/20150304-00/?p=44543.
|
||||
// Note that trying to do the adjustment in WM_GETMINMAXINFO is ignored by Windows.
|
||||
szp := (*windows.NCCalcSizeParams)(unsafe.Pointer(uintptr(lParam)))
|
||||
mi := windows.GetMonitorInfo(w.hwnd)
|
||||
szp.Rgrc[0] = mi.WorkArea
|
||||
return 0
|
||||
case windows.WM_PAINT:
|
||||
w.draw(true)
|
||||
case windows.WM_SIZE:
|
||||
w.update()
|
||||
switch wParam {
|
||||
case windows.SIZE_MINIMIZED:
|
||||
w.update()
|
||||
w.config.Mode = Minimized
|
||||
w.setStage(system.StagePaused)
|
||||
case windows.SIZE_MAXIMIZED, windows.SIZE_RESTORED:
|
||||
w.update()
|
||||
case windows.SIZE_MAXIMIZED:
|
||||
w.config.Mode = Maximized
|
||||
w.setStage(system.StageRunning)
|
||||
case windows.SIZE_RESTORED:
|
||||
if w.config.Mode != Fullscreen {
|
||||
w.config.Mode = Windowed
|
||||
}
|
||||
w.setStage(system.StageRunning)
|
||||
}
|
||||
case windows.WM_GETMINMAXINFO:
|
||||
mm := (*windows.MinMaxInfo)(unsafe.Pointer(uintptr(lParam)))
|
||||
var bw, bh int32
|
||||
if w.config.Decorated {
|
||||
r := windows.GetWindowRect(w.hwnd)
|
||||
cr := windows.GetClientRect(w.hwnd)
|
||||
bw = r.Right - r.Left - (cr.Right - cr.Left)
|
||||
bh = r.Bottom - r.Top - (cr.Bottom - cr.Top)
|
||||
}
|
||||
if p := w.config.MinSize; p.X > 0 || p.Y > 0 {
|
||||
mm.PtMinTrackSize = windows.Point{
|
||||
X: int32(p.X) + w.deltas.width,
|
||||
Y: int32(p.Y) + w.deltas.height,
|
||||
X: int32(p.X) + bw,
|
||||
Y: int32(p.Y) + bh,
|
||||
}
|
||||
}
|
||||
if p := w.config.MaxSize; p.X > 0 || p.Y > 0 {
|
||||
mm.PtMaxTrackSize = windows.Point{
|
||||
X: int32(p.X) + w.deltas.width,
|
||||
Y: int32(p.Y) + w.deltas.height,
|
||||
X: int32(p.X) + bw,
|
||||
Y: int32(p.Y) + bh,
|
||||
}
|
||||
}
|
||||
return 0
|
||||
case windows.WM_SETCURSOR:
|
||||
w.cursorIn = (lParam & 0xffff) == windows.HTCLIENT
|
||||
if w.cursorIn {
|
||||
@@ -390,11 +422,12 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
|
||||
comp.Start = state.RunesIndex(state.UTF16Index(comp.Start) + start)
|
||||
}
|
||||
w.w.SetComposingRegion(comp)
|
||||
pos := end
|
||||
if lParam&windows.GCS_CURSORPOS != 0 {
|
||||
rel := windows.ImmGetCompositionValue(imc, windows.GCS_CURSORPOS)
|
||||
pos := state.RunesIndex(state.UTF16Index(rng.Start) + rel)
|
||||
w.w.SetEditorSelection(key.Range{Start: pos, End: pos})
|
||||
pos = state.RunesIndex(state.UTF16Index(rng.Start) + rel)
|
||||
}
|
||||
w.w.SetEditorSelection(key.Range{Start: pos, End: pos})
|
||||
return windows.TRUE
|
||||
case windows.WM_IME_ENDCOMPOSITION:
|
||||
w.w.SetComposingRegion(key.Range{Start: -1, End: -1})
|
||||
@@ -421,16 +454,62 @@ func getModifiers() key.Modifiers {
|
||||
return kmods
|
||||
}
|
||||
|
||||
// hitTest returns the non-client area hit by the point, needed to
|
||||
// process WM_NCHITTEST.
|
||||
func (w *window) hitTest(x, y int) uintptr {
|
||||
if w.config.Mode == Fullscreen {
|
||||
return windows.HTCLIENT
|
||||
}
|
||||
if w.config.Mode != Windowed {
|
||||
// Only windowed mode should allow resizing.
|
||||
return windows.HTCLIENT
|
||||
}
|
||||
// Check for resize handle before system actions; otherwise it can be impossible to
|
||||
// resize a custom-decorations window when the system move area is flush with the
|
||||
// edge of the window.
|
||||
top := y <= w.borderSize.Y
|
||||
bottom := y >= w.config.Size.Y-w.borderSize.Y
|
||||
left := x <= w.borderSize.X
|
||||
right := x >= w.config.Size.X-w.borderSize.X
|
||||
switch {
|
||||
case top && left:
|
||||
return windows.HTTOPLEFT
|
||||
case top && right:
|
||||
return windows.HTTOPRIGHT
|
||||
case bottom && left:
|
||||
return windows.HTBOTTOMLEFT
|
||||
case bottom && right:
|
||||
return windows.HTBOTTOMRIGHT
|
||||
case top:
|
||||
return windows.HTTOP
|
||||
case bottom:
|
||||
return windows.HTBOTTOM
|
||||
case left:
|
||||
return windows.HTLEFT
|
||||
case right:
|
||||
return windows.HTRIGHT
|
||||
}
|
||||
p := f32.Pt(float32(x), float32(y))
|
||||
if a, ok := w.w.ActionAt(p); ok && a == system.ActionMove {
|
||||
return windows.HTCAPTION
|
||||
}
|
||||
return windows.HTCLIENT
|
||||
}
|
||||
|
||||
func (w *window) pointerButton(btn pointer.Buttons, press bool, lParam uintptr, kmods key.Modifiers) {
|
||||
var typ pointer.Type
|
||||
if !w.focused {
|
||||
windows.SetFocus(w.hwnd)
|
||||
}
|
||||
|
||||
var kind pointer.Kind
|
||||
if press {
|
||||
typ = pointer.Press
|
||||
kind = pointer.Press
|
||||
if w.pointerBtns == 0 {
|
||||
windows.SetCapture(w.hwnd)
|
||||
}
|
||||
w.pointerBtns |= btn
|
||||
} else {
|
||||
typ = pointer.Release
|
||||
kind = pointer.Release
|
||||
w.pointerBtns &^= btn
|
||||
if w.pointerBtns == 0 {
|
||||
windows.ReleaseCapture()
|
||||
@@ -439,7 +518,7 @@ func (w *window) pointerButton(btn pointer.Buttons, press bool, lParam uintptr,
|
||||
x, y := coordsFromlParam(lParam)
|
||||
p := f32.Point{X: float32(x), Y: float32(y)}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: typ,
|
||||
Kind: kind,
|
||||
Source: pointer.Mouse,
|
||||
Position: p,
|
||||
Buttons: w.pointerBtns,
|
||||
@@ -454,7 +533,7 @@ func coordsFromlParam(lParam uintptr) (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
||||
func (w *window) scrollEvent(wParam, lParam uintptr, horizontal bool) {
|
||||
func (w *window) scrollEvent(wParam, lParam uintptr, horizontal bool, kmods key.Modifiers) {
|
||||
x, y := coordsFromlParam(lParam)
|
||||
// The WM_MOUSEWHEEL coordinates are in screen coordinates, in contrast
|
||||
// to other mouse events.
|
||||
@@ -466,15 +545,21 @@ func (w *window) scrollEvent(wParam, lParam uintptr, horizontal bool) {
|
||||
if horizontal {
|
||||
sp.X = dist
|
||||
} else {
|
||||
sp.Y = -dist
|
||||
// support horizontal scroll (shift + mousewheel)
|
||||
if kmods == key.ModShift {
|
||||
sp.X = -dist
|
||||
} else {
|
||||
sp.Y = -dist
|
||||
}
|
||||
}
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Scroll,
|
||||
Source: pointer.Mouse,
|
||||
Position: p,
|
||||
Buttons: w.pointerBtns,
|
||||
Scroll: sp,
|
||||
Time: windows.GetMessageTime(),
|
||||
Kind: pointer.Scroll,
|
||||
Source: pointer.Mouse,
|
||||
Position: p,
|
||||
Buttons: w.pointerBtns,
|
||||
Scroll: sp,
|
||||
Modifiers: kmods,
|
||||
Time: windows.GetMessageTime(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -587,78 +672,67 @@ func (w *window) readClipboard() error {
|
||||
}
|
||||
|
||||
func (w *window) Configure(options []Option) {
|
||||
oldConfig := w.config
|
||||
dpi := windows.GetSystemDPI()
|
||||
metric := configForDPI(dpi)
|
||||
w.config.apply(metric, options)
|
||||
windows.SetWindowText(w.hwnd, w.config.Title)
|
||||
// Decorations are never disabled.
|
||||
w.config.Decorated = true
|
||||
|
||||
style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE)
|
||||
var showMode int32
|
||||
var x, y, width, height int32
|
||||
swpStyle := uintptr(windows.SWP_NOZORDER | windows.SWP_FRAMECHANGED)
|
||||
winStyle := uintptr(windows.WS_OVERLAPPEDWINDOW)
|
||||
style &^= winStyle
|
||||
switch w.config.Mode {
|
||||
case Minimized:
|
||||
windows.ShowWindow(w.hwnd, windows.SW_SHOWMINIMIZED)
|
||||
style |= winStyle
|
||||
swpStyle |= windows.SWP_NOMOVE | windows.SWP_NOSIZE
|
||||
showMode = windows.SW_SHOWMINIMIZED
|
||||
|
||||
case Maximized:
|
||||
// Set window style.
|
||||
style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE) & (^uintptr(windows.WS_MAXIMIZE))
|
||||
windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style|windows.WS_OVERLAPPEDWINDOW)
|
||||
mi := windows.GetMonitorInfo(w.hwnd).Monitor
|
||||
w.config.Size = image.Point{X: int(mi.Right - mi.Left), Y: int(mi.Bottom - mi.Top)}
|
||||
windows.ShowWindow(w.hwnd, windows.SW_SHOWMAXIMIZED)
|
||||
style |= winStyle
|
||||
swpStyle |= windows.SWP_NOMOVE | windows.SWP_NOSIZE
|
||||
showMode = windows.SW_SHOWMAXIMIZED
|
||||
|
||||
case Windowed:
|
||||
windows.SetWindowText(w.hwnd, w.config.Title)
|
||||
// Set window style.
|
||||
style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE) & (^uintptr(windows.WS_MAXIMIZE))
|
||||
windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style|windows.WS_OVERLAPPEDWINDOW)
|
||||
// Get target for client areaa size.
|
||||
width := int32(w.config.Size.X)
|
||||
height := int32(w.config.Size.Y)
|
||||
style |= winStyle
|
||||
showMode = windows.SW_SHOWNORMAL
|
||||
// Get target for client area size.
|
||||
width = int32(w.config.Size.X)
|
||||
height = int32(w.config.Size.Y)
|
||||
// Get the current window size and position.
|
||||
wr := windows.GetWindowRect(w.hwnd)
|
||||
// Set desired window size.
|
||||
wr.Right = wr.Left + width
|
||||
wr.Bottom = wr.Top + height
|
||||
// Convert from client size to window size.
|
||||
r := wr
|
||||
windows.AdjustWindowRectEx(&r, windows.WS_OVERLAPPEDWINDOW, 0, windows.WS_EX_APPWINDOW|windows.WS_EX_WINDOWEDGE)
|
||||
// Calculate difference between client and full window sizes.
|
||||
w.deltas.width = r.Right - wr.Right + wr.Left - r.Left
|
||||
w.deltas.height = r.Bottom - wr.Bottom + wr.Top - r.Top
|
||||
// Set new window size and position.
|
||||
x := wr.Left
|
||||
y := wr.Top
|
||||
dx := r.Right - r.Left
|
||||
dy := r.Bottom - r.Top
|
||||
if w.config.center {
|
||||
// Calculate center position on current monitor.
|
||||
mi := windows.GetMonitorInfo(w.hwnd).Monitor
|
||||
x = (mi.Right - mi.Left - dx) / 2
|
||||
y = (mi.Bottom - mi.Top - dy) / 2
|
||||
// Centering is done only once.
|
||||
w.config.center = false
|
||||
x = wr.Left
|
||||
y = wr.Top
|
||||
if w.config.Decorated {
|
||||
// Compute client size and position. Note that the client size is
|
||||
// equal to the window size when we are in control of decorations.
|
||||
r := windows.Rect{
|
||||
Right: width,
|
||||
Bottom: height,
|
||||
}
|
||||
windows.AdjustWindowRectEx(&r, uint32(style), 0, dwExStyle)
|
||||
width = r.Right - r.Left
|
||||
height = r.Bottom - r.Top
|
||||
}
|
||||
if !w.config.Decorated {
|
||||
// Enable drop shadows when we draw decorations.
|
||||
windows.DwmExtendFrameIntoClientArea(w.hwnd, windows.Margins{-1, -1, -1, -1})
|
||||
}
|
||||
windows.SetWindowPos(w.hwnd, 0, x, y, dx, dy, windows.SWP_NOOWNERZORDER|windows.SWP_FRAMECHANGED)
|
||||
windows.ShowWindow(w.hwnd, windows.SW_SHOWNORMAL)
|
||||
|
||||
case Fullscreen:
|
||||
style := windows.GetWindowLong(w.hwnd, windows.GWL_STYLE)
|
||||
windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style&^windows.WS_OVERLAPPEDWINDOW)
|
||||
swpStyle |= windows.SWP_NOMOVE | windows.SWP_NOSIZE
|
||||
mi := windows.GetMonitorInfo(w.hwnd)
|
||||
w.config.Size = image.Point{X: int(mi.Monitor.Right - mi.Monitor.Left), Y: int(mi.Monitor.Bottom - mi.Monitor.Top)}
|
||||
windows.SetWindowPos(w.hwnd, 0,
|
||||
mi.Monitor.Left, mi.Monitor.Top,
|
||||
mi.Monitor.Right-mi.Monitor.Left,
|
||||
mi.Monitor.Bottom-mi.Monitor.Top,
|
||||
windows.SWP_NOOWNERZORDER|windows.SWP_FRAMECHANGED,
|
||||
)
|
||||
windows.ShowWindow(w.hwnd, windows.SW_SHOW)
|
||||
}
|
||||
// A config event is sent to the main event loop whenever the configuration is changed
|
||||
if oldConfig != w.config {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
x, y = mi.Monitor.Left, mi.Monitor.Top
|
||||
width = mi.Monitor.Right - mi.Monitor.Left
|
||||
height = mi.Monitor.Bottom - mi.Monitor.Top
|
||||
showMode = windows.SW_SHOWMAXIMIZED
|
||||
}
|
||||
windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style)
|
||||
windows.SetWindowPos(w.hwnd, 0, x, y, width, height, swpStyle)
|
||||
windows.ShowWindow(w.hwnd, showMode)
|
||||
|
||||
w.update()
|
||||
}
|
||||
|
||||
func (w *window) WriteClipboard(s string) {
|
||||
@@ -761,13 +835,30 @@ func (w *window) HWND() (syscall.Handle, int, int) {
|
||||
return w.hwnd, w.config.Size.X, w.config.Size.Y
|
||||
}
|
||||
|
||||
func (w *window) Close() {
|
||||
windows.PostMessage(w.hwnd, windows.WM_CLOSE, 0, 0)
|
||||
func (w *window) Perform(acts system.Action) {
|
||||
walkActions(acts, func(a system.Action) {
|
||||
switch a {
|
||||
case system.ActionCenter:
|
||||
if w.config.Mode != Windowed {
|
||||
break
|
||||
}
|
||||
r := windows.GetWindowRect(w.hwnd)
|
||||
dx := r.Right - r.Left
|
||||
dy := r.Bottom - r.Top
|
||||
// Calculate center position on current monitor.
|
||||
mi := windows.GetMonitorInfo(w.hwnd).Monitor
|
||||
x := (mi.Right - mi.Left - dx) / 2
|
||||
y := (mi.Bottom - mi.Top - dy) / 2
|
||||
windows.SetWindowPos(w.hwnd, 0, x, y, dx, dy, windows.SWP_NOZORDER|windows.SWP_FRAMECHANGED)
|
||||
case system.ActionRaise:
|
||||
w.raise()
|
||||
case system.ActionClose:
|
||||
windows.PostMessage(w.hwnd, windows.WM_CLOSE, 0, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (w *window) Perform(system.Action) {}
|
||||
|
||||
func (w *window) Raise() {
|
||||
func (w *window) raise() {
|
||||
windows.SetForegroundWindow(w.hwnd)
|
||||
windows.SetWindowPos(w.hwnd, windows.HWND_TOPMOST, 0, 0, 0, 0,
|
||||
windows.SWP_NOMOVE|windows.SWP_NOSIZE|windows.SWP_SHOWWINDOW)
|
||||
|
||||
+59
-45
@@ -30,8 +30,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -172,7 +170,7 @@ func (w *x11Window) Configure(options []Option) {
|
||||
switch prev.Mode {
|
||||
case Fullscreen:
|
||||
case Minimized:
|
||||
w.Raise()
|
||||
w.raise()
|
||||
fallthrough
|
||||
default:
|
||||
w.config.Mode = Fullscreen
|
||||
@@ -190,7 +188,7 @@ func (w *x11Window) Configure(options []Option) {
|
||||
switch prev.Mode {
|
||||
case Fullscreen:
|
||||
case Minimized:
|
||||
w.Raise()
|
||||
w.raise()
|
||||
fallthrough
|
||||
default:
|
||||
w.config.Mode = Maximized
|
||||
@@ -205,7 +203,7 @@ func (w *x11Window) Configure(options []Option) {
|
||||
C.XResizeWindow(w.x, w.xw, C.uint(cnf.Size.X), C.uint(cnf.Size.Y))
|
||||
case Minimized:
|
||||
w.config.Mode = Windowed
|
||||
w.Raise()
|
||||
w.raise()
|
||||
case Maximized:
|
||||
w.config.Mode = Windowed
|
||||
w.sendWMStateEvent(_NET_WM_STATE_REMOVE, w.atoms.wmStateMaximizedHorz, w.atoms.wmStateMaximizedVert)
|
||||
@@ -230,29 +228,11 @@ func (w *x11Window) Configure(options []Option) {
|
||||
if shints.flags != 0 {
|
||||
C.XSetWMNormalHints(w.x, w.xw, &shints)
|
||||
}
|
||||
if cnf.center {
|
||||
screen := C.XDefaultScreen(w.x)
|
||||
width := C.XDisplayWidth(w.x, screen)
|
||||
height := C.XDisplayHeight(w.x, screen)
|
||||
|
||||
var attrs C.XWindowAttributes
|
||||
C.XGetWindowAttributes(w.x, w.xw, &attrs)
|
||||
width -= attrs.border_width
|
||||
height -= attrs.border_width
|
||||
|
||||
sz := w.config.Size
|
||||
x := (int(width) - sz.X) / 2
|
||||
y := (int(height) - sz.Y) / 2
|
||||
|
||||
C.XMoveResizeWindow(w.x, w.xw, C.int(x), C.int(y), C.uint(sz.X), C.uint(sz.Y))
|
||||
}
|
||||
}
|
||||
if cnf.Decorated != prev.Decorated {
|
||||
w.config.Decorated = cnf.Decorated
|
||||
}
|
||||
if w.config != prev {
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
w.w.Event(ConfigEvent{Config: w.config})
|
||||
}
|
||||
|
||||
func (w *x11Window) setTitle(prev, cnf Config) {
|
||||
@@ -273,9 +253,38 @@ func (w *x11Window) setTitle(prev, cnf Config) {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *x11Window) Perform(system.Action) {}
|
||||
func (w *x11Window) Perform(acts system.Action) {
|
||||
walkActions(acts, func(a system.Action) {
|
||||
switch a {
|
||||
case system.ActionCenter:
|
||||
w.center()
|
||||
case system.ActionRaise:
|
||||
w.raise()
|
||||
}
|
||||
})
|
||||
if acts&system.ActionClose != 0 {
|
||||
w.close()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *x11Window) Raise() {
|
||||
func (w *x11Window) center() {
|
||||
screen := C.XDefaultScreen(w.x)
|
||||
width := C.XDisplayWidth(w.x, screen)
|
||||
height := C.XDisplayHeight(w.x, screen)
|
||||
|
||||
var attrs C.XWindowAttributes
|
||||
C.XGetWindowAttributes(w.x, w.xw, &attrs)
|
||||
width -= attrs.border_width
|
||||
height -= attrs.border_width
|
||||
|
||||
sz := w.config.Size
|
||||
x := (int(width) - sz.X) / 2
|
||||
y := (int(height) - sz.Y) / 2
|
||||
|
||||
C.XMoveResizeWindow(w.x, w.xw, C.int(x), C.int(y), C.uint(sz.X), C.uint(sz.Y))
|
||||
}
|
||||
|
||||
func (w *x11Window) raise() {
|
||||
var xev C.XEvent
|
||||
ev := (*C.XClientMessageEvent)(unsafe.Pointer(&xev))
|
||||
*ev = C.XClientMessageEvent{
|
||||
@@ -321,8 +330,8 @@ func (w *x11Window) SetInputHint(_ key.InputHint) {}
|
||||
|
||||
func (w *x11Window) EditorStateChanged(old, new editorState) {}
|
||||
|
||||
// Close the window.
|
||||
func (w *x11Window) Close() {
|
||||
// close the window.
|
||||
func (w *x11Window) close() {
|
||||
var xev C.XEvent
|
||||
ev := (*C.XClientMessageEvent)(unsafe.Pointer(&xev))
|
||||
*ev = C.XClientMessageEvent{
|
||||
@@ -458,7 +467,6 @@ loop:
|
||||
})
|
||||
}
|
||||
}
|
||||
w.w.Event(system.DestroyEvent{Err: nil})
|
||||
}
|
||||
|
||||
func (w *x11Window) destroy() {
|
||||
@@ -480,7 +488,6 @@ func (w *x11Window) destroy() {
|
||||
|
||||
// atom is a wrapper around XInternAtom. Callers should cache the result
|
||||
// in order to limit round-trips to the X server.
|
||||
//
|
||||
func (w *x11Window) atom(name string, onlyIfExists bool) C.Atom {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
@@ -494,7 +501,6 @@ func (w *x11Window) atom(name string, onlyIfExists bool) C.Atom {
|
||||
// x11EventHandler wraps static variables for the main event loop.
|
||||
// Its sole purpose is to prevent heap allocation and reduce clutter
|
||||
// in x11window.loop.
|
||||
//
|
||||
type x11EventHandler struct {
|
||||
w *x11Window
|
||||
text []byte
|
||||
@@ -502,7 +508,6 @@ type x11EventHandler struct {
|
||||
}
|
||||
|
||||
// handleEvents returns true if the window needs to be redrawn.
|
||||
//
|
||||
func (h *x11EventHandler) handleEvents() bool {
|
||||
w := h.w
|
||||
xev := h.xev
|
||||
@@ -542,7 +547,7 @@ func (h *x11EventHandler) handleEvents() bool {
|
||||
case C.ButtonPress, C.ButtonRelease:
|
||||
bevt := (*C.XButtonEvent)(unsafe.Pointer(xev))
|
||||
ev := pointer.Event{
|
||||
Type: pointer.Press,
|
||||
Kind: pointer.Press,
|
||||
Source: pointer.Mouse,
|
||||
Position: f32.Point{
|
||||
X: float32(bevt.x),
|
||||
@@ -552,7 +557,7 @@ func (h *x11EventHandler) handleEvents() bool {
|
||||
Modifiers: w.xkb.Modifiers(),
|
||||
}
|
||||
if bevt._type == C.ButtonRelease {
|
||||
ev.Type = pointer.Release
|
||||
ev.Kind = pointer.Release
|
||||
}
|
||||
var btn pointer.Buttons
|
||||
const scrollScale = 10
|
||||
@@ -564,21 +569,29 @@ func (h *x11EventHandler) handleEvents() bool {
|
||||
case C.Button3:
|
||||
btn = pointer.ButtonSecondary
|
||||
case C.Button4:
|
||||
// scroll up
|
||||
ev.Type = pointer.Scroll
|
||||
ev.Scroll.Y = -scrollScale
|
||||
ev.Kind = pointer.Scroll
|
||||
// scroll up or left (if shift is pressed).
|
||||
if ev.Modifiers == key.ModShift {
|
||||
ev.Scroll.X = -scrollScale
|
||||
} else {
|
||||
ev.Scroll.Y = -scrollScale
|
||||
}
|
||||
case C.Button5:
|
||||
// scroll down
|
||||
ev.Type = pointer.Scroll
|
||||
ev.Scroll.Y = +scrollScale
|
||||
// scroll down or right (if shift is pressed).
|
||||
ev.Kind = pointer.Scroll
|
||||
if ev.Modifiers == key.ModShift {
|
||||
ev.Scroll.X = +scrollScale
|
||||
} else {
|
||||
ev.Scroll.Y = +scrollScale
|
||||
}
|
||||
case 6:
|
||||
// http://xahlee.info/linux/linux_x11_mouse_button_number.html
|
||||
// scroll left
|
||||
ev.Type = pointer.Scroll
|
||||
// scroll left.
|
||||
ev.Kind = pointer.Scroll
|
||||
ev.Scroll.X = -scrollScale * 2
|
||||
case 7:
|
||||
// scroll right
|
||||
ev.Type = pointer.Scroll
|
||||
ev.Kind = pointer.Scroll
|
||||
ev.Scroll.X = +scrollScale * 2
|
||||
default:
|
||||
continue
|
||||
@@ -594,7 +607,7 @@ func (h *x11EventHandler) handleEvents() bool {
|
||||
case C.MotionNotify:
|
||||
mevt := (*C.XMotionEvent)(unsafe.Pointer(xev))
|
||||
w.w.Event(pointer.Event{
|
||||
Type: pointer.Move,
|
||||
Kind: pointer.Move,
|
||||
Source: pointer.Mouse,
|
||||
Buttons: w.pointerBtns,
|
||||
Position: f32.Point{
|
||||
@@ -786,7 +799,7 @@ func newX11Window(gioWin *callbacks, options []Option) error {
|
||||
hints.flags = C.InputHint
|
||||
C.XSetWMHints(dpy, win, &hints)
|
||||
|
||||
name := C.CString(filepath.Base(os.Args[0]))
|
||||
name := C.CString(ID)
|
||||
defer C.free(unsafe.Pointer(name))
|
||||
wmhints := C.XClassHint{name, name}
|
||||
C.XSetClassHint(dpy, win, &wmhints)
|
||||
@@ -820,6 +833,7 @@ func newX11Window(gioWin *callbacks, options []Option) error {
|
||||
w.setStage(system.StageRunning)
|
||||
w.loop()
|
||||
w.w.Event(X11ViewEvent{})
|
||||
w.w.Event(system.DestroyEvent{Err: nil})
|
||||
w.destroy()
|
||||
}()
|
||||
return nil
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
Package bluetooth implements permissions to access Bluetooth and Bluetooth
|
||||
Low Energy hardware, including the ability to discover and pair devices.
|
||||
|
||||
Android
|
||||
# Android
|
||||
|
||||
The following entries will be added to AndroidManifest.xml:
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
|
||||
|
||||
Note that ACCESS_FINE_LOCATION is required on Android before the Bluetooth
|
||||
device may be used.
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
/*
|
||||
Package camera implements permissions to access camera hardware.
|
||||
|
||||
Android
|
||||
# Android
|
||||
|
||||
The following entries will be added to AndroidManifest.xml:
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false"/>
|
||||
|
||||
CAMERA is a "dangerous" permission. See documentation for package
|
||||
gioui.org/app/permission for more information.
|
||||
|
||||
@@ -34,7 +34,7 @@ program's source code:
|
||||
_ "net"
|
||||
)
|
||||
|
||||
Android -- Dangerous Permissions
|
||||
# Android -- Dangerous Permissions
|
||||
|
||||
Certain permissions on Android are marked with a protection level of
|
||||
"dangerous". This means that, in addition to including the relevant
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
/*
|
||||
Package networkstate implements permissions to access network connectivity information.
|
||||
|
||||
Android
|
||||
# Android
|
||||
|
||||
The following entries will be added to AndroidManifest.xml:
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
*/
|
||||
package networkstate
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
Package storage implements read and write storage permissions
|
||||
on mobile devices.
|
||||
|
||||
Android
|
||||
# Android
|
||||
|
||||
The following entries will be added to AndroidManifest.xml:
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE are "dangerous" permissions.
|
||||
See documentation for package gioui.org/app/permission for more information.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
/*
|
||||
Package wakelock implements permission to acquire locks that keep the system
|
||||
from suspending.
|
||||
|
||||
# Android
|
||||
|
||||
The following entries will be added to AndroidManifest.xml:
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
*/
|
||||
package wakelock
|
||||
+297
-203
@@ -16,6 +16,7 @@ import (
|
||||
"gioui.org/f32"
|
||||
"gioui.org/font/gofont"
|
||||
"gioui.org/gpu"
|
||||
"gioui.org/internal/debug"
|
||||
"gioui.org/internal/ops"
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/io/key"
|
||||
@@ -25,7 +26,7 @@ import (
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/text"
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
@@ -55,19 +56,22 @@ type Window struct {
|
||||
immediateRedraws chan struct{}
|
||||
// scheduledRedraws is sent the most recent delayed redraw time.
|
||||
scheduledRedraws chan time.Time
|
||||
// options are the options waiting to be applied.
|
||||
options chan []Option
|
||||
// actions are the actions waiting to be performed.
|
||||
actions chan system.Action
|
||||
|
||||
// out is where the platform backend delivers events bound for the
|
||||
// user program.
|
||||
out chan event.Event
|
||||
frames chan *op.Ops
|
||||
frameAck chan struct{}
|
||||
closing bool
|
||||
// dead is closed when the window is destroyed.
|
||||
dead chan struct{}
|
||||
destroy chan struct{}
|
||||
|
||||
stage system.Stage
|
||||
animating bool
|
||||
hasNextFrame bool
|
||||
nextFrame time.Time
|
||||
delayedDraw *time.Timer
|
||||
// viewport is the latest frame size with insets applied.
|
||||
viewport image.Rectangle
|
||||
// metric is the metric from the most recent frame.
|
||||
@@ -77,10 +81,16 @@ type Window struct {
|
||||
cursor pointer.Cursor
|
||||
decorations struct {
|
||||
op.Ops
|
||||
// enabled tracks the Decorated option as
|
||||
// given to the Option method. It may differ
|
||||
// from Config.Decorated depending on platform
|
||||
// capability.
|
||||
enabled bool
|
||||
Config
|
||||
height unit.Dp
|
||||
currentHeight int
|
||||
*material.Theme
|
||||
*widget.Decorations
|
||||
size image.Point // decorations size
|
||||
}
|
||||
|
||||
callbacks callbacks
|
||||
@@ -99,6 +109,16 @@ type Window struct {
|
||||
}
|
||||
|
||||
imeState editorState
|
||||
|
||||
// event stores the state required for processing and delivering events
|
||||
// from NextEvent. If we had support for range over func, this would
|
||||
// be the iterator state.
|
||||
eventState struct {
|
||||
created bool
|
||||
initialOpts []Option
|
||||
wakeup func()
|
||||
timer *time.Timer
|
||||
}
|
||||
}
|
||||
|
||||
type editorState struct {
|
||||
@@ -119,9 +139,6 @@ type queue struct {
|
||||
q router.Router
|
||||
}
|
||||
|
||||
// Pre-allocate the ack event to avoid garbage.
|
||||
var ackEvent event.Event
|
||||
|
||||
// NewWindow creates a new window for a set of window
|
||||
// options. The options are hints; the platform is free to
|
||||
// ignore or adjust them.
|
||||
@@ -133,9 +150,26 @@ var ackEvent event.Event
|
||||
// Calling NewWindow more than once is not supported on
|
||||
// iOS, Android, WebAssembly.
|
||||
func NewWindow(options ...Option) *Window {
|
||||
debug.Parse()
|
||||
// Measure decoration height.
|
||||
deco := new(widget.Decorations)
|
||||
theme := material.NewTheme()
|
||||
theme.Shaper = text.NewShaper(text.NoSystemFonts(), text.WithCollection(gofont.Regular()))
|
||||
decoStyle := material.Decorations(theme, deco, 0, "")
|
||||
gtx := layout.Context{
|
||||
Ops: new(op.Ops),
|
||||
// Measure in Dp.
|
||||
Metric: unit.Metric{},
|
||||
}
|
||||
// Allow plenty of space.
|
||||
gtx.Constraints.Max.Y = 200
|
||||
dims := decoStyle.Layout(gtx)
|
||||
decoHeight := unit.Dp(dims.Size.Y)
|
||||
defaultOptions := []Option{
|
||||
Size(unit.Dp(800), unit.Dp(600)),
|
||||
Size(800, 600),
|
||||
Title("Gio"),
|
||||
Decorated(true),
|
||||
decoHeightOpt(decoHeight),
|
||||
}
|
||||
options = append(defaultOptions, options...)
|
||||
var cnf Config
|
||||
@@ -143,7 +177,7 @@ func NewWindow(options ...Option) *Window {
|
||||
|
||||
w := &Window{
|
||||
out: make(chan event.Event),
|
||||
immediateRedraws: make(chan struct{}, 0),
|
||||
immediateRedraws: make(chan struct{}),
|
||||
redraws: make(chan struct{}, 1),
|
||||
scheduledRedraws: make(chan time.Time, 1),
|
||||
frames: make(chan *op.Ops),
|
||||
@@ -151,19 +185,26 @@ func NewWindow(options ...Option) *Window {
|
||||
driverFuncs: make(chan func(d driver), 1),
|
||||
wakeups: make(chan struct{}, 1),
|
||||
wakeupFuncs: make(chan func()),
|
||||
dead: make(chan struct{}),
|
||||
destroy: make(chan struct{}),
|
||||
options: make(chan []Option, 1),
|
||||
actions: make(chan system.Action, 1),
|
||||
nocontext: cnf.CustomRenderer,
|
||||
}
|
||||
w.decorations.Theme = theme
|
||||
w.decorations.Decorations = deco
|
||||
w.decorations.enabled = cnf.Decorated
|
||||
w.decorations.height = decoHeight
|
||||
w.imeState.compose = key.Range{Start: -1, End: -1}
|
||||
w.semantic.ids = make(map[router.SemanticID]router.SemanticNode)
|
||||
w.callbacks.w = w
|
||||
go w.run(options)
|
||||
w.eventState.initialOpts = options
|
||||
return w
|
||||
}
|
||||
|
||||
// Events returns the channel where events are delivered.
|
||||
func (w *Window) Events() <-chan event.Event {
|
||||
return w.out
|
||||
func decoHeightOpt(h unit.Dp) Option {
|
||||
return func(m unit.Metric, c *Config) {
|
||||
c.decoHeight = h
|
||||
}
|
||||
}
|
||||
|
||||
// update the window contents, input operations declare input handlers,
|
||||
@@ -174,7 +215,16 @@ func (w *Window) update(frame *op.Ops) {
|
||||
<-w.frameAck
|
||||
}
|
||||
|
||||
func (w *Window) validateAndProcess(d driver, size image.Point, sync bool, frame *op.Ops) error {
|
||||
func (w *Window) validateAndProcess(d driver, size image.Point, sync bool, frame *op.Ops, sigChan chan<- struct{}) error {
|
||||
signal := func() {
|
||||
if sigChan != nil {
|
||||
// We're done with frame, let the client continue.
|
||||
sigChan <- struct{}{}
|
||||
// Signal at most once.
|
||||
sigChan = nil
|
||||
}
|
||||
}
|
||||
defer signal()
|
||||
for {
|
||||
if w.gpu == nil && !w.nocontext {
|
||||
var err error
|
||||
@@ -200,21 +250,24 @@ func (w *Window) validateAndProcess(d driver, size image.Point, sync bool, frame
|
||||
return err
|
||||
}
|
||||
}
|
||||
if w.gpu == nil && !w.nocontext {
|
||||
if w.ctx != nil {
|
||||
if err := w.ctx.Lock(); err != nil {
|
||||
w.destroyGPU()
|
||||
return err
|
||||
}
|
||||
}
|
||||
if w.gpu == nil && !w.nocontext {
|
||||
gpu, err := gpu.New(w.ctx.API())
|
||||
w.ctx.Unlock()
|
||||
if err != nil {
|
||||
w.ctx.Unlock()
|
||||
w.destroyGPU()
|
||||
return err
|
||||
}
|
||||
w.gpu = gpu
|
||||
}
|
||||
if w.gpu != nil {
|
||||
if err := w.render(frame, size); err != nil {
|
||||
if err := w.frame(frame, size); err != nil {
|
||||
w.ctx.Unlock()
|
||||
if errors.Is(err, errOutOfDate) {
|
||||
// GPU surface needs refreshing.
|
||||
sync = true
|
||||
@@ -228,15 +281,19 @@ func (w *Window) validateAndProcess(d driver, size image.Point, sync bool, frame
|
||||
}
|
||||
}
|
||||
w.queue.q.Frame(frame)
|
||||
return nil
|
||||
// Let the client continue as soon as possible, in particular before
|
||||
// a potentially blocking Present.
|
||||
signal()
|
||||
var err error
|
||||
if w.gpu != nil {
|
||||
err = w.ctx.Present()
|
||||
w.ctx.Unlock()
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Window) render(frame *op.Ops, viewport image.Point) error {
|
||||
if err := w.ctx.Lock(); err != nil {
|
||||
return err
|
||||
}
|
||||
defer w.ctx.Unlock()
|
||||
func (w *Window) frame(frame *op.Ops, viewport image.Point) error {
|
||||
if runtime.GOOS == "js" {
|
||||
// Use transparent black when Gio is embedded, to allow mixing of Gio and
|
||||
// foreign content below.
|
||||
@@ -248,10 +305,7 @@ func (w *Window) render(frame *op.Ops, viewport image.Point) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := w.gpu.Frame(frame, target, viewport); err != nil {
|
||||
return err
|
||||
}
|
||||
return w.ctx.Present()
|
||||
return w.gpu.Frame(frame, target, viewport)
|
||||
}
|
||||
|
||||
func (w *Window) processFrame(d driver, frameStart time.Time) {
|
||||
@@ -318,18 +372,18 @@ func (w *Window) Invalidate() {
|
||||
|
||||
// Option applies the options to the window.
|
||||
func (w *Window) Option(opts ...Option) {
|
||||
w.driverDefer(func(d driver) {
|
||||
d.Configure(opts)
|
||||
})
|
||||
}
|
||||
|
||||
// ReadClipboard initiates a read of the clipboard in the form
|
||||
// of a clipboard.Event. Multiple reads may be coalesced
|
||||
// to a single event.
|
||||
func (w *Window) ReadClipboard() {
|
||||
w.driverDefer(func(d driver) {
|
||||
d.ReadClipboard()
|
||||
})
|
||||
if len(opts) == 0 {
|
||||
return
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case old := <-w.options:
|
||||
opts = append(old, opts...)
|
||||
case w.options <- opts:
|
||||
w.wakeup()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WriteClipboard writes a string to the clipboard.
|
||||
@@ -355,7 +409,7 @@ func (w *Window) Run(f func()) {
|
||||
})
|
||||
select {
|
||||
case <-done:
|
||||
case <-w.dead:
|
||||
case <-w.destroy:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,13 +419,13 @@ func (w *Window) driverDefer(f func(d driver)) {
|
||||
select {
|
||||
case w.driverFuncs <- f:
|
||||
w.wakeup()
|
||||
case <-w.dead:
|
||||
case <-w.destroy:
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Window) updateAnimation(d driver) {
|
||||
animate := false
|
||||
if w.stage >= system.StageRunning && w.hasNextFrame {
|
||||
if w.stage >= system.StageInactive && w.hasNextFrame {
|
||||
if dt := time.Until(w.nextFrame); dt <= 0 {
|
||||
animate = true
|
||||
} else {
|
||||
@@ -412,29 +466,52 @@ func (c *callbacks) SetDriver(d driver) {
|
||||
c.w.wakeupFuncs <- wakeup
|
||||
}
|
||||
|
||||
func (c *callbacks) Event(e event.Event) {
|
||||
func (c *callbacks) Event(e event.Event) bool {
|
||||
if c.d == nil {
|
||||
panic("event while no driver active")
|
||||
}
|
||||
c.waitEvents = append(c.waitEvents, e)
|
||||
if c.busy {
|
||||
return
|
||||
return true
|
||||
}
|
||||
c.busy = true
|
||||
defer func() {
|
||||
c.busy = false
|
||||
}()
|
||||
var handled bool
|
||||
for len(c.waitEvents) > 0 {
|
||||
e := c.waitEvents[0]
|
||||
copy(c.waitEvents, c.waitEvents[1:])
|
||||
c.waitEvents = c.waitEvents[:len(c.waitEvents)-1]
|
||||
c.w.processEvent(c.d, e)
|
||||
handled = c.w.processEvent(c.d, e)
|
||||
}
|
||||
c.busy = false
|
||||
select {
|
||||
case <-c.w.destroy:
|
||||
return handled
|
||||
default:
|
||||
}
|
||||
c.w.updateState(c.d)
|
||||
if c.w.closing {
|
||||
c.w.closing = false
|
||||
c.d.Close()
|
||||
if _, ok := e.(wakeupEvent); ok {
|
||||
select {
|
||||
case opts := <-c.w.options:
|
||||
cnf := Config{Decorated: c.w.decorations.enabled}
|
||||
for _, opt := range opts {
|
||||
opt(c.w.metric, &cnf)
|
||||
}
|
||||
c.w.decorations.enabled = cnf.Decorated
|
||||
decoHeight := c.w.decorations.height
|
||||
if !c.w.decorations.enabled {
|
||||
decoHeight = 0
|
||||
}
|
||||
opts = append(opts, decoHeightOpt(decoHeight))
|
||||
c.d.Configure(opts)
|
||||
default:
|
||||
}
|
||||
select {
|
||||
case acts := <-c.w.actions:
|
||||
c.d.Perform(acts)
|
||||
default:
|
||||
}
|
||||
}
|
||||
return handled
|
||||
}
|
||||
|
||||
// SemanticRoot returns the ID of the semantic root.
|
||||
@@ -502,10 +579,6 @@ func (c *callbacks) SetEditorSnippet(r key.Range) {
|
||||
c.Event(key.SnippetEvent(r))
|
||||
}
|
||||
|
||||
func (c *callbacks) MoveFocus(dir router.FocusDirection) {
|
||||
c.w.moveFocus(dir, c.d)
|
||||
}
|
||||
|
||||
func (w *Window) moveFocus(dir router.FocusDirection, d driver) {
|
||||
if w.queue.q.MoveFocus(dir) {
|
||||
w.queue.q.RevealFocus(w.viewport)
|
||||
@@ -523,12 +596,10 @@ func (w *Window) moveFocus(dir router.FocusDirection, d driver) {
|
||||
default:
|
||||
return
|
||||
}
|
||||
const scrollABit = 50
|
||||
dist := v.Mul(w.metric.Px(unit.Dp(scrollABit)))
|
||||
const scrollABit = unit.Dp(50)
|
||||
dist := v.Mul(int(w.metric.Dp(scrollABit)))
|
||||
w.queue.q.ScrollFocus(dist)
|
||||
}
|
||||
w.setNextFrame(time.Time{})
|
||||
w.updateAnimation(d)
|
||||
}
|
||||
|
||||
func (c *callbacks) ClickFocus() {
|
||||
@@ -537,6 +608,10 @@ func (c *callbacks) ClickFocus() {
|
||||
c.w.updateAnimation(c.d)
|
||||
}
|
||||
|
||||
func (c *callbacks) ActionAt(p f32.Point) (system.Action, bool) {
|
||||
return c.w.queue.q.ActionAt(p)
|
||||
}
|
||||
|
||||
func (e *editorState) Replace(r key.Range, text string) {
|
||||
if r.Start > r.End {
|
||||
r.Start, r.End = r.End, r.Start
|
||||
@@ -645,7 +720,7 @@ func (w *Window) waitAck(d driver) {
|
||||
select {
|
||||
case f := <-w.driverFuncs:
|
||||
f(d)
|
||||
case w.out <- ackEvent:
|
||||
case w.out <- theFlushEvent:
|
||||
// A dummy event went through, so we know the application has processed the previous event.
|
||||
return
|
||||
case <-w.immediateRedraws:
|
||||
@@ -670,20 +745,19 @@ func (w *Window) destroyGPU() {
|
||||
}
|
||||
|
||||
// waitFrame waits for the client to either call FrameEvent.Frame
|
||||
// or to continue event handling. It returns whether the client
|
||||
// called Frame or not.
|
||||
func (w *Window) waitFrame(d driver) (*op.Ops, bool) {
|
||||
// or to continue event handling.
|
||||
func (w *Window) waitFrame(d driver) *op.Ops {
|
||||
for {
|
||||
select {
|
||||
case f := <-w.driverFuncs:
|
||||
f(d)
|
||||
case frame := <-w.frames:
|
||||
// The client called FrameEvent.Frame.
|
||||
return frame, true
|
||||
case w.out <- ackEvent:
|
||||
return frame
|
||||
case w.out <- theFlushEvent:
|
||||
// The client ignored FrameEvent and continued processing
|
||||
// events.
|
||||
return nil, false
|
||||
return nil
|
||||
case <-w.immediateRedraws:
|
||||
// Invalidate was called during frame processing.
|
||||
w.setNextFrame(time.Time{})
|
||||
@@ -741,15 +815,15 @@ func (w *Window) updateState(d driver) {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Window) processEvent(d driver, e event.Event) {
|
||||
func (w *Window) processEvent(d driver, e event.Event) bool {
|
||||
select {
|
||||
case <-w.dead:
|
||||
return
|
||||
case <-w.destroy:
|
||||
return false
|
||||
default:
|
||||
}
|
||||
switch e2 := e.(type) {
|
||||
case system.StageEvent:
|
||||
if e2.Stage < system.StageRunning {
|
||||
if e2.Stage < system.StageInactive {
|
||||
if w.gpu != nil {
|
||||
w.ctx.Lock()
|
||||
w.gpu.Release()
|
||||
@@ -765,7 +839,7 @@ func (w *Window) processEvent(d driver, e event.Event) {
|
||||
if e2.Size == (image.Point{}) {
|
||||
panic(errors.New("internal error: zero-sized Draw"))
|
||||
}
|
||||
if w.stage < system.StageRunning {
|
||||
if w.stage < system.StageInactive {
|
||||
// No drawing if not visible.
|
||||
break
|
||||
}
|
||||
@@ -783,12 +857,12 @@ func (w *Window) processEvent(d driver, e event.Event) {
|
||||
wrapper.Reset()
|
||||
viewport := image.Rectangle{
|
||||
Min: image.Point{
|
||||
X: e2.Metric.Px(e2.Insets.Left),
|
||||
Y: e2.Metric.Px(e2.Insets.Top),
|
||||
X: e2.Metric.Dp(e2.Insets.Left),
|
||||
Y: e2.Metric.Dp(e2.Insets.Top),
|
||||
},
|
||||
Max: image.Point{
|
||||
X: e2.Size.X - e2.Metric.Px(e2.Insets.Right),
|
||||
Y: e2.Size.Y - e2.Metric.Px(e2.Insets.Bottom),
|
||||
X: e2.Size.X - e2.Metric.Dp(e2.Insets.Right),
|
||||
Y: e2.Size.Y - e2.Metric.Dp(e2.Insets.Bottom),
|
||||
},
|
||||
}
|
||||
// Scroll to focus if viewport is shrinking in any dimension.
|
||||
@@ -796,102 +870,125 @@ func (w *Window) processEvent(d driver, e event.Event) {
|
||||
w.queue.q.RevealFocus(viewport)
|
||||
}
|
||||
w.viewport = viewport
|
||||
size := e2.Size // save the initial window size as the decorations will change it.
|
||||
e2.FrameEvent.Size = w.decorate(d, e2.FrameEvent, wrapper)
|
||||
viewSize := e2.Size
|
||||
m := op.Record(wrapper)
|
||||
size, offset := w.decorate(d, e2.FrameEvent, wrapper)
|
||||
e2.FrameEvent.Size = size
|
||||
deco := m.Stop()
|
||||
w.out <- e2.FrameEvent
|
||||
frame, gotFrame := w.waitFrame(d)
|
||||
cl := clip.Rect(image.Rectangle{Max: e2.FrameEvent.Size}).Push(wrapper)
|
||||
ops.AddCall(&wrapper.Internal, &frame.Internal, ops.PC{}, ops.PCFor(&frame.Internal))
|
||||
cl.Pop()
|
||||
err := w.validateAndProcess(d, size, e2.Sync, wrapper)
|
||||
if gotFrame {
|
||||
// We're done with frame, let the client continue.
|
||||
w.frameAck <- struct{}{}
|
||||
frame := w.waitFrame(d)
|
||||
var signal chan<- struct{}
|
||||
if frame != nil {
|
||||
signal = w.frameAck
|
||||
off := op.Offset(offset).Push(wrapper)
|
||||
ops.AddCall(&wrapper.Internal, &frame.Internal, ops.PC{}, ops.PCFor(&frame.Internal))
|
||||
off.Pop()
|
||||
}
|
||||
if err != nil {
|
||||
deco.Add(wrapper)
|
||||
if err := w.validateAndProcess(d, viewSize, e2.Sync, wrapper, signal); err != nil {
|
||||
w.destroyGPU()
|
||||
w.out <- system.DestroyEvent{Err: err}
|
||||
close(w.dead)
|
||||
close(w.out)
|
||||
close(w.destroy)
|
||||
break
|
||||
}
|
||||
w.processFrame(d, frameStart)
|
||||
w.updateCursor(d)
|
||||
case *system.CommandEvent:
|
||||
w.out <- e
|
||||
w.waitAck(d)
|
||||
case system.DestroyEvent:
|
||||
w.destroyGPU()
|
||||
w.out <- e2
|
||||
close(w.dead)
|
||||
close(w.out)
|
||||
close(w.destroy)
|
||||
case ViewEvent:
|
||||
w.out <- e2
|
||||
w.waitAck(d)
|
||||
case wakeupEvent:
|
||||
case ConfigEvent:
|
||||
w.decorations.Config = e2.Config
|
||||
if !w.fallbackDecorate() {
|
||||
// Decorations are no longer applied.
|
||||
w.decorations.Decorations = nil
|
||||
w.decorations.size = image.Point{}
|
||||
}
|
||||
e2.Config.Size = e2.Config.Size.Sub(w.decorations.size)
|
||||
e2.Config = w.effectiveConfig()
|
||||
w.out <- e2
|
||||
case wakeupEvent:
|
||||
case event.Event:
|
||||
// Convert tab or shift+tab presses to focus moves.
|
||||
if e, ok := e.(key.Event); ok && e.State == key.Press && e.Name == key.NameTab && e.Modifiers&^key.ModShift == 0 {
|
||||
dir := router.FocusForward
|
||||
if e.Modifiers.Contain(key.ModShift) {
|
||||
dir = router.FocusBackward
|
||||
handled := w.queue.q.Queue(e2)
|
||||
if e, ok := e.(key.Event); ok && !handled {
|
||||
if e.State == key.Press {
|
||||
handled = true
|
||||
isMobile := runtime.GOOS == "ios" || runtime.GOOS == "android"
|
||||
switch {
|
||||
case e.Name == key.NameTab && e.Modifiers == 0:
|
||||
w.moveFocus(router.FocusForward, d)
|
||||
case e.Name == key.NameTab && e.Modifiers == key.ModShift:
|
||||
w.moveFocus(router.FocusBackward, d)
|
||||
case e.Name == key.NameUpArrow && e.Modifiers == 0 && isMobile:
|
||||
w.moveFocus(router.FocusUp, d)
|
||||
case e.Name == key.NameDownArrow && e.Modifiers == 0 && isMobile:
|
||||
w.moveFocus(router.FocusDown, d)
|
||||
case e.Name == key.NameLeftArrow && e.Modifiers == 0 && isMobile:
|
||||
w.moveFocus(router.FocusLeft, d)
|
||||
case e.Name == key.NameRightArrow && e.Modifiers == 0 && isMobile:
|
||||
w.moveFocus(router.FocusRight, d)
|
||||
default:
|
||||
handled = false
|
||||
}
|
||||
}
|
||||
w.moveFocus(dir, d)
|
||||
} else if w.queue.q.Queue(e2) {
|
||||
// As a special case, the top-most input handler receives all unhandled
|
||||
// events.
|
||||
if !handled {
|
||||
handled = w.queue.q.QueueTopmost(e)
|
||||
}
|
||||
}
|
||||
w.updateCursor(d)
|
||||
if handled {
|
||||
w.setNextFrame(time.Time{})
|
||||
w.updateAnimation(d)
|
||||
}
|
||||
w.updateCursor(d)
|
||||
w.out <- e
|
||||
return handled
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (w *Window) run(options []Option) {
|
||||
if err := newWindow(&w.callbacks, options); err != nil {
|
||||
w.out <- system.DestroyEvent{Err: err}
|
||||
close(w.dead)
|
||||
close(w.out)
|
||||
return
|
||||
// NextEvent blocks until an event is received from the window, such as
|
||||
// [io/system.FrameEvent]. It blocks forever if called after [io/system.DestroyEvent]
|
||||
// has been returned.
|
||||
func (w *Window) NextEvent() event.Event {
|
||||
state := &w.eventState
|
||||
if !state.created {
|
||||
state.created = true
|
||||
if err := newWindow(&w.callbacks, state.initialOpts); err != nil {
|
||||
close(w.destroy)
|
||||
return system.DestroyEvent{Err: err}
|
||||
}
|
||||
}
|
||||
var wakeup func()
|
||||
var timer *time.Timer
|
||||
for {
|
||||
var (
|
||||
wakeups <-chan struct{}
|
||||
timeC <-chan time.Time
|
||||
)
|
||||
if wakeup != nil {
|
||||
if state.wakeup != nil {
|
||||
wakeups = w.wakeups
|
||||
if timer != nil {
|
||||
timeC = timer.C
|
||||
if state.timer != nil {
|
||||
timeC = state.timer.C
|
||||
}
|
||||
}
|
||||
select {
|
||||
case t := <-w.scheduledRedraws:
|
||||
if timer != nil {
|
||||
timer.Stop()
|
||||
if state.timer != nil {
|
||||
state.timer.Stop()
|
||||
}
|
||||
timer = time.NewTimer(time.Until(t))
|
||||
case <-w.dead:
|
||||
return
|
||||
state.timer = time.NewTimer(time.Until(t))
|
||||
case e := <-w.out:
|
||||
// Receiving a flushEvent indicates to the platform backend that
|
||||
// all previous events have been processed by the user program.
|
||||
if _, ok := e.(flushEvent); ok {
|
||||
break
|
||||
}
|
||||
return e
|
||||
case <-timeC:
|
||||
select {
|
||||
case w.redraws <- struct{}{}:
|
||||
wakeup()
|
||||
state.wakeup()
|
||||
default:
|
||||
}
|
||||
case <-wakeups:
|
||||
wakeup()
|
||||
case wakeup = <-w.wakeupFuncs:
|
||||
state.wakeup()
|
||||
case state.wakeup = <-w.wakeupFuncs:
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -905,31 +1002,18 @@ func (w *Window) updateCursor(d driver) {
|
||||
|
||||
func (w *Window) fallbackDecorate() bool {
|
||||
cnf := w.decorations.Config
|
||||
return !cnf.Decorated && cnf.Mode != Fullscreen && !w.nocontext
|
||||
return w.decorations.enabled && !cnf.Decorated && cnf.Mode != Fullscreen && !w.nocontext
|
||||
}
|
||||
|
||||
// decorate the window if enabled and returns the corresponding Insets.
|
||||
func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) image.Point {
|
||||
func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) (size, offset image.Point) {
|
||||
if !w.fallbackDecorate() {
|
||||
return e.Size
|
||||
}
|
||||
theme := w.decorations.Theme
|
||||
if theme == nil {
|
||||
theme = material.NewTheme(gofont.Collection())
|
||||
w.decorations.Theme = theme
|
||||
return e.Size, image.Pt(0, 0)
|
||||
}
|
||||
deco := w.decorations.Decorations
|
||||
if deco == nil {
|
||||
deco = new(widget.Decorations)
|
||||
w.decorations.Decorations = deco
|
||||
}
|
||||
allActions := system.ActionMinimize | system.ActionMaximize | system.ActionUnmaximize |
|
||||
system.ActionClose | system.ActionMove |
|
||||
system.ActionResizeNorth | system.ActionResizeSouth |
|
||||
system.ActionResizeWest | system.ActionResizeEast |
|
||||
system.ActionResizeNorthWest | system.ActionResizeSouthWest |
|
||||
system.ActionResizeNorthEast | system.ActionResizeSouthEast
|
||||
style := material.Decorations(theme, deco, allActions, w.decorations.Config.Title)
|
||||
system.ActionClose | system.ActionMove
|
||||
style := material.Decorations(w.decorations.Theme, deco, allActions, w.decorations.Config.Title)
|
||||
// Update the decorations based on the current window mode.
|
||||
var actions system.Action
|
||||
switch m := w.decorations.Config.Mode; m {
|
||||
@@ -952,54 +1036,53 @@ func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) image.Point
|
||||
Metric: e.Metric,
|
||||
Constraints: layout.Exact(e.Size),
|
||||
}
|
||||
dims := style.Layout(gtx)
|
||||
// Update the window based on the actions on the decorations.
|
||||
w.Perform(deco.Actions())
|
||||
w.Perform(deco.Update(gtx))
|
||||
style.Layout(gtx)
|
||||
// Offset to place the frame content below the decorations.
|
||||
size := image.Point{Y: dims.Size.Y}
|
||||
op.Offset(f32.Point{Y: float32(size.Y)}).Add(o)
|
||||
appSize := e.Size.Sub(size)
|
||||
if w.decorations.size != size {
|
||||
w.decorations.size = size
|
||||
cnf := w.decorations.Config
|
||||
cnf.Size = appSize
|
||||
w.out <- ConfigEvent{Config: cnf}
|
||||
decoHeight := gtx.Dp(w.decorations.Config.decoHeight)
|
||||
if w.decorations.currentHeight != decoHeight {
|
||||
w.decorations.currentHeight = decoHeight
|
||||
w.out <- ConfigEvent{Config: w.effectiveConfig()}
|
||||
}
|
||||
return appSize
|
||||
e.Size.Y -= w.decorations.currentHeight
|
||||
return e.Size, image.Pt(0, decoHeight)
|
||||
}
|
||||
|
||||
func (w *Window) effectiveConfig() Config {
|
||||
cnf := w.decorations.Config
|
||||
cnf.Size.Y -= w.decorations.currentHeight
|
||||
cnf.Decorated = w.decorations.enabled || cnf.Decorated
|
||||
return cnf
|
||||
}
|
||||
|
||||
// Perform the actions on the window.
|
||||
func (w *Window) Perform(actions system.Action) {
|
||||
w.driverDefer(func(d driver) {
|
||||
var options []Option
|
||||
walkActions(actions, func(action system.Action) {
|
||||
switch action {
|
||||
case system.ActionMinimize:
|
||||
options = append(options, Minimized.Option())
|
||||
case system.ActionMaximize:
|
||||
options = append(options, Maximized.Option())
|
||||
case system.ActionUnmaximize:
|
||||
options = append(options, Windowed.Option())
|
||||
case system.ActionRaise:
|
||||
d.Raise()
|
||||
case system.ActionCenter:
|
||||
options = append(options,
|
||||
func(m unit.Metric, cnf *Config) {
|
||||
// Set the flag so the driver can later do the actual centering.
|
||||
cnf.center = true
|
||||
})
|
||||
case system.ActionClose:
|
||||
w.closing = true
|
||||
default:
|
||||
return
|
||||
}
|
||||
actions &^= action
|
||||
})
|
||||
if len(options) > 0 {
|
||||
d.Configure(options)
|
||||
walkActions(actions, func(action system.Action) {
|
||||
switch action {
|
||||
case system.ActionMinimize:
|
||||
w.Option(Minimized.Option())
|
||||
case system.ActionMaximize:
|
||||
w.Option(Maximized.Option())
|
||||
case system.ActionUnmaximize:
|
||||
w.Option(Windowed.Option())
|
||||
default:
|
||||
return
|
||||
}
|
||||
d.Perform(actions)
|
||||
actions &^= action
|
||||
})
|
||||
if actions == 0 {
|
||||
return
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case old := <-w.actions:
|
||||
actions |= old
|
||||
case w.actions <- actions:
|
||||
w.wakeup()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (q *queue) Events(k event.Tag) []event.Event {
|
||||
@@ -1014,50 +1097,50 @@ func Title(t string) Option {
|
||||
}
|
||||
|
||||
// Size sets the size of the window. The mode will be changed to Windowed.
|
||||
func Size(w, h unit.Value) Option {
|
||||
if w.V <= 0 {
|
||||
func Size(w, h unit.Dp) Option {
|
||||
if w <= 0 {
|
||||
panic("width must be larger than or equal to 0")
|
||||
}
|
||||
if h.V <= 0 {
|
||||
if h <= 0 {
|
||||
panic("height must be larger than or equal to 0")
|
||||
}
|
||||
return func(m unit.Metric, cnf *Config) {
|
||||
cnf.Mode = Windowed
|
||||
cnf.Size = image.Point{
|
||||
X: m.Px(w),
|
||||
Y: m.Px(h),
|
||||
X: m.Dp(w),
|
||||
Y: m.Dp(h),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MaxSize sets the maximum size of the window.
|
||||
func MaxSize(w, h unit.Value) Option {
|
||||
if w.V <= 0 {
|
||||
func MaxSize(w, h unit.Dp) Option {
|
||||
if w <= 0 {
|
||||
panic("width must be larger than or equal to 0")
|
||||
}
|
||||
if h.V <= 0 {
|
||||
if h <= 0 {
|
||||
panic("height must be larger than or equal to 0")
|
||||
}
|
||||
return func(m unit.Metric, cnf *Config) {
|
||||
cnf.MaxSize = image.Point{
|
||||
X: m.Px(w),
|
||||
Y: m.Px(h),
|
||||
X: m.Dp(w),
|
||||
Y: m.Dp(h),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MinSize sets the minimum size of the window.
|
||||
func MinSize(w, h unit.Value) Option {
|
||||
if w.V <= 0 {
|
||||
func MinSize(w, h unit.Dp) Option {
|
||||
if w <= 0 {
|
||||
panic("width must be larger than or equal to 0")
|
||||
}
|
||||
if h.V <= 0 {
|
||||
if h <= 0 {
|
||||
panic("height must be larger than or equal to 0")
|
||||
}
|
||||
return func(m unit.Metric, cnf *Config) {
|
||||
cnf.MinSize = image.Point{
|
||||
X: m.Px(w),
|
||||
Y: m.Px(h),
|
||||
X: m.Dp(w),
|
||||
Y: m.Dp(h),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1096,3 +1179,14 @@ func Decorated(enabled bool) Option {
|
||||
cnf.Decorated = enabled
|
||||
}
|
||||
}
|
||||
|
||||
// flushEvent is sent to detect when the user program
|
||||
// has completed processing of all prior events. Its an
|
||||
// [io/event.Event] but only for internal use.
|
||||
type flushEvent struct{}
|
||||
|
||||
func (t flushEvent) ImplementsEvent() {}
|
||||
|
||||
// theFlushEvent avoids allocating garbage when sending
|
||||
// flushEvents.
|
||||
var theFlushEvent flushEvent
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
module gioui.org/cmd
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
gioui.org v0.0.0-20220328154813-a3f147541fd0
|
||||
github.com/akavel/rsrc v0.10.1
|
||||
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4
|
||||
github.com/chromedp/chromedp v0.5.2
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
|
||||
golang.org/x/text v0.3.6
|
||||
golang.org/x/tools v0.1.0
|
||||
)
|
||||
-475
@@ -1,475 +0,0 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
eliasnaur.com/font v0.0.0-20220124212145-832bb8fc08c3/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA=
|
||||
gioui.org v0.0.0-20220328154813-a3f147541fd0 h1:n4FUiCT6P4a2wF6hwX4a5R8TpjAhu/d+3nhwZW16MAI=
|
||||
gioui.org v0.0.0-20220328154813-a3f147541fd0/go.mod h1:b8vBukexG6eYuXZa14asjLAWJ+JjbZ/ophEnS2FjYUg=
|
||||
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
|
||||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
|
||||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
|
||||
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
|
||||
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
github.com/akavel/rsrc v0.10.1 h1:hCCPImjmFKVNGpeLZyTDRHEFC283DzyTXTo0cO0Rq9o=
|
||||
github.com/akavel/rsrc v0.10.1/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
|
||||
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
|
||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
||||
github.com/benoitkugler/pstokenizer v1.0.0/go.mod h1:l1G2Voirz0q/jj0TQfabNxVsa8HZXh/VMxFSRALWTiE=
|
||||
github.com/benoitkugler/textlayout v0.0.5/go.mod h1:puH4v13Uz7uIhIH0XMk5jgc8U3MXcn5r3VlV9K8n0D8=
|
||||
github.com/benoitkugler/textlayout v0.0.10 h1:uIaQgH4pBFw1LQ0tPkfjgxo94WYcckzzQaB41L2X84w=
|
||||
github.com/benoitkugler/textlayout v0.0.10/go.mod h1:puH4v13Uz7uIhIH0XMk5jgc8U3MXcn5r3VlV9K8n0D8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4 h1:QD3KxSJ59L2lxG6MXBjNHxiQO2RmxTQ3XcK+wO44WOg=
|
||||
github.com/chromedp/cdproto v0.0.0-20191114225735-6626966fbae4/go.mod h1:PfAWWKJqjlGFYJEidUM6aVIWPr0EpobeyVWEEmplX7g=
|
||||
github.com/chromedp/chromedp v0.5.2 h1:W8xBXQuUnd2dZK0SN/lyVwsQM7KgW+kY5HGnntms194=
|
||||
github.com/chromedp/chromedp v0.5.2/go.mod h1:rsTo/xRo23KZZwFmWk2Ui79rBaVRRATCjLzNQlOFSiA=
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:po7NpZ/QiTKzBKyrsEAxwnTamCoh8uDk/egRpQ7siIc=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gioui/uax v0.2.1-0.20220325163150-e3d987515a12 h1:1bjaB/5IIicfKpP4k0s30T2WEw//Kh00zULa8DQ0cxA=
|
||||
github.com/gioui/uax v0.2.1-0.20220325163150-e3d987515a12/go.mod h1:kDhBRTA/i3H46PVdhqcw26TdGSIj42TOKNWKY+Kipnw=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-text/typesetting v0.0.0-20220112121102-58fe93c84506 h1:1TPz/Gn/MsXwJ6bEtI9wdkPcQYr2X3V9I+wz4wPYUdY=
|
||||
github.com/go-text/typesetting v0.0.0-20220112121102-58fe93c84506/go.mod h1:R0mlTNeyszZ/tKQhbZA7SRGjx+OHsmNzgN2jTV7yZcs=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
|
||||
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
|
||||
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
|
||||
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
||||
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/knq/sysutil v0.0.0-20191005231841-15668db23d08 h1:V0an7KRw92wmJysvFvtqtKMAPmvS5O0jtB0nYo6t+gs=
|
||||
github.com/knq/sysutil v0.0.0-20191005231841-15668db23d08/go.mod h1:dFWs1zEqDjFtnBXsd1vPOZaLsESovai349994nHx3e0=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
|
||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.21.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
|
||||
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
|
||||
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
|
||||
go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc=
|
||||
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
|
||||
golang.org/x/exp v0.0.0-20210722180016-6781d3edade3 h1:IlrJD2AM5p8JhN/wVny9jt6gJ9hut2VALhSeZ3SYluk=
|
||||
golang.org/x/exp v0.0.0-20210722180016-6781d3edade3/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
@@ -1,143 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/png"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type AndroidTestDriver struct {
|
||||
driverBase
|
||||
|
||||
sdkDir string
|
||||
adbPath string
|
||||
}
|
||||
|
||||
var rxAdbDevice = regexp.MustCompile(`(.*)\s+device$`)
|
||||
|
||||
func (d *AndroidTestDriver) Start(path string) {
|
||||
d.sdkDir = os.Getenv("ANDROID_SDK_ROOT")
|
||||
if d.sdkDir == "" {
|
||||
d.Skipf("Android SDK is required; set $ANDROID_SDK_ROOT")
|
||||
}
|
||||
d.adbPath = filepath.Join(d.sdkDir, "platform-tools", "adb")
|
||||
if _, err := os.Stat(d.adbPath); os.IsNotExist(err) {
|
||||
d.Skipf("adb not found")
|
||||
}
|
||||
|
||||
devOut := bytes.TrimSpace(d.adb("devices"))
|
||||
devices := rxAdbDevice.FindAllSubmatch(devOut, -1)
|
||||
switch len(devices) {
|
||||
case 0:
|
||||
d.Skipf("no Android devices attached via adb; skipping")
|
||||
case 1:
|
||||
default:
|
||||
d.Skipf("multiple Android devices attached via adb; skipping")
|
||||
}
|
||||
|
||||
// If the device is attached but asleep, it's probably just charging.
|
||||
// Don't use it; the screen needs to be on and unlocked for the test to
|
||||
// work.
|
||||
if !bytes.Contains(
|
||||
d.adb("shell", "dumpsys", "power"),
|
||||
[]byte(" mWakefulness=Awake"),
|
||||
) {
|
||||
d.Skipf("Android device isn't awake; skipping")
|
||||
}
|
||||
|
||||
// First, build the app.
|
||||
apk := filepath.Join(d.tempDir("gio-endtoend-android"), "e2e.apk")
|
||||
d.gogio("-target=android", "-appid="+appid, "-o="+apk, path)
|
||||
|
||||
// Make sure the app isn't installed already, and try to uninstall it
|
||||
// when we finish. Previous failed test runs might have left the app.
|
||||
d.tryUninstall()
|
||||
d.adb("install", apk)
|
||||
d.Cleanup(d.tryUninstall)
|
||||
|
||||
// Force our e2e app to be fullscreen, so that the android system bar at
|
||||
// the top doesn't mess with our screenshots.
|
||||
// TODO(mvdan): is there a way to do this via gio, so that we don't need
|
||||
// to set up a global Android setting via the shell?
|
||||
d.adb("shell", "settings", "put", "global", "policy_control", "immersive.full="+appid)
|
||||
|
||||
// Make sure the app isn't already running.
|
||||
d.adb("shell", "pm", "clear", appid)
|
||||
|
||||
// Start listening for log messages.
|
||||
{
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, d.adbPath,
|
||||
"logcat",
|
||||
"-s", // suppress other logs
|
||||
"-T1", // don't show previous log messages
|
||||
appid+":*", // show all logs from our gio app ID
|
||||
)
|
||||
output, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
cmd.Stderr = cmd.Stdout
|
||||
d.output = output
|
||||
if err := cmd.Start(); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(cancel)
|
||||
}
|
||||
|
||||
// Start the app.
|
||||
d.adb("shell", "monkey", "-p", appid, "1")
|
||||
|
||||
// Wait for the gio app to render.
|
||||
d.waitForFrame()
|
||||
}
|
||||
|
||||
func (d *AndroidTestDriver) Screenshot() image.Image {
|
||||
out := d.adb("shell", "screencap", "-p")
|
||||
img, err := png.Decode(bytes.NewReader(out))
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
func (d *AndroidTestDriver) tryUninstall() {
|
||||
cmd := exec.Command(d.adbPath, "shell", "pm", "uninstall", appid)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
if bytes.Contains(out, []byte("Unknown package")) {
|
||||
// The package is not installed. Don't log anything.
|
||||
return
|
||||
}
|
||||
d.Logf("could not uninstall: %v\n%s", err, out)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *AndroidTestDriver) adb(args ...interface{}) []byte {
|
||||
strs := []string{}
|
||||
for _, arg := range args {
|
||||
strs = append(strs, fmt.Sprint(arg))
|
||||
}
|
||||
cmd := exec.Command(d.adbPath, strs...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
d.Errorf("%s", out)
|
||||
d.Fatal(err)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (d *AndroidTestDriver) Click(x, y int) {
|
||||
d.adb("shell", "input", "tap", x, y)
|
||||
|
||||
// Wait for the gio app to render after this click.
|
||||
d.waitForFrame()
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,156 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type buildInfo struct {
|
||||
appID string
|
||||
archs []string
|
||||
ldflags string
|
||||
minsdk int
|
||||
name string
|
||||
pkgDir string
|
||||
pkgPath string
|
||||
iconPath string
|
||||
tags string
|
||||
target string
|
||||
version int
|
||||
key string
|
||||
password string
|
||||
}
|
||||
|
||||
func newBuildInfo(pkgPath string) (*buildInfo, error) {
|
||||
pkgMetadata, err := getPkgMetadata(pkgPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
appID := getAppID(pkgMetadata)
|
||||
appIcon := filepath.Join(pkgMetadata.Dir, "appicon.png")
|
||||
if *iconPath != "" {
|
||||
appIcon = *iconPath
|
||||
}
|
||||
bi := &buildInfo{
|
||||
appID: appID,
|
||||
archs: getArchs(),
|
||||
ldflags: getLdFlags(appID),
|
||||
minsdk: *minsdk,
|
||||
name: getPkgName(pkgMetadata),
|
||||
pkgDir: pkgMetadata.Dir,
|
||||
pkgPath: pkgPath,
|
||||
iconPath: appIcon,
|
||||
tags: *extraTags,
|
||||
target: *target,
|
||||
version: *version,
|
||||
key: *signKey,
|
||||
password: *signPass,
|
||||
}
|
||||
return bi, nil
|
||||
}
|
||||
|
||||
func getArchs() []string {
|
||||
if *archNames != "" {
|
||||
return strings.Split(*archNames, ",")
|
||||
}
|
||||
switch *target {
|
||||
case "js":
|
||||
return []string{"wasm"}
|
||||
case "ios", "tvos":
|
||||
// Only 64-bit support.
|
||||
return []string{"arm64", "amd64"}
|
||||
case "android":
|
||||
return []string{"arm", "arm64", "386", "amd64"}
|
||||
case "windows":
|
||||
goarch := os.Getenv("GOARCH")
|
||||
if goarch == "" {
|
||||
goarch = runtime.GOARCH
|
||||
}
|
||||
return []string{goarch}
|
||||
default:
|
||||
// TODO: Add flag tests.
|
||||
panic("The target value has already been validated, this will never execute.")
|
||||
}
|
||||
}
|
||||
|
||||
func getLdFlags(appID string) string {
|
||||
var ldflags []string
|
||||
if extra := *extraLdflags; extra != "" {
|
||||
ldflags = append(ldflags, strings.Split(extra, " ")...)
|
||||
}
|
||||
// Pass appID along, to be used for logging on platforms like Android.
|
||||
ldflags = append(ldflags, fmt.Sprintf("-X gioui.org/app/internal/log.appID=%s", appID))
|
||||
// Pass along all remaining arguments to the app.
|
||||
if appArgs := flag.Args()[1:]; len(appArgs) > 0 {
|
||||
ldflags = append(ldflags, fmt.Sprintf("-X gioui.org/app.extraArgs=%s", strings.Join(appArgs, "|")))
|
||||
}
|
||||
if m := *linkMode; m != "" {
|
||||
ldflags = append(ldflags, "-linkmode="+m)
|
||||
}
|
||||
return strings.Join(ldflags, " ")
|
||||
}
|
||||
|
||||
type packageMetadata struct {
|
||||
PkgPath string
|
||||
Dir string
|
||||
}
|
||||
|
||||
func getPkgMetadata(pkgPath string) (*packageMetadata, error) {
|
||||
pkgImportPath, err := runCmd(exec.Command("go", "list", "-f", "{{.ImportPath}}", pkgPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkgDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", pkgPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &packageMetadata{
|
||||
PkgPath: pkgImportPath,
|
||||
Dir: pkgDir,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getAppID(pkgMetadata *packageMetadata) string {
|
||||
if *appID != "" {
|
||||
return *appID
|
||||
}
|
||||
elems := strings.Split(pkgMetadata.PkgPath, "/")
|
||||
domain := strings.Split(elems[0], ".")
|
||||
name := ""
|
||||
if len(elems) > 1 {
|
||||
name = "." + elems[len(elems)-1]
|
||||
}
|
||||
if len(elems) < 2 && len(domain) < 2 {
|
||||
name = "." + domain[0]
|
||||
domain[0] = "localhost"
|
||||
} else {
|
||||
for i := 0; i < len(domain)/2; i++ {
|
||||
opp := len(domain) - 1 - i
|
||||
domain[i], domain[opp] = domain[opp], domain[i]
|
||||
}
|
||||
}
|
||||
|
||||
pkgDomain := strings.Join(domain, ".")
|
||||
appid := []rune(pkgDomain + name)
|
||||
|
||||
// a Java-language-style package name may contain upper- and lower-case
|
||||
// letters and underscores with individual parts separated by '.'.
|
||||
// https://developer.android.com/guide/topics/manifest/manifest-element
|
||||
for i, c := range appid {
|
||||
if !('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' ||
|
||||
c == '_' || c == '.') {
|
||||
appid[i] = '_'
|
||||
}
|
||||
}
|
||||
return string(appid)
|
||||
}
|
||||
|
||||
func getPkgName(pkgMetadata *packageMetadata) string {
|
||||
return path.Base(pkgMetadata.PkgPath)
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
type expval struct {
|
||||
in, out string
|
||||
}
|
||||
|
||||
func TestAppID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []expval{
|
||||
{"example", "localhost.example"},
|
||||
{"example.com", "com.example"},
|
||||
{"www.example.com", "com.example.www"},
|
||||
{"examplecom/app", "examplecom.app"},
|
||||
{"example.com/app", "com.example.app"},
|
||||
{"www.example.com/app", "com.example.www.app"},
|
||||
{"www.en.example.com/app", "com.example.en.www.app"},
|
||||
{"example.com/dir/app", "com.example.app"},
|
||||
{"example.com/dir.ext/app", "com.example.app"},
|
||||
{"example.com/dir/app.ext", "com.example.app.ext"},
|
||||
{"example-com.net/dir/app", "net.example_com.app"},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
got := getAppID(&packageMetadata{PkgPath: test.in})
|
||||
if exp := test.out; got != exp {
|
||||
t.Errorf("(%d): expected '%s', got '%s'", i, exp, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
/*
|
||||
The gogio tool builds and packages Gio programs for Android, iOS/tvOS
|
||||
and WebAssembly.
|
||||
|
||||
Run gogio with no arguments for instructions, or see the examples at
|
||||
https://gioui.org.
|
||||
*/
|
||||
package main
|
||||
@@ -1,331 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var raceEnabled = false
|
||||
|
||||
var headless = flag.Bool("headless", true, "run end-to-end tests in headless mode")
|
||||
|
||||
const appid = "localhost.gogio.endtoend"
|
||||
|
||||
// TestDriver is implemented by each of the platforms we can run end-to-end
|
||||
// tests on. None of its methods return any errors, as the errors are directly
|
||||
// reported to testing.T via methods like Fatal.
|
||||
type TestDriver interface {
|
||||
initBase(t *testing.T, width, height int)
|
||||
|
||||
// Start opens the Gio app found at path. The driver should attempt to
|
||||
// run the app with the base driver's width and height, and the
|
||||
// platform's background should be white.
|
||||
//
|
||||
// When the function returns, the gio app must be ready to use on the
|
||||
// platform, with its initial frame fully drawn.
|
||||
Start(path string)
|
||||
|
||||
// Screenshot takes a screenshot of the Gio app on the platform.
|
||||
Screenshot() image.Image
|
||||
|
||||
// Click performs a pointer click at the specified coordinates,
|
||||
// including both press and release. It returns when the next frame is
|
||||
// fully drawn.
|
||||
Click(x, y int)
|
||||
}
|
||||
|
||||
type driverBase struct {
|
||||
*testing.T
|
||||
|
||||
width, height int
|
||||
|
||||
output io.Reader
|
||||
frameNotifs chan bool
|
||||
}
|
||||
|
||||
func (d *driverBase) initBase(t *testing.T, width, height int) {
|
||||
d.T = t
|
||||
d.width, d.height = width, height
|
||||
}
|
||||
|
||||
func TestEndToEnd(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skipf("end-to-end tests tend to be slow")
|
||||
}
|
||||
|
||||
t.Parallel()
|
||||
|
||||
const (
|
||||
testdataWithGoImportPkgPath = "gioui.org/cmd/gogio/testdata"
|
||||
testdataWithRelativePkgPath = "testdata/testdata.go"
|
||||
)
|
||||
// Keep this list local, to not reuse TestDriver objects.
|
||||
subtests := []struct {
|
||||
name string
|
||||
driver TestDriver
|
||||
pkgPath string
|
||||
}{
|
||||
{"X11 using go import path", &X11TestDriver{}, testdataWithGoImportPkgPath},
|
||||
{"X11", &X11TestDriver{}, testdataWithRelativePkgPath},
|
||||
// Doesn't work on the builders.
|
||||
//{"Wayland", &WaylandTestDriver{}, testdataWithRelativePkgPath},
|
||||
{"JS", &JSTestDriver{}, testdataWithRelativePkgPath},
|
||||
{"Android", &AndroidTestDriver{}, testdataWithRelativePkgPath},
|
||||
{"Windows", &WineTestDriver{}, testdataWithRelativePkgPath},
|
||||
}
|
||||
|
||||
for _, subtest := range subtests {
|
||||
t.Run(subtest.name, func(t *testing.T) {
|
||||
subtest := subtest // copy the changing loop variable
|
||||
t.Parallel()
|
||||
runEndToEndTest(t, subtest.driver, subtest.pkgPath)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func runEndToEndTest(t *testing.T, driver TestDriver, pkgPath string) {
|
||||
size := image.Point{X: 800, Y: 600}
|
||||
driver.initBase(t, size.X, size.Y)
|
||||
|
||||
t.Log("starting driver and gio app")
|
||||
driver.Start(pkgPath)
|
||||
|
||||
beef := color.NRGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff}
|
||||
white := color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||
black := color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff}
|
||||
gray := color.NRGBA{R: 0xbb, G: 0xbb, B: 0xbb, A: 0xff}
|
||||
red := color.NRGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}
|
||||
|
||||
// These are the four colors at the beginning.
|
||||
t.Log("taking initial screenshot")
|
||||
withRetries(t, 4*time.Second, func() error {
|
||||
img := driver.Screenshot()
|
||||
size = img.Bounds().Size() // override the default size
|
||||
return checkImageCorners(img, beef, white, black, gray)
|
||||
})
|
||||
|
||||
// TODO(mvdan): implement this properly in the Wayland driver; swaymsg
|
||||
// almost works to automate clicks, but the button presses end up in the
|
||||
// wrong coordinates.
|
||||
if _, ok := driver.(*WaylandTestDriver); ok {
|
||||
return
|
||||
}
|
||||
|
||||
// Click the first and last sections to turn them red.
|
||||
t.Log("clicking twice and taking another screenshot")
|
||||
driver.Click(1*(size.X/4), 1*(size.Y/4))
|
||||
driver.Click(3*(size.X/4), 3*(size.Y/4))
|
||||
withRetries(t, 4*time.Second, func() error {
|
||||
img := driver.Screenshot()
|
||||
return checkImageCorners(img, red, white, black, red)
|
||||
})
|
||||
}
|
||||
|
||||
// withRetries keeps retrying fn until it succeeds, or until the timeout is hit.
|
||||
// It uses a rudimentary kind of backoff, which starts with 100ms delays. As
|
||||
// such, timeout should generally be in the order of seconds.
|
||||
func withRetries(t *testing.T, timeout time.Duration, fn func() error) {
|
||||
t.Helper()
|
||||
|
||||
timeoutTimer := time.NewTimer(timeout)
|
||||
defer timeoutTimer.Stop()
|
||||
backoff := 100 * time.Millisecond
|
||||
|
||||
tries := 0
|
||||
var lastErr error
|
||||
for {
|
||||
if lastErr = fn(); lastErr == nil {
|
||||
return
|
||||
}
|
||||
tries++
|
||||
t.Logf("retrying after %s", backoff)
|
||||
|
||||
// Use a timer instead of a sleep, so that the timeout can stop
|
||||
// the backoff early. Don't reuse this timer, since we're not in
|
||||
// a hot loop, and we don't want tricky code.
|
||||
backoffTimer := time.NewTimer(backoff)
|
||||
defer backoffTimer.Stop()
|
||||
|
||||
select {
|
||||
case <-timeoutTimer.C:
|
||||
t.Errorf("last error: %v", lastErr)
|
||||
t.Fatalf("hit timeout of %s after %d tries", timeout, tries)
|
||||
case <-backoffTimer.C:
|
||||
}
|
||||
|
||||
// Keep doubling it until a maximum. With the start at 100ms,
|
||||
// we'll do: 100ms, 200ms, 400ms, 800ms, 1.6s, and 2s forever.
|
||||
backoff *= 2
|
||||
if max := 2 * time.Second; backoff > max {
|
||||
backoff = max
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type colorMismatch struct {
|
||||
x, y int
|
||||
wantRGB, gotRGB [3]uint32
|
||||
}
|
||||
|
||||
func (m colorMismatch) String() string {
|
||||
return fmt.Sprintf("%3d,%-3d got 0x%04x%04x%04x, want 0x%04x%04x%04x",
|
||||
m.x, m.y,
|
||||
m.gotRGB[0], m.gotRGB[1], m.gotRGB[2],
|
||||
m.wantRGB[0], m.wantRGB[1], m.wantRGB[2],
|
||||
)
|
||||
}
|
||||
|
||||
func checkImageCorners(img image.Image, topLeft, topRight, botLeft, botRight color.Color) error {
|
||||
// The colors are split in four rectangular sections. Check the corners
|
||||
// of each of the sections. We check the corners left to right, top to
|
||||
// bottom, like when reading left-to-right text.
|
||||
|
||||
size := img.Bounds().Size()
|
||||
var mismatches []colorMismatch
|
||||
|
||||
checkColor := func(x, y int, want color.Color) {
|
||||
r, g, b, _ := want.RGBA()
|
||||
got := img.At(x, y)
|
||||
r_, g_, b_, _ := got.RGBA()
|
||||
if r_ != r || g_ != g || b_ != b {
|
||||
mismatches = append(mismatches, colorMismatch{
|
||||
x: x,
|
||||
y: y,
|
||||
wantRGB: [3]uint32{r, g, b},
|
||||
gotRGB: [3]uint32{r_, g_, b_},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
minX, minY := 5, 5
|
||||
maxX, maxY := (size.X/2)-5, (size.Y/2)-5
|
||||
checkColor(minX, minY, topLeft)
|
||||
checkColor(maxX, minY, topLeft)
|
||||
checkColor(minX, maxY, topLeft)
|
||||
checkColor(maxX, maxY, topLeft)
|
||||
}
|
||||
{
|
||||
minX, minY := (size.X/2)+5, 5
|
||||
maxX, maxY := size.X-5, (size.Y/2)-5
|
||||
checkColor(minX, minY, topRight)
|
||||
checkColor(maxX, minY, topRight)
|
||||
checkColor(minX, maxY, topRight)
|
||||
checkColor(maxX, maxY, topRight)
|
||||
}
|
||||
{
|
||||
minX, minY := 5, (size.Y/2)+5
|
||||
maxX, maxY := (size.X/2)-5, size.Y-5
|
||||
checkColor(minX, minY, botLeft)
|
||||
checkColor(maxX, minY, botLeft)
|
||||
checkColor(minX, maxY, botLeft)
|
||||
checkColor(maxX, maxY, botLeft)
|
||||
}
|
||||
{
|
||||
minX, minY := (size.X/2)+5, (size.Y/2)+5
|
||||
maxX, maxY := size.X-5, size.Y-5
|
||||
checkColor(minX, minY, botRight)
|
||||
checkColor(maxX, minY, botRight)
|
||||
checkColor(minX, maxY, botRight)
|
||||
checkColor(maxX, maxY, botRight)
|
||||
}
|
||||
if n := len(mismatches); n > 0 {
|
||||
b := new(strings.Builder)
|
||||
fmt.Fprintf(b, "encountered %d color mismatches:\n", n)
|
||||
for _, m := range mismatches {
|
||||
fmt.Fprintf(b, "%s\n", m)
|
||||
}
|
||||
return errors.New(b.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *driverBase) waitForFrame() {
|
||||
d.Helper()
|
||||
|
||||
if d.frameNotifs == nil {
|
||||
// Start the goroutine that reads output lines and notifies of
|
||||
// new frames via frameNotifs. The test doesn't wait for this
|
||||
// goroutine to finish; it will naturally end when the output
|
||||
// reader reaches an error like EOF.
|
||||
d.frameNotifs = make(chan bool, 1)
|
||||
if d.output == nil {
|
||||
d.Fatal("need an output reader to be notified of frames")
|
||||
}
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(d.output)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
d.Log(line)
|
||||
if strings.Contains(line, "gio frame ready") {
|
||||
d.frameNotifs <- true
|
||||
}
|
||||
}
|
||||
// Since we're only interested in the output while the
|
||||
// app runs, and we don't know when it finishes here,
|
||||
// ignore "already closed" pipe errors.
|
||||
if err := scanner.Err(); err != nil && !errors.Is(err, os.ErrClosed) {
|
||||
d.Errorf("reading app output: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Unfortunately, there isn't a way to select on a test failing, since
|
||||
// testing.T doesn't have anything like a context or a "done" channel.
|
||||
//
|
||||
// We can't let selects block forever, since the default -test.timeout
|
||||
// is ten minutes - far too long for tests that take seconds.
|
||||
//
|
||||
// For now, a static short timeout is better than nothing. 5s is plenty
|
||||
// for our simple test app to render on any device.
|
||||
select {
|
||||
case <-d.frameNotifs:
|
||||
case <-time.After(5 * time.Second):
|
||||
d.Fatalf("timed out waiting for a frame to be ready")
|
||||
}
|
||||
}
|
||||
|
||||
func (d *driverBase) needPrograms(names ...string) {
|
||||
d.Helper()
|
||||
for _, name := range names {
|
||||
if _, err := exec.LookPath(name); err != nil {
|
||||
d.Skipf("%s needed to run", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *driverBase) tempDir(name string) string {
|
||||
d.Helper()
|
||||
dir, err := ioutil.TempDir("", name)
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(func() { os.RemoveAll(dir) })
|
||||
return dir
|
||||
}
|
||||
|
||||
func (d *driverBase) gogio(args ...string) {
|
||||
d.Helper()
|
||||
prog, err := os.Executable()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command(prog, args...)
|
||||
cmd.Env = append(os.Environ(), "RUN_GOGIO=1")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
d.Fatalf("gogio error: %s:\n%s", err, out)
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main
|
||||
|
||||
const mainUsage = `The gogio command builds and packages Gio (gioui.org) programs.
|
||||
|
||||
Usage:
|
||||
|
||||
gogio -target <target> [flags] <package> [run arguments]
|
||||
|
||||
The gogio tool builds and packages Gio programs for platforms where additional
|
||||
metadata or support files are required.
|
||||
|
||||
The package argument specifies an import path or a single Go source file to
|
||||
package. Any run arguments are appended to os.Args at runtime.
|
||||
|
||||
Compiled Java class files from jar files in the package directory are
|
||||
included in Android builds.
|
||||
|
||||
The mandatory -target flag selects the target platform: ios or android for the
|
||||
mobile platforms, tvos for Apple's tvOS, js for WebAssembly/WebGL.
|
||||
|
||||
The -arch flag specifies a comma separated list of GOARCHs to include. The
|
||||
default is all supported architectures.
|
||||
|
||||
The -o flag specifies an output file or directory, depending on the target.
|
||||
|
||||
The -buildmode flag selects the build mode. Two build modes are available, exe
|
||||
and archive. Buildmode exe outputs an .ipa file for iOS or tvOS, an .apk file
|
||||
for Android or a directory with the WebAssembly module and support files for
|
||||
a browser.
|
||||
|
||||
The -ldflags and -tags flags pass extra linker flags and tags to the go tool.
|
||||
|
||||
As a special case for iOS or tvOS, specifying a path that ends with ".app"
|
||||
will output an app directory suitable for a simulator.
|
||||
|
||||
The other buildmode is archive, which will output an .aar library for Android
|
||||
or a .framework for iOS and tvOS.
|
||||
|
||||
The -icon flag specifies a path to a PNG image to use as app icon on iOS and Android.
|
||||
If left unspecified, the appicon.png file from the main package is used
|
||||
(if it exists).
|
||||
|
||||
The -appid flag specifies the package name for Android or the bundle id for
|
||||
iOS and tvOS. A bundle id must be provisioned through Xcode before the gogio
|
||||
tool can use it.
|
||||
|
||||
The -version flag specifies the integer version code for Android and the last
|
||||
component of the 1.0.X version for iOS and tvOS.
|
||||
|
||||
For Android builds the -minsdk flag specify the minimum SDK level. For example,
|
||||
use -minsdk 22 to target Android 5.1 (Lollipop) and later.
|
||||
|
||||
For Windows builds the -minsdk flag specify the minimum OS version. For example,
|
||||
use -mindk 10 to target Windows 10 and later, -minsdk 6 for Windows Vista and later.
|
||||
|
||||
For iOS builds the -minsdk flag specify the minimum iOS version. For example,
|
||||
use -mindk 15 to target iOS 15.0 and later.
|
||||
|
||||
The -work flag prints the path to the working directory and suppress
|
||||
its deletion.
|
||||
|
||||
The -x flag will print all the external commands executed by the gogio tool.
|
||||
|
||||
The -signkey flag specifies the path of the keystore, used for signing Android apk/aab files.
|
||||
|
||||
The -signpass flag specifies the password of the keystore, ignored if -signkey is not provided.
|
||||
`
|
||||
@@ -1,589 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
const (
|
||||
minIOSVersion = 10
|
||||
// Metal is available from iOS 8 on devices, yet from version 13 on the
|
||||
// simulator.
|
||||
minSimulatorVersion = 13
|
||||
)
|
||||
|
||||
func buildIOS(tmpDir, target string, bi *buildInfo) error {
|
||||
appName := bi.name
|
||||
switch *buildMode {
|
||||
case "archive":
|
||||
framework := *destPath
|
||||
if framework == "" {
|
||||
framework = fmt.Sprintf("%s.framework", strings.Title(appName))
|
||||
}
|
||||
return archiveIOS(tmpDir, target, framework, bi)
|
||||
case "exe":
|
||||
out := *destPath
|
||||
if out == "" {
|
||||
out = appName + ".ipa"
|
||||
}
|
||||
forDevice := strings.HasSuffix(out, ".ipa")
|
||||
// Filter out unsupported architectures.
|
||||
for i := len(bi.archs) - 1; i >= 0; i-- {
|
||||
switch bi.archs[i] {
|
||||
case "arm", "arm64":
|
||||
if forDevice {
|
||||
continue
|
||||
}
|
||||
case "386", "amd64":
|
||||
if !forDevice {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
bi.archs = append(bi.archs[:i], bi.archs[i+1:]...)
|
||||
}
|
||||
tmpFramework := filepath.Join(tmpDir, "Gio.framework")
|
||||
if err := archiveIOS(tmpDir, target, tmpFramework, bi); err != nil {
|
||||
return err
|
||||
}
|
||||
if !forDevice && !strings.HasSuffix(out, ".app") {
|
||||
return fmt.Errorf("the specified output directory %q does not end in .app or .ipa", out)
|
||||
}
|
||||
if !forDevice {
|
||||
return exeIOS(tmpDir, target, out, bi)
|
||||
}
|
||||
payload := filepath.Join(tmpDir, "Payload")
|
||||
appDir := filepath.Join(payload, appName+".app")
|
||||
if err := os.MkdirAll(appDir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := exeIOS(tmpDir, target, appDir, bi); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := signIOS(bi, tmpDir, appDir); err != nil {
|
||||
return err
|
||||
}
|
||||
return zipDir(out, tmpDir, "Payload")
|
||||
default:
|
||||
panic("unreachable")
|
||||
}
|
||||
}
|
||||
|
||||
func signIOS(bi *buildInfo, tmpDir, app string) error {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
provPattern := filepath.Join(home, "Library", "MobileDevice", "Provisioning Profiles", "*.mobileprovision")
|
||||
provisions, err := filepath.Glob(provPattern)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
provInfo := filepath.Join(tmpDir, "provision.plist")
|
||||
var avail []string
|
||||
for _, prov := range provisions {
|
||||
// Decode the provision file to a plist.
|
||||
_, err := runCmd(exec.Command("security", "cms", "-D", "-i", prov, "-o", provInfo))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
expUnix, err := runCmd(exec.Command("/usr/libexec/PlistBuddy", "-c", "Print:ExpirationDate", provInfo))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
exp, err := time.Parse(time.UnixDate, expUnix)
|
||||
if err != nil {
|
||||
return fmt.Errorf("sign: failed to parse expiration date from %q: %v", prov, err)
|
||||
}
|
||||
if exp.Before(time.Now()) {
|
||||
continue
|
||||
}
|
||||
appIDPrefix, err := runCmd(exec.Command("/usr/libexec/PlistBuddy", "-c", "Print:ApplicationIdentifierPrefix:0", provInfo))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
provAppID, err := runCmd(exec.Command("/usr/libexec/PlistBuddy", "-c", "Print:Entitlements:application-identifier", provInfo))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
expAppID := fmt.Sprintf("%s.%s", appIDPrefix, bi.appID)
|
||||
avail = append(avail, provAppID)
|
||||
if expAppID != provAppID {
|
||||
continue
|
||||
}
|
||||
// Copy provisioning file.
|
||||
embedded := filepath.Join(app, "embedded.mobileprovision")
|
||||
if err := copyFile(embedded, prov); err != nil {
|
||||
return err
|
||||
}
|
||||
certDER, err := runCmdRaw(exec.Command("/usr/libexec/PlistBuddy", "-c", "Print:DeveloperCertificates:0", provInfo))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Omit trailing newline.
|
||||
certDER = certDER[:len(certDER)-1]
|
||||
entitlements, err := runCmd(exec.Command("/usr/libexec/PlistBuddy", "-x", "-c", "Print:Entitlements", provInfo))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
entFile := filepath.Join(tmpDir, "entitlements.plist")
|
||||
if err := ioutil.WriteFile(entFile, []byte(entitlements), 0660); err != nil {
|
||||
return err
|
||||
}
|
||||
identity := sha1.Sum(certDER)
|
||||
idHex := hex.EncodeToString(identity[:])
|
||||
_, err = runCmd(exec.Command("codesign", "-s", idHex, "-v", "--entitlements", entFile, app))
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("sign: no valid provisioning profile found for bundle id %q among %v", bi.appID, avail)
|
||||
}
|
||||
|
||||
func exeIOS(tmpDir, target, app string, bi *buildInfo) error {
|
||||
if bi.appID == "" {
|
||||
return errors.New("app id is empty; use -appid to set it")
|
||||
}
|
||||
if err := os.RemoveAll(app); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Mkdir(app, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
mainm := filepath.Join(tmpDir, "main.m")
|
||||
const mainmSrc = `@import UIKit;
|
||||
@import Gio;
|
||||
|
||||
@interface GioAppDelegate : UIResponder <UIApplicationDelegate>
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@end
|
||||
|
||||
@implementation GioAppDelegate
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
GioViewController *controller = [[GioViewController alloc] initWithNibName:nil bundle:nil];
|
||||
self.window.rootViewController = controller;
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([GioAppDelegate class]));
|
||||
}
|
||||
}`
|
||||
if err := ioutil.WriteFile(mainm, []byte(mainmSrc), 0660); err != nil {
|
||||
return err
|
||||
}
|
||||
appName := strings.Title(bi.name)
|
||||
exe := filepath.Join(app, appName)
|
||||
lipo := exec.Command("xcrun", "lipo", "-o", exe, "-create")
|
||||
var builds errgroup.Group
|
||||
for _, a := range bi.archs {
|
||||
clang, cflags, err := iosCompilerFor(target, a, bi.minsdk)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
exeSlice := filepath.Join(tmpDir, "app-"+a)
|
||||
lipo.Args = append(lipo.Args, exeSlice)
|
||||
compile := exec.Command(clang, cflags...)
|
||||
compile.Args = append(compile.Args,
|
||||
"-Werror",
|
||||
"-fmodules",
|
||||
"-fobjc-arc",
|
||||
"-x", "objective-c",
|
||||
"-F", tmpDir,
|
||||
"-o", exeSlice,
|
||||
mainm,
|
||||
)
|
||||
builds.Go(func() error {
|
||||
_, err := runCmd(compile)
|
||||
return err
|
||||
})
|
||||
}
|
||||
if err := builds.Wait(); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := runCmd(lipo); err != nil {
|
||||
return err
|
||||
}
|
||||
infoPlist := buildInfoPlist(bi)
|
||||
plistFile := filepath.Join(app, "Info.plist")
|
||||
if err := ioutil.WriteFile(plistFile, []byte(infoPlist), 0660); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := os.Stat(bi.iconPath); err == nil {
|
||||
assetPlist, err := iosIcons(bi, tmpDir, app, bi.iconPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Merge assets plist with Info.plist
|
||||
cmd := exec.Command(
|
||||
"/usr/libexec/PlistBuddy",
|
||||
"-c", "Merge "+assetPlist,
|
||||
plistFile,
|
||||
)
|
||||
if _, err := runCmd(cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := runCmd(exec.Command("plutil", "-convert", "binary1", plistFile)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// iosIcons builds an asset catalog and compile it with the Xcode command actool.
|
||||
// iosIcons returns the asset plist file to be merged into Info.plist.
|
||||
func iosIcons(bi *buildInfo, tmpDir, appDir, icon string) (string, error) {
|
||||
assets := filepath.Join(tmpDir, "Assets.xcassets")
|
||||
if err := os.Mkdir(assets, 0700); err != nil {
|
||||
return "", err
|
||||
}
|
||||
appIcon := filepath.Join(assets, "AppIcon.appiconset")
|
||||
err := buildIcons(appIcon, icon, []iconVariant{
|
||||
{path: "ios_2x.png", size: 120},
|
||||
{path: "ios_3x.png", size: 180},
|
||||
// The App Store icon is not allowed to contain
|
||||
// transparent pixels.
|
||||
{path: "ios_store.png", size: 1024, fill: true},
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
contentJson := `{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "ios_2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "ios_3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "1024x1024",
|
||||
"idiom" : "ios-marketing",
|
||||
"filename" : "ios_store.png",
|
||||
"scale" : "1x"
|
||||
}
|
||||
]
|
||||
}`
|
||||
contentFile := filepath.Join(appIcon, "Contents.json")
|
||||
if err := ioutil.WriteFile(contentFile, []byte(contentJson), 0600); err != nil {
|
||||
return "", err
|
||||
}
|
||||
assetPlist := filepath.Join(tmpDir, "assets.plist")
|
||||
|
||||
minsdk := bi.minsdk
|
||||
if minsdk == 0 {
|
||||
minsdk = minIOSVersion
|
||||
}
|
||||
compile := exec.Command(
|
||||
"actool",
|
||||
"--compile", appDir,
|
||||
"--platform", iosPlatformFor(bi.target),
|
||||
"--minimum-deployment-target", strconv.Itoa(minsdk),
|
||||
"--app-icon", "AppIcon",
|
||||
"--output-partial-info-plist", assetPlist,
|
||||
assets)
|
||||
_, err = runCmd(compile)
|
||||
return assetPlist, err
|
||||
}
|
||||
|
||||
func buildInfoPlist(bi *buildInfo) string {
|
||||
appName := strings.Title(bi.name)
|
||||
platform := iosPlatformFor(bi.target)
|
||||
var supportPlatform string
|
||||
switch bi.target {
|
||||
case "ios":
|
||||
supportPlatform = "iPhoneOS"
|
||||
case "tvos":
|
||||
supportPlatform = "AppleTVOS"
|
||||
}
|
||||
return fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>%s</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>%s</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>%s</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.%d</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>%d</string>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array><string>arm64</string></array>
|
||||
<key>DTPlatformName</key>
|
||||
<string>%s</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>12.4</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>%d</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>%s</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>16G73</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>16G73</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>%s12.4</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1030</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>10G8</string>
|
||||
</dict>
|
||||
</plist>`, appName, bi.appID, appName, bi.version, bi.version, platform, minIOSVersion, supportPlatform, platform)
|
||||
}
|
||||
|
||||
func iosPlatformFor(target string) string {
|
||||
switch target {
|
||||
case "ios":
|
||||
return "iphoneos"
|
||||
case "tvos":
|
||||
return "appletvos"
|
||||
default:
|
||||
panic("invalid platform " + target)
|
||||
}
|
||||
}
|
||||
|
||||
func archiveIOS(tmpDir, target, frameworkRoot string, bi *buildInfo) error {
|
||||
framework := filepath.Base(frameworkRoot)
|
||||
const suf = ".framework"
|
||||
if !strings.HasSuffix(framework, suf) {
|
||||
return fmt.Errorf("the specified output %q does not end in '.framework'", frameworkRoot)
|
||||
}
|
||||
framework = framework[:len(framework)-len(suf)]
|
||||
if err := os.RemoveAll(frameworkRoot); err != nil {
|
||||
return err
|
||||
}
|
||||
frameworkDir := filepath.Join(frameworkRoot, "Versions", "A")
|
||||
for _, dir := range []string{"Headers", "Modules"} {
|
||||
p := filepath.Join(frameworkDir, dir)
|
||||
if err := os.MkdirAll(p, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
symlinks := [][2]string{
|
||||
{"Versions/Current/Headers", "Headers"},
|
||||
{"Versions/Current/Modules", "Modules"},
|
||||
{"Versions/Current/" + framework, framework},
|
||||
{"A", filepath.Join("Versions", "Current")},
|
||||
}
|
||||
for _, l := range symlinks {
|
||||
if err := os.Symlink(l[0], filepath.Join(frameworkRoot, l[1])); err != nil && !os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
exe := filepath.Join(frameworkDir, framework)
|
||||
lipo := exec.Command("xcrun", "lipo", "-o", exe, "-create")
|
||||
var builds errgroup.Group
|
||||
tags := bi.tags
|
||||
goos := "ios"
|
||||
supportsIOS, err := supportsGOOS("ios")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !supportsIOS {
|
||||
// Go 1.15 and earlier target iOS with GOOS=darwin, tags=ios.
|
||||
goos = "darwin"
|
||||
tags = "ios " + tags
|
||||
}
|
||||
for _, a := range bi.archs {
|
||||
clang, cflags, err := iosCompilerFor(target, a, bi.minsdk)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lib := filepath.Join(tmpDir, "gio-"+a)
|
||||
cmd := exec.Command(
|
||||
"go",
|
||||
"build",
|
||||
"-ldflags=-s -w "+bi.ldflags,
|
||||
"-buildmode=c-archive",
|
||||
"-o", lib,
|
||||
"-tags", tags,
|
||||
bi.pkgPath,
|
||||
)
|
||||
lipo.Args = append(lipo.Args, lib)
|
||||
cflagsLine := strings.Join(cflags, " ")
|
||||
cmd.Env = append(
|
||||
os.Environ(),
|
||||
"GOOS="+goos,
|
||||
"GOARCH="+a,
|
||||
"CGO_ENABLED=1",
|
||||
"CC="+clang,
|
||||
"CGO_CFLAGS="+cflagsLine,
|
||||
"CGO_LDFLAGS="+cflagsLine,
|
||||
)
|
||||
builds.Go(func() error {
|
||||
_, err := runCmd(cmd)
|
||||
return err
|
||||
})
|
||||
}
|
||||
if err := builds.Wait(); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := runCmd(lipo); err != nil {
|
||||
return err
|
||||
}
|
||||
appDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", "gioui.org/app/"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
headerDst := filepath.Join(frameworkDir, "Headers", framework+".h")
|
||||
headerSrc := filepath.Join(appDir, "framework_ios.h")
|
||||
if err := copyFile(headerDst, headerSrc); err != nil {
|
||||
return err
|
||||
}
|
||||
module := fmt.Sprintf(`framework module "%s" {
|
||||
header "%[1]s.h"
|
||||
|
||||
export *
|
||||
}`, framework)
|
||||
moduleFile := filepath.Join(frameworkDir, "Modules", "module.modulemap")
|
||||
return ioutil.WriteFile(moduleFile, []byte(module), 0644)
|
||||
}
|
||||
|
||||
func supportsGOOS(wantGoos string) (bool, error) {
|
||||
geese, err := runCmd(exec.Command("go", "tool", "dist", "list"))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, pair := range strings.Split(geese, "\n") {
|
||||
s := strings.SplitN(pair, "/", 2)
|
||||
if len(s) != 2 {
|
||||
return false, fmt.Errorf("go tool dist list: invalid GOOS/GOARCH pair: %s", pair)
|
||||
}
|
||||
goos := s[0]
|
||||
if goos == wantGoos {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func iosCompilerFor(target, arch string, minsdk int) (string, []string, error) {
|
||||
var (
|
||||
platformSDK string
|
||||
platformOS string
|
||||
)
|
||||
switch target {
|
||||
case "ios":
|
||||
platformOS = "ios"
|
||||
platformSDK = "iphone"
|
||||
case "tvos":
|
||||
platformOS = "tvos"
|
||||
platformSDK = "appletv"
|
||||
}
|
||||
switch arch {
|
||||
case "arm", "arm64":
|
||||
platformSDK += "os"
|
||||
if minsdk == 0 {
|
||||
minsdk = minIOSVersion
|
||||
}
|
||||
case "386", "amd64":
|
||||
platformOS += "-simulator"
|
||||
platformSDK += "simulator"
|
||||
if minsdk == 0 {
|
||||
minsdk = minSimulatorVersion
|
||||
}
|
||||
default:
|
||||
return "", nil, fmt.Errorf("unsupported -arch: %s", arch)
|
||||
}
|
||||
sdkPath, err := runCmd(exec.Command("xcrun", "--sdk", platformSDK, "--show-sdk-path"))
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
clang, err := runCmd(exec.Command("xcrun", "--sdk", platformSDK, "--find", "clang"))
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
cflags := []string{
|
||||
"-fembed-bitcode",
|
||||
"-arch", allArchs[arch].iosArch,
|
||||
"-isysroot", sdkPath,
|
||||
"-m" + platformOS + "-version-min=" + strconv.Itoa(minsdk),
|
||||
}
|
||||
return clang, cflags, nil
|
||||
}
|
||||
|
||||
func zipDir(dst, base, dir string) (err error) {
|
||||
f, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if cerr := f.Close(); err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
zipf := zip.NewWriter(f)
|
||||
err = filepath.Walk(filepath.Join(base, dir), func(path string, f os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if f.IsDir() {
|
||||
return nil
|
||||
}
|
||||
rel := filepath.ToSlash(path[len(base)+1:])
|
||||
entry, err := zipf.Create(rel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
src, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer src.Close()
|
||||
_, err = io.Copy(entry, src)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return zipf.Close()
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"image"
|
||||
"image/png"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os/exec"
|
||||
|
||||
"github.com/chromedp/cdproto/runtime"
|
||||
"github.com/chromedp/chromedp"
|
||||
|
||||
_ "gioui.org/unit" // the build tool adds it to go.mod, so keep it there
|
||||
)
|
||||
|
||||
type JSTestDriver struct {
|
||||
driverBase
|
||||
|
||||
// ctx is the chromedp context.
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func (d *JSTestDriver) Start(path string) {
|
||||
if raceEnabled {
|
||||
d.Skipf("js/wasm doesn't support -race; skipping")
|
||||
}
|
||||
|
||||
// First, build the app.
|
||||
dir := d.tempDir("gio-endtoend-js")
|
||||
d.gogio("-target=js", "-o="+dir, path)
|
||||
|
||||
// Second, start Chrome.
|
||||
opts := append(chromedp.DefaultExecAllocatorOptions[:],
|
||||
chromedp.Flag("headless", *headless),
|
||||
)
|
||||
|
||||
actx, cancel := chromedp.NewExecAllocator(context.Background(), opts...)
|
||||
d.Cleanup(cancel)
|
||||
|
||||
ctx, cancel := chromedp.NewContext(actx,
|
||||
// Send all logf/errf calls to t.Logf
|
||||
chromedp.WithLogf(d.Logf),
|
||||
)
|
||||
d.Cleanup(cancel)
|
||||
d.ctx = ctx
|
||||
|
||||
if err := chromedp.Run(ctx); err != nil {
|
||||
if errors.Is(err, exec.ErrNotFound) {
|
||||
d.Skipf("test requires Chrome to be installed: %v", err)
|
||||
return
|
||||
}
|
||||
d.Fatal(err)
|
||||
}
|
||||
pr, pw := io.Pipe()
|
||||
d.Cleanup(func() { pw.Close() })
|
||||
d.output = pr
|
||||
chromedp.ListenTarget(ctx, func(ev interface{}) {
|
||||
switch ev := ev.(type) {
|
||||
case *runtime.EventConsoleAPICalled:
|
||||
switch ev.Type {
|
||||
case "log", "info", "warning", "error":
|
||||
var b bytes.Buffer
|
||||
b.WriteString("console.")
|
||||
b.WriteString(string(ev.Type))
|
||||
b.WriteString("(")
|
||||
for i, arg := range ev.Args {
|
||||
if i > 0 {
|
||||
b.WriteString(", ")
|
||||
}
|
||||
b.Write(arg.Value)
|
||||
}
|
||||
b.WriteString(")\n")
|
||||
pw.Write(b.Bytes())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Third, serve the app folder, set the browser tab dimensions, and
|
||||
// navigate to the folder.
|
||||
ts := httptest.NewServer(http.FileServer(http.Dir(dir)))
|
||||
d.Cleanup(ts.Close)
|
||||
|
||||
if err := chromedp.Run(ctx,
|
||||
chromedp.EmulateViewport(int64(d.width), int64(d.height)),
|
||||
chromedp.Navigate(ts.URL),
|
||||
); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for the gio app to render.
|
||||
d.waitForFrame()
|
||||
}
|
||||
|
||||
func (d *JSTestDriver) Screenshot() image.Image {
|
||||
var buf []byte
|
||||
if err := chromedp.Run(d.ctx,
|
||||
chromedp.CaptureScreenshot(&buf),
|
||||
); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
img, err := png.Decode(bytes.NewReader(buf))
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
func (d *JSTestDriver) Click(x, y int) {
|
||||
if err := chromedp.Run(d.ctx,
|
||||
chromedp.MouseClickXY(float64(x), float64(y)),
|
||||
); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for the gio app to render after this click.
|
||||
d.waitForFrame()
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"golang.org/x/tools/go/packages"
|
||||
)
|
||||
|
||||
func buildJS(bi *buildInfo) error {
|
||||
out := *destPath
|
||||
if out == "" {
|
||||
out = bi.name
|
||||
}
|
||||
if err := os.MkdirAll(out, 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
cmd := exec.Command(
|
||||
"go",
|
||||
"build",
|
||||
"-ldflags="+bi.ldflags,
|
||||
"-tags="+bi.tags,
|
||||
"-o", filepath.Join(out, "main.wasm"),
|
||||
bi.pkgPath,
|
||||
)
|
||||
cmd.Env = append(
|
||||
os.Environ(),
|
||||
"GOOS=js",
|
||||
"GOARCH=wasm",
|
||||
)
|
||||
_, err := runCmd(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var faviconPath string
|
||||
if _, err := os.Stat(bi.iconPath); err == nil {
|
||||
// Copy icon to the output folder
|
||||
icon, err := ioutil.ReadFile(bi.iconPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(filepath.Join(out, filepath.Base(bi.iconPath)), icon, 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
faviconPath = filepath.Base(bi.iconPath)
|
||||
}
|
||||
|
||||
indexTemplate, err := template.New("").Parse(jsIndex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
if err := indexTemplate.Execute(&b, struct {
|
||||
Name string
|
||||
Icon string
|
||||
}{
|
||||
Name: bi.name,
|
||||
Icon: faviconPath,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(out, "index.html"), b.Bytes(), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
goroot, err := runCmd(exec.Command("go", "env", "GOROOT"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wasmJS := filepath.Join(goroot, "misc", "wasm", "wasm_exec.js")
|
||||
if _, err := os.Stat(wasmJS); err != nil {
|
||||
return fmt.Errorf("failed to find $GOROOT/misc/wasm/wasm_exec.js driver: %v", err)
|
||||
}
|
||||
pkgs, err := packages.Load(&packages.Config{
|
||||
Mode: packages.NeedName | packages.NeedFiles | packages.NeedImports | packages.NeedDeps,
|
||||
Env: append(os.Environ(), "GOOS=js", "GOARCH=wasm"),
|
||||
}, bi.pkgPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
extraJS, err := findPackagesJS(pkgs[0], make(map[string]bool))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return mergeJSFiles(filepath.Join(out, "wasm.js"), append([]string{wasmJS}, extraJS...)...)
|
||||
}
|
||||
|
||||
func findPackagesJS(p *packages.Package, visited map[string]bool) (extraJS []string, err error) {
|
||||
if len(p.GoFiles) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
js, err := filepath.Glob(filepath.Join(filepath.Dir(p.GoFiles[0]), "*_js.js"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
extraJS = append(extraJS, js...)
|
||||
for _, imp := range p.Imports {
|
||||
if !visited[imp.ID] {
|
||||
extra, err := findPackagesJS(imp, visited)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
extraJS = append(extraJS, extra...)
|
||||
visited[imp.ID] = true
|
||||
}
|
||||
}
|
||||
return extraJS, nil
|
||||
}
|
||||
|
||||
// mergeJSFiles will merge all files into a single `wasm.js`. It will prepend the jsSetGo
|
||||
// and append the jsStartGo.
|
||||
func mergeJSFiles(dst string, files ...string) (err error) {
|
||||
w, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if cerr := w.Close(); err != nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
_, err = io.Copy(w, strings.NewReader(jsSetGo))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i := range files {
|
||||
r, err := os.Open(files[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(w, r)
|
||||
r.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err = io.Copy(w, strings.NewReader(jsStartGo))
|
||||
return err
|
||||
}
|
||||
|
||||
const (
|
||||
jsIndex = `<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
{{ if .Icon }}<link rel="icon" href="{{.Icon}}" type="image/x-icon" />{{ end }}
|
||||
{{ if .Name }}<title>{{.Name}}</title>{{ end }}
|
||||
<script src="wasm.js"></script>
|
||||
<style>
|
||||
body,pre { margin:0;padding:0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>`
|
||||
// jsSetGo sets the `window.go` variable.
|
||||
jsSetGo = `(() => {
|
||||
window.go = {argv: [], env: {}, importObject: {go: {}}};
|
||||
const argv = new URLSearchParams(location.search).get("argv");
|
||||
if (argv) {
|
||||
window.go["argv"] = argv.split(" ");
|
||||
}
|
||||
})();`
|
||||
// jsStartGo initializes the main.wasm.
|
||||
jsStartGo = `(() => {
|
||||
defaultGo = new Go();
|
||||
Object.assign(defaultGo["argv"], defaultGo["argv"].concat(go["argv"]));
|
||||
Object.assign(defaultGo["env"], go["env"]);
|
||||
for (let key in go["importObject"]) {
|
||||
if (typeof defaultGo["importObject"][key] === "undefined") {
|
||||
defaultGo["importObject"][key] = {};
|
||||
}
|
||||
Object.assign(defaultGo["importObject"][key], go["importObject"][key]);
|
||||
}
|
||||
window.go = defaultGo;
|
||||
if (!WebAssembly.instantiateStreaming) { // polyfill
|
||||
WebAssembly.instantiateStreaming = async (resp, importObject) => {
|
||||
const source = await (await resp).arrayBuffer();
|
||||
return await WebAssembly.instantiate(source, importObject);
|
||||
};
|
||||
}
|
||||
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => {
|
||||
go.run(result.instance);
|
||||
});
|
||||
})();`
|
||||
)
|
||||
@@ -1,224 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/image/draw"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
var (
|
||||
target = flag.String("target", "", "specify target (ios, tvos, android, js).\n")
|
||||
archNames = flag.String("arch", "", "specify architecture(s) to include (arm, arm64, amd64).")
|
||||
minsdk = flag.Int("minsdk", 0, "specify the minimum supported operating system level")
|
||||
buildMode = flag.String("buildmode", "exe", "specify buildmode (archive, exe)")
|
||||
destPath = flag.String("o", "", "output file or directory.\nFor -target ios or tvos, use the .app suffix to target simulators.")
|
||||
appID = flag.String("appid", "", "app identifier (for -buildmode=exe)")
|
||||
version = flag.Int("version", 1, "app version (for -buildmode=exe)")
|
||||
printCommands = flag.Bool("x", false, "print the commands")
|
||||
keepWorkdir = flag.Bool("work", false, "print the name of the temporary work directory and do not delete it when exiting.")
|
||||
linkMode = flag.String("linkmode", "", "set the -linkmode flag of the go tool")
|
||||
extraLdflags = flag.String("ldflags", "", "extra flags to the Go linker")
|
||||
extraTags = flag.String("tags", "", "extra tags to the Go tool")
|
||||
iconPath = flag.String("icon", "", "specify an icon for iOS and Android")
|
||||
signKey = flag.String("signkey", "", "specify the path of the keystore to be used to sign Android apk files.")
|
||||
signPass = flag.String("signpass", "", "specify the password to decrypt the signkey.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Usage = func() {
|
||||
fmt.Fprint(os.Stderr, mainUsage)
|
||||
}
|
||||
flag.Parse()
|
||||
if err := flagValidate(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "gogio: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
buildInfo, err := newBuildInfo(flag.Arg(0))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "gogio: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := build(buildInfo); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "gogio: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func flagValidate() error {
|
||||
pkgPathArg := flag.Arg(0)
|
||||
if pkgPathArg == "" {
|
||||
return errors.New("specify a package")
|
||||
}
|
||||
if *target == "" {
|
||||
return errors.New("please specify -target")
|
||||
}
|
||||
switch *target {
|
||||
case "ios", "tvos", "android", "js", "windows":
|
||||
default:
|
||||
return fmt.Errorf("invalid -target %s", *target)
|
||||
}
|
||||
switch *buildMode {
|
||||
case "archive", "exe":
|
||||
default:
|
||||
return fmt.Errorf("invalid -buildmode %s", *buildMode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func build(bi *buildInfo) error {
|
||||
tmpDir, err := ioutil.TempDir("", "gogio-")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if *keepWorkdir {
|
||||
fmt.Fprintf(os.Stderr, "WORKDIR=%s\n", tmpDir)
|
||||
} else {
|
||||
defer os.RemoveAll(tmpDir)
|
||||
}
|
||||
switch *target {
|
||||
case "js":
|
||||
return buildJS(bi)
|
||||
case "ios", "tvos":
|
||||
return buildIOS(tmpDir, *target, bi)
|
||||
case "android":
|
||||
return buildAndroid(tmpDir, bi)
|
||||
case "windows":
|
||||
return buildWindows(tmpDir, bi)
|
||||
default:
|
||||
panic("unreachable")
|
||||
}
|
||||
}
|
||||
|
||||
func runCmdRaw(cmd *exec.Cmd) ([]byte, error) {
|
||||
if *printCommands {
|
||||
fmt.Printf("%s\n", strings.Join(cmd.Args, " "))
|
||||
}
|
||||
out, err := cmd.Output()
|
||||
if err == nil {
|
||||
return out, nil
|
||||
}
|
||||
if err, ok := err.(*exec.ExitError); ok {
|
||||
return nil, fmt.Errorf("%s failed: %s%s", strings.Join(cmd.Args, " "), out, err.Stderr)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func runCmd(cmd *exec.Cmd) (string, error) {
|
||||
out, err := runCmdRaw(cmd)
|
||||
return string(bytes.TrimSpace(out)), err
|
||||
}
|
||||
|
||||
func copyFile(dst, src string) (err error) {
|
||||
r, err := os.Open(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer r.Close()
|
||||
w, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if cerr := w.Close(); err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
_, err = io.Copy(w, r)
|
||||
return err
|
||||
}
|
||||
|
||||
type arch struct {
|
||||
iosArch string
|
||||
jniArch string
|
||||
clangArch string
|
||||
}
|
||||
|
||||
var allArchs = map[string]arch{
|
||||
"arm": {
|
||||
iosArch: "armv7",
|
||||
jniArch: "armeabi-v7a",
|
||||
clangArch: "armv7a-linux-androideabi",
|
||||
},
|
||||
"arm64": {
|
||||
iosArch: "arm64",
|
||||
jniArch: "arm64-v8a",
|
||||
clangArch: "aarch64-linux-android",
|
||||
},
|
||||
"386": {
|
||||
iosArch: "i386",
|
||||
jniArch: "x86",
|
||||
clangArch: "i686-linux-android",
|
||||
},
|
||||
"amd64": {
|
||||
iosArch: "x86_64",
|
||||
jniArch: "x86_64",
|
||||
clangArch: "x86_64-linux-android",
|
||||
},
|
||||
}
|
||||
|
||||
type iconVariant struct {
|
||||
path string
|
||||
size int
|
||||
fill bool
|
||||
}
|
||||
|
||||
func buildIcons(baseDir, icon string, variants []iconVariant) error {
|
||||
f, err := os.Open(icon)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
img, _, err := image.Decode(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var resizes errgroup.Group
|
||||
for _, v := range variants {
|
||||
v := v
|
||||
resizes.Go(func() (err error) {
|
||||
path := filepath.Join(baseDir, v.path)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if cerr := f.Close(); err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
return png.Encode(f, resizeIcon(v, img))
|
||||
})
|
||||
}
|
||||
return resizes.Wait()
|
||||
}
|
||||
|
||||
func resizeIcon(v iconVariant, img image.Image) *image.NRGBA {
|
||||
scaled := image.NewNRGBA(image.Rectangle{Max: image.Point{X: v.size, Y: v.size}})
|
||||
op := draw.Src
|
||||
if v.fill {
|
||||
op = draw.Over
|
||||
draw.Draw(scaled, scaled.Bounds(), &image.Uniform{color.White}, image.Point{}, draw.Src)
|
||||
}
|
||||
draw.CatmullRom.Scale(scaled, scaled.Bounds(), img, img.Bounds(), op, nil)
|
||||
|
||||
return scaled
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
if os.Getenv("RUN_GOGIO") != "" {
|
||||
// Allow the end-to-end tests to call the gogio tool without
|
||||
// having to build it from scratch, nor having to refactor the
|
||||
// main function to avoid using global variables.
|
||||
main()
|
||||
os.Exit(0) // main already exits, but just in case.
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package main
|
||||
|
||||
var AndroidPermissions = map[string][]string{
|
||||
"network": {
|
||||
"android.permission.INTERNET",
|
||||
},
|
||||
"networkstate": {
|
||||
"android.permission.ACCESS_NETWORK_STATE",
|
||||
},
|
||||
"bluetooth": {
|
||||
"android.permission.BLUETOOTH",
|
||||
"android.permission.BLUETOOTH_ADMIN",
|
||||
"android.permission.ACCESS_FINE_LOCATION",
|
||||
},
|
||||
"camera": {
|
||||
"android.permission.CAMERA",
|
||||
},
|
||||
"storage": {
|
||||
"android.permission.READ_EXTERNAL_STORAGE",
|
||||
"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||
},
|
||||
}
|
||||
|
||||
var AndroidFeatures = map[string][]string{
|
||||
"default": {`glEsVersion="0x00020000"`, `name="android.hardware.type.pc"`},
|
||||
"bluetooth": {
|
||||
`name="android.hardware.bluetooth"`,
|
||||
`name="android.hardware.bluetooth_le"`,
|
||||
},
|
||||
"camera": {
|
||||
`name="android.hardware.camera"`,
|
||||
},
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
//go:build race
|
||||
// +build race
|
||||
|
||||
package main_test
|
||||
|
||||
func init() { raceEnabled = true }
|
||||
Vendored
-142
@@ -1,142 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
// A simple app used for gogio's end-to-end tests.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"log"
|
||||
|
||||
"gioui.org/app"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/op/paint"
|
||||
)
|
||||
|
||||
func main() {
|
||||
go func() {
|
||||
w := app.NewWindow()
|
||||
if err := loop(w); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}()
|
||||
app.Main()
|
||||
}
|
||||
|
||||
type notifyFrame int
|
||||
|
||||
const (
|
||||
notifyNone notifyFrame = iota
|
||||
notifyInvalidate
|
||||
notifyPrint
|
||||
)
|
||||
|
||||
// notify keeps track of whether we want to print to stdout to notify the user
|
||||
// when a frame is ready. Initially we want to notify about the first frame.
|
||||
var notify = notifyInvalidate
|
||||
|
||||
type (
|
||||
C = layout.Context
|
||||
D = layout.Dimensions
|
||||
)
|
||||
|
||||
func loop(w *app.Window) error {
|
||||
topLeft := quarterWidget{
|
||||
color: color.NRGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff},
|
||||
}
|
||||
topRight := quarterWidget{
|
||||
color: color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
|
||||
}
|
||||
botLeft := quarterWidget{
|
||||
color: color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff},
|
||||
}
|
||||
botRight := quarterWidget{
|
||||
color: color.NRGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x80},
|
||||
}
|
||||
|
||||
var ops op.Ops
|
||||
for {
|
||||
e := <-w.Events()
|
||||
switch e := e.(type) {
|
||||
case system.DestroyEvent:
|
||||
return e.Err
|
||||
case system.FrameEvent:
|
||||
gtx := layout.NewContext(&ops, e)
|
||||
// Clear background to white, even on embedded platforms such as webassembly.
|
||||
paint.Fill(gtx.Ops, color.NRGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff})
|
||||
layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||
layout.Flexed(1, func(gtx C) D {
|
||||
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
||||
// r1c1
|
||||
layout.Flexed(1, func(gtx C) D { return topLeft.Layout(gtx) }),
|
||||
// r1c2
|
||||
layout.Flexed(1, func(gtx C) D { return topRight.Layout(gtx) }),
|
||||
)
|
||||
}),
|
||||
layout.Flexed(1, func(gtx C) D {
|
||||
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
||||
// r2c1
|
||||
layout.Flexed(1, func(gtx C) D { return botLeft.Layout(gtx) }),
|
||||
// r2c2
|
||||
layout.Flexed(1, func(gtx C) D { return botRight.Layout(gtx) }),
|
||||
)
|
||||
}),
|
||||
)
|
||||
|
||||
e.Frame(gtx.Ops)
|
||||
|
||||
switch notify {
|
||||
case notifyInvalidate:
|
||||
notify = notifyPrint
|
||||
w.Invalidate()
|
||||
case notifyPrint:
|
||||
notify = notifyNone
|
||||
fmt.Println("gio frame ready")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// quarterWidget paints a quarter of the screen with one color. When clicked, it
|
||||
// turns red, going back to its normal color when clicked again.
|
||||
type quarterWidget struct {
|
||||
color color.NRGBA
|
||||
|
||||
clicked bool
|
||||
}
|
||||
|
||||
var red = color.NRGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}
|
||||
|
||||
func (w *quarterWidget) Layout(gtx layout.Context) layout.Dimensions {
|
||||
var color color.NRGBA
|
||||
if w.clicked {
|
||||
color = red
|
||||
} else {
|
||||
color = w.color
|
||||
}
|
||||
|
||||
r := image.Rectangle{Max: gtx.Constraints.Max}
|
||||
paint.FillShape(gtx.Ops, color, clip.Rect(r).Op())
|
||||
|
||||
defer clip.Rect(image.Rectangle{
|
||||
Max: image.Pt(gtx.Constraints.Max.X, gtx.Constraints.Max.Y),
|
||||
}).Push(gtx.Ops).Pop()
|
||||
pointer.InputOp{
|
||||
Tag: w,
|
||||
Types: pointer.Press,
|
||||
}.Add(gtx.Ops)
|
||||
|
||||
for _, e := range gtx.Events(w) {
|
||||
if e, ok := e.(pointer.Event); ok && e.Type == pointer.Press {
|
||||
w.clicked = !w.clicked
|
||||
// notify when we're done updating the frame.
|
||||
notify = notifyInvalidate
|
||||
}
|
||||
}
|
||||
return layout.Dimensions{Size: gtx.Constraints.Max}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/png"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"text/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WaylandTestDriver struct {
|
||||
driverBase
|
||||
|
||||
runtimeDir string
|
||||
socket string
|
||||
display string
|
||||
}
|
||||
|
||||
// No bars or anything fancy. Just a white background with our dimensions.
|
||||
var tmplSwayConfig = template.Must(template.New("").Parse(`
|
||||
output * bg #FFFFFF solid_color
|
||||
output * mode {{.Width}}x{{.Height}}
|
||||
default_border none
|
||||
`))
|
||||
|
||||
var rxSwayReady = regexp.MustCompile(`Running compositor on wayland display '(.*)'`)
|
||||
|
||||
func (d *WaylandTestDriver) Start(path string) {
|
||||
// We want os.Environ, so that it can e.g. find $DISPLAY to run within
|
||||
// X11. wlroots env vars are documented at:
|
||||
// https://github.com/swaywm/wlroots/blob/master/docs/env_vars.md
|
||||
env := os.Environ()
|
||||
if *headless {
|
||||
env = append(env, "WLR_BACKENDS=headless")
|
||||
}
|
||||
|
||||
d.needPrograms(
|
||||
"sway", // to run a wayland compositor
|
||||
"grim", // to take screenshots
|
||||
"swaymsg", // to send input
|
||||
)
|
||||
|
||||
// First, build the app.
|
||||
dir := d.tempDir("gio-endtoend-wayland")
|
||||
bin := filepath.Join(dir, "red")
|
||||
flags := []string{"build", "-tags", "nox11", "-o=" + bin}
|
||||
if raceEnabled {
|
||||
flags = append(flags, "-race")
|
||||
}
|
||||
flags = append(flags, path)
|
||||
cmd := exec.Command("go", flags...)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
d.Fatalf("could not build app: %s:\n%s", err, out)
|
||||
}
|
||||
|
||||
conf := filepath.Join(dir, "config")
|
||||
f, err := os.Create(conf)
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
if err := tmplSwayConfig.Execute(f, struct{ Width, Height int }{
|
||||
d.width, d.height,
|
||||
}); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
|
||||
d.socket = filepath.Join(dir, "socket")
|
||||
env = append(env, "SWAYSOCK="+d.socket)
|
||||
d.runtimeDir = dir
|
||||
env = append(env, "XDG_RUNTIME_DIR="+d.runtimeDir)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
d.Cleanup(wg.Wait)
|
||||
|
||||
// First, start sway.
|
||||
{
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, "sway", "--config", conf, "--verbose")
|
||||
cmd.Env = env
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
if err := cmd.Start(); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(cancel)
|
||||
d.Cleanup(func() {
|
||||
// Give it a chance to exit gracefully, cleaning up
|
||||
// after itself. After 10ms, the deferred cancel above
|
||||
// will signal an os.Kill.
|
||||
cmd.Process.Signal(os.Interrupt)
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
})
|
||||
|
||||
// Wait for sway to be ready. We probably don't need a deadline
|
||||
// here.
|
||||
br := bufio.NewReader(stderr)
|
||||
for {
|
||||
line, err := br.ReadString('\n')
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
if m := rxSwayReady.FindStringSubmatch(line); m != nil {
|
||||
d.display = m[1]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil && ctx.Err() == nil && !strings.Contains(err.Error(), "interrupt") {
|
||||
// Don't print all stderr, since we use --verbose.
|
||||
// TODO(mvdan): if it's useful, probably filter
|
||||
// errors and show them.
|
||||
d.Error(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
// Then, start our program on the sway compositor above.
|
||||
{
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, bin)
|
||||
cmd.Env = []string{"XDG_RUNTIME_DIR=" + d.runtimeDir, "WAYLAND_DISPLAY=" + d.display}
|
||||
output, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
cmd.Stderr = cmd.Stdout
|
||||
d.output = output
|
||||
if err := cmd.Start(); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(cancel)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil && ctx.Err() == nil {
|
||||
d.Error(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
// Wait for the gio app to render.
|
||||
d.waitForFrame()
|
||||
}
|
||||
|
||||
func (d *WaylandTestDriver) Screenshot() image.Image {
|
||||
cmd := exec.Command("grim", "/dev/stdout")
|
||||
cmd.Env = []string{"XDG_RUNTIME_DIR=" + d.runtimeDir, "WAYLAND_DISPLAY=" + d.display}
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
d.Errorf("%s", out)
|
||||
d.Fatal(err)
|
||||
}
|
||||
img, err := png.Decode(bytes.NewReader(out))
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
func (d *WaylandTestDriver) swaymsg(args ...interface{}) {
|
||||
strs := []string{"--socket", d.socket}
|
||||
for _, arg := range args {
|
||||
strs = append(strs, fmt.Sprint(arg))
|
||||
}
|
||||
cmd := exec.Command("swaymsg", strs...)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
d.Errorf("%s", out)
|
||||
d.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *WaylandTestDriver) Click(x, y int) {
|
||||
d.swaymsg("seat", "-", "cursor", "set", x, y)
|
||||
d.swaymsg("seat", "-", "cursor", "press", "button1")
|
||||
d.swaymsg("seat", "-", "cursor", "release", "button1")
|
||||
|
||||
// Wait for the gio app to render after this click.
|
||||
d.waitForFrame()
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"image"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/image/draw"
|
||||
)
|
||||
|
||||
// Wine is tightly coupled with X11 at the moment, and we can reuse the same
|
||||
// methods to automate screenshots and clicks. The main difference is how we
|
||||
// build and run the app.
|
||||
|
||||
// The only quirk is that it seems impossible for the Wine window to take the
|
||||
// entirety of the X server's dimensions, even if we try to resize it to take
|
||||
// the entire display. It seems to want to leave some vertical space empty,
|
||||
// presumably for window decorations or the "start" bar on Windows. To work
|
||||
// around that, make the X server 50x50px bigger, and crop the screenshots back
|
||||
// to the original size.
|
||||
|
||||
type WineTestDriver struct {
|
||||
X11TestDriver
|
||||
}
|
||||
|
||||
func (d *WineTestDriver) Start(path string) {
|
||||
d.needPrograms("wine")
|
||||
|
||||
// First, build the app.
|
||||
bin := filepath.Join(d.tempDir("gio-endtoend-windows"), "red.exe")
|
||||
flags := []string{"build", "-o=" + bin}
|
||||
if raceEnabled {
|
||||
if runtime.GOOS != "windows" {
|
||||
// cross-compilation disables CGo, which breaks -race.
|
||||
d.Skipf("can't cross-compile -race for Windows; skipping")
|
||||
}
|
||||
flags = append(flags, "-race")
|
||||
}
|
||||
flags = append(flags, path)
|
||||
cmd := exec.Command("go", flags...)
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, "GOOS=windows")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
d.Fatalf("could not build app: %s:\n%s", err, out)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
d.Cleanup(wg.Wait)
|
||||
|
||||
// Add 50x50px to the display dimensions, as discussed earlier.
|
||||
d.startServer(&wg, d.width+50, d.height+50)
|
||||
|
||||
// Then, start our program via Wine on the X server above.
|
||||
{
|
||||
cacheDir, err := os.UserCacheDir()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
// Use a wine directory separate from the default ~/.wine, so
|
||||
// that the user's winecfg doesn't affect our test. This will
|
||||
// default to ~/.cache/gio-e2e-wine. We use the user's cache,
|
||||
// to reuse a previously set up wineprefix.
|
||||
wineprefix := filepath.Join(cacheDir, "gio-e2e-wine")
|
||||
|
||||
// First, ensure that wineprefix is up to date with wineboot.
|
||||
// Wait for this separately from the first frame, as setting up
|
||||
// a new prefix might take 5s on its own.
|
||||
env := []string{
|
||||
"DISPLAY=" + d.display,
|
||||
"WINEDEBUG=fixme-all", // hide "fixme" noise
|
||||
"WINEPREFIX=" + wineprefix,
|
||||
|
||||
// Disable wine-gecko (Explorer) and wine-mono (.NET).
|
||||
// Otherwise, if not installed, wineboot will get stuck
|
||||
// with a prompt to install them on the virtual X
|
||||
// display. Moreover, Gio doesn't need either, and wine
|
||||
// is faster without them.
|
||||
"WINEDLLOVERRIDES=mscoree,mshtml=",
|
||||
}
|
||||
{
|
||||
start := time.Now()
|
||||
cmd := exec.Command("wine", "wineboot", "-i")
|
||||
cmd.Env = env
|
||||
// Use a combined output pipe instead of CombinedOutput,
|
||||
// so that we only wait for the child process to exit,
|
||||
// and we don't need to wait for all of wine's
|
||||
// grandchildren to exit and stop writing. This is
|
||||
// relevant as wine leaves "wineserver" lingering for
|
||||
// three seconds by default, to be reused later.
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
cmd.Stderr = cmd.Stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
io.Copy(os.Stderr, stdout)
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Logf("set up WINEPREFIX in %s", time.Since(start))
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, "wine", bin)
|
||||
cmd.Env = env
|
||||
output, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
cmd.Stderr = cmd.Stdout
|
||||
d.output = output
|
||||
if err := cmd.Start(); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(cancel)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil && ctx.Err() == nil {
|
||||
d.Error(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
// Wait for the gio app to render.
|
||||
d.waitForFrame()
|
||||
|
||||
// xdotool seems to fail at actually moving the window if we use it
|
||||
// immediately after Gio is ready. Why?
|
||||
// We can't tell if the windowmove operation worked until we take a
|
||||
// screenshot, because the getwindowgeometry op reports the 0x0
|
||||
// coordinates even if the window wasn't moved properly.
|
||||
// A sleep of ~20ms seems to be enough on an idle laptop. Use 20x that.
|
||||
// TODO(mvdan): revisit this, when you have a spare three hours.
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
id := d.xdotool("search", "--sync", "--onlyvisible", "--name", "Gio")
|
||||
d.xdotool("windowmove", "--sync", id, 0, 0)
|
||||
}
|
||||
|
||||
func (d *WineTestDriver) Screenshot() image.Image {
|
||||
img := d.X11TestDriver.Screenshot()
|
||||
// Crop the screenshot back to the original dimensions.
|
||||
cropped := image.NewRGBA(image.Rect(0, 0, d.width, d.height))
|
||||
draw.Draw(cropped, cropped.Bounds(), img, image.Point{}, draw.Src)
|
||||
return cropped
|
||||
}
|
||||
@@ -1,416 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/png"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/akavel/rsrc/binutil"
|
||||
"github.com/akavel/rsrc/coff"
|
||||
"golang.org/x/text/encoding/unicode"
|
||||
)
|
||||
|
||||
func buildWindows(tmpDir string, bi *buildInfo) error {
|
||||
builder := &windowsBuilder{TempDir: tmpDir}
|
||||
builder.DestDir = *destPath
|
||||
if builder.DestDir == "" {
|
||||
builder.DestDir = bi.pkgPath
|
||||
}
|
||||
|
||||
name := bi.name
|
||||
if *destPath != "" {
|
||||
if filepath.Ext(*destPath) != ".exe" {
|
||||
return fmt.Errorf("invalid output name %q, it must end with `.exe`", *destPath)
|
||||
}
|
||||
name = filepath.Base(*destPath)
|
||||
}
|
||||
name = strings.TrimSuffix(name, ".exe")
|
||||
sdk := bi.minsdk
|
||||
if sdk > 10 {
|
||||
return fmt.Errorf("invalid minsdk (%d) it's higher than Windows 10", sdk)
|
||||
}
|
||||
version := strconv.Itoa(bi.version)
|
||||
if bi.version > math.MaxUint16 {
|
||||
return fmt.Errorf("version (%d) is larger than the maximum (%d)", bi.version, math.MaxUint16)
|
||||
}
|
||||
|
||||
for _, arch := range bi.archs {
|
||||
builder.Coff = coff.NewRSRC()
|
||||
builder.Coff.Arch(arch)
|
||||
|
||||
if err := builder.embedIcon(bi.iconPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := builder.embedManifest(windowsManifest{
|
||||
Version: "1.0.0." + version,
|
||||
WindowsVersion: sdk,
|
||||
Name: name,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("can't create manifest: %v", err)
|
||||
}
|
||||
|
||||
if err := builder.embedInfo(windowsResources{
|
||||
Version: [2]uint32{uint32(1) << 16, uint32(bi.version)},
|
||||
VersionHuman: "1.0.0." + version,
|
||||
Name: name,
|
||||
Language: 0x0400, // Process Default Language: https://docs.microsoft.com/en-us/previous-versions/ms957130(v=msdn.10)
|
||||
}); err != nil {
|
||||
return fmt.Errorf("can't create info: %v", err)
|
||||
}
|
||||
|
||||
if err := builder.buildResource(bi, name, arch); err != nil {
|
||||
return fmt.Errorf("can't build the resources: %v", err)
|
||||
}
|
||||
|
||||
if err := builder.buildProgram(bi, name, arch); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type (
|
||||
windowsResources struct {
|
||||
Version [2]uint32
|
||||
VersionHuman string
|
||||
Language uint16
|
||||
Name string
|
||||
}
|
||||
windowsManifest struct {
|
||||
Version string
|
||||
WindowsVersion int
|
||||
Name string
|
||||
}
|
||||
windowsBuilder struct {
|
||||
TempDir string
|
||||
DestDir string
|
||||
Coff *coff.Coff
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
// https://docs.microsoft.com/en-us/windows/win32/menurc/resource-types
|
||||
windowsResourceIcon = 3
|
||||
windowsResourceIconGroup = windowsResourceIcon + 11
|
||||
windowsResourceManifest = 24
|
||||
windowsResourceVersion = 16
|
||||
)
|
||||
|
||||
type bufferCoff struct {
|
||||
bytes.Buffer
|
||||
}
|
||||
|
||||
func (b *bufferCoff) Size() int64 {
|
||||
return int64(b.Len())
|
||||
}
|
||||
|
||||
func (b *windowsBuilder) embedIcon(path string) (err error) {
|
||||
iconFile, err := os.Open(path)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("can't read the icon located at %s: %v", path, err)
|
||||
}
|
||||
defer iconFile.Close()
|
||||
|
||||
iconImage, err := png.Decode(iconFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't decode the PNG file (%s): %v", path, err)
|
||||
}
|
||||
|
||||
sizes := []int{16, 32, 48, 64, 128, 256}
|
||||
var iconHeader bufferCoff
|
||||
|
||||
// GRPICONDIR structure.
|
||||
if err := binary.Write(&iconHeader, binary.LittleEndian, [3]uint16{0, 1, uint16(len(sizes))}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, size := range sizes {
|
||||
var iconBuffer bufferCoff
|
||||
|
||||
if err := png.Encode(&iconBuffer, resizeIcon(iconVariant{size: size, fill: false}, iconImage)); err != nil {
|
||||
return fmt.Errorf("can't encode image: %v", err)
|
||||
}
|
||||
|
||||
b.Coff.AddResource(windowsResourceIcon, uint16(size), &iconBuffer)
|
||||
|
||||
if err := binary.Write(&iconHeader, binary.LittleEndian, struct {
|
||||
Size [2]uint8
|
||||
Color [2]uint8
|
||||
Planes uint16
|
||||
BitCount uint16
|
||||
Length uint32
|
||||
Id uint16
|
||||
}{
|
||||
Size: [2]uint8{uint8(size % 256), uint8(size % 256)}, // "0" means 256px.
|
||||
Planes: 1,
|
||||
BitCount: 32,
|
||||
Length: uint32(iconBuffer.Len()),
|
||||
Id: uint16(size),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
b.Coff.AddResource(windowsResourceIconGroup, 1, &iconHeader)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *windowsBuilder) buildResource(buildInfo *buildInfo, name string, arch string) error {
|
||||
out, err := os.Create(filepath.Join(buildInfo.pkgPath, name+"_windows_"+arch+".syso"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
b.Coff.Freeze()
|
||||
|
||||
// See https://github.com/akavel/rsrc/internal/write.go#L13.
|
||||
w := binutil.Writer{W: out}
|
||||
binutil.Walk(b.Coff, func(v reflect.Value, path string) error {
|
||||
if binutil.Plain(v.Kind()) {
|
||||
w.WriteLE(v.Interface())
|
||||
return nil
|
||||
}
|
||||
vv, ok := v.Interface().(binutil.SizedReader)
|
||||
if ok {
|
||||
w.WriteFromSized(vv)
|
||||
return binutil.WALK_SKIP
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if w.Err != nil {
|
||||
return fmt.Errorf("error writing output file: %s", w.Err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *windowsBuilder) buildProgram(buildInfo *buildInfo, name string, arch string) error {
|
||||
dest := b.DestDir
|
||||
if len(buildInfo.archs) > 1 {
|
||||
dest = filepath.Join(filepath.Dir(b.DestDir), name+"_"+arch+".exe")
|
||||
}
|
||||
|
||||
cmd := exec.Command(
|
||||
"go",
|
||||
"build",
|
||||
"-ldflags=-H=windowsgui "+buildInfo.ldflags,
|
||||
"-tags="+buildInfo.tags,
|
||||
"-o", dest,
|
||||
buildInfo.pkgPath,
|
||||
)
|
||||
cmd.Env = append(
|
||||
os.Environ(),
|
||||
"GOOS=windows",
|
||||
"GOARCH="+arch,
|
||||
)
|
||||
_, err := runCmd(cmd)
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *windowsBuilder) embedManifest(v windowsManifest) error {
|
||||
t, err := template.New("manifest").Parse(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<assemblyIdentity type="win32" name="{{.Name}}" version="{{.Version}}" />
|
||||
<description>{{.Name}}</description>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
{{if (le .WindowsVersion 10)}}<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
{{end}}
|
||||
{{if (le .WindowsVersion 9)}}<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
{{end}}
|
||||
{{if (le .WindowsVersion 8)}}<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
{{end}}
|
||||
{{if (le .WindowsVersion 7)}}<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
{{end}}
|
||||
{{if (le .WindowsVersion 6)}}<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
{{end}}
|
||||
</application>
|
||||
</compatibility>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var manifest bufferCoff
|
||||
if err := t.Execute(&manifest, v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.Coff.AddResource(windowsResourceManifest, 1, &manifest)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *windowsBuilder) embedInfo(v windowsResources) error {
|
||||
page := uint16(1)
|
||||
|
||||
// https://docs.microsoft.com/pt-br/windows/win32/menurc/vs-versioninfo
|
||||
t := newValue(valueBinary, "VS_VERSION_INFO", []io.WriterTo{
|
||||
// https://docs.microsoft.com/pt-br/windows/win32/api/VerRsrc/ns-verrsrc-vs_fixedfileinfo
|
||||
windowsInfoValueFixed{
|
||||
Signature: 0xFEEF04BD,
|
||||
StructVersion: 0x00010000,
|
||||
FileVersion: v.Version,
|
||||
ProductVersion: v.Version,
|
||||
FileFlagMask: 0x3F,
|
||||
FileFlags: 0,
|
||||
FileOS: 0x40004,
|
||||
FileType: 0x1,
|
||||
FileSubType: 0,
|
||||
},
|
||||
// https://docs.microsoft.com/pt-br/windows/win32/menurc/stringfileinfo
|
||||
newValue(valueText, "StringFileInfo", []io.WriterTo{
|
||||
// https://docs.microsoft.com/pt-br/windows/win32/menurc/stringtable
|
||||
newValue(valueText, fmt.Sprintf("%04X%04X", v.Language, page), []io.WriterTo{
|
||||
// https://docs.microsoft.com/pt-br/windows/win32/menurc/string-str
|
||||
newValue(valueText, "ProductVersion", v.VersionHuman),
|
||||
newValue(valueText, "FileVersion", v.VersionHuman),
|
||||
newValue(valueText, "FileDescription", v.Name),
|
||||
newValue(valueText, "ProductName", v.Name),
|
||||
// TODO include more data: gogio must have some way to provide such information (like Company Name, Copyright...)
|
||||
}),
|
||||
}),
|
||||
// https://docs.microsoft.com/pt-br/windows/win32/menurc/varfileinfo
|
||||
newValue(valueBinary, "VarFileInfo", []io.WriterTo{
|
||||
// https://docs.microsoft.com/pt-br/windows/win32/menurc/var-str
|
||||
newValue(valueBinary, "Translation", uint32(page)<<16|uint32(v.Language)),
|
||||
}),
|
||||
})
|
||||
|
||||
// For some reason the ValueLength of the VS_VERSIONINFO must be the byte-length of `windowsInfoValueFixed`:
|
||||
t.ValueLength = 52
|
||||
|
||||
var verrsrc bufferCoff
|
||||
if _, err := t.WriteTo(&verrsrc); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b.Coff.AddResource(windowsResourceVersion, 1, &verrsrc)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type windowsInfoValueFixed struct {
|
||||
Signature uint32
|
||||
StructVersion uint32
|
||||
FileVersion [2]uint32
|
||||
ProductVersion [2]uint32
|
||||
FileFlagMask uint32
|
||||
FileFlags uint32
|
||||
FileOS uint32
|
||||
FileType uint32
|
||||
FileSubType uint32
|
||||
FileDate [2]uint32
|
||||
}
|
||||
|
||||
func (v windowsInfoValueFixed) WriteTo(w io.Writer) (_ int64, err error) {
|
||||
return 0, binary.Write(w, binary.LittleEndian, v)
|
||||
}
|
||||
|
||||
type windowsInfoValue struct {
|
||||
Length uint16
|
||||
ValueLength uint16
|
||||
Type uint16
|
||||
Key []byte
|
||||
Value []byte
|
||||
}
|
||||
|
||||
func (v windowsInfoValue) WriteTo(w io.Writer) (_ int64, err error) {
|
||||
// binary.Write doesn't support []byte inside struct.
|
||||
if err = binary.Write(w, binary.LittleEndian, [3]uint16{v.Length, v.ValueLength, v.Type}); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if _, err = w.Write(v.Key); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if _, err = w.Write(v.Value); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
const (
|
||||
valueBinary uint16 = 0
|
||||
valueText uint16 = 1
|
||||
)
|
||||
|
||||
func newValue(valueType uint16, key string, input interface{}) windowsInfoValue {
|
||||
v := windowsInfoValue{
|
||||
Type: valueType,
|
||||
Length: 6,
|
||||
}
|
||||
|
||||
padding := func(in []byte) []byte {
|
||||
if l := uint16(len(in)) + v.Length; l%4 != 0 {
|
||||
return append(in, make([]byte, 4-l%4)...)
|
||||
}
|
||||
return in
|
||||
}
|
||||
|
||||
v.Key = padding(utf16Encode(key))
|
||||
v.Length += uint16(len(v.Key))
|
||||
|
||||
switch in := input.(type) {
|
||||
case string:
|
||||
v.Value = padding(utf16Encode(in))
|
||||
v.ValueLength = uint16(len(v.Value) / 2)
|
||||
case []io.WriterTo:
|
||||
var buff bytes.Buffer
|
||||
for k := range in {
|
||||
if _, err := in[k].WriteTo(&buff); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
v.Value = buff.Bytes()
|
||||
default:
|
||||
var buff bytes.Buffer
|
||||
if err := binary.Write(&buff, binary.LittleEndian, in); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
v.ValueLength = uint16(buff.Len())
|
||||
v.Value = buff.Bytes()
|
||||
}
|
||||
|
||||
v.Length += uint16(len(v.Value))
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// utf16Encode encodes the string to UTF16 with null-termination.
|
||||
func utf16Encode(s string) []byte {
|
||||
b, err := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM).NewEncoder().Bytes([]byte(s))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return append(b, 0x00, 0x00) // null-termination.
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/png"
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type X11TestDriver struct {
|
||||
driverBase
|
||||
|
||||
display string
|
||||
}
|
||||
|
||||
func (d *X11TestDriver) Start(path string) {
|
||||
// First, build the app.
|
||||
bin := filepath.Join(d.tempDir("gio-endtoend-x11"), "red")
|
||||
flags := []string{"build", "-tags", "nowayland", "-o=" + bin}
|
||||
if raceEnabled {
|
||||
flags = append(flags, "-race")
|
||||
}
|
||||
flags = append(flags, path)
|
||||
cmd := exec.Command("go", flags...)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
d.Fatalf("could not build app: %s:\n%s", err, out)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
d.Cleanup(wg.Wait)
|
||||
|
||||
d.startServer(&wg, d.width, d.height)
|
||||
|
||||
// Then, start our program on the X server above.
|
||||
{
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, bin)
|
||||
cmd.Env = []string{"DISPLAY=" + d.display}
|
||||
output, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
cmd.Stderr = cmd.Stdout
|
||||
d.output = output
|
||||
if err := cmd.Start(); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(cancel)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil && ctx.Err() == nil {
|
||||
d.Error(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
// Wait for the gio app to render.
|
||||
d.waitForFrame()
|
||||
}
|
||||
|
||||
func (d *X11TestDriver) startServer(wg *sync.WaitGroup, width, height int) {
|
||||
// Pick a random display number between 1 and 100,000. Most machines
|
||||
// will only be using :0, so there's only a 0.001% chance of two
|
||||
// concurrent test runs to run into a conflict.
|
||||
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
d.display = fmt.Sprintf(":%d", rnd.Intn(100000)+1)
|
||||
|
||||
var xprog string
|
||||
xflags := []string{
|
||||
"-wr", // we want a white background; the default is black
|
||||
}
|
||||
if *headless {
|
||||
xprog = "Xvfb" // virtual X server
|
||||
xflags = append(xflags, "-screen", "0", fmt.Sprintf("%dx%dx24", width, height))
|
||||
} else {
|
||||
xprog = "Xephyr" // nested X server as a window
|
||||
xflags = append(xflags, "-screen", fmt.Sprintf("%dx%d", width, height))
|
||||
}
|
||||
xflags = append(xflags, d.display)
|
||||
|
||||
d.needPrograms(
|
||||
xprog, // to run the X server
|
||||
"scrot", // to take screenshots
|
||||
"xdotool", // to send input
|
||||
)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, xprog, xflags...)
|
||||
combined := &bytes.Buffer{}
|
||||
cmd.Stdout = combined
|
||||
cmd.Stderr = combined
|
||||
if err := cmd.Start(); err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
d.Cleanup(cancel)
|
||||
d.Cleanup(func() {
|
||||
// Give it a chance to exit gracefully, cleaning up
|
||||
// after itself. After 10ms, the deferred cancel above
|
||||
// will signal an os.Kill.
|
||||
cmd.Process.Signal(os.Interrupt)
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
})
|
||||
|
||||
// Wait for the X server to be ready. The socket path isn't
|
||||
// terribly portable, but that's okay for now.
|
||||
withRetries(d.T, time.Second, func() error {
|
||||
socket := fmt.Sprintf("/tmp/.X11-unix/X%s", d.display[1:])
|
||||
_, err := os.Stat(socket)
|
||||
return err
|
||||
})
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil && ctx.Err() == nil {
|
||||
// Print all output and error.
|
||||
io.Copy(os.Stdout, combined)
|
||||
d.Error(err)
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
func (d *X11TestDriver) Screenshot() image.Image {
|
||||
cmd := exec.Command("scrot", "--silent", "--overwrite", "/dev/stdout")
|
||||
cmd.Env = []string{"DISPLAY=" + d.display}
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
d.Errorf("%s", out)
|
||||
d.Fatal(err)
|
||||
}
|
||||
img, err := png.Decode(bytes.NewReader(out))
|
||||
if err != nil {
|
||||
d.Fatal(err)
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
func (d *X11TestDriver) xdotool(args ...interface{}) string {
|
||||
d.Helper()
|
||||
strs := make([]string, len(args))
|
||||
for i, arg := range args {
|
||||
strs[i] = fmt.Sprint(arg)
|
||||
}
|
||||
cmd := exec.Command("xdotool", strs...)
|
||||
cmd.Env = []string{"DISPLAY=" + d.display}
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
d.Errorf("%s", out)
|
||||
d.Fatal(err)
|
||||
}
|
||||
return string(bytes.TrimSpace(out))
|
||||
}
|
||||
|
||||
func (d *X11TestDriver) Click(x, y int) {
|
||||
d.xdotool("mousemove", "--sync", x, y)
|
||||
d.xdotool("click", "1")
|
||||
|
||||
// Wait for the gio app to render after this click.
|
||||
d.waitForFrame()
|
||||
}
|
||||
+32
-3
@@ -3,11 +3,11 @@
|
||||
package f32
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Affine2D represents an affine 2D transformation. The zero value if Affine2D
|
||||
// Affine2D represents an affine 2D transformation. The zero value of Affine2D
|
||||
// represents the identity transform.
|
||||
type Affine2D struct {
|
||||
// in order to make the zero value of Affine2D represent the identity
|
||||
@@ -112,6 +112,15 @@ func (a Affine2D) Elems() (sx, hx, ox, hy, sy, oy float32) {
|
||||
return a.a + 1, a.b, a.c, a.d, a.e + 1, a.f
|
||||
}
|
||||
|
||||
// Split a transform into two parts, one which is pure offset and the
|
||||
// other representing the scaling, shearing and rotation part.
|
||||
func (a *Affine2D) Split() (srs Affine2D, offset Point) {
|
||||
return Affine2D{
|
||||
a: a.a, b: a.b, c: 0,
|
||||
d: a.d, e: a.e, f: 0,
|
||||
}, Point{X: a.c, Y: a.f}
|
||||
}
|
||||
|
||||
func (a Affine2D) scale(factor Point) Affine2D {
|
||||
return Affine2D{
|
||||
(a.a+1)*factor.X - 1, a.b * factor.X, a.c * factor.X,
|
||||
@@ -139,5 +148,25 @@ func (a Affine2D) shear(radiansX, radiansY float32) Affine2D {
|
||||
|
||||
func (a Affine2D) String() string {
|
||||
sx, hx, ox, hy, sy, oy := a.Elems()
|
||||
return fmt.Sprintf("[[%f %f %f] [%f %f %f]]", sx, hx, ox, hy, sy, oy)
|
||||
|
||||
// precision 6, one period, negative sign and space per number
|
||||
const prec = 6
|
||||
const charsPerFloat = prec + 2 + 1
|
||||
s := make([]byte, 0, 6*charsPerFloat+6)
|
||||
|
||||
s = append(s, '[', '[')
|
||||
s = strconv.AppendFloat(s, float64(sx), 'g', prec, 32)
|
||||
s = append(s, ' ')
|
||||
s = strconv.AppendFloat(s, float64(hx), 'g', prec, 32)
|
||||
s = append(s, ' ')
|
||||
s = strconv.AppendFloat(s, float64(ox), 'g', prec, 32)
|
||||
s = append(s, ']', ' ', '[')
|
||||
s = strconv.AppendFloat(s, float64(hy), 'g', prec, 32)
|
||||
s = append(s, ' ')
|
||||
s = strconv.AppendFloat(s, float64(sy), 'g', prec, 32)
|
||||
s = append(s, ' ')
|
||||
s = strconv.AppendFloat(s, float64(oy), 'g', prec, 32)
|
||||
s = append(s, ']', ']')
|
||||
|
||||
return string(s)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,29 @@ func TestTransformOffset(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
tests := []struct {
|
||||
in Affine2D
|
||||
exp string
|
||||
}{
|
||||
{
|
||||
in: NewAffine2D(9, 11, 13, 17, 19, 23),
|
||||
exp: "[[9 11 13] [17 19 23]]",
|
||||
}, {
|
||||
in: NewAffine2D(29, 31, 37, 43, 47, 53),
|
||||
exp: "[[29 31 37] [43 47 53]]",
|
||||
}, {
|
||||
in: NewAffine2D(29.142342, 31.4123412, 37.53152, 43.51324213, 47.123412, 53.14312342),
|
||||
exp: "[[29.1423 31.4123 37.5315] [43.5132 47.1234 53.1431]]",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if test.in.String() != test.exp {
|
||||
t.Errorf("string mismatch: have %q, want %q", test.in.String(), test.exp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTransformScale(t *testing.T) {
|
||||
p := Point{X: 1, Y: 2}
|
||||
s := Point{X: -1, Y: 2}
|
||||
|
||||
+6
-142
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
Package f32 is a float32 implementation of package image's
|
||||
Point and Rectangle.
|
||||
Point and affine transformations.
|
||||
|
||||
The coordinate space has the origin in the top left
|
||||
corner with the axes extending right and down.
|
||||
@@ -26,30 +26,6 @@ func (p Point) String() string {
|
||||
"," + strconv.FormatFloat(float64(p.Y), 'f', -1, 32) + ")"
|
||||
}
|
||||
|
||||
// A Rectangle contains the points (X, Y) where Min.X <= X < Max.X,
|
||||
// Min.Y <= Y < Max.Y.
|
||||
type Rectangle struct {
|
||||
Min, Max Point
|
||||
}
|
||||
|
||||
// String return a string representation of r.
|
||||
func (r Rectangle) String() string {
|
||||
return r.Min.String() + "-" + r.Max.String()
|
||||
}
|
||||
|
||||
// Rect is a shorthand for Rectangle{Point{x0, y0}, Point{x1, y1}}.
|
||||
// The returned Rectangle has x0 and y0 swapped if necessary so that
|
||||
// it's correctly formed.
|
||||
func Rect(x0, y0, x1, y1 float32) Rectangle {
|
||||
if x0 > x1 {
|
||||
x0, x1 = x1, x0
|
||||
}
|
||||
if y0 > y1 {
|
||||
y0, y1 = y1, y0
|
||||
}
|
||||
return Rectangle{Point{x0, y0}, Point{x1, y1}}
|
||||
}
|
||||
|
||||
// Pt is shorthand for Point{X: x, Y: y}.
|
||||
func Pt(x, y float32) Point {
|
||||
return Point{X: x, Y: y}
|
||||
@@ -75,122 +51,10 @@ func (p Point) Div(s float32) Point {
|
||||
return Point{X: p.X / s, Y: p.Y / s}
|
||||
}
|
||||
|
||||
// In reports whether p is in r.
|
||||
func (p Point) In(r Rectangle) bool {
|
||||
return r.Min.X <= p.X && p.X < r.Max.X &&
|
||||
r.Min.Y <= p.Y && p.Y < r.Max.Y
|
||||
}
|
||||
|
||||
// Size returns r's width and height.
|
||||
func (r Rectangle) Size() Point {
|
||||
return Point{X: r.Dx(), Y: r.Dy()}
|
||||
}
|
||||
|
||||
// Dx returns r's width.
|
||||
func (r Rectangle) Dx() float32 {
|
||||
return r.Max.X - r.Min.X
|
||||
}
|
||||
|
||||
// Dy returns r's Height.
|
||||
func (r Rectangle) Dy() float32 {
|
||||
return r.Max.Y - r.Min.Y
|
||||
}
|
||||
|
||||
// Intersect returns the intersection of r and s.
|
||||
func (r Rectangle) Intersect(s Rectangle) Rectangle {
|
||||
if r.Min.X < s.Min.X {
|
||||
r.Min.X = s.Min.X
|
||||
}
|
||||
if r.Min.Y < s.Min.Y {
|
||||
r.Min.Y = s.Min.Y
|
||||
}
|
||||
if r.Max.X > s.Max.X {
|
||||
r.Max.X = s.Max.X
|
||||
}
|
||||
if r.Max.Y > s.Max.Y {
|
||||
r.Max.Y = s.Max.Y
|
||||
}
|
||||
if r.Empty() {
|
||||
return Rectangle{}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Union returns the union of r and s.
|
||||
func (r Rectangle) Union(s Rectangle) Rectangle {
|
||||
if r.Empty() {
|
||||
return s
|
||||
}
|
||||
if s.Empty() {
|
||||
return r
|
||||
}
|
||||
if r.Min.X > s.Min.X {
|
||||
r.Min.X = s.Min.X
|
||||
}
|
||||
if r.Min.Y > s.Min.Y {
|
||||
r.Min.Y = s.Min.Y
|
||||
}
|
||||
if r.Max.X < s.Max.X {
|
||||
r.Max.X = s.Max.X
|
||||
}
|
||||
if r.Max.Y < s.Max.Y {
|
||||
r.Max.Y = s.Max.Y
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Canon returns the canonical version of r, where Min is to
|
||||
// the upper left of Max.
|
||||
func (r Rectangle) Canon() Rectangle {
|
||||
if r.Max.X < r.Min.X {
|
||||
r.Min.X, r.Max.X = r.Max.X, r.Min.X
|
||||
}
|
||||
if r.Max.Y < r.Min.Y {
|
||||
r.Min.Y, r.Max.Y = r.Max.Y, r.Min.Y
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Empty reports whether r represents the empty area.
|
||||
func (r Rectangle) Empty() bool {
|
||||
return r.Min.X >= r.Max.X || r.Min.Y >= r.Max.Y
|
||||
}
|
||||
|
||||
// Add offsets r with the vector p.
|
||||
func (r Rectangle) Add(p Point) Rectangle {
|
||||
return Rectangle{
|
||||
Point{r.Min.X + p.X, r.Min.Y + p.Y},
|
||||
Point{r.Max.X + p.X, r.Max.Y + p.Y},
|
||||
// Round returns the integer point closest to p.
|
||||
func (p Point) Round() image.Point {
|
||||
return image.Point{
|
||||
X: int(math.Round(float64(p.X))),
|
||||
Y: int(math.Round(float64(p.Y))),
|
||||
}
|
||||
}
|
||||
|
||||
// Sub offsets r with the vector -p.
|
||||
func (r Rectangle) Sub(p Point) Rectangle {
|
||||
return Rectangle{
|
||||
Point{r.Min.X - p.X, r.Min.Y - p.Y},
|
||||
Point{r.Max.X - p.X, r.Max.Y - p.Y},
|
||||
}
|
||||
}
|
||||
|
||||
// Round returns the smallest integer rectangle that
|
||||
// contains r.
|
||||
func (r Rectangle) Round() image.Rectangle {
|
||||
return image.Rectangle{
|
||||
Min: image.Point{
|
||||
X: int(floor(r.Min.X)),
|
||||
Y: int(floor(r.Min.Y)),
|
||||
},
|
||||
Max: image.Point{
|
||||
X: int(ceil(r.Max.X)),
|
||||
Y: int(ceil(r.Max.Y)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ceil(v float32) int {
|
||||
return int(math.Ceil(float64(v)))
|
||||
}
|
||||
|
||||
func floor(v float32) int {
|
||||
return int(math.Floor(float64(v)))
|
||||
}
|
||||
|
||||
Generated
+22
-47
@@ -3,17 +3,17 @@
|
||||
"android": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1648412532,
|
||||
"narHash": "sha256-zh0rLcppJ5i2Bh8oBWjBhDvgOrMhDGdXINbp3bhrs0U=",
|
||||
"lastModified": 1659298920,
|
||||
"narHash": "sha256-LgRMge8BZUG15EN43iDJOlnEMX1dvRprB7SaoNqgibU=",
|
||||
"owner": "tadfisher",
|
||||
"repo": "android-nixpkgs",
|
||||
"rev": "b1318b23926260685dbb09dd127f38c917fc7441",
|
||||
"rev": "d4f20a3cd4ce961bb23b48447457f6810d69ae5e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -24,15 +24,21 @@
|
||||
},
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"flake-utils": [
|
||||
"android",
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"android",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1647857022,
|
||||
"narHash": "sha256-Aw70NWLOIwKhT60MHDGjgWis3DP3faCzr6ap9CSayek=",
|
||||
"lastModified": 1658746384,
|
||||
"narHash": "sha256-CCJcoMOcXyZFrV1ag4XMTpAPjLWb4Anbv+ktXFI1ry0=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "0a5ff74dacb9ea22614f64e61aeb3ca0bf0e7311",
|
||||
"rev": "0ffc7937bb5e8141af03d462b468bd071eb18e1b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -43,26 +49,11 @@
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1642700792,
|
||||
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
|
||||
"lastModified": 1656928814,
|
||||
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1648297722,
|
||||
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -73,27 +64,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1643381941,
|
||||
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
|
||||
"lastModified": 1659305579,
|
||||
"narHash": "sha256-SFeQTmh7hc9Y2fSkooHaoS8mDfPa04sfmUCtQ8MA6Pg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1648469949,
|
||||
"narHash": "sha256-ExCG9k36QNs0bNsi2NwnfL4w/kjb661rW43pf03ok/Y=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a63a39e23873d5d72753ff12bb418cb7e470790c",
|
||||
"rev": "5857574d45925585baffde730369414319228a84",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -105,7 +80,7 @@
|
||||
"root": {
|
||||
"inputs": {
|
||||
"android": "android",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -47,6 +47,12 @@
|
||||
xorg.libXfixes
|
||||
libGL
|
||||
pkgconfig
|
||||
] else if stdenv.isDarwin then [
|
||||
darwin.apple_sdk_11_0.frameworks.Foundation
|
||||
darwin.apple_sdk_11_0.frameworks.Metal
|
||||
darwin.apple_sdk_11_0.frameworks.QuartzCore
|
||||
darwin.apple_sdk_11_0.frameworks.AppKit
|
||||
darwin.apple_sdk_11_0.MacOSX-SDK
|
||||
] else [ ]);
|
||||
} // (if stdenv.isLinux then {
|
||||
LD_LIBRARY_PATH = "${vulkan-loader}/lib";
|
||||
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Package font provides type describing font faces attributes.
|
||||
*/
|
||||
package font
|
||||
|
||||
import (
|
||||
"github.com/go-text/typesetting/font"
|
||||
)
|
||||
|
||||
// A FontFace is a Font and a matching Face.
|
||||
type FontFace struct {
|
||||
Font Font
|
||||
Face Face
|
||||
}
|
||||
|
||||
// Style is the font style.
|
||||
type Style int
|
||||
|
||||
// Weight is a font weight, in CSS units subtracted 400 so the zero value
|
||||
// is normal text weight.
|
||||
type Weight int
|
||||
|
||||
// Font specify a particular typeface variant, style and weight.
|
||||
type Font struct {
|
||||
// Typeface specifies the name(s) of the the font faces to try. See [Typeface]
|
||||
// for details.
|
||||
Typeface Typeface
|
||||
// Style specifies the kind of text style.
|
||||
Style Style
|
||||
// Weight is the text weight.
|
||||
Weight Weight
|
||||
}
|
||||
|
||||
// Face is an opaque handle to a typeface. The concrete implementation depends
|
||||
// upon the kind of font and shaper in use.
|
||||
type Face interface {
|
||||
Face() font.Face
|
||||
}
|
||||
|
||||
// Typeface identifies a list of font families to attempt to use for displaying
|
||||
// a string. The syntax is a comma-delimited list of family names. In order to
|
||||
// allow for the remote possibility of needing to express a font family name
|
||||
// containing a comma, name entries may be quoted using either single or double
|
||||
// quotes. Within quotes, a literal quotation mark can be expressed by escaping
|
||||
// it with `\`. A literal backslash may be expressed by escaping it with another
|
||||
// `\`.
|
||||
//
|
||||
// Here's an example Typeface:
|
||||
//
|
||||
// Times New Roman, Georgia, serif
|
||||
//
|
||||
// This is equivalent to the above:
|
||||
//
|
||||
// "Times New Roman", 'Georgia', serif
|
||||
//
|
||||
// Here are some valid uses of escape sequences:
|
||||
//
|
||||
// "Contains a literal \" doublequote", 'Literal \' Singlequote', "\\ Literal backslash", '\\ another'
|
||||
//
|
||||
// This syntax has the happy side effect that most CSS "font-family" rules are
|
||||
// valid Typefaces (without the trailing semicolon).
|
||||
//
|
||||
// Generic CSS font families are supported, and are automatically expanded to lists
|
||||
// of known font families with a matching style. The supported generic families are:
|
||||
//
|
||||
// - fantasy
|
||||
// - math
|
||||
// - emoji
|
||||
// - serif
|
||||
// - sans-serif
|
||||
// - cursive
|
||||
// - monospace
|
||||
type Typeface string
|
||||
|
||||
const (
|
||||
Regular Style = iota
|
||||
Italic
|
||||
)
|
||||
|
||||
const (
|
||||
Thin Weight = -300
|
||||
ExtraLight Weight = -200
|
||||
Light Weight = -100
|
||||
Normal Weight = 0
|
||||
Medium Weight = 100
|
||||
SemiBold Weight = 200
|
||||
Bold Weight = 300
|
||||
ExtraBold Weight = 400
|
||||
Black Weight = 500
|
||||
)
|
||||
|
||||
func (s Style) String() string {
|
||||
switch s {
|
||||
case Regular:
|
||||
return "Regular"
|
||||
case Italic:
|
||||
return "Italic"
|
||||
default:
|
||||
panic("invalid Style")
|
||||
}
|
||||
}
|
||||
|
||||
func (w Weight) String() string {
|
||||
switch w {
|
||||
case Thin:
|
||||
return "Thin"
|
||||
case ExtraLight:
|
||||
return "ExtraLight"
|
||||
case Light:
|
||||
return "Light"
|
||||
case Normal:
|
||||
return "Normal"
|
||||
case Medium:
|
||||
return "Medium"
|
||||
case SemiBold:
|
||||
return "SemiBold"
|
||||
case Bold:
|
||||
return "Bold"
|
||||
case ExtraBold:
|
||||
return "ExtraBold"
|
||||
case Black:
|
||||
return "Black"
|
||||
default:
|
||||
panic("invalid Weight")
|
||||
}
|
||||
}
|
||||
+38
-19
@@ -24,29 +24,49 @@ import (
|
||||
"golang.org/x/image/font/gofont/gosmallcaps"
|
||||
"golang.org/x/image/font/gofont/gosmallcapsitalic"
|
||||
|
||||
"gioui.org/font"
|
||||
"gioui.org/font/opentype"
|
||||
"gioui.org/text"
|
||||
)
|
||||
|
||||
var (
|
||||
regOnce sync.Once
|
||||
reg []font.FontFace
|
||||
once sync.Once
|
||||
collection []text.FontFace
|
||||
collection []font.FontFace
|
||||
)
|
||||
|
||||
func Collection() []text.FontFace {
|
||||
func loadRegular() {
|
||||
regOnce.Do(func() {
|
||||
faces, err := opentype.ParseCollection(goregular.TTF)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to parse font: %v", err))
|
||||
}
|
||||
reg = faces
|
||||
collection = append(collection, reg[0])
|
||||
})
|
||||
}
|
||||
|
||||
// Regular returns a collection of only the Go regular font face.
|
||||
func Regular() []font.FontFace {
|
||||
loadRegular()
|
||||
return reg
|
||||
}
|
||||
|
||||
// Regular returns a collection of all available Go font faces.
|
||||
func Collection() []font.FontFace {
|
||||
loadRegular()
|
||||
once.Do(func() {
|
||||
register(text.Font{}, goregular.TTF)
|
||||
register(text.Font{Style: text.Italic}, goitalic.TTF)
|
||||
register(text.Font{Weight: text.Bold}, gobold.TTF)
|
||||
register(text.Font{Style: text.Italic, Weight: text.Bold}, gobolditalic.TTF)
|
||||
register(text.Font{Weight: text.Medium}, gomedium.TTF)
|
||||
register(text.Font{Weight: text.Medium, Style: text.Italic}, gomediumitalic.TTF)
|
||||
register(text.Font{Variant: "Mono"}, gomono.TTF)
|
||||
register(text.Font{Variant: "Mono", Weight: text.Bold}, gomonobold.TTF)
|
||||
register(text.Font{Variant: "Mono", Weight: text.Bold, Style: text.Italic}, gomonobolditalic.TTF)
|
||||
register(text.Font{Variant: "Mono", Style: text.Italic}, gomonoitalic.TTF)
|
||||
register(text.Font{Variant: "Smallcaps"}, gosmallcaps.TTF)
|
||||
register(text.Font{Variant: "Smallcaps", Style: text.Italic}, gosmallcapsitalic.TTF)
|
||||
register(goitalic.TTF)
|
||||
register(gobold.TTF)
|
||||
register(gobolditalic.TTF)
|
||||
register(gomedium.TTF)
|
||||
register(gomediumitalic.TTF)
|
||||
register(gomono.TTF)
|
||||
register(gomonobold.TTF)
|
||||
register(gomonobolditalic.TTF)
|
||||
register(gomonoitalic.TTF)
|
||||
register(gosmallcaps.TTF)
|
||||
register(gosmallcapsitalic.TTF)
|
||||
// Ensure that any outside appends will not reuse the backing store.
|
||||
n := len(collection)
|
||||
collection = collection[:n:n]
|
||||
@@ -54,11 +74,10 @@ func Collection() []text.FontFace {
|
||||
return collection
|
||||
}
|
||||
|
||||
func register(fnt text.Font, ttf []byte) {
|
||||
face, err := opentype.Parse(ttf)
|
||||
func register(ttf []byte) {
|
||||
faces, err := opentype.ParseCollection(ttf)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to parse font: %v", err))
|
||||
}
|
||||
fnt.Typeface = "Go"
|
||||
collection = append(collection, text.FontFace{Font: fnt, Face: face})
|
||||
collection = append(collection, faces[0])
|
||||
}
|
||||
|
||||
@@ -1,530 +0,0 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/text"
|
||||
"github.com/benoitkugler/textlayout/language"
|
||||
"github.com/gioui/uax/segment"
|
||||
"github.com/gioui/uax/uax14"
|
||||
"github.com/go-text/typesetting/di"
|
||||
"github.com/go-text/typesetting/font"
|
||||
"github.com/go-text/typesetting/shaping"
|
||||
"golang.org/x/image/math/fixed"
|
||||
)
|
||||
|
||||
// computeGlyphClusters populates the Clusters field of a Layout.
|
||||
// The order of the clusters is visual, meaning
|
||||
// that the first cluster is the leftmost cluster displayed even when
|
||||
// the cluster is part of RTL text.
|
||||
func computeGlyphClusters(l *text.Layout) {
|
||||
clusters := make([]text.GlyphCluster, 0, len(l.Glyphs)+1)
|
||||
if len(l.Glyphs) < 1 {
|
||||
if l.Runes.Count > 0 {
|
||||
// Empty line corresponding to a newline character.
|
||||
clusters = append(clusters, text.GlyphCluster{
|
||||
Runes: text.Range{
|
||||
Count: 1,
|
||||
Offset: l.Runes.Offset,
|
||||
},
|
||||
})
|
||||
}
|
||||
l.Clusters = clusters
|
||||
return
|
||||
}
|
||||
rtl := l.Direction == system.RTL
|
||||
|
||||
// Check for trailing whitespace characters and synthesize
|
||||
// GlyphClusters to represent them.
|
||||
lastGlyph := l.Glyphs[len(l.Glyphs)-1]
|
||||
if rtl {
|
||||
lastGlyph = l.Glyphs[0]
|
||||
}
|
||||
trailingNewline := lastGlyph.ClusterIndex+lastGlyph.RuneCount < l.Runes.Count+l.Runes.Offset
|
||||
newlineCluster := text.GlyphCluster{
|
||||
Runes: text.Range{
|
||||
Count: 1,
|
||||
Offset: l.Runes.Count + l.Runes.Offset - 1,
|
||||
},
|
||||
Glyphs: text.Range{
|
||||
Offset: len(l.Glyphs),
|
||||
},
|
||||
}
|
||||
|
||||
var (
|
||||
i int = 0
|
||||
inc int = 1
|
||||
runesProcessed int = 0
|
||||
glyphsProcessed int = 0
|
||||
)
|
||||
|
||||
if rtl {
|
||||
i = len(l.Glyphs) - 1
|
||||
inc = -inc
|
||||
glyphsProcessed = len(l.Glyphs) - 1
|
||||
newlineCluster.Glyphs.Offset = 0
|
||||
}
|
||||
// Construct clusters from the line's glyphs.
|
||||
for ; i < len(l.Glyphs) && i >= 0; i += inc {
|
||||
g := l.Glyphs[i]
|
||||
xAdv := g.XAdvance * fixed.Int26_6(inc)
|
||||
for k := 0; k < g.GlyphCount-1 && k < len(l.Glyphs); k++ {
|
||||
i += inc
|
||||
xAdv += l.Glyphs[i].XAdvance * fixed.Int26_6(inc)
|
||||
}
|
||||
|
||||
startRune := runesProcessed
|
||||
runeIncrement := g.RuneCount
|
||||
startGlyph := glyphsProcessed
|
||||
glyphIncrement := g.GlyphCount * inc
|
||||
if rtl {
|
||||
startGlyph = glyphsProcessed + glyphIncrement + 1
|
||||
}
|
||||
clusters = append(clusters, text.GlyphCluster{
|
||||
Advance: xAdv,
|
||||
Runes: text.Range{
|
||||
Count: g.RuneCount,
|
||||
Offset: startRune + l.Runes.Offset,
|
||||
},
|
||||
Glyphs: text.Range{
|
||||
Count: g.GlyphCount,
|
||||
Offset: startGlyph,
|
||||
},
|
||||
})
|
||||
runesProcessed += runeIncrement
|
||||
glyphsProcessed += glyphIncrement
|
||||
}
|
||||
// Insert synthetic clusters at the right edge of the line.
|
||||
if trailingNewline {
|
||||
clusters = append(clusters, newlineCluster)
|
||||
}
|
||||
l.Clusters = clusters
|
||||
return
|
||||
}
|
||||
|
||||
// langConfig describes the language and writing system of a body of text.
|
||||
type langConfig struct {
|
||||
// Language the text is written in.
|
||||
language.Language
|
||||
// Writing system used to represent the text.
|
||||
language.Script
|
||||
// Direction of the text, usually driven by the writing system.
|
||||
di.Direction
|
||||
}
|
||||
|
||||
// mapRunesToClusterIndices returns a slice. Each index within that slice corresponds
|
||||
// to an index within the runes input slice. The value stored at that index is the
|
||||
// index of the glyph at the start of the corresponding glyph cluster shaped by
|
||||
// harfbuzz.
|
||||
func mapRunesToClusterIndices(runes []rune, glyphs []shaping.Glyph) []int {
|
||||
mapping := make([]int, len(runes))
|
||||
glyphCursor := 0
|
||||
if len(runes) == 0 {
|
||||
return nil
|
||||
}
|
||||
// If the final cluster values are lower than the starting ones,
|
||||
// the text is RTL.
|
||||
rtl := len(glyphs) > 0 && glyphs[len(glyphs)-1].ClusterIndex < glyphs[0].ClusterIndex
|
||||
if rtl {
|
||||
glyphCursor = len(glyphs) - 1
|
||||
}
|
||||
for i := range runes {
|
||||
for glyphCursor >= 0 && glyphCursor < len(glyphs) &&
|
||||
((rtl && glyphs[glyphCursor].ClusterIndex <= i) ||
|
||||
(!rtl && glyphs[glyphCursor].ClusterIndex < i)) {
|
||||
if rtl {
|
||||
glyphCursor--
|
||||
} else {
|
||||
glyphCursor++
|
||||
}
|
||||
}
|
||||
if rtl {
|
||||
glyphCursor++
|
||||
} else if (glyphCursor >= 0 && glyphCursor < len(glyphs) &&
|
||||
glyphs[glyphCursor].ClusterIndex > i) ||
|
||||
(glyphCursor == len(glyphs) && len(glyphs) > 1) {
|
||||
glyphCursor--
|
||||
targetClusterIndex := glyphs[glyphCursor].ClusterIndex
|
||||
for glyphCursor-1 >= 0 && glyphs[glyphCursor-1].ClusterIndex == targetClusterIndex {
|
||||
glyphCursor--
|
||||
}
|
||||
}
|
||||
if glyphCursor < 0 {
|
||||
glyphCursor = 0
|
||||
} else if glyphCursor >= len(glyphs) {
|
||||
glyphCursor = len(glyphs) - 1
|
||||
}
|
||||
mapping[i] = glyphCursor
|
||||
}
|
||||
return mapping
|
||||
}
|
||||
|
||||
// inclusiveGlyphRange returns the inclusive range of runes and glyphs matching
|
||||
// the provided start and breakAfter rune positions.
|
||||
// runeToGlyph must be a valid mapping from the rune representation to the
|
||||
// glyph reprsentation produced by mapRunesToClusterIndices.
|
||||
// numGlyphs is the number of glyphs in the output representing the runes
|
||||
// under consideration.
|
||||
func inclusiveGlyphRange(start, breakAfter int, runeToGlyph []int, numGlyphs int) (glyphStart, glyphEnd int) {
|
||||
rtl := runeToGlyph[len(runeToGlyph)-1] < runeToGlyph[0]
|
||||
runeStart := start
|
||||
runeEnd := breakAfter
|
||||
if rtl {
|
||||
glyphStart = runeToGlyph[runeEnd]
|
||||
if runeStart-1 >= 0 {
|
||||
glyphEnd = runeToGlyph[runeStart-1] - 1
|
||||
} else {
|
||||
glyphEnd = numGlyphs - 1
|
||||
}
|
||||
} else {
|
||||
glyphStart = runeToGlyph[runeStart]
|
||||
if runeEnd+1 < len(runeToGlyph) {
|
||||
glyphEnd = runeToGlyph[runeEnd+1] - 1
|
||||
} else {
|
||||
glyphEnd = numGlyphs - 1
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// breakOption represets a location within the rune slice at which
|
||||
// it may be safe to break a line of text.
|
||||
type breakOption struct {
|
||||
// breakAtRune is the index at which it is safe to break.
|
||||
breakAtRune int
|
||||
// penalty is the cost of breaking at this index. Negative
|
||||
// penalties mean that the break is beneficial, and a penalty
|
||||
// of uax14.PenaltyForMustBreak means a required break.
|
||||
penalty int
|
||||
}
|
||||
|
||||
// getBreakOptions returns a slice of line break candidates for the
|
||||
// text in the provided slice.
|
||||
func getBreakOptions(text []rune) []breakOption {
|
||||
// Collect options for breaking the lines in a slice.
|
||||
var options []breakOption
|
||||
const adjust = -1
|
||||
breaker := uax14.NewLineWrap()
|
||||
segmenter := segment.NewSegmenter(breaker)
|
||||
segmenter.InitFromSlice(text)
|
||||
runeOffset := 0
|
||||
brokeAtEnd := false
|
||||
for segmenter.Next() {
|
||||
penalty, _ := segmenter.Penalties()
|
||||
// Determine the indices of the breaking runes in the runes
|
||||
// slice. Would be nice if the API provided this.
|
||||
currentSegment := segmenter.Runes()
|
||||
runeOffset += len(currentSegment)
|
||||
|
||||
// Collect all break options.
|
||||
options = append(options, breakOption{
|
||||
penalty: penalty,
|
||||
breakAtRune: runeOffset + adjust,
|
||||
})
|
||||
if options[len(options)-1].breakAtRune == len(text)-1 {
|
||||
brokeAtEnd = true
|
||||
}
|
||||
}
|
||||
if len(text) > 0 && !brokeAtEnd {
|
||||
options = append(options, breakOption{
|
||||
penalty: uax14.PenaltyForMustBreak,
|
||||
breakAtRune: len(text) - 1,
|
||||
})
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
type Shaper func(shaping.Input) (shaping.Output, error)
|
||||
|
||||
// paragraph shapes a single paragraph of text, breaking it into multiple lines
|
||||
// to fit within the provided maxWidth.
|
||||
func paragraph(shaper Shaper, face font.Face, ppem fixed.Int26_6, maxWidth int, lc langConfig, paragraph []rune) ([]output, error) {
|
||||
// TODO: handle splitting bidi text here
|
||||
|
||||
// Shape the text.
|
||||
input := toInput(face, ppem, lc, paragraph)
|
||||
out, err := shaper(input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Get a mapping from input runes to output glyphs.
|
||||
runeToGlyph := mapRunesToClusterIndices(paragraph, out.Glyphs)
|
||||
|
||||
// Fetch line break candidates.
|
||||
breaks := getBreakOptions(paragraph)
|
||||
|
||||
return lineWrap(out, input.Direction, paragraph, runeToGlyph, breaks, maxWidth), nil
|
||||
}
|
||||
|
||||
// shouldKeepSegmentOnLine decides whether the segment of text from the current
|
||||
// end of the line to the provided breakOption should be kept on the current
|
||||
// line. It should be called successively with each available breakOption,
|
||||
// and the line should be broken (without keeping the current segment)
|
||||
// whenever it returns false.
|
||||
//
|
||||
// The parameters require some explanation:
|
||||
// out - the shaping.Output that is being line-broken.
|
||||
// runeToGlyph - a mapping where accessing the slice at the index of a rune
|
||||
// int out will yield the index of the first glyph corresponding to that rune.
|
||||
// lineStartRune - the index of the first rune in the line.
|
||||
// b - the line break candidate under consideration.
|
||||
// curLineWidth - the amount of space total in the current line.
|
||||
// curLineUsed - the amount of space in the current line that is already used.
|
||||
// nextLineWidth - the amount of space available on the next line.
|
||||
//
|
||||
// This function returns both a valid shaping.Output broken at b and a boolean
|
||||
// indicating whether the returned output should be used.
|
||||
func shouldKeepSegmentOnLine(out shaping.Output, runeToGlyph []int, lineStartRune int, b breakOption, curLineWidth, curLineUsed, nextLineWidth int) (candidateLine shaping.Output, keep bool) {
|
||||
// Convert the break target to an inclusive index.
|
||||
glyphStart, glyphEnd := inclusiveGlyphRange(lineStartRune, b.breakAtRune, runeToGlyph, len(out.Glyphs))
|
||||
|
||||
// Construct a line out of the inclusive glyph range.
|
||||
candidateLine = out
|
||||
candidateLine.Glyphs = candidateLine.Glyphs[glyphStart : glyphEnd+1]
|
||||
candidateLine.RecomputeAdvance()
|
||||
candidateAdvance := candidateLine.Advance.Ceil()
|
||||
if candidateAdvance > curLineWidth && candidateAdvance-curLineUsed <= nextLineWidth {
|
||||
// If it fits on the next line, put it there.
|
||||
return candidateLine, false
|
||||
}
|
||||
|
||||
return candidateLine, true
|
||||
}
|
||||
|
||||
// lineWrap wraps the shaped glyphs of a paragraph to a particular max width.
|
||||
func lineWrap(out shaping.Output, dir di.Direction, paragraph []rune, runeToGlyph []int, breaks []breakOption, maxWidth int) []output {
|
||||
var outputs []output
|
||||
if len(breaks) == 0 {
|
||||
// Pass empty lines through as empty.
|
||||
outputs = append(outputs, output{
|
||||
Shaped: out,
|
||||
RuneRange: text.Range{
|
||||
Count: len(paragraph),
|
||||
},
|
||||
})
|
||||
return outputs
|
||||
}
|
||||
|
||||
for i := 0; i < len(breaks); i++ {
|
||||
b := breaks[i]
|
||||
if b.breakAtRune+1 < len(runeToGlyph) {
|
||||
// Check if this break is valid.
|
||||
gIdx := runeToGlyph[b.breakAtRune]
|
||||
g2Idx := runeToGlyph[b.breakAtRune+1]
|
||||
cIdx := out.Glyphs[gIdx].ClusterIndex
|
||||
c2Idx := out.Glyphs[g2Idx].ClusterIndex
|
||||
if cIdx == c2Idx {
|
||||
// This break is within a harfbuzz cluster, and is
|
||||
// therefore invalid.
|
||||
copy(breaks[i:], breaks[i+1:])
|
||||
breaks = breaks[:len(breaks)-1]
|
||||
i--
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
start := 0
|
||||
runesProcessed := 0
|
||||
for i := 0; i < len(breaks); i++ {
|
||||
b := breaks[i]
|
||||
// Always keep the first segment on a line.
|
||||
good, _ := shouldKeepSegmentOnLine(out, runeToGlyph, start, b, maxWidth, 0, maxWidth)
|
||||
end := b.breakAtRune
|
||||
innerLoop:
|
||||
for k := i + 1; k < len(breaks); k++ {
|
||||
bb := breaks[k]
|
||||
candidate, ok := shouldKeepSegmentOnLine(out, runeToGlyph, start, bb, maxWidth, good.Advance.Ceil(), maxWidth)
|
||||
if ok {
|
||||
// Use this new, longer segment.
|
||||
good = candidate
|
||||
end = bb.breakAtRune
|
||||
i++
|
||||
} else {
|
||||
break innerLoop
|
||||
}
|
||||
}
|
||||
numRunes := end - start + 1
|
||||
outputs = append(outputs, output{
|
||||
Shaped: good,
|
||||
RuneRange: text.Range{
|
||||
Count: numRunes,
|
||||
Offset: runesProcessed,
|
||||
},
|
||||
})
|
||||
runesProcessed += numRunes
|
||||
start = end + 1
|
||||
}
|
||||
return outputs
|
||||
}
|
||||
|
||||
// output is a run of shaped text with metadata about its position
|
||||
// within a text document.
|
||||
type output struct {
|
||||
Shaped shaping.Output
|
||||
RuneRange text.Range
|
||||
}
|
||||
|
||||
func toSystemDirection(d di.Direction) system.TextDirection {
|
||||
switch d {
|
||||
case di.DirectionLTR:
|
||||
return system.LTR
|
||||
case di.DirectionRTL:
|
||||
return system.RTL
|
||||
}
|
||||
return system.LTR
|
||||
}
|
||||
|
||||
// toGioGlyphs converts text shaper glyphs into the minimal representation
|
||||
// that Gio needs.
|
||||
func toGioGlyphs(in []shaping.Glyph) []text.Glyph {
|
||||
out := make([]text.Glyph, 0, len(in))
|
||||
for _, g := range in {
|
||||
out = append(out, text.Glyph{
|
||||
ID: g.GlyphID,
|
||||
ClusterIndex: g.ClusterIndex,
|
||||
RuneCount: g.RuneCount,
|
||||
GlyphCount: g.GlyphCount,
|
||||
XAdvance: g.XAdvance,
|
||||
YAdvance: g.YAdvance,
|
||||
XOffset: g.XOffset,
|
||||
YOffset: g.YOffset,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ToLine converts the output into a text.Line
|
||||
func (o output) ToLine() text.Line {
|
||||
advances := make([]fixed.Int26_6, 0, len(o.Shaped.Glyphs))
|
||||
for _, glyph := range o.Shaped.Glyphs {
|
||||
advances = append(advances, glyph.XAdvance)
|
||||
}
|
||||
layout := text.Layout{
|
||||
Glyphs: toGioGlyphs(o.Shaped.Glyphs),
|
||||
Runes: o.RuneRange,
|
||||
Direction: toSystemDirection(o.Shaped.Direction),
|
||||
}
|
||||
return text.Line{
|
||||
Layout: layout,
|
||||
Bounds: fixed.Rectangle26_6{
|
||||
Min: fixed.Point26_6{
|
||||
Y: -o.Shaped.LineBounds.Ascent,
|
||||
},
|
||||
Max: fixed.Point26_6{
|
||||
X: o.Shaped.Advance,
|
||||
Y: -o.Shaped.LineBounds.Ascent + o.Shaped.LineBounds.LineHeight(),
|
||||
},
|
||||
},
|
||||
Width: o.Shaped.Advance,
|
||||
Ascent: o.Shaped.LineBounds.Ascent,
|
||||
Descent: -o.Shaped.LineBounds.Descent + o.Shaped.LineBounds.Gap,
|
||||
}
|
||||
}
|
||||
|
||||
func mapDirection(d system.TextDirection) di.Direction {
|
||||
switch d {
|
||||
case system.LTR:
|
||||
return di.DirectionLTR
|
||||
case system.RTL:
|
||||
return di.DirectionRTL
|
||||
}
|
||||
return di.DirectionLTR
|
||||
}
|
||||
|
||||
// Document shapes text using the given font, ppem, maximum line width, language,
|
||||
// and sequence of runes. It returns a slice of lines corresponding to the txt,
|
||||
// broken to fit within maxWidth and on paragraph boundaries.
|
||||
func Document(shaper Shaper, face font.Face, ppem fixed.Int26_6, maxWidth int, lc system.Locale, txt io.RuneReader) []text.Line {
|
||||
var (
|
||||
outputs []text.Line
|
||||
startByte int
|
||||
startRune int
|
||||
paragraphText []rune
|
||||
done bool
|
||||
langs = make(map[language.Script]int)
|
||||
)
|
||||
for !done {
|
||||
var (
|
||||
bytes int
|
||||
runes int
|
||||
)
|
||||
newlineAdjust := 0
|
||||
paragraphLoop:
|
||||
for r, sz, re := txt.ReadRune(); !done; r, sz, re = txt.ReadRune() {
|
||||
if re != nil {
|
||||
done = true
|
||||
continue
|
||||
}
|
||||
paragraphText = append(paragraphText, r)
|
||||
script := language.LookupScript(r)
|
||||
if _, ok := langs[script]; ok {
|
||||
langs[script]++
|
||||
} else {
|
||||
langs[script] = 1
|
||||
}
|
||||
bytes += sz
|
||||
runes++
|
||||
if r == '\n' {
|
||||
newlineAdjust = 1
|
||||
break paragraphLoop
|
||||
}
|
||||
}
|
||||
var (
|
||||
primary language.Script
|
||||
primaryTotal int
|
||||
)
|
||||
for script, total := range langs {
|
||||
if total > primaryTotal {
|
||||
primary = script
|
||||
primaryTotal = total
|
||||
}
|
||||
}
|
||||
if lc.Language == "" {
|
||||
lc.Language = "EN"
|
||||
}
|
||||
lcfg := langConfig{
|
||||
Language: language.NewLanguage(lc.Language),
|
||||
Script: primary,
|
||||
Direction: mapDirection(lc.Direction),
|
||||
}
|
||||
lines, _ := paragraph(shaper, face, ppem, maxWidth, lcfg, paragraphText[:len(paragraphText)-newlineAdjust])
|
||||
for i := range lines {
|
||||
// Update the offsets of each paragraph to be correct within the
|
||||
// whole document.
|
||||
lines[i].RuneRange.Offset += startRune
|
||||
// Update the cluster values to be rune indices within the entire
|
||||
// document.
|
||||
for k := range lines[i].Shaped.Glyphs {
|
||||
lines[i].Shaped.Glyphs[k].ClusterIndex += startRune
|
||||
}
|
||||
outputs = append(outputs, lines[i].ToLine())
|
||||
}
|
||||
// If there was a trailing newline update the byte counts to include
|
||||
// it on the last line of the paragraph.
|
||||
if newlineAdjust > 0 {
|
||||
outputs[len(outputs)-1].Layout.Runes.Count += newlineAdjust
|
||||
}
|
||||
paragraphText = paragraphText[:0]
|
||||
startByte += bytes
|
||||
startRune += runes
|
||||
}
|
||||
for i := range outputs {
|
||||
computeGlyphClusters(&outputs[i].Layout)
|
||||
}
|
||||
return outputs
|
||||
}
|
||||
|
||||
// toInput converts its parameters into a shaping.Input.
|
||||
func toInput(face font.Face, ppem fixed.Int26_6, lc langConfig, runes []rune) shaping.Input {
|
||||
var input shaping.Input
|
||||
input.Direction = lc.Direction
|
||||
input.Text = runes
|
||||
input.Size = ppem
|
||||
input.Face = face
|
||||
input.Language = lc.Language
|
||||
input.Script = lc.Script
|
||||
input.RunStart = 0
|
||||
input.RunEnd = len(runes)
|
||||
return input
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+171
-117
@@ -2,137 +2,191 @@
|
||||
|
||||
// Package opentype implements text layout and shaping for OpenType
|
||||
// files.
|
||||
//
|
||||
// NOTE: the OpenType specification allows for fonts to include bitmap images
|
||||
// in a variety of formats. In the interest of small binary sizes, the opentype
|
||||
// package only automatically imports the PNG image decoder. If you have a font
|
||||
// with glyphs in JPEG or TIFF formats, register those decoders with the image
|
||||
// package in order to ensure those glyphs are visible in text.
|
||||
package opentype
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
_ "image/png"
|
||||
|
||||
"github.com/benoitkugler/textlayout/fonts"
|
||||
"github.com/benoitkugler/textlayout/fonts/truetype"
|
||||
"github.com/benoitkugler/textlayout/harfbuzz"
|
||||
"github.com/go-text/typesetting/shaping"
|
||||
"golang.org/x/image/font"
|
||||
"golang.org/x/image/math/fixed"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/font/opentype/internal"
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/text"
|
||||
giofont "gioui.org/font"
|
||||
"github.com/go-text/typesetting/font"
|
||||
fontapi "github.com/go-text/typesetting/opentype/api/font"
|
||||
"github.com/go-text/typesetting/opentype/api/metadata"
|
||||
"github.com/go-text/typesetting/opentype/loader"
|
||||
)
|
||||
|
||||
// Font implements the text.Shaper interface using a rich text
|
||||
// shaping engine.
|
||||
type Font struct {
|
||||
font *truetype.Font
|
||||
// Face is a thread-safe representation of a loaded font. For efficiency, applications
|
||||
// should construct a face for any given font file once, reusing it across different
|
||||
// text shapers.
|
||||
type Face struct {
|
||||
face font.Font
|
||||
font giofont.Font
|
||||
}
|
||||
|
||||
// Parse constructs a Font from source bytes.
|
||||
func Parse(src []byte) (*Font, error) {
|
||||
face, err := truetype.Parse(bytes.NewReader(src))
|
||||
// Parse constructs a Face from source bytes.
|
||||
func Parse(src []byte) (Face, error) {
|
||||
ld, err := loader.NewLoader(bytes.NewReader(src))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed parsing truetype font: %w", err)
|
||||
return Face{}, err
|
||||
}
|
||||
return &Font{
|
||||
font: face,
|
||||
font, md, err := parseLoader(ld)
|
||||
if err != nil {
|
||||
return Face{}, fmt.Errorf("failed parsing truetype font: %w", err)
|
||||
}
|
||||
return Face{
|
||||
face: font,
|
||||
font: md,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (f *Font) Layout(ppem fixed.Int26_6, maxWidth int, lc system.Locale, txt io.RuneReader) ([]text.Line, error) {
|
||||
return internal.Document(shaping.Shape, f.font, ppem, maxWidth, lc, txt), nil
|
||||
}
|
||||
|
||||
func (f *Font) Shape(ppem fixed.Int26_6, str text.Layout) clip.PathSpec {
|
||||
return textPath(ppem, f, str)
|
||||
}
|
||||
|
||||
func (f *Font) Metrics(ppem fixed.Int26_6) font.Metrics {
|
||||
metrics := font.Metrics{}
|
||||
font := harfbuzz.NewFont(f.font)
|
||||
font.XScale = int32(ppem.Ceil()) << 6
|
||||
font.YScale = font.XScale
|
||||
// Use any horizontal direction.
|
||||
fontExtents := font.ExtentsForDirection(harfbuzz.LeftToRight)
|
||||
ascender := fixed.I(int(fontExtents.Ascender * 64))
|
||||
descender := fixed.I(int(fontExtents.Descender * 64))
|
||||
gap := fixed.I(int(fontExtents.LineGap * 64))
|
||||
metrics.Height = ascender + descender + gap
|
||||
metrics.Ascent = ascender
|
||||
metrics.Descent = descender
|
||||
// These three are not readily available.
|
||||
// TODO(whereswaldon): figure out how to get these values.
|
||||
metrics.XHeight = ascender
|
||||
metrics.CapHeight = ascender
|
||||
metrics.CaretSlope = image.Pt(0, 1)
|
||||
|
||||
return metrics
|
||||
}
|
||||
|
||||
func textPath(ppem fixed.Int26_6, font *Font, str text.Layout) clip.PathSpec {
|
||||
var lastPos f32.Point
|
||||
var builder clip.Path
|
||||
ops := new(op.Ops)
|
||||
var x fixed.Int26_6
|
||||
builder.Begin(ops)
|
||||
rune := 0
|
||||
ppemInt := ppem.Round()
|
||||
ppem16 := uint16(ppemInt)
|
||||
scaleFactor := float32(ppemInt) / float32(font.font.Upem())
|
||||
for _, g := range str.Glyphs {
|
||||
advance := g.XAdvance
|
||||
outline, ok := font.font.GlyphData(g.ID, ppem16, ppem16).(fonts.GlyphOutline)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
// Move to glyph position.
|
||||
pos := f32.Point{
|
||||
X: float32(x)/64 - float32(g.XOffset)/64,
|
||||
Y: -float32(g.YOffset) / 64,
|
||||
}
|
||||
builder.Move(pos.Sub(lastPos))
|
||||
lastPos = pos
|
||||
var lastArg f32.Point
|
||||
|
||||
// Convert sfnt.Segments to relative segments.
|
||||
for _, fseg := range outline.Segments {
|
||||
nargs := 1
|
||||
switch fseg.Op {
|
||||
case fonts.SegmentOpQuadTo:
|
||||
nargs = 2
|
||||
case fonts.SegmentOpCubeTo:
|
||||
nargs = 3
|
||||
}
|
||||
var args [3]f32.Point
|
||||
for i := 0; i < nargs; i++ {
|
||||
a := f32.Point{
|
||||
X: fseg.Args[i].X * scaleFactor,
|
||||
Y: -fseg.Args[i].Y * scaleFactor,
|
||||
}
|
||||
args[i] = a.Sub(lastArg)
|
||||
if i == nargs-1 {
|
||||
lastArg = a
|
||||
}
|
||||
}
|
||||
switch fseg.Op {
|
||||
case fonts.SegmentOpMoveTo:
|
||||
builder.Move(args[0])
|
||||
case fonts.SegmentOpLineTo:
|
||||
builder.Line(args[0])
|
||||
case fonts.SegmentOpQuadTo:
|
||||
builder.Quad(args[0], args[1])
|
||||
case fonts.SegmentOpCubeTo:
|
||||
builder.Cube(args[0], args[1], args[2])
|
||||
default:
|
||||
panic("unsupported segment op")
|
||||
}
|
||||
}
|
||||
lastPos = lastPos.Add(lastArg)
|
||||
x += advance
|
||||
rune++
|
||||
// ParseCollection parse an Opentype font file, with support for collections.
|
||||
// Single font files are supported, returning a slice with length 1.
|
||||
// The returned fonts are automatically wrapped in a text.FontFace with
|
||||
// inferred font metadata.
|
||||
// BUG(whereswaldon): the only Variant that can be detected automatically is
|
||||
// "Mono".
|
||||
func ParseCollection(src []byte) ([]giofont.FontFace, error) {
|
||||
lds, err := loader.NewLoaders(bytes.NewReader(src))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]giofont.FontFace, len(lds))
|
||||
for i, ld := range lds {
|
||||
face, md, err := parseLoader(ld)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("reading font %d of collection: %s", i, err)
|
||||
}
|
||||
ff := Face{
|
||||
face: face,
|
||||
font: md,
|
||||
}
|
||||
out[i] = giofont.FontFace{
|
||||
Face: ff,
|
||||
Font: ff.Font(),
|
||||
}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func DescriptionToFont(md metadata.Description) giofont.Font {
|
||||
return giofont.Font{
|
||||
Typeface: giofont.Typeface(md.Family),
|
||||
Style: gioStyle(md.Aspect.Style),
|
||||
Weight: gioWeight(md.Aspect.Weight),
|
||||
}
|
||||
}
|
||||
|
||||
func FontToDescription(font giofont.Font) metadata.Description {
|
||||
return metadata.Description{
|
||||
Family: string(font.Typeface),
|
||||
Aspect: metadata.Aspect{
|
||||
Style: mdStyle(font.Style),
|
||||
Weight: mdWeight(font.Weight),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// parseLoader parses the contents of the loader into a face and its metadata.
|
||||
func parseLoader(ld *loader.Loader) (font.Font, giofont.Font, error) {
|
||||
ft, err := fontapi.NewFont(ld)
|
||||
if err != nil {
|
||||
return nil, giofont.Font{}, err
|
||||
}
|
||||
data := DescriptionToFont(metadata.Metadata(ld))
|
||||
return ft, data, nil
|
||||
}
|
||||
|
||||
// Face returns a thread-unsafe wrapper for this Face suitable for use by a single shaper.
|
||||
// Face many be invoked any number of times and is safe so long as each return value is
|
||||
// only used by one goroutine.
|
||||
func (f Face) Face() font.Face {
|
||||
return &fontapi.Face{Font: f.face}
|
||||
}
|
||||
|
||||
// FontFace returns a text.Font with populated font metadata for the
|
||||
// font.
|
||||
// BUG(whereswaldon): the only Variant that can be detected automatically is
|
||||
// "Mono".
|
||||
func (f Face) Font() giofont.Font {
|
||||
return f.font
|
||||
}
|
||||
|
||||
func gioStyle(s metadata.Style) giofont.Style {
|
||||
switch s {
|
||||
case metadata.StyleItalic:
|
||||
return giofont.Italic
|
||||
case metadata.StyleNormal:
|
||||
fallthrough
|
||||
default:
|
||||
return giofont.Regular
|
||||
}
|
||||
}
|
||||
|
||||
func mdStyle(g giofont.Style) metadata.Style {
|
||||
switch g {
|
||||
case giofont.Italic:
|
||||
return metadata.StyleItalic
|
||||
case giofont.Regular:
|
||||
fallthrough
|
||||
default:
|
||||
return metadata.StyleNormal
|
||||
}
|
||||
}
|
||||
|
||||
func gioWeight(w metadata.Weight) giofont.Weight {
|
||||
switch w {
|
||||
case metadata.WeightThin:
|
||||
return giofont.Thin
|
||||
case metadata.WeightExtraLight:
|
||||
return giofont.ExtraLight
|
||||
case metadata.WeightLight:
|
||||
return giofont.Light
|
||||
case metadata.WeightNormal:
|
||||
return giofont.Normal
|
||||
case metadata.WeightMedium:
|
||||
return giofont.Medium
|
||||
case metadata.WeightSemibold:
|
||||
return giofont.SemiBold
|
||||
case metadata.WeightBold:
|
||||
return giofont.Bold
|
||||
case metadata.WeightExtraBold:
|
||||
return giofont.ExtraBold
|
||||
case metadata.WeightBlack:
|
||||
return giofont.Black
|
||||
default:
|
||||
return giofont.Normal
|
||||
}
|
||||
}
|
||||
|
||||
func mdWeight(g giofont.Weight) metadata.Weight {
|
||||
switch g {
|
||||
case giofont.Thin:
|
||||
return metadata.WeightThin
|
||||
case giofont.ExtraLight:
|
||||
return metadata.WeightExtraLight
|
||||
case giofont.Light:
|
||||
return metadata.WeightLight
|
||||
case giofont.Normal:
|
||||
return metadata.WeightNormal
|
||||
case giofont.Medium:
|
||||
return metadata.WeightMedium
|
||||
case giofont.SemiBold:
|
||||
return metadata.WeightSemibold
|
||||
case giofont.Bold:
|
||||
return metadata.WeightBold
|
||||
case giofont.ExtraBold:
|
||||
return metadata.WeightExtraBold
|
||||
case giofont.Black:
|
||||
return metadata.WeightBlack
|
||||
default:
|
||||
return metadata.WeightNormal
|
||||
}
|
||||
return builder.End()
|
||||
}
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
package opentype
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/image/font/gofont/goregular"
|
||||
"golang.org/x/image/math/fixed"
|
||||
|
||||
"gioui.org/internal/ops"
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/text"
|
||||
)
|
||||
|
||||
var english = system.Locale{
|
||||
Language: "EN",
|
||||
Direction: system.LTR,
|
||||
}
|
||||
|
||||
func TestEmptyString(t *testing.T) {
|
||||
face, err := Parse(goregular.TTF)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ppem := fixed.I(200)
|
||||
|
||||
lines, err := face.Layout(ppem, 2000, english, strings.NewReader(""))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(lines) == 0 {
|
||||
t.Fatalf("Layout returned no lines for empty string; expected 1")
|
||||
}
|
||||
l := lines[0]
|
||||
exp := fixed.Rectangle26_6{
|
||||
Min: fixed.Point26_6{
|
||||
Y: fixed.Int26_6(-12094),
|
||||
},
|
||||
Max: fixed.Point26_6{
|
||||
Y: fixed.Int26_6(2700),
|
||||
},
|
||||
}
|
||||
if got := l.Bounds; got != exp {
|
||||
t.Errorf("got bounds %+v for empty string; expected %+v", got, exp)
|
||||
}
|
||||
}
|
||||
|
||||
func decompressFontFile(name string) (*Font, []byte, error) {
|
||||
f, err := os.Open(name)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("could not open file for reading: %s: %v", name, err)
|
||||
}
|
||||
defer f.Close()
|
||||
gz, err := gzip.NewReader(f)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("font file contains invalid gzip data: %v", err)
|
||||
}
|
||||
src, err := ioutil.ReadAll(gz)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to decompress font file: %v", err)
|
||||
}
|
||||
fnt, err := Parse(src)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("file did not contain a valid font: %v", err)
|
||||
}
|
||||
return fnt, src, nil
|
||||
}
|
||||
|
||||
// mergeFonts produces a trivial OpenType Collection (OTC) file for two source fonts.
|
||||
// It makes many assumptions and is not meant for general use.
|
||||
// For file format details, see https://docs.microsoft.com/en-us/typography/opentype/spec/otff
|
||||
// For a robust tool to generate these files, see https://pypi.org/project/afdko/
|
||||
func mergeFonts(ttf1, ttf2 []byte) []byte {
|
||||
// Locations to place the two embedded fonts. All of the offsets to the fonts' internal tables will need to be
|
||||
// shifted from the start of the file by the appropriate amount, and then everything will work as expected.
|
||||
offset1 := uint32(20) // Length of OpenType collection headers
|
||||
offset2 := offset1 + uint32(len(ttf1))
|
||||
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.Write([]byte("ttcf\x00\x01\x00\x00\x00\x00\x00\x02"))
|
||||
_ = binary.Write(&buf, binary.BigEndian, offset1)
|
||||
_ = binary.Write(&buf, binary.BigEndian, offset2)
|
||||
|
||||
// Inline function to copy a font into the collection verbatim, except for adding an offset to all of the font's
|
||||
// table positions.
|
||||
copyOffsetTTF := func(ttf []byte, offset uint32) {
|
||||
_, _ = buf.Write(ttf[:12])
|
||||
numTables := binary.BigEndian.Uint16(ttf[4:6])
|
||||
for i := uint16(0); i < numTables; i++ {
|
||||
p := 12 + 16*i
|
||||
_, _ = buf.Write(ttf[p : p+8])
|
||||
tblLoc := binary.BigEndian.Uint32(ttf[p+8:p+12]) + offset
|
||||
_ = binary.Write(&buf, binary.BigEndian, tblLoc)
|
||||
_, _ = buf.Write(ttf[p+12 : p+16])
|
||||
}
|
||||
_, _ = buf.Write(ttf[12+16*numTables:])
|
||||
}
|
||||
copyOffsetTTF(ttf1, offset1)
|
||||
copyOffsetTTF(ttf2, offset2)
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
// shapeRune uses a given Face to shape exactly one rune at a fixed size, then returns the resulting shape data.
|
||||
func shapeRune(f text.Face, r rune) (clip.PathSpec, error) {
|
||||
ppem := fixed.I(200)
|
||||
lines, err := f.Layout(ppem, 2000, english, strings.NewReader(string(r)))
|
||||
if err != nil {
|
||||
return clip.PathSpec{}, err
|
||||
}
|
||||
if len(lines) != 1 {
|
||||
return clip.PathSpec{}, fmt.Errorf("unexpected rendering for \"U+%08X\": got %d lines (expected: 1)", r, len(lines))
|
||||
}
|
||||
return f.Shape(ppem, lines[0].Layout), nil
|
||||
}
|
||||
|
||||
// areShapesEqual returns true iff both given text shapes are produced with identical operations.
|
||||
func areShapesEqual(shape1, shape2 clip.PathSpec) bool {
|
||||
var ops1, ops2 op.Ops
|
||||
clip.Outline{Path: shape1}.Op().Push(&ops1).Pop()
|
||||
clip.Outline{Path: shape2}.Op().Push(&ops2).Pop()
|
||||
var r1, r2 ops.Reader
|
||||
r1.Reset(&ops1.Internal)
|
||||
r2.Reset(&ops2.Internal)
|
||||
for {
|
||||
encOp1, ok1 := r1.Decode()
|
||||
encOp2, ok2 := r2.Decode()
|
||||
if ok1 != ok2 {
|
||||
return false
|
||||
}
|
||||
if !ok1 {
|
||||
break
|
||||
}
|
||||
if len(encOp1.Refs) > 0 || len(encOp2.Refs) > 0 {
|
||||
panic("unexpected ops with refs in font shaping test")
|
||||
}
|
||||
if !bytes.Equal(encOp1.Data, encOp2.Data) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
+49
-50
@@ -39,18 +39,18 @@ type Hover struct {
|
||||
func (h *Hover) Add(ops *op.Ops) {
|
||||
pointer.InputOp{
|
||||
Tag: h,
|
||||
Types: pointer.Enter | pointer.Leave,
|
||||
Kinds: pointer.Enter | pointer.Leave,
|
||||
}.Add(ops)
|
||||
}
|
||||
|
||||
// Hovered returns whether a pointer is inside the area.
|
||||
func (h *Hover) Hovered(q event.Queue) bool {
|
||||
// Update state and report whether a pointer is inside the area.
|
||||
func (h *Hover) Update(q event.Queue) bool {
|
||||
for _, ev := range q.Events(h) {
|
||||
e, ok := ev.(pointer.Event)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch e.Type {
|
||||
switch e.Kind {
|
||||
case pointer.Leave, pointer.Cancel:
|
||||
if h.entered && h.pid == e.PointerID {
|
||||
h.entered = false
|
||||
@@ -87,11 +87,11 @@ type Click struct {
|
||||
}
|
||||
|
||||
// ClickEvent represent a click action, either a
|
||||
// TypePress for the beginning of a click or a
|
||||
// TypeClick for a completed click.
|
||||
// KindPress for the beginning of a click or a
|
||||
// KindClick for a completed click.
|
||||
type ClickEvent struct {
|
||||
Type ClickType
|
||||
Position f32.Point
|
||||
Kind ClickKind
|
||||
Position image.Point
|
||||
Source pointer.Source
|
||||
Modifiers key.Modifiers
|
||||
// NumClicks records successive clicks occurring
|
||||
@@ -99,7 +99,7 @@ type ClickEvent struct {
|
||||
NumClicks int
|
||||
}
|
||||
|
||||
type ClickType uint8
|
||||
type ClickKind uint8
|
||||
|
||||
// Drag detects drag gestures in the form of pointer.Drag events.
|
||||
type Drag struct {
|
||||
@@ -136,15 +136,15 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
// TypePress is reported for the first pointer
|
||||
// KindPress is reported for the first pointer
|
||||
// press.
|
||||
TypePress ClickType = iota
|
||||
// TypeClick is reported when a click action
|
||||
KindPress ClickKind = iota
|
||||
// KindClick is reported when a click action
|
||||
// is complete.
|
||||
TypeClick
|
||||
// TypeCancel is reported when the gesture is
|
||||
KindClick
|
||||
// KindCancel is reported when the gesture is
|
||||
// cancelled.
|
||||
TypeCancel
|
||||
KindCancel
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -157,13 +157,13 @@ const (
|
||||
StateFlinging
|
||||
)
|
||||
|
||||
var touchSlop = unit.Dp(3)
|
||||
const touchSlop = unit.Dp(3)
|
||||
|
||||
// Add the handler to the operation list to receive click events.
|
||||
func (c *Click) Add(ops *op.Ops) {
|
||||
pointer.InputOp{
|
||||
Tag: c,
|
||||
Types: pointer.Press | pointer.Release | pointer.Enter | pointer.Leave,
|
||||
Kinds: pointer.Press | pointer.Release | pointer.Enter | pointer.Leave,
|
||||
}.Add(ops)
|
||||
}
|
||||
|
||||
@@ -177,30 +177,24 @@ func (c *Click) Pressed() bool {
|
||||
return c.pressed
|
||||
}
|
||||
|
||||
// Events returns the next click events, if any.
|
||||
func (c *Click) Events(q event.Queue) []ClickEvent {
|
||||
// Update state and return the click events.
|
||||
func (c *Click) Update(q event.Queue) []ClickEvent {
|
||||
var events []ClickEvent
|
||||
for _, evt := range q.Events(c) {
|
||||
e, ok := evt.(pointer.Event)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch e.Type {
|
||||
switch e.Kind {
|
||||
case pointer.Release:
|
||||
if !c.pressed || c.pid != e.PointerID {
|
||||
break
|
||||
}
|
||||
c.pressed = false
|
||||
if !c.entered || c.hovered {
|
||||
if e.Time-c.clickedAt < doubleClickDuration {
|
||||
c.clicks++
|
||||
} else {
|
||||
c.clicks = 1
|
||||
}
|
||||
c.clickedAt = e.Time
|
||||
events = append(events, ClickEvent{Type: TypeClick, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers, NumClicks: c.clicks})
|
||||
events = append(events, ClickEvent{Kind: KindClick, Position: e.Position.Round(), Source: e.Source, Modifiers: e.Modifiers, NumClicks: c.clicks})
|
||||
} else {
|
||||
events = append(events, ClickEvent{Type: TypeCancel})
|
||||
events = append(events, ClickEvent{Kind: KindCancel})
|
||||
}
|
||||
case pointer.Cancel:
|
||||
wasPressed := c.pressed
|
||||
@@ -208,7 +202,7 @@ func (c *Click) Events(q event.Queue) []ClickEvent {
|
||||
c.hovered = false
|
||||
c.entered = false
|
||||
if wasPressed {
|
||||
events = append(events, ClickEvent{Type: TypeCancel})
|
||||
events = append(events, ClickEvent{Kind: KindCancel})
|
||||
}
|
||||
case pointer.Press:
|
||||
if c.pressed {
|
||||
@@ -224,7 +218,13 @@ func (c *Click) Events(q event.Queue) []ClickEvent {
|
||||
break
|
||||
}
|
||||
c.pressed = true
|
||||
events = append(events, ClickEvent{Type: TypePress, Position: e.Position, Source: e.Source, Modifiers: e.Modifiers})
|
||||
if e.Time-c.clickedAt < doubleClickDuration {
|
||||
c.clicks++
|
||||
} else {
|
||||
c.clicks = 1
|
||||
}
|
||||
c.clickedAt = e.Time
|
||||
events = append(events, ClickEvent{Kind: KindPress, Position: e.Position.Round(), Source: e.Source, Modifiers: e.Modifiers, NumClicks: c.clicks})
|
||||
case pointer.Leave:
|
||||
if !c.pressed {
|
||||
c.pid = e.PointerID
|
||||
@@ -254,7 +254,7 @@ func (s *Scroll) Add(ops *op.Ops, bounds image.Rectangle) {
|
||||
oph := pointer.InputOp{
|
||||
Tag: s,
|
||||
Grab: s.grab,
|
||||
Types: pointer.Press | pointer.Drag | pointer.Release | pointer.Scroll,
|
||||
Kinds: pointer.Press | pointer.Drag | pointer.Release | pointer.Scroll,
|
||||
ScrollBounds: bounds,
|
||||
}
|
||||
oph.Add(ops)
|
||||
@@ -268,9 +268,8 @@ func (s *Scroll) Stop() {
|
||||
s.flinger = fling.Animation{}
|
||||
}
|
||||
|
||||
// Scroll detects the scrolling distance from the available events and
|
||||
// ongoing fling gestures.
|
||||
func (s *Scroll) Scroll(cfg unit.Metric, q event.Queue, t time.Time, axis Axis) int {
|
||||
// Update state and report the scroll distance along axis.
|
||||
func (s *Scroll) Update(cfg unit.Metric, q event.Queue, t time.Time, axis Axis) int {
|
||||
if s.axis != axis {
|
||||
s.axis = axis
|
||||
return 0
|
||||
@@ -281,7 +280,7 @@ func (s *Scroll) Scroll(cfg unit.Metric, q event.Queue, t time.Time, axis Axis)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch e.Type {
|
||||
switch e.Kind {
|
||||
case pointer.Press:
|
||||
if s.dragging {
|
||||
break
|
||||
@@ -303,7 +302,7 @@ func (s *Scroll) Scroll(cfg unit.Metric, q event.Queue, t time.Time, axis Axis)
|
||||
break
|
||||
}
|
||||
fling := s.estimator.Estimate()
|
||||
if slop, d := float32(cfg.Px(touchSlop)), fling.Distance; d < -slop || d > slop {
|
||||
if slop, d := float32(cfg.Dp(touchSlop)), fling.Distance; d < -slop || d > slop {
|
||||
s.flinger.Start(cfg, t, fling.Velocity)
|
||||
}
|
||||
fallthrough
|
||||
@@ -329,7 +328,7 @@ func (s *Scroll) Scroll(cfg unit.Metric, q event.Queue, t time.Time, axis Axis)
|
||||
v := int(math.Round(float64(val)))
|
||||
dist := s.last - v
|
||||
if e.Priority < pointer.Grabbed {
|
||||
slop := cfg.Px(touchSlop)
|
||||
slop := cfg.Dp(touchSlop)
|
||||
if dist := dist; dist >= slop || -slop >= dist {
|
||||
s.grab = true
|
||||
}
|
||||
@@ -368,12 +367,12 @@ func (d *Drag) Add(ops *op.Ops) {
|
||||
pointer.InputOp{
|
||||
Tag: d,
|
||||
Grab: d.grab,
|
||||
Types: pointer.Press | pointer.Drag | pointer.Release,
|
||||
Kinds: pointer.Press | pointer.Drag | pointer.Release,
|
||||
}.Add(ops)
|
||||
}
|
||||
|
||||
// Events returns the next drag events, if any.
|
||||
func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event {
|
||||
// Update state and return the drag events.
|
||||
func (d *Drag) Update(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event {
|
||||
var events []pointer.Event
|
||||
for _, e := range q.Events(d) {
|
||||
e, ok := e.(pointer.Event)
|
||||
@@ -381,7 +380,7 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event
|
||||
continue
|
||||
}
|
||||
|
||||
switch e.Type {
|
||||
switch e.Kind {
|
||||
case pointer.Press:
|
||||
if !(e.Buttons == pointer.ButtonPrimary || e.Source == pointer.Touch) {
|
||||
continue
|
||||
@@ -407,7 +406,7 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event
|
||||
}
|
||||
if e.Priority < pointer.Grabbed {
|
||||
diff := e.Position.Sub(d.start)
|
||||
slop := cfg.Px(touchSlop)
|
||||
slop := cfg.Dp(touchSlop)
|
||||
if diff.X*diff.X+diff.Y*diff.Y > float32(slop*slop) {
|
||||
d.grab = true
|
||||
}
|
||||
@@ -444,16 +443,16 @@ func (a Axis) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (ct ClickType) String() string {
|
||||
func (ct ClickKind) String() string {
|
||||
switch ct {
|
||||
case TypePress:
|
||||
return "TypePress"
|
||||
case TypeClick:
|
||||
return "TypeClick"
|
||||
case TypeCancel:
|
||||
return "TypeCancel"
|
||||
case KindPress:
|
||||
return "KindPress"
|
||||
case KindClick:
|
||||
return "KindClick"
|
||||
case KindCancel:
|
||||
return "KindCancel"
|
||||
default:
|
||||
panic("invalid ClickType")
|
||||
panic("invalid ClickKind")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-9
@@ -26,16 +26,16 @@ func TestHover(t *testing.T) {
|
||||
r.Frame(ops)
|
||||
|
||||
r.Queue(
|
||||
pointer.Event{Type: pointer.Move, Position: f32.Pt(30, 30)},
|
||||
pointer.Event{Kind: pointer.Move, Position: f32.Pt(30, 30)},
|
||||
)
|
||||
if !h.Hovered(r) {
|
||||
if !h.Update(r) {
|
||||
t.Fatal("expected hovered")
|
||||
}
|
||||
|
||||
r.Queue(
|
||||
pointer.Event{Type: pointer.Move, Position: f32.Pt(50, 50)},
|
||||
pointer.Event{Kind: pointer.Move, Position: f32.Pt(50, 50)},
|
||||
)
|
||||
if h.Hovered(r) {
|
||||
if h.Update(r) {
|
||||
t.Fatal("expected not hovered")
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestMouseClicks(t *testing.T) {
|
||||
r.Frame(&ops)
|
||||
r.Queue(tc.events...)
|
||||
|
||||
events := click.Events(&r)
|
||||
events := click.Update(&r)
|
||||
clicks := filterMouseClicks(events)
|
||||
if got, want := len(clicks), len(tc.clicks); got != want {
|
||||
t.Fatalf("got %d mouse clicks, expected %d", got, want)
|
||||
@@ -92,15 +92,16 @@ func TestMouseClicks(t *testing.T) {
|
||||
|
||||
func mouseClickEvents(times ...time.Duration) []event.Event {
|
||||
press := pointer.Event{
|
||||
Type: pointer.Press,
|
||||
Kind: pointer.Press,
|
||||
Source: pointer.Mouse,
|
||||
Buttons: pointer.ButtonPrimary,
|
||||
}
|
||||
events := make([]event.Event, 0, 2*len(times))
|
||||
for _, t := range times {
|
||||
press := press
|
||||
press.Time = t
|
||||
release := press
|
||||
release.Type = pointer.Release
|
||||
release.Time = t
|
||||
release.Kind = pointer.Release
|
||||
events = append(events, press, release)
|
||||
}
|
||||
return events
|
||||
@@ -109,7 +110,7 @@ func mouseClickEvents(times ...time.Duration) []event.Event {
|
||||
func filterMouseClicks(events []ClickEvent) []ClickEvent {
|
||||
var clicks []ClickEvent
|
||||
for _, ev := range events {
|
||||
if ev.Type == TypeClick {
|
||||
if ev.Kind == KindClick {
|
||||
clicks = append(clicks, ev)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
module gioui.org
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
golang.org/x/exp v0.0.0-20210722180016-6781d3edade3
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
|
||||
)
|
||||
|
||||
require (
|
||||
eliasnaur.com/font v0.0.0-20220124212145-832bb8fc08c3
|
||||
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d
|
||||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2
|
||||
gioui.org/shader v1.0.6
|
||||
github.com/benoitkugler/textlayout v0.0.10
|
||||
github.com/gioui/uax v0.2.1-0.20220325163150-e3d987515a12
|
||||
github.com/go-text/typesetting v0.0.0-20220112121102-58fe93c84506
|
||||
gioui.org/shader v1.0.8
|
||||
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372
|
||||
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95
|
||||
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91
|
||||
golang.org/x/image v0.5.0
|
||||
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64
|
||||
)
|
||||
|
||||
require golang.org/x/text v0.3.6 // indirect
|
||||
require golang.org/x/text v0.7.0
|
||||
|
||||
@@ -1,453 +1,43 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
eliasnaur.com/font v0.0.0-20220124212145-832bb8fc08c3 h1:djFprmHZgrSepsHAIRMp5UJn3PzsoTg9drI+BDmif5Q=
|
||||
eliasnaur.com/font v0.0.0-20220124212145-832bb8fc08c3/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA=
|
||||
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY=
|
||||
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA=
|
||||
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
|
||||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
|
||||
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
|
||||
gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y=
|
||||
gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
|
||||
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
|
||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
||||
github.com/benoitkugler/pstokenizer v1.0.0/go.mod h1:l1G2Voirz0q/jj0TQfabNxVsa8HZXh/VMxFSRALWTiE=
|
||||
github.com/benoitkugler/textlayout v0.0.5/go.mod h1:puH4v13Uz7uIhIH0XMk5jgc8U3MXcn5r3VlV9K8n0D8=
|
||||
github.com/benoitkugler/textlayout v0.0.10 h1:uIaQgH4pBFw1LQ0tPkfjgxo94WYcckzzQaB41L2X84w=
|
||||
github.com/benoitkugler/textlayout v0.0.10/go.mod h1:puH4v13Uz7uIhIH0XMk5jgc8U3MXcn5r3VlV9K8n0D8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:po7NpZ/QiTKzBKyrsEAxwnTamCoh8uDk/egRpQ7siIc=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gioui/uax v0.2.1-0.20220325163150-e3d987515a12 h1:1bjaB/5IIicfKpP4k0s30T2WEw//Kh00zULa8DQ0cxA=
|
||||
github.com/gioui/uax v0.2.1-0.20220325163150-e3d987515a12/go.mod h1:kDhBRTA/i3H46PVdhqcw26TdGSIj42TOKNWKY+Kipnw=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-text/typesetting v0.0.0-20220112121102-58fe93c84506 h1:1TPz/Gn/MsXwJ6bEtI9wdkPcQYr2X3V9I+wz4wPYUdY=
|
||||
github.com/go-text/typesetting v0.0.0-20220112121102-58fe93c84506/go.mod h1:R0mlTNeyszZ/tKQhbZA7SRGjx+OHsmNzgN2jTV7yZcs=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
||||
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.21.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
|
||||
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
|
||||
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
|
||||
go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc=
|
||||
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
gioui.org/shader v1.0.8 h1:6ks0o/A+b0ne7RzEqRZK5f4Gboz2CfG+mVliciy6+qA=
|
||||
gioui.org/shader v1.0.8/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
|
||||
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372 h1:FQivqchis6bE2/9uF70M2gmmLpe82esEm2QadL0TEJo=
|
||||
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22 h1:LBQTFxP2MfsyEDqSKmUBZaDuDHN1vpqDyOZjcqS7MYI=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
|
||||
golang.org/x/exp v0.0.0-20210722180016-6781d3edade3 h1:IlrJD2AM5p8JhN/wVny9jt6gJ9hut2VALhSeZ3SYluk=
|
||||
golang.org/x/exp v0.0.0-20210722180016-6781d3edade3/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 h1:sBdrWpxhGDdTAYNqbgBLAR+ULAPPhfgncLr1X0lyWtg=
|
||||
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
|
||||
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91 h1:ryT6Nf0R83ZgD8WnFFdfI8wCeyqgdXWN4+CkFVNPAT0=
|
||||
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8=
|
||||
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
|
||||
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 h1:UiNENfZ8gDvpiWw7IpOMQ27spWmThO1RwwdQVbJahJM=
|
||||
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
|
||||
+26
-20
@@ -5,12 +5,16 @@ package gpu
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/internal/f32"
|
||||
)
|
||||
|
||||
type resourceCache struct {
|
||||
res map[interface{}]resource
|
||||
newRes map[interface{}]resource
|
||||
res map[interface{}]resourceCacheValue
|
||||
}
|
||||
|
||||
type resourceCacheValue struct {
|
||||
used bool
|
||||
resource resource
|
||||
}
|
||||
|
||||
// opCache is like a resourceCache but using concrete types and a
|
||||
@@ -35,46 +39,48 @@ type opCacheValue struct {
|
||||
|
||||
func newResourceCache() *resourceCache {
|
||||
return &resourceCache{
|
||||
res: make(map[interface{}]resource),
|
||||
newRes: make(map[interface{}]resource),
|
||||
res: make(map[interface{}]resourceCacheValue),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *resourceCache) get(key interface{}) (resource, bool) {
|
||||
v, exists := r.res[key]
|
||||
if exists {
|
||||
r.newRes[key] = v
|
||||
if !exists {
|
||||
return nil, false
|
||||
}
|
||||
return v, exists
|
||||
if !v.used {
|
||||
v.used = true
|
||||
r.res[key] = v
|
||||
}
|
||||
return v.resource, exists
|
||||
}
|
||||
|
||||
func (r *resourceCache) put(key interface{}, val resource) {
|
||||
if _, exists := r.newRes[key]; exists {
|
||||
v, exists := r.res[key]
|
||||
if exists && v.used {
|
||||
panic(fmt.Errorf("key exists, %p", key))
|
||||
}
|
||||
r.res[key] = val
|
||||
r.newRes[key] = val
|
||||
v.used = true
|
||||
v.resource = val
|
||||
r.res[key] = v
|
||||
}
|
||||
|
||||
func (r *resourceCache) frame() {
|
||||
for k, v := range r.res {
|
||||
if _, exists := r.newRes[k]; !exists {
|
||||
if v.used {
|
||||
v.used = false
|
||||
r.res[k] = v
|
||||
} else {
|
||||
delete(r.res, k)
|
||||
v.release()
|
||||
v.resource.release()
|
||||
}
|
||||
}
|
||||
for k, v := range r.newRes {
|
||||
delete(r.newRes, k)
|
||||
r.res[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
func (r *resourceCache) release() {
|
||||
r.frame()
|
||||
for _, v := range r.res {
|
||||
v.release()
|
||||
v.resource.release()
|
||||
}
|
||||
r.newRes = nil
|
||||
r.res = nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package gpu
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkResourceCache(b *testing.B) {
|
||||
offset := 0
|
||||
const N = 100
|
||||
|
||||
cache := newResourceCache()
|
||||
for i := 0; i < b.N; i++ {
|
||||
// half are the same and half updated
|
||||
for k := 0; k < N; k++ {
|
||||
cache.put(offset+k, nullResource{})
|
||||
}
|
||||
cache.frame()
|
||||
offset += N / 2
|
||||
}
|
||||
}
|
||||
|
||||
type nullResource struct{}
|
||||
|
||||
func (nullResource) release() {}
|
||||
+41
-9
@@ -1,7 +1,10 @@
|
||||
package gpu
|
||||
|
||||
import (
|
||||
"gioui.org/f32"
|
||||
"encoding/binary"
|
||||
"math"
|
||||
|
||||
"gioui.org/internal/f32"
|
||||
"gioui.org/internal/stroke"
|
||||
)
|
||||
|
||||
@@ -9,19 +12,48 @@ type quadSplitter struct {
|
||||
bounds f32.Rectangle
|
||||
contour uint32
|
||||
d *drawOps
|
||||
|
||||
// scratch space used by calls to stroke.SplitCubic
|
||||
scratch []stroke.QuadSegment
|
||||
}
|
||||
|
||||
func encodeQuadTo(data []byte, meta uint32, from, ctrl, to f32.Point) {
|
||||
// NW.
|
||||
encodeVertex(data, meta, -1, 1, from, ctrl, to)
|
||||
// NE.
|
||||
encodeVertex(data[vertStride:], meta, 1, 1, from, ctrl, to)
|
||||
// SW.
|
||||
encodeVertex(data[vertStride*2:], meta, -1, -1, from, ctrl, to)
|
||||
// SE.
|
||||
encodeVertex(data[vertStride*3:], meta, 1, -1, from, ctrl, to)
|
||||
// inlined code:
|
||||
// encodeVertex(data, meta, -1, 1, from, ctrl, to)
|
||||
// encodeVertex(data[vertStride:], meta, 1, 1, from, ctrl, to)
|
||||
// encodeVertex(data[vertStride*2:], meta, -1, -1, from, ctrl, to)
|
||||
// encodeVertex(data[vertStride*3:], meta, 1, -1, from, ctrl, to)
|
||||
// this code needs to stay in sync with `vertex.encode`.
|
||||
|
||||
bo := binary.LittleEndian
|
||||
data = data[:vertStride*4]
|
||||
|
||||
// encode the main template
|
||||
bo.PutUint32(data[4:8], meta)
|
||||
bo.PutUint32(data[8:12], math.Float32bits(from.X))
|
||||
bo.PutUint32(data[12:16], math.Float32bits(from.Y))
|
||||
bo.PutUint32(data[16:20], math.Float32bits(ctrl.X))
|
||||
bo.PutUint32(data[20:24], math.Float32bits(ctrl.Y))
|
||||
bo.PutUint32(data[24:28], math.Float32bits(to.X))
|
||||
bo.PutUint32(data[28:32], math.Float32bits(to.Y))
|
||||
|
||||
copy(data[vertStride*1:vertStride*2], data[vertStride*0:vertStride*1])
|
||||
copy(data[vertStride*2:vertStride*3], data[vertStride*0:vertStride*1])
|
||||
copy(data[vertStride*3:vertStride*4], data[vertStride*0:vertStride*1])
|
||||
|
||||
bo.PutUint32(data[vertStride*0:vertStride*0+4], math.Float32bits(nwCorner))
|
||||
bo.PutUint32(data[vertStride*1:vertStride*1+4], math.Float32bits(neCorner))
|
||||
bo.PutUint32(data[vertStride*2:vertStride*2+4], math.Float32bits(swCorner))
|
||||
bo.PutUint32(data[vertStride*3:vertStride*3+4], math.Float32bits(seCorner))
|
||||
}
|
||||
|
||||
const (
|
||||
nwCorner = 1*0.25 + 0*0.5
|
||||
neCorner = 1*0.25 + 1*0.5
|
||||
swCorner = 0*0.25 + 0*0.5
|
||||
seCorner = 0*0.25 + 1*0.5
|
||||
)
|
||||
|
||||
func encodeVertex(data []byte, meta uint32, cornerx, cornery int16, from, ctrl, to f32.Point) {
|
||||
var corner float32
|
||||
if cornerx == 1 {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package gpu
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gioui.org/internal/f32"
|
||||
)
|
||||
|
||||
func BenchmarkEncodeQuadTo(b *testing.B) {
|
||||
var data [vertStride * 4]byte
|
||||
for i := 0; i < b.N; i++ {
|
||||
v := float32(i)
|
||||
encodeQuadTo(data[:], 123,
|
||||
f32.Point{X: v, Y: v},
|
||||
f32.Point{X: v, Y: v},
|
||||
f32.Point{X: v, Y: v},
|
||||
)
|
||||
}
|
||||
}
|
||||
+12
-29
@@ -12,18 +12,18 @@ import (
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/bits"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/cpu"
|
||||
"gioui.org/f32"
|
||||
"gioui.org/gpu/internal/driver"
|
||||
"gioui.org/internal/byteslice"
|
||||
"gioui.org/internal/f32"
|
||||
"gioui.org/internal/f32color"
|
||||
"gioui.org/internal/ops"
|
||||
"gioui.org/internal/scene"
|
||||
@@ -265,7 +265,6 @@ type clipState struct {
|
||||
path []byte
|
||||
pathKey ops.Key
|
||||
intersect f32.Rectangle
|
||||
push bool
|
||||
|
||||
clipKey
|
||||
}
|
||||
@@ -308,11 +307,6 @@ type encoder struct {
|
||||
ntrans int
|
||||
}
|
||||
|
||||
type encodeState struct {
|
||||
trans f32.Affine2D
|
||||
clip f32.Rectangle
|
||||
}
|
||||
|
||||
// sizedBuffer holds a GPU buffer, or its equivalent CPU memory.
|
||||
type sizedBuffer struct {
|
||||
size int
|
||||
@@ -410,12 +404,6 @@ func newCompute(ctx driver.Device) (*compute, error) {
|
||||
conf: new(config),
|
||||
memHeader: new(memoryHeader),
|
||||
}
|
||||
null, err := ctx.NewTexture(driver.TextureFormatRGBA8, 1, 1, driver.FilterNearest, driver.FilterNearest, driver.BufferBindingShaderStorageRead)
|
||||
if err != nil {
|
||||
g.Release()
|
||||
return nil, err
|
||||
}
|
||||
g.output.nullMaterials = null
|
||||
shaders := []struct {
|
||||
prog *computeProgram
|
||||
src shader.Sources
|
||||
@@ -437,6 +425,13 @@ func newCompute(ctx driver.Device) (*compute, error) {
|
||||
}
|
||||
if g.useCPU {
|
||||
g.dispatcher = newDispatcher(runtime.NumCPU())
|
||||
} else {
|
||||
null, err := ctx.NewTexture(driver.TextureFormatRGBA8, 1, 1, driver.FilterNearest, driver.FilterNearest, driver.BufferBindingShaderStorageRead)
|
||||
if err != nil {
|
||||
g.Release()
|
||||
return nil, err
|
||||
}
|
||||
g.output.nullMaterials = null
|
||||
}
|
||||
|
||||
copyVert, copyFrag, err := newShaders(ctx, gio.Shader_copy_vert, gio.Shader_copy_frag)
|
||||
@@ -660,7 +655,7 @@ func (g *compute) dumpAtlases() {
|
||||
if err := png.Encode(&buf, nrgba); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := ioutil.WriteFile(fmt.Sprintf("dump-%d.png", i), buf.Bytes(), 0600); err != nil {
|
||||
if err := os.WriteFile(fmt.Sprintf("dump-%d.png", i), buf.Bytes(), 0600); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -855,7 +850,7 @@ func (g *compute) blitLayers(d driver.LoadDesc, fbo driver.Texture, viewport ima
|
||||
for _, l := range layers {
|
||||
placef := layout.FPt(l.alloc.rect.Min)
|
||||
sizef := layout.FPt(l.rect.Size())
|
||||
r := layout.FRect(l.rect)
|
||||
r := f32.FRect(l.rect)
|
||||
quad := [4]layerVertex{
|
||||
{posX: float32(r.Min.X), posY: float32(r.Min.Y), u: placef.X, v: placef.Y},
|
||||
{posX: float32(r.Max.X), posY: float32(r.Min.Y), u: placef.X + sizef.X, v: placef.Y},
|
||||
@@ -1612,13 +1607,6 @@ func (e *encoder) numElements() int {
|
||||
return len(e.scene)
|
||||
}
|
||||
|
||||
func (e *encoder) append(e2 encoder) {
|
||||
e.scene = append(e.scene, e2.scene...)
|
||||
e.npath += e2.npath
|
||||
e.npathseg += e2.npathseg
|
||||
e.ntrans += e2.ntrans
|
||||
}
|
||||
|
||||
func (e *encoder) transform(m f32.Affine2D) {
|
||||
e.scene = append(e.scene, scene.Transform(m))
|
||||
e.ntrans++
|
||||
@@ -1666,11 +1654,6 @@ func (e *encoder) line(start, end f32.Point) {
|
||||
e.npathseg++
|
||||
}
|
||||
|
||||
func (e *encoder) quad(start, ctrl, end f32.Point) {
|
||||
e.scene = append(e.scene, scene.Quad(start, ctrl, end))
|
||||
e.npathseg++
|
||||
}
|
||||
|
||||
func (c *collector) reset() {
|
||||
c.prevFrame, c.frame = c.frame, c.prevFrame
|
||||
c.profile = false
|
||||
@@ -1782,7 +1765,7 @@ func (c *collector) collect(root *op.Ops, viewport image.Point, texOps *[]textur
|
||||
case ops.TypeClip:
|
||||
var op ops.ClipOp
|
||||
op.Decode(encOp.Data)
|
||||
bounds := layout.FRect(op.Bounds)
|
||||
bounds := f32.FRect(op.Bounds)
|
||||
c.addClip(&state, fview, bounds, pathData.data, pathData.key, pathData.hash, strWidth, true)
|
||||
pathData.data = nil
|
||||
strWidth = 0
|
||||
|
||||
+238
-63
@@ -18,9 +18,9 @@ import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/gpu/internal/driver"
|
||||
"gioui.org/internal/byteslice"
|
||||
"gioui.org/internal/f32"
|
||||
"gioui.org/internal/f32color"
|
||||
"gioui.org/internal/ops"
|
||||
"gioui.org/internal/scene"
|
||||
@@ -68,22 +68,40 @@ type renderer struct {
|
||||
pather *pather
|
||||
packer packer
|
||||
intersections packer
|
||||
layers packer
|
||||
layerFBOs fboSet
|
||||
}
|
||||
|
||||
type drawOps struct {
|
||||
profile bool
|
||||
reader ops.Reader
|
||||
states []f32.Affine2D
|
||||
transStack []f32.Affine2D
|
||||
vertCache []byte
|
||||
viewport image.Point
|
||||
clear bool
|
||||
clearColor f32color.RGBA
|
||||
imageOps []imageOp
|
||||
pathOps []*pathOp
|
||||
pathOpCache []pathOp
|
||||
qs quadSplitter
|
||||
pathCache *opCache
|
||||
profile bool
|
||||
reader ops.Reader
|
||||
states []f32.Affine2D
|
||||
transStack []f32.Affine2D
|
||||
layers []opacityLayer
|
||||
opacityStack []int
|
||||
vertCache []byte
|
||||
viewport image.Point
|
||||
clear bool
|
||||
clearColor f32color.RGBA
|
||||
imageOps []imageOp
|
||||
pathOps []*pathOp
|
||||
pathOpCache []pathOp
|
||||
qs quadSplitter
|
||||
pathCache *opCache
|
||||
}
|
||||
|
||||
type opacityLayer struct {
|
||||
opacity float32
|
||||
parent int
|
||||
// depth of the opacity stack. Layers of equal depth are
|
||||
// independent and may be packed into one atlas.
|
||||
depth int
|
||||
// opStart and opEnd denote the range of drawOps.imageOps
|
||||
// that belong to the layer.
|
||||
opStart, opEnd int
|
||||
// clip of the layer operations.
|
||||
clip image.Rectangle
|
||||
place placement
|
||||
}
|
||||
|
||||
type drawState struct {
|
||||
@@ -127,7 +145,12 @@ type imageOp struct {
|
||||
clip image.Rectangle
|
||||
material material
|
||||
clipType clipType
|
||||
place placement
|
||||
// place is either a placement in the path fbos or intersection fbos,
|
||||
// depending on clipType.
|
||||
place placement
|
||||
// layerOps is the number of operations this
|
||||
// operation replaces.
|
||||
layerOps int
|
||||
}
|
||||
|
||||
func decodeStrokeOp(data []byte) float32 {
|
||||
@@ -154,17 +177,25 @@ type material struct {
|
||||
// For materialTypeColor.
|
||||
color f32color.RGBA
|
||||
// For materialTypeLinearGradient.
|
||||
color1 f32color.RGBA
|
||||
color2 f32color.RGBA
|
||||
color1 f32color.RGBA
|
||||
color2 f32color.RGBA
|
||||
opacity float32
|
||||
// For materialTypeTexture.
|
||||
data imageOpData
|
||||
tex driver.Texture
|
||||
uvTrans f32.Affine2D
|
||||
}
|
||||
|
||||
const (
|
||||
filterLinear = 0
|
||||
filterNearest = 1
|
||||
)
|
||||
|
||||
// imageOpData is the shadow of paint.ImageOp.
|
||||
type imageOpData struct {
|
||||
src *image.RGBA
|
||||
handle interface{}
|
||||
filter byte
|
||||
}
|
||||
|
||||
type linearGradientOpData struct {
|
||||
@@ -182,10 +213,12 @@ func decodeImageOp(data []byte, refs []interface{}) imageOpData {
|
||||
return imageOpData{
|
||||
src: refs[0].(*image.RGBA),
|
||||
handle: handle,
|
||||
filter: data[1],
|
||||
}
|
||||
}
|
||||
|
||||
func decodeColorOp(data []byte) color.NRGBA {
|
||||
data = data[:ops.TypeColorLen]
|
||||
return color.NRGBA{
|
||||
R: data[1],
|
||||
G: data[2],
|
||||
@@ -195,6 +228,7 @@ func decodeColorOp(data []byte) color.NRGBA {
|
||||
}
|
||||
|
||||
func decodeLinearGradientOp(data []byte) linearGradientOpData {
|
||||
data = data[:ops.TypeLinearGradientLen]
|
||||
bo := binary.LittleEndian
|
||||
return linearGradientOpData{
|
||||
stop1: f32.Point{
|
||||
@@ -220,8 +254,6 @@ func decodeLinearGradientOp(data []byte) linearGradientOpData {
|
||||
}
|
||||
}
|
||||
|
||||
type clipType uint8
|
||||
|
||||
type resource interface {
|
||||
release()
|
||||
}
|
||||
@@ -271,6 +303,9 @@ type blitUniforms struct {
|
||||
transform [4]float32
|
||||
uvTransformR1 [4]float32
|
||||
uvTransformR2 [4]float32
|
||||
opacity float32
|
||||
fbo float32
|
||||
_ [2]float32
|
||||
}
|
||||
|
||||
type colorUniforms struct {
|
||||
@@ -282,7 +317,7 @@ type gradientUniforms struct {
|
||||
color2 f32color.RGBA
|
||||
}
|
||||
|
||||
type materialType uint8
|
||||
type clipType uint8
|
||||
|
||||
const (
|
||||
clipTypeNone clipType = iota
|
||||
@@ -290,6 +325,8 @@ const (
|
||||
clipTypeIntersection
|
||||
)
|
||||
|
||||
type materialType uint8
|
||||
|
||||
const (
|
||||
materialColor materialType = iota
|
||||
materialLinearGradient
|
||||
@@ -389,6 +426,8 @@ func (g *gpu) frame(target RenderTarget) error {
|
||||
g.coverTimer.begin()
|
||||
g.renderer.uploadImages(g.cache, g.drawOps.imageOps)
|
||||
g.renderer.prepareDrawOps(g.cache, g.drawOps.imageOps)
|
||||
g.drawOps.layers = g.renderer.packLayers(g.drawOps.layers)
|
||||
g.renderer.drawLayers(g.cache, g.drawOps.layers, g.drawOps.imageOps)
|
||||
d := driver.LoadDesc{
|
||||
ClearColor: g.drawOps.clearColor,
|
||||
}
|
||||
@@ -398,7 +437,7 @@ func (g *gpu) frame(target RenderTarget) error {
|
||||
}
|
||||
g.ctx.BeginRenderPass(defFBO, d)
|
||||
g.ctx.Viewport(0, 0, viewport.X, viewport.Y)
|
||||
g.renderer.drawOps(g.cache, g.drawOps.imageOps)
|
||||
g.renderer.drawOps(g.cache, false, image.Point{}, g.renderer.blitter.viewport, g.drawOps.imageOps)
|
||||
g.coverTimer.end()
|
||||
g.ctx.EndRenderPass()
|
||||
g.cleanupTimer.begin()
|
||||
@@ -422,19 +461,41 @@ func (g *gpu) Profile() string {
|
||||
}
|
||||
|
||||
func (r *renderer) texHandle(cache *resourceCache, data imageOpData) driver.Texture {
|
||||
type cachekey struct {
|
||||
filter byte
|
||||
handle any
|
||||
}
|
||||
key := cachekey{
|
||||
filter: data.filter,
|
||||
handle: data.handle,
|
||||
}
|
||||
|
||||
var tex *texture
|
||||
t, exists := cache.get(data.handle)
|
||||
t, exists := cache.get(key)
|
||||
if !exists {
|
||||
t = &texture{
|
||||
src: data.src,
|
||||
}
|
||||
cache.put(data.handle, t)
|
||||
cache.put(key, t)
|
||||
}
|
||||
tex = t.(*texture)
|
||||
if tex.tex != nil {
|
||||
return tex.tex
|
||||
}
|
||||
handle, err := r.ctx.NewTexture(driver.TextureFormatSRGBA, data.src.Bounds().Dx(), data.src.Bounds().Dy(), driver.FilterLinear, driver.FilterLinear, driver.BufferBindingTexture)
|
||||
|
||||
var minFilter, magFilter driver.TextureFilter
|
||||
switch data.filter {
|
||||
case filterLinear:
|
||||
minFilter, magFilter = driver.FilterLinearMipmapLinear, driver.FilterLinear
|
||||
case filterNearest:
|
||||
minFilter, magFilter = driver.FilterNearest, driver.FilterNearest
|
||||
}
|
||||
|
||||
handle, err := r.ctx.NewTexture(driver.TextureFormatSRGBA,
|
||||
data.src.Bounds().Dx(), data.src.Bounds().Dy(),
|
||||
minFilter, magFilter,
|
||||
driver.BufferBindingTexture,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -462,15 +523,18 @@ func newRenderer(ctx driver.Device) *renderer {
|
||||
if cap := 8192; maxDim > cap {
|
||||
maxDim = cap
|
||||
}
|
||||
d := image.Pt(maxDim, maxDim)
|
||||
|
||||
r.packer.maxDims = image.Pt(maxDim, maxDim)
|
||||
r.intersections.maxDims = image.Pt(maxDim, maxDim)
|
||||
r.packer.maxDims = d
|
||||
r.intersections.maxDims = d
|
||||
r.layers.maxDims = d
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *renderer) release() {
|
||||
r.pather.release()
|
||||
r.blitter.release()
|
||||
r.layerFBOs.delete(r.ctx, 0)
|
||||
}
|
||||
|
||||
func newBlitter(ctx driver.Device) *blitter {
|
||||
@@ -695,8 +759,8 @@ func (r *renderer) intersectPath(p *pathOp, clip image.Rectangle) {
|
||||
}
|
||||
fbo := r.pather.stenciler.cover(p.place.Idx)
|
||||
r.ctx.BindTexture(0, fbo.tex)
|
||||
coverScale, coverOff := texSpaceTransform(layout.FRect(uv), fbo.size)
|
||||
subScale, subOff := texSpaceTransform(layout.FRect(sub), p.clip.Size())
|
||||
coverScale, coverOff := texSpaceTransform(f32.FRect(uv), fbo.size)
|
||||
subScale, subOff := texSpaceTransform(f32.FRect(sub), p.clip.Size())
|
||||
r.pather.stenciler.ipipeline.uniforms.vert.uvTransform = [4]float32{coverScale.X, coverScale.Y, coverOff.X, coverOff.Y}
|
||||
r.pather.stenciler.ipipeline.uniforms.vert.subUVTransform = [4]float32{subScale.X, subScale.Y, subOff.X, subOff.Y}
|
||||
r.pather.stenciler.ipipeline.pipeline.UploadUniforms(r.ctx)
|
||||
@@ -745,8 +809,7 @@ func (r *renderer) packStencils(pops *[]*pathOp) {
|
||||
ops = ops[:len(ops)-1]
|
||||
continue
|
||||
}
|
||||
sz := image.Point{X: p.clip.Dx(), Y: p.clip.Dy()}
|
||||
place, ok := r.packer.add(sz)
|
||||
place, ok := r.packer.add(p.clip.Size())
|
||||
if !ok {
|
||||
// The clip area is at most the entire screen. Hopefully no
|
||||
// screen is larger than GL_MAX_TEXTURE_SIZE.
|
||||
@@ -758,6 +821,83 @@ func (r *renderer) packStencils(pops *[]*pathOp) {
|
||||
*pops = ops
|
||||
}
|
||||
|
||||
func (r *renderer) packLayers(layers []opacityLayer) []opacityLayer {
|
||||
// Make every layer bounds contain nested layers; cull empty layers.
|
||||
for i := len(layers) - 1; i >= 0; i-- {
|
||||
l := layers[i]
|
||||
if l.parent != -1 {
|
||||
b := layers[l.parent].clip
|
||||
layers[l.parent].clip = b.Union(l.clip)
|
||||
}
|
||||
if l.clip.Empty() {
|
||||
layers = append(layers[:i], layers[i+1:]...)
|
||||
}
|
||||
}
|
||||
// Pack layers.
|
||||
r.layers.clear()
|
||||
depth := 0
|
||||
for i := range layers {
|
||||
l := &layers[i]
|
||||
// Only layers of the same depth may be packed together.
|
||||
if l.depth != depth {
|
||||
r.layers.newPage()
|
||||
}
|
||||
place, ok := r.layers.add(l.clip.Size())
|
||||
if !ok {
|
||||
// The layer area is at most the entire screen. Hopefully no
|
||||
// screen is larger than GL_MAX_TEXTURE_SIZE.
|
||||
panic(fmt.Errorf("layer size %v is larger than maximum texture size %v", l.clip.Size(), r.layers.maxDims))
|
||||
}
|
||||
l.place = place
|
||||
}
|
||||
return layers
|
||||
}
|
||||
|
||||
func (r *renderer) drawLayers(cache *resourceCache, layers []opacityLayer, ops []imageOp) {
|
||||
if len(r.layers.sizes) == 0 {
|
||||
return
|
||||
}
|
||||
fbo := -1
|
||||
r.layerFBOs.resize(r.ctx, driver.TextureFormatSRGBA, r.layers.sizes)
|
||||
for i := len(layers) - 1; i >= 0; i-- {
|
||||
l := layers[i]
|
||||
if fbo != l.place.Idx {
|
||||
if fbo != -1 {
|
||||
r.ctx.EndRenderPass()
|
||||
r.ctx.PrepareTexture(r.layerFBOs.fbos[fbo].tex)
|
||||
}
|
||||
fbo = l.place.Idx
|
||||
f := r.layerFBOs.fbos[fbo]
|
||||
r.ctx.BeginRenderPass(f.tex, driver.LoadDesc{Action: driver.LoadActionClear})
|
||||
}
|
||||
v := image.Rectangle{
|
||||
Min: l.place.Pos,
|
||||
Max: l.place.Pos.Add(l.clip.Size()),
|
||||
}
|
||||
r.ctx.Viewport(v.Min.X, v.Min.Y, v.Max.X, v.Max.Y)
|
||||
f := r.layerFBOs.fbos[fbo]
|
||||
r.drawOps(cache, true, l.clip.Min.Mul(-1), l.clip.Size(), ops[l.opStart:l.opEnd])
|
||||
sr := f32.FRect(v)
|
||||
uvScale, uvOffset := texSpaceTransform(sr, f.size)
|
||||
uvTrans := f32.Affine2D{}.Scale(f32.Point{}, uvScale).Offset(uvOffset)
|
||||
// Replace layer ops with one textured op.
|
||||
ops[l.opStart] = imageOp{
|
||||
clip: l.clip,
|
||||
material: material{
|
||||
material: materialTexture,
|
||||
tex: f.tex,
|
||||
uvTrans: uvTrans,
|
||||
opacity: l.opacity,
|
||||
},
|
||||
layerOps: l.opEnd - l.opStart - 1,
|
||||
}
|
||||
}
|
||||
if fbo != -1 {
|
||||
r.ctx.EndRenderPass()
|
||||
r.ctx.PrepareTexture(r.layerFBOs.fbos[fbo].tex)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *drawOps) reset(viewport image.Point) {
|
||||
d.profile = false
|
||||
d.viewport = viewport
|
||||
@@ -766,6 +906,8 @@ func (d *drawOps) reset(viewport image.Point) {
|
||||
d.pathOpCache = d.pathOpCache[:0]
|
||||
d.vertCache = d.vertCache[:0]
|
||||
d.transStack = d.transStack[:0]
|
||||
d.layers = d.layers[:0]
|
||||
d.opacityStack = d.opacityStack[:0]
|
||||
}
|
||||
|
||||
func (d *drawOps) collect(root *op.Ops, viewport image.Point) {
|
||||
@@ -821,15 +963,6 @@ func (d *drawOps) addClipPath(state *drawState, aux []byte, auxKey opKey, bounds
|
||||
state.cpath = npath
|
||||
}
|
||||
|
||||
// split a transform into two parts, one which is pure offset and the
|
||||
// other representing the scaling, shearing and rotation part
|
||||
func splitTransform(t f32.Affine2D) (srs f32.Affine2D, offset f32.Point) {
|
||||
sx, hx, ox, hy, sy, oy := t.Elems()
|
||||
offset = f32.Point{X: ox, Y: oy}
|
||||
srs = f32.NewAffine2D(sx, hx, 0, hy, sy, 0)
|
||||
return
|
||||
}
|
||||
|
||||
func (d *drawOps) save(id int, state f32.Affine2D) {
|
||||
if extra := id - len(d.states) + 1; extra > 0 {
|
||||
d.states = append(d.states, make([]f32.Affine2D, extra)...)
|
||||
@@ -873,6 +1006,27 @@ loop:
|
||||
state.t = d.transStack[n-1]
|
||||
d.transStack = d.transStack[:n-1]
|
||||
|
||||
case ops.TypePushOpacity:
|
||||
opacity := ops.DecodeOpacity(encOp.Data)
|
||||
parent := -1
|
||||
depth := len(d.opacityStack)
|
||||
if depth > 0 {
|
||||
parent = d.opacityStack[depth-1]
|
||||
}
|
||||
lidx := len(d.layers)
|
||||
d.layers = append(d.layers, opacityLayer{
|
||||
opacity: opacity,
|
||||
parent: parent,
|
||||
depth: depth,
|
||||
opStart: len(d.imageOps),
|
||||
})
|
||||
d.opacityStack = append(d.opacityStack, lidx)
|
||||
case ops.TypePopOpacity:
|
||||
n := len(d.opacityStack)
|
||||
idx := d.opacityStack[n-1]
|
||||
d.layers[idx].opEnd = len(d.imageOps)
|
||||
d.opacityStack = d.opacityStack[:n-1]
|
||||
|
||||
case ops.TypeStroke:
|
||||
quads.key.strokeWidth = decodeStrokeOp(encOp.Data)
|
||||
|
||||
@@ -888,8 +1042,8 @@ loop:
|
||||
var op ops.ClipOp
|
||||
op.Decode(encOp.Data)
|
||||
quads.key.outline = op.Outline
|
||||
bounds := layout.FRect(op.Bounds)
|
||||
trans, off := splitTransform(state.t)
|
||||
bounds := f32.FRect(op.Bounds)
|
||||
trans, off := state.t.Split()
|
||||
if len(quads.aux) > 0 {
|
||||
// There is a clipping path, build the gpu data and update the
|
||||
// cache key such that it will be equal only if the transform is the
|
||||
@@ -935,7 +1089,7 @@ loop:
|
||||
// Transform (if needed) the painting rectangle and if so generate a clip path,
|
||||
// for those cases also compute a partialTrans that maps texture coordinates between
|
||||
// the new bounding rectangle and the transformed original paint rectangle.
|
||||
t, off := splitTransform(state.t)
|
||||
t, off := state.t.Split()
|
||||
// Fill the clip area, unless the material is a (bounded) image.
|
||||
// TODO: Find a tighter bound.
|
||||
inf := float32(1e6)
|
||||
@@ -965,7 +1119,7 @@ loop:
|
||||
mat := state.materialFor(bnd, off, partialTrans, bounds)
|
||||
|
||||
rect := state.cpath == nil || state.cpath.rect
|
||||
if bounds.Min == (image.Point{}) && bounds.Max == d.viewport && rect && mat.opaque && (mat.material == materialColor) {
|
||||
if bounds.Min == (image.Point{}) && bounds.Max == d.viewport && rect && mat.opaque && (mat.material == materialColor) && len(d.opacityStack) == 0 {
|
||||
// The image is a uniform opaque color and takes up the whole screen.
|
||||
// Scrap images up to and including this image and set clear color.
|
||||
d.imageOps = d.imageOps[:0]
|
||||
@@ -978,6 +1132,15 @@ loop:
|
||||
clip: bounds,
|
||||
material: mat,
|
||||
}
|
||||
if n := len(d.opacityStack); n > 0 {
|
||||
idx := d.opacityStack[n-1]
|
||||
lb := d.layers[idx].clip
|
||||
if lb.Empty() {
|
||||
d.layers[idx].clip = img.clip
|
||||
} else {
|
||||
d.layers[idx].clip = lb.Union(img.clip)
|
||||
}
|
||||
}
|
||||
|
||||
d.imageOps = append(d.imageOps, img)
|
||||
if clipData != nil {
|
||||
@@ -1007,7 +1170,9 @@ func expandPathOp(p *pathOp, clip image.Rectangle) {
|
||||
}
|
||||
|
||||
func (d *drawState) materialFor(rect f32.Rectangle, off f32.Point, partTrans f32.Affine2D, clip image.Rectangle) material {
|
||||
var m material
|
||||
m := material{
|
||||
opacity: 1.,
|
||||
}
|
||||
switch d.matType {
|
||||
case materialColor:
|
||||
m.material = materialColor
|
||||
@@ -1047,10 +1212,11 @@ func (d *drawState) materialFor(rect f32.Rectangle, off f32.Point, partTrans f32
|
||||
}
|
||||
|
||||
func (r *renderer) uploadImages(cache *resourceCache, ops []imageOp) {
|
||||
for _, img := range ops {
|
||||
for i := range ops {
|
||||
img := &ops[i]
|
||||
m := img.material
|
||||
if m.material == materialTexture {
|
||||
r.texHandle(cache, m.data)
|
||||
img.material.tex = r.texHandle(cache, m.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1060,10 +1226,10 @@ func (r *renderer) prepareDrawOps(cache *resourceCache, ops []imageOp) {
|
||||
m := img.material
|
||||
switch m.material {
|
||||
case materialTexture:
|
||||
r.ctx.PrepareTexture(r.texHandle(cache, m.data))
|
||||
r.ctx.PrepareTexture(m.tex)
|
||||
}
|
||||
|
||||
var fbo stencilFBO
|
||||
var fbo FBO
|
||||
switch img.clipType {
|
||||
case clipTypeNone:
|
||||
continue
|
||||
@@ -1076,24 +1242,26 @@ func (r *renderer) prepareDrawOps(cache *resourceCache, ops []imageOp) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *renderer) drawOps(cache *resourceCache, ops []imageOp) {
|
||||
func (r *renderer) drawOps(cache *resourceCache, isFBO bool, opOff image.Point, viewport image.Point, ops []imageOp) {
|
||||
var coverTex driver.Texture
|
||||
for _, img := range ops {
|
||||
for i := 0; i < len(ops); i++ {
|
||||
img := ops[i]
|
||||
i += img.layerOps
|
||||
m := img.material
|
||||
switch m.material {
|
||||
case materialTexture:
|
||||
r.ctx.BindTexture(0, r.texHandle(cache, m.data))
|
||||
r.ctx.BindTexture(0, m.tex)
|
||||
}
|
||||
drc := img.clip
|
||||
drc := img.clip.Add(opOff)
|
||||
|
||||
scale, off := clipSpaceTransform(drc, r.blitter.viewport)
|
||||
var fbo stencilFBO
|
||||
scale, off := clipSpaceTransform(drc, viewport)
|
||||
var fbo FBO
|
||||
switch img.clipType {
|
||||
case clipTypeNone:
|
||||
p := r.blitter.pipelines[m.material]
|
||||
r.ctx.BindPipeline(p.pipeline)
|
||||
r.ctx.BindVertexBuffer(r.blitter.quadVerts, 0)
|
||||
r.blitter.blit(m.material, m.color, m.color1, m.color2, scale, off, m.uvTrans)
|
||||
r.blitter.blit(m.material, isFBO, m.color, m.color1, m.color2, scale, off, m.opacity, m.uvTrans)
|
||||
continue
|
||||
case clipTypePath:
|
||||
fbo = r.pather.stenciler.cover(img.place.Idx)
|
||||
@@ -1108,15 +1276,15 @@ func (r *renderer) drawOps(cache *resourceCache, ops []imageOp) {
|
||||
Min: img.place.Pos,
|
||||
Max: img.place.Pos.Add(drc.Size()),
|
||||
}
|
||||
coverScale, coverOff := texSpaceTransform(layout.FRect(uv), fbo.size)
|
||||
coverScale, coverOff := texSpaceTransform(f32.FRect(uv), fbo.size)
|
||||
p := r.pather.coverer.pipelines[m.material]
|
||||
r.ctx.BindPipeline(p.pipeline)
|
||||
r.ctx.BindVertexBuffer(r.blitter.quadVerts, 0)
|
||||
r.pather.cover(m.material, m.color, m.color1, m.color2, scale, off, m.uvTrans, coverScale, coverOff)
|
||||
r.pather.cover(m.material, isFBO, m.color, m.color1, m.color2, scale, off, m.uvTrans, coverScale, coverOff)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *blitter) blit(mat materialType, col f32color.RGBA, col1, col2 f32color.RGBA, scale, off f32.Point, uvTrans f32.Affine2D) {
|
||||
func (b *blitter) blit(mat materialType, fbo bool, col f32color.RGBA, col1, col2 f32color.RGBA, scale, off f32.Point, opacity float32, uvTrans f32.Affine2D) {
|
||||
p := b.pipelines[mat]
|
||||
b.ctx.BindPipeline(p.pipeline)
|
||||
var uniforms *blitUniforms
|
||||
@@ -1126,18 +1294,23 @@ func (b *blitter) blit(mat materialType, col f32color.RGBA, col1, col2 f32color.
|
||||
uniforms = &b.colUniforms.blitUniforms
|
||||
case materialTexture:
|
||||
t1, t2, t3, t4, t5, t6 := uvTrans.Elems()
|
||||
b.texUniforms.blitUniforms.uvTransformR1 = [4]float32{t1, t2, t3, 0}
|
||||
b.texUniforms.blitUniforms.uvTransformR2 = [4]float32{t4, t5, t6, 0}
|
||||
uniforms = &b.texUniforms.blitUniforms
|
||||
uniforms.uvTransformR1 = [4]float32{t1, t2, t3, 0}
|
||||
uniforms.uvTransformR2 = [4]float32{t4, t5, t6, 0}
|
||||
case materialLinearGradient:
|
||||
b.linearGradientUniforms.color1 = col1
|
||||
b.linearGradientUniforms.color2 = col2
|
||||
|
||||
t1, t2, t3, t4, t5, t6 := uvTrans.Elems()
|
||||
b.linearGradientUniforms.blitUniforms.uvTransformR1 = [4]float32{t1, t2, t3, 0}
|
||||
b.linearGradientUniforms.blitUniforms.uvTransformR2 = [4]float32{t4, t5, t6, 0}
|
||||
uniforms = &b.linearGradientUniforms.blitUniforms
|
||||
uniforms.uvTransformR1 = [4]float32{t1, t2, t3, 0}
|
||||
uniforms.uvTransformR2 = [4]float32{t4, t5, t6, 0}
|
||||
}
|
||||
uniforms.fbo = 0
|
||||
if fbo {
|
||||
uniforms.fbo = 1
|
||||
}
|
||||
uniforms.opacity = opacity
|
||||
uniforms.transform = [4]float32{scale.X, scale.Y, off.X, off.Y}
|
||||
p.UploadUniforms(b.ctx)
|
||||
b.ctx.DrawArrays(0, 4)
|
||||
@@ -1334,7 +1507,9 @@ func decodeToOutlineQuads(qs *quadSplitter, tr f32.Affine2D, pathData []byte) {
|
||||
q = q.Transform(tr)
|
||||
qs.splitAndEncode(q)
|
||||
case scene.OpCubic:
|
||||
for _, q := range stroke.SplitCubic(scene.DecodeCubic(cmd)) {
|
||||
from, ctrl0, ctrl1, to := scene.DecodeCubic(cmd)
|
||||
qs.scratch = stroke.SplitCubic(from, ctrl0, ctrl1, to, qs.scratch[:0])
|
||||
for _, q := range qs.scratch {
|
||||
q = q.Transform(tr)
|
||||
qs.splitAndEncode(q)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
@@ -122,7 +122,7 @@ func TestFramebuffers(t *testing.T) {
|
||||
sz := image.Point{X: 800, Y: 600}
|
||||
var (
|
||||
col1 = color.NRGBA{R: 0xac, G: 0xbd, B: 0xef, A: 0xde}
|
||||
col2 = color.NRGBA{R: 0xfe, G: 0xba, B: 0xbe, A: 0xca}
|
||||
col2 = color.NRGBA{R: 0xfe, G: 0xbb, B: 0xbe, A: 0xca}
|
||||
)
|
||||
fbo1 := newFBO(t, b, sz)
|
||||
fbo2 := newFBO(t, b, sz)
|
||||
@@ -202,5 +202,5 @@ func saveImage(file string, img image.Image) error {
|
||||
if err := png.Encode(&buf, img); err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(file, buf.Bytes(), 0666)
|
||||
return os.WriteFile(file, buf.Bytes(), 0666)
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func NewWindow(width, height int) (*Window, error) {
|
||||
)
|
||||
if err != nil {
|
||||
dev.Release()
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
// Note that the gpu takes ownership of dev.
|
||||
gp, err := gpu.NewWithDevice(dev)
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
|
||||
#cgo LDFLAGS: -framework CoreGraphics
|
||||
#cgo CFLAGS: -Werror -Wno-deprecated-declarations -fobjc-arc -x objective-c
|
||||
#cgo LDFLAGS: -framework CoreGraphics -framework Metal -framework Foundation
|
||||
|
||||
@import Metal;
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
static CFTypeRef createDevice(void) {
|
||||
@autoreleasepool {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
newContextFallback = func() (context, error) {
|
||||
newContextPrimary = func() (context, error) {
|
||||
return egl.NewContext(egl.EGL_DEFAULT_DISPLAY)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"image/color"
|
||||
"testing"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/internal/f32color"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
@@ -50,20 +49,14 @@ func TestClipping(t *testing.T) {
|
||||
var ops op.Ops
|
||||
paint.ColorOp{Color: col}.Add(&ops)
|
||||
clip.RRect{
|
||||
Rect: f32.Rectangle{
|
||||
Min: f32.Point{X: 50, Y: 50},
|
||||
Max: f32.Point{X: 250, Y: 250},
|
||||
},
|
||||
SE: 75,
|
||||
Rect: image.Rect(50, 50, 250, 250),
|
||||
SE: 75,
|
||||
}.Push(&ops)
|
||||
paint.PaintOp{}.Add(&ops)
|
||||
paint.ColorOp{Color: col2}.Add(&ops)
|
||||
clip.RRect{
|
||||
Rect: f32.Rectangle{
|
||||
Min: f32.Point{X: 100, Y: 100},
|
||||
Max: f32.Point{X: 350, Y: 350},
|
||||
},
|
||||
NW: 75,
|
||||
Rect: image.Rect(100, 100, 350, 350),
|
||||
NW: 75,
|
||||
}.Push(&ops)
|
||||
paint.PaintOp{}.Add(&ops)
|
||||
if err := w.Frame(&ops); err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ type vkContext struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
newContextPrimary = newVulkanContext
|
||||
newContextFallback = newVulkanContext
|
||||
}
|
||||
|
||||
func newVulkanContext() (context, error) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"math"
|
||||
"math/bits"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
@@ -58,6 +59,7 @@ type Texture struct {
|
||||
|
||||
width int
|
||||
height int
|
||||
mipmap bool
|
||||
foreign bool
|
||||
}
|
||||
|
||||
@@ -219,17 +221,33 @@ func (b *Backend) NewTexture(format driver.TextureFormat, width, height int, min
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported texture format %d", format)
|
||||
}
|
||||
bindFlags := convBufferBinding(bindings)
|
||||
miscFlags := uint32(0)
|
||||
mipmap := minFilter == driver.FilterLinearMipmapLinear
|
||||
nmipmaps := 1
|
||||
if mipmap {
|
||||
// Flags required by ID3D11DeviceContext::GenerateMips.
|
||||
bindFlags |= d3d11.BIND_SHADER_RESOURCE | d3d11.BIND_RENDER_TARGET
|
||||
miscFlags |= d3d11.RESOURCE_MISC_GENERATE_MIPS
|
||||
dim := width
|
||||
if height > dim {
|
||||
dim = height
|
||||
}
|
||||
log2 := 32 - bits.LeadingZeros32(uint32(dim)) - 1
|
||||
nmipmaps = log2 + 1
|
||||
}
|
||||
tex, err := b.dev.CreateTexture2D(&d3d11.TEXTURE2D_DESC{
|
||||
Width: uint32(width),
|
||||
Height: uint32(height),
|
||||
MipLevels: 1,
|
||||
MipLevels: uint32(nmipmaps),
|
||||
ArraySize: 1,
|
||||
Format: d3dfmt,
|
||||
SampleDesc: d3d11.DXGI_SAMPLE_DESC{
|
||||
Count: 1,
|
||||
Quality: 0,
|
||||
},
|
||||
BindFlags: convBufferBinding(bindings),
|
||||
BindFlags: bindFlags,
|
||||
MiscFlags: miscFlags,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -247,6 +265,8 @@ func (b *Backend) NewTexture(format driver.TextureFormat, width, height int, min
|
||||
filter = d3d11.FILTER_MIN_MAG_MIP_POINT
|
||||
case minFilter == driver.FilterLinear && magFilter == driver.FilterLinear:
|
||||
filter = d3d11.FILTER_MIN_MAG_LINEAR_MIP_POINT
|
||||
case minFilter == driver.FilterLinearMipmapLinear && magFilter == driver.FilterLinear:
|
||||
filter = d3d11.FILTER_MIN_MAG_MIP_LINEAR
|
||||
default:
|
||||
d3d11.IUnknownRelease(unsafe.Pointer(tex), tex.Vtbl.Release)
|
||||
return nil, fmt.Errorf("unsupported texture filter combination %d, %d", minFilter, magFilter)
|
||||
@@ -325,7 +345,7 @@ func (b *Backend) NewTexture(format driver.TextureFormat, width, height int, min
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return &Texture{backend: b, format: d3dfmt, tex: tex, sampler: sampler, resView: resView, uaView: uaView, renderTarget: fbo, bindings: bindings, width: width, height: height}, nil
|
||||
return &Texture{backend: b, format: d3dfmt, tex: tex, sampler: sampler, resView: resView, uaView: uaView, renderTarget: fbo, bindings: bindings, width: width, height: height, mipmap: mipmap}, nil
|
||||
}
|
||||
|
||||
func (b *Backend) newInputLayout(vertexShader shader.Sources, layout []driver.InputDesc) (*d3d11.InputLayout, error) {
|
||||
@@ -609,6 +629,9 @@ func (t *Texture) Upload(offset, size image.Point, pixels []byte, stride int) {
|
||||
}
|
||||
res := (*d3d11.Resource)(unsafe.Pointer(t.tex))
|
||||
t.backend.ctx.UpdateSubresource(res, dst, uint32(stride), uint32(len(pixels)), pixels)
|
||||
if t.mipmap {
|
||||
t.backend.ctx.GenerateMips(t.resView)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Texture) Release() {
|
||||
|
||||
@@ -166,6 +166,7 @@ const (
|
||||
const (
|
||||
FilterNearest TextureFilter = iota
|
||||
FilterLinear
|
||||
FilterLinearMipmapLinear
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -13,10 +13,8 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -Werror -xobjective-c -fmodules -fobjc-arc
|
||||
#cgo LDFLAGS: -framework CoreGraphics
|
||||
|
||||
@import Metal;
|
||||
#cgo CFLAGS: -Werror -xobjective-c -fobjc-arc
|
||||
#cgo LDFLAGS: -framework CoreGraphics -framework Metal -framework Foundation
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <Metal/Metal.h>
|
||||
@@ -241,6 +239,14 @@ static void blitEncCopyBufferToTexture(CFTypeRef blitEncRef, CFTypeRef bufRef, C
|
||||
}
|
||||
}
|
||||
|
||||
static void blitEncGenerateMipmapsForTexture(CFTypeRef blitEncRef, CFTypeRef texRef) {
|
||||
@autoreleasepool {
|
||||
id<MTLBlitCommandEncoder> enc = (__bridge id<MTLBlitCommandEncoder>)blitEncRef;
|
||||
id<MTLTexture> tex = (__bridge id<MTLTexture>)texRef;
|
||||
[enc generateMipmapsForTexture: tex];
|
||||
}
|
||||
}
|
||||
|
||||
static void blitEncCopyTextureToBuffer(CFTypeRef blitEncRef, CFTypeRef texRef, CFTypeRef bufRef, NSUInteger offset, NSUInteger stride, NSUInteger length, MTLSize dims, MTLOrigin orig) {
|
||||
@autoreleasepool {
|
||||
id<MTLBlitCommandEncoder> enc = (__bridge id<MTLBlitCommandEncoder>)blitEncRef;
|
||||
@@ -271,25 +277,26 @@ static void blitEncCopyBufferToBuffer(CFTypeRef blitEncRef, CFTypeRef srcRef, CF
|
||||
}
|
||||
}
|
||||
|
||||
static CFTypeRef newTexture(CFTypeRef devRef, NSUInteger width, NSUInteger height, MTLPixelFormat format, MTLTextureUsage usage) {
|
||||
static CFTypeRef newTexture(CFTypeRef devRef, NSUInteger width, NSUInteger height, MTLPixelFormat format, MTLTextureUsage usage, int mipmapped) {
|
||||
@autoreleasepool {
|
||||
id<MTLDevice> dev = (__bridge id<MTLDevice>)devRef;
|
||||
MTLTextureDescriptor *mtlDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat: format
|
||||
width: width
|
||||
height: height
|
||||
mipmapped: NO];
|
||||
mipmapped: mipmapped ? YES : NO];
|
||||
mtlDesc.usage = usage;
|
||||
mtlDesc.storageMode = MTLStorageModePrivate;
|
||||
return CFBridgingRetain([dev newTextureWithDescriptor:mtlDesc]);
|
||||
}
|
||||
}
|
||||
|
||||
static CFTypeRef newSampler(CFTypeRef devRef, MTLSamplerMinMagFilter minFilter, MTLSamplerMinMagFilter magFilter) {
|
||||
static CFTypeRef newSampler(CFTypeRef devRef, MTLSamplerMinMagFilter minFilter, MTLSamplerMinMagFilter magFilter, MTLSamplerMipFilter mipFilter) {
|
||||
@autoreleasepool {
|
||||
id<MTLDevice> dev = (__bridge id<MTLDevice>)devRef;
|
||||
MTLSamplerDescriptor *desc = [MTLSamplerDescriptor new];
|
||||
desc.minFilter = minFilter;
|
||||
desc.magFilter = magFilter;
|
||||
desc.mipFilter = mipFilter;
|
||||
return CFBridgingRetain([dev newSamplerStateWithDescriptor:desc]);
|
||||
}
|
||||
}
|
||||
@@ -407,6 +414,7 @@ type Texture struct {
|
||||
sampler C.CFTypeRef
|
||||
width int
|
||||
height int
|
||||
mipmap bool
|
||||
foreign bool
|
||||
}
|
||||
|
||||
@@ -583,26 +591,33 @@ func (b *Backend) NewTexture(format driver.TextureFormat, width, height int, min
|
||||
if bindings&driver.BufferBindingShaderStorageWrite != 0 {
|
||||
usage |= C.MTLTextureUsageShaderWrite
|
||||
}
|
||||
tex := C.newTexture(b.dev, C.NSUInteger(width), C.NSUInteger(height), mformat, usage)
|
||||
min, mip := samplerFilterFor(minFilter)
|
||||
max, _ := samplerFilterFor(magFilter)
|
||||
mipmap := mip != C.MTLSamplerMipFilterNotMipmapped
|
||||
mipmapped := C.int(0)
|
||||
if mipmap {
|
||||
mipmapped = 1
|
||||
}
|
||||
tex := C.newTexture(b.dev, C.NSUInteger(width), C.NSUInteger(height), mformat, usage, mipmapped)
|
||||
if tex == 0 {
|
||||
return nil, errors.New("metal: [MTLDevice newTextureWithDescriptor:] failed")
|
||||
}
|
||||
min := samplerFilterFor(minFilter)
|
||||
max := samplerFilterFor(magFilter)
|
||||
s := C.newSampler(b.dev, min, max)
|
||||
s := C.newSampler(b.dev, min, max, mip)
|
||||
if s == 0 {
|
||||
C.CFRelease(tex)
|
||||
return nil, errors.New("metal: [MTLDevice newSamplerStateWithDescriptor:] failed")
|
||||
}
|
||||
return &Texture{backend: b, texture: tex, sampler: s, width: width, height: height}, nil
|
||||
return &Texture{backend: b, texture: tex, sampler: s, width: width, height: height, mipmap: mipmap}, nil
|
||||
}
|
||||
|
||||
func samplerFilterFor(f driver.TextureFilter) C.MTLSamplerMinMagFilter {
|
||||
func samplerFilterFor(f driver.TextureFilter) (C.MTLSamplerMinMagFilter, C.MTLSamplerMipFilter) {
|
||||
switch f {
|
||||
case driver.FilterNearest:
|
||||
return C.MTLSamplerMinMagFilterNearest
|
||||
return C.MTLSamplerMinMagFilterNearest, C.MTLSamplerMipFilterNotMipmapped
|
||||
case driver.FilterLinear:
|
||||
return C.MTLSamplerMinMagFilterLinear
|
||||
return C.MTLSamplerMinMagFilterLinear, C.MTLSamplerMipFilterNotMipmapped
|
||||
case driver.FilterLinearMipmapLinear:
|
||||
return C.MTLSamplerMinMagFilterLinear, C.MTLSamplerMipFilterLinear
|
||||
default:
|
||||
panic("invalid texture filter")
|
||||
}
|
||||
@@ -902,6 +917,9 @@ func (t *Texture) Upload(offset, size image.Point, pixels []byte, stride int) {
|
||||
depth: 1,
|
||||
}
|
||||
C.blitEncCopyBufferToTexture(enc, buf, t.texture, C.NSUInteger(off), C.NSUInteger(dstStride), C.NSUInteger(len(store)), msize, orig)
|
||||
if t.mipmap {
|
||||
C.blitEncGenerateMipmapsForTexture(enc, t.texture)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Texture) Release() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"math/bits"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -49,7 +50,6 @@ type Backend struct {
|
||||
type glState struct {
|
||||
drawFBO gl.Framebuffer
|
||||
readFBO gl.Framebuffer
|
||||
renderBuf gl.Renderbuffer
|
||||
vertAttribs [5]struct {
|
||||
obj gl.Buffer
|
||||
enabled bool
|
||||
@@ -106,6 +106,7 @@ type texture struct {
|
||||
triple textureTriple
|
||||
width int
|
||||
height int
|
||||
mipmap bool
|
||||
bindings driver.BufferBinding
|
||||
foreign bool
|
||||
}
|
||||
@@ -154,11 +155,6 @@ type uniformLocation struct {
|
||||
size int
|
||||
}
|
||||
|
||||
type inputLayout struct {
|
||||
inputs []shader.InputLocation
|
||||
layout []driver.InputDesc
|
||||
}
|
||||
|
||||
// textureTriple holds the type settings for
|
||||
// a TexImage2D call.
|
||||
type textureTriple struct {
|
||||
@@ -249,13 +245,17 @@ func (b *Backend) BeginFrame(target driver.RenderTarget, clear bool, viewport im
|
||||
b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, renderFBO)
|
||||
if b.gles {
|
||||
// If the output framebuffer is not in the sRGB colorspace already, emulate it.
|
||||
var fbEncoding int
|
||||
if !renderFBO.Valid() {
|
||||
fbEncoding = b.funcs.GetFramebufferAttachmentParameteri(gl.FRAMEBUFFER, gl.BACK, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING)
|
||||
} else {
|
||||
fbEncoding = b.funcs.GetFramebufferAttachmentParameteri(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING)
|
||||
fbSRGB := false
|
||||
if !b.gles || b.glver[0] > 2 {
|
||||
var fbEncoding int
|
||||
if !renderFBO.Valid() {
|
||||
fbEncoding = b.funcs.GetFramebufferAttachmentParameteri(gl.FRAMEBUFFER, gl.BACK, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING)
|
||||
} else {
|
||||
fbEncoding = b.funcs.GetFramebufferAttachmentParameteri(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING)
|
||||
}
|
||||
fbSRGB = fbEncoding != gl.LINEAR
|
||||
}
|
||||
if fbEncoding == gl.LINEAR && viewport != (image.Point{}) {
|
||||
if !fbSRGB && viewport != (image.Point{}) {
|
||||
if b.sRGBFBO == nil {
|
||||
sfbo, err := NewSRGBFBO(b.funcs, &b.glstate)
|
||||
if err != nil {
|
||||
@@ -307,14 +307,16 @@ func (b *Backend) EndFrame() {
|
||||
|
||||
func (b *Backend) queryState() glState {
|
||||
s := glState{
|
||||
prog: gl.Program(b.funcs.GetBinding(gl.CURRENT_PROGRAM)),
|
||||
arrayBuf: gl.Buffer(b.funcs.GetBinding(gl.ARRAY_BUFFER_BINDING)),
|
||||
elemBuf: gl.Buffer(b.funcs.GetBinding(gl.ELEMENT_ARRAY_BUFFER_BINDING)),
|
||||
drawFBO: gl.Framebuffer(b.funcs.GetBinding(gl.FRAMEBUFFER_BINDING)),
|
||||
clearColor: b.funcs.GetFloat4(gl.COLOR_CLEAR_VALUE),
|
||||
viewport: b.funcs.GetInteger4(gl.VIEWPORT),
|
||||
unpack_row_length: b.funcs.GetInteger(gl.UNPACK_ROW_LENGTH),
|
||||
pack_row_length: b.funcs.GetInteger(gl.PACK_ROW_LENGTH),
|
||||
prog: gl.Program(b.funcs.GetBinding(gl.CURRENT_PROGRAM)),
|
||||
arrayBuf: gl.Buffer(b.funcs.GetBinding(gl.ARRAY_BUFFER_BINDING)),
|
||||
elemBuf: gl.Buffer(b.funcs.GetBinding(gl.ELEMENT_ARRAY_BUFFER_BINDING)),
|
||||
drawFBO: gl.Framebuffer(b.funcs.GetBinding(gl.FRAMEBUFFER_BINDING)),
|
||||
clearColor: b.funcs.GetFloat4(gl.COLOR_CLEAR_VALUE),
|
||||
viewport: b.funcs.GetInteger4(gl.VIEWPORT),
|
||||
}
|
||||
if !b.gles || b.glver[0] > 2 {
|
||||
s.unpack_row_length = b.funcs.GetInteger(gl.UNPACK_ROW_LENGTH)
|
||||
s.pack_row_length = b.funcs.GetInteger(gl.PACK_ROW_LENGTH)
|
||||
}
|
||||
s.blend.enable = b.funcs.IsEnabled(gl.BLEND)
|
||||
s.blend.srcRGB = gl.Enum(b.funcs.GetInteger(gl.BLEND_SRC_RGB))
|
||||
@@ -426,13 +428,6 @@ func (s *glState) activeTexture(f *gl.Functions, unit gl.Enum) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *glState) bindRenderbuffer(f *gl.Functions, target gl.Enum, r gl.Renderbuffer) {
|
||||
if !r.Equal(s.renderBuf) {
|
||||
f.BindRenderbuffer(gl.RENDERBUFFER, r)
|
||||
s.renderBuf = r
|
||||
}
|
||||
}
|
||||
|
||||
func (s *glState) bindTexture(f *gl.Functions, unit int, t gl.Texture) {
|
||||
s.activeTexture(f, gl.TEXTURE0+gl.Enum(unit))
|
||||
if !t.Equal(s.texUnits.binds[unit]) {
|
||||
@@ -448,13 +443,6 @@ func (s *glState) bindVertexArray(f *gl.Functions, a gl.VertexArray) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *glState) deleteRenderbuffer(f *gl.Functions, r gl.Renderbuffer) {
|
||||
f.DeleteRenderbuffer(r)
|
||||
if r.Equal(s.renderBuf) {
|
||||
s.renderBuf = gl.Renderbuffer{}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *glState) deleteFramebuffer(f *gl.Functions, fbo gl.Framebuffer) {
|
||||
f.DeleteFramebuffer(fbo)
|
||||
if fbo.Equal(s.drawFBO) {
|
||||
@@ -715,13 +703,29 @@ func (b *Backend) NewTexture(format driver.TextureFormat, width, height int, min
|
||||
return nil, errors.New("unsupported texture format")
|
||||
}
|
||||
b.BindTexture(0, tex)
|
||||
b.funcs.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, toTexFilter(magFilter))
|
||||
b.funcs.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, toTexFilter(minFilter))
|
||||
min, mipmap := toTexFilter(minFilter)
|
||||
mag, _ := toTexFilter(magFilter)
|
||||
if b.gles && b.glver[0] < 3 {
|
||||
// OpenGL ES 2 only supports mipmaps for power-of-two textures.
|
||||
mipmap = false
|
||||
}
|
||||
tex.mipmap = mipmap
|
||||
b.funcs.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, mag)
|
||||
b.funcs.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, min)
|
||||
b.funcs.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
|
||||
b.funcs.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
|
||||
if b.gles && b.glver[0] >= 3 {
|
||||
if mipmap {
|
||||
nmipmaps := 1
|
||||
if mipmap {
|
||||
dim := width
|
||||
if height > dim {
|
||||
dim = height
|
||||
}
|
||||
log2 := 32 - bits.LeadingZeros32(uint32(dim)) - 1
|
||||
nmipmaps = log2 + 1
|
||||
}
|
||||
// Immutable textures are required for BindImageTexture, and can't hurt otherwise.
|
||||
b.funcs.TexStorage2D(gl.TEXTURE_2D, 1, tex.triple.internalFormat, width, height)
|
||||
b.funcs.TexStorage2D(gl.TEXTURE_2D, nmipmaps, tex.triple.internalFormat, width, height)
|
||||
} else {
|
||||
b.funcs.TexImage2D(gl.TEXTURE_2D, 0, tex.triple.internalFormat, width, height, tex.triple.format, tex.triple.typ)
|
||||
}
|
||||
@@ -1156,17 +1160,25 @@ func (b *Backend) CopyTexture(dst driver.Texture, dstOrigin image.Point, src dri
|
||||
func (t *texture) ReadPixels(src image.Rectangle, pixels []byte, stride int) error {
|
||||
glErr(t.backend.funcs)
|
||||
t.backend.glstate.bindFramebuffer(t.backend.funcs, gl.FRAMEBUFFER, t.ensureFBO())
|
||||
if len(pixels) < src.Dx()*src.Dy()*4 {
|
||||
w, h := src.Dx(), src.Dy()
|
||||
if len(pixels) < w*h*4 {
|
||||
return errors.New("unexpected RGBA size")
|
||||
}
|
||||
w, h := src.Dx(), src.Dy()
|
||||
// WebGL 1 doesn't support PACK_ROW_LENGTH != 0. Avoid it if possible.
|
||||
// OpenGL ES 2 doesn't support PACK_ROW_LENGTH != 0. Avoid it if possible.
|
||||
rowLen := 0
|
||||
if n := stride / 4; n != w {
|
||||
rowLen = n
|
||||
}
|
||||
t.backend.glstate.pixelStorei(t.backend.funcs, gl.PACK_ROW_LENGTH, rowLen)
|
||||
t.backend.funcs.ReadPixels(src.Min.X, src.Min.Y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels)
|
||||
if rowLen == 0 || t.backend.glver[0] > 2 {
|
||||
t.backend.glstate.pixelStorei(t.backend.funcs, gl.PACK_ROW_LENGTH, rowLen)
|
||||
t.backend.funcs.ReadPixels(src.Min.X, src.Min.Y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels)
|
||||
} else {
|
||||
tmp := make([]byte, w*h*4)
|
||||
t.backend.funcs.ReadPixels(src.Min.X, src.Min.Y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, tmp)
|
||||
for y := 0; y < h; y++ {
|
||||
copy(pixels[y*stride:], tmp[y*w*4:])
|
||||
}
|
||||
}
|
||||
return glErr(t.backend.funcs)
|
||||
}
|
||||
|
||||
@@ -1207,12 +1219,14 @@ func (p *pipeline) Release() {
|
||||
*p = pipeline{}
|
||||
}
|
||||
|
||||
func toTexFilter(f driver.TextureFilter) int {
|
||||
func toTexFilter(f driver.TextureFilter) (int, bool) {
|
||||
switch f {
|
||||
case driver.FilterNearest:
|
||||
return gl.NEAREST
|
||||
return gl.NEAREST, false
|
||||
case driver.FilterLinear:
|
||||
return gl.LINEAR
|
||||
return gl.LINEAR, false
|
||||
case driver.FilterLinearMipmapLinear:
|
||||
return gl.LINEAR_MIPMAP_LINEAR, true
|
||||
default:
|
||||
panic("unsupported texture filter")
|
||||
}
|
||||
@@ -1246,6 +1260,9 @@ func (t *texture) Upload(offset, size image.Point, pixels []byte, stride int) {
|
||||
}
|
||||
t.backend.glstate.pixelStorei(t.backend.funcs, gl.UNPACK_ROW_LENGTH, rowLen)
|
||||
t.backend.funcs.TexSubImage2D(gl.TEXTURE_2D, 0, offset.X, offset.Y, size.X, size.Y, t.triple.format, t.triple.typ, pixels)
|
||||
if t.mipmap {
|
||||
t.backend.funcs.GenerateMipmap(gl.TEXTURE_2D)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *timer) Begin() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/op/paint"
|
||||
"gioui.org/text"
|
||||
"gioui.org/widget/material"
|
||||
)
|
||||
|
||||
@@ -33,7 +34,8 @@ func setupBenchmark(b *testing.B) (layout.Context, *headless.Window, *material.T
|
||||
Ops: ops,
|
||||
Constraints: layout.Exact(sz),
|
||||
}
|
||||
th := material.NewTheme(gofont.Collection())
|
||||
th := material.NewTheme()
|
||||
th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection()))
|
||||
return gtx, w, th
|
||||
}
|
||||
|
||||
@@ -86,7 +88,7 @@ func BenchmarkDrawUI(b *testing.B) {
|
||||
resetOps(gtx)
|
||||
|
||||
off := float32(math.Mod(float64(i)/10, 10))
|
||||
t := op.Offset(f32.Pt(off, off)).Push(gtx.Ops)
|
||||
t := op.Affine(f32.Affine2D{}.Offset(f32.Pt(off, off))).Push(gtx.Ops)
|
||||
|
||||
drawCore(gtx, th)
|
||||
|
||||
@@ -157,13 +159,13 @@ func Benchmark1000CirclesInstanced(b *testing.B) {
|
||||
func draw1000Circles(gtx layout.Context) {
|
||||
ops := gtx.Ops
|
||||
for x := 0; x < 100; x++ {
|
||||
op.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
op.Offset(image.Pt(x*10, 0)).Add(ops)
|
||||
for y := 0; y < 10; y++ {
|
||||
paint.FillShape(ops,
|
||||
color.NRGBA{R: 100 + uint8(x), G: 100 + uint8(y), B: 100, A: 120},
|
||||
clip.RRect{Rect: f32.Rect(0, 0, 10, 10), NE: 5, SE: 5, SW: 5, NW: 5}.Op(ops),
|
||||
clip.RRect{Rect: image.Rect(0, 0, 10, 10), NE: 5, SE: 5, SW: 5, NW: 5}.Op(ops),
|
||||
)
|
||||
op.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
op.Offset(image.Pt(0, 100)).Add(ops)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,17 +174,17 @@ func draw1000CirclesInstanced(gtx layout.Context) {
|
||||
ops := gtx.Ops
|
||||
|
||||
r := op.Record(ops)
|
||||
cl := clip.RRect{Rect: f32.Rect(0, 0, 10, 10), NE: 5, SE: 5, SW: 5, NW: 5}.Push(ops)
|
||||
cl := clip.RRect{Rect: image.Rect(0, 0, 10, 10), NE: 5, SE: 5, SW: 5, NW: 5}.Push(ops)
|
||||
paint.PaintOp{}.Add(ops)
|
||||
cl.Pop()
|
||||
c := r.Stop()
|
||||
|
||||
for x := 0; x < 100; x++ {
|
||||
op.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
op.Offset(image.Pt(x*10, 0)).Add(ops)
|
||||
for y := 0; y < 10; y++ {
|
||||
paint.ColorOp{Color: color.NRGBA{R: 100 + uint8(x), G: 100 + uint8(y), B: 100, A: 120}}.Add(ops)
|
||||
c.Add(ops)
|
||||
op.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
op.Offset(image.Pt(0, 100)).Add(ops)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,13 +205,13 @@ func drawIndividualShapes(gtx layout.Context, th *material.Theme) chan op.CallOp
|
||||
ops := &op1
|
||||
c := op.Record(ops)
|
||||
for x := 0; x < 9; x++ {
|
||||
op.Offset(f32.Pt(float32(x*50), 0)).Add(ops)
|
||||
op.Offset(image.Pt(x*50, 0)).Add(ops)
|
||||
for y := 0; y < 9; y++ {
|
||||
paint.FillShape(ops,
|
||||
color.NRGBA{R: 100 + uint8(x), G: 100 + uint8(y), B: 100, A: 120},
|
||||
clip.RRect{Rect: f32.Rect(0, 0, 25, 25), NE: 10, SE: 10, SW: 10, NW: 10}.Op(ops),
|
||||
clip.RRect{Rect: image.Rect(0, 0, 25, 25), NE: 10, SE: 10, SW: 10, NW: 10}.Op(ops),
|
||||
)
|
||||
op.Offset(f32.Pt(0, float32(50))).Add(ops)
|
||||
op.Offset(image.Pt(0, 50)).Add(ops)
|
||||
}
|
||||
}
|
||||
c1 <- c.Stop()
|
||||
@@ -224,7 +226,7 @@ func drawShapeInstances(gtx layout.Context, th *material.Theme) chan op.CallOp {
|
||||
co := op.Record(ops)
|
||||
|
||||
r := op.Record(ops)
|
||||
cl := clip.RRect{Rect: f32.Rect(0, 0, 25, 25), NE: 10, SE: 10, SW: 10, NW: 10}.Push(ops)
|
||||
cl := clip.RRect{Rect: image.Rect(0, 0, 25, 25), NE: 10, SE: 10, SW: 10, NW: 10}.Push(ops)
|
||||
paint.PaintOp{}.Add(ops)
|
||||
cl.Pop()
|
||||
c := r.Stop()
|
||||
@@ -233,7 +235,7 @@ func drawShapeInstances(gtx layout.Context, th *material.Theme) chan op.CallOp {
|
||||
rad := float32(0)
|
||||
for x := 0; x < 20; x++ {
|
||||
for y := 0; y < 20; y++ {
|
||||
t := op.Offset(f32.Pt(float32(x*50+25), float32(y*50+25))).Push(ops)
|
||||
t := op.Offset(image.Pt(x*50+25, y*50+25)).Push(ops)
|
||||
c.Add(ops)
|
||||
t.Pop()
|
||||
rad += math.Pi * 2 / 400
|
||||
@@ -253,7 +255,7 @@ func drawText(gtx layout.Context, th *material.Theme) chan op.CallOp {
|
||||
txt := material.H6(th, "")
|
||||
for x := 0; x < 40; x++ {
|
||||
txt.Text = textRows[x]
|
||||
t := op.Offset(f32.Pt(float32(0), float32(24*x))).Push(ops)
|
||||
t := op.Offset(image.Pt(0, 24*x)).Push(ops)
|
||||
gtx.Ops = ops
|
||||
txt.Layout(gtx)
|
||||
t.Pop()
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestPaintRect(t *testing.T) {
|
||||
|
||||
func TestPaintClippedRect(t *testing.T) {
|
||||
run(t, func(o *op.Ops) {
|
||||
defer clip.RRect{Rect: f32.Rect(25, 25, 60, 60)}.Push(o).Pop()
|
||||
defer clip.RRect{Rect: image.Rect(25, 25, 60, 60)}.Push(o).Pop()
|
||||
paint.FillShape(o, red, clip.Rect(image.Rect(0, 0, 50, 50)).Op())
|
||||
}, func(r result) {
|
||||
r.expect(0, 0, transparent)
|
||||
@@ -42,8 +42,8 @@ func TestPaintClippedRect(t *testing.T) {
|
||||
|
||||
func TestPaintClippedCircle(t *testing.T) {
|
||||
run(t, func(o *op.Ops) {
|
||||
r := float32(10)
|
||||
defer clip.RRect{Rect: f32.Rect(20, 20, 40, 40), SE: r, SW: r, NW: r, NE: r}.Push(o).Pop()
|
||||
const r = 10
|
||||
defer clip.RRect{Rect: image.Rect(20, 20, 40, 40), SE: r, SW: r, NW: r, NE: r}.Push(o).Pop()
|
||||
defer clip.Rect(image.Rect(0, 0, 30, 50)).Push(o).Pop()
|
||||
paint.Fill(o, red)
|
||||
}, func(r result) {
|
||||
@@ -124,13 +124,13 @@ func TestPaintTexture(t *testing.T) {
|
||||
func TestTexturedStrokeClipped(t *testing.T) {
|
||||
run(t, func(o *op.Ops) {
|
||||
smallSquares.Add(o)
|
||||
defer op.Offset(f32.Pt(50, 50)).Push(o).Pop()
|
||||
defer op.Offset(image.Pt(50, 50)).Push(o).Pop()
|
||||
defer clip.Stroke{
|
||||
Path: clip.RRect{Rect: f32.Rect(0, 0, 30, 30)}.Path(o),
|
||||
Path: clip.RRect{Rect: image.Rect(0, 0, 30, 30)}.Path(o),
|
||||
Width: 10,
|
||||
}.Op().Push(o).Pop()
|
||||
defer clip.RRect{Rect: f32.Rect(-30, -30, 60, 60)}.Push(o).Pop()
|
||||
defer op.Offset(f32.Pt(-10, -10)).Push(o).Pop()
|
||||
defer clip.RRect{Rect: image.Rect(-30, -30, 60, 60)}.Push(o).Pop()
|
||||
defer op.Offset(image.Pt(-10, -10)).Push(o).Pop()
|
||||
paint.PaintOp{}.Add(o)
|
||||
}, func(r result) {
|
||||
})
|
||||
@@ -139,12 +139,12 @@ func TestTexturedStrokeClipped(t *testing.T) {
|
||||
func TestTexturedStroke(t *testing.T) {
|
||||
run(t, func(o *op.Ops) {
|
||||
smallSquares.Add(o)
|
||||
defer op.Offset(f32.Pt(50, 50)).Push(o).Pop()
|
||||
defer op.Offset(image.Pt(50, 50)).Push(o).Pop()
|
||||
defer clip.Stroke{
|
||||
Path: clip.RRect{Rect: f32.Rect(0, 0, 30, 30)}.Path(o),
|
||||
Path: clip.RRect{Rect: image.Rect(0, 0, 30, 30)}.Path(o),
|
||||
Width: 10,
|
||||
}.Op().Push(o).Pop()
|
||||
defer op.Offset(f32.Pt(-10, -10)).Push(o).Pop()
|
||||
defer op.Offset(image.Pt(-10, -10)).Push(o).Pop()
|
||||
paint.PaintOp{}.Add(o)
|
||||
}, func(r result) {
|
||||
})
|
||||
@@ -153,7 +153,7 @@ func TestTexturedStroke(t *testing.T) {
|
||||
func TestPaintClippedTexture(t *testing.T) {
|
||||
run(t, func(o *op.Ops) {
|
||||
squares.Add(o)
|
||||
defer clip.RRect{Rect: f32.Rect(0, 0, 40, 40)}.Push(o).Pop()
|
||||
defer clip.RRect{Rect: image.Rect(0, 0, 40, 40)}.Push(o).Pop()
|
||||
defer scale(80.0/512, 80.0/512).Push(o).Pop()
|
||||
paint.PaintOp{}.Add(o)
|
||||
}, func(r result) {
|
||||
@@ -163,6 +163,8 @@ func TestPaintClippedTexture(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStrokedPathZeroWidth(t *testing.T) {
|
||||
t.Skip("test broken, see issue 479")
|
||||
|
||||
run(t, func(o *op.Ops) {
|
||||
{
|
||||
p := new(clip.Path)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 569 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user