feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
+148
@@ -0,0 +1,148 @@
|
||||
//go:build windows
|
||||
|
||||
package d3d11
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/internal/gpu/gputest"
|
||||
"github.com/egoist/mygo/internal/scene"
|
||||
)
|
||||
|
||||
// changingScenes calls frame with the steps of random scenes changing a
|
||||
// little at a time, over an opaque color and a translucent one, each with
|
||||
// a renderer drawing in part and one drawing whole, both new: each scene
|
||||
// has an atlas of its own.
|
||||
func changingScenes(t *testing.T, seeds uint64, frame func(r, whole *Renderer, s *scene.Scene, step int, what string)) {
|
||||
for seed := range seeds {
|
||||
m := gputest.NewChanging(seed)
|
||||
if seed%3 == 2 {
|
||||
m.Clear = scene.Color{R: 20, G: 40, B: 200, A: 77}
|
||||
}
|
||||
s := m.Scene()
|
||||
r, err := New(hiddenWindow(t, s.Width, s.Height))
|
||||
if err != nil {
|
||||
t.Skip("no Direct3D 11:", err)
|
||||
}
|
||||
if r.ctx1 == 0 {
|
||||
r.Release()
|
||||
t.Skip("no Direct3D 11.1")
|
||||
}
|
||||
whole, err := New(hiddenWindow(t, s.Width, s.Height))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
whole.ctx1 = 0 // never in part
|
||||
// No subtests: the windows take their messages on this thread.
|
||||
for step := range 30 {
|
||||
what := fmt.Sprintf("seed %d", seed)
|
||||
if step > 0 {
|
||||
what += ", " + m.Change(s)
|
||||
}
|
||||
frame(r, whole, s, step, what)
|
||||
}
|
||||
r.Release()
|
||||
whole.Release()
|
||||
}
|
||||
}
|
||||
|
||||
// TestPartialFramesMatchWhole draws random scenes changing a little at a
|
||||
// time into a back buffer that keeps what was drawn, as DXGI completes
|
||||
// one presented in part with the last frame, each frame only where it
|
||||
// changed, and requires the bytes of each frame drawn whole.
|
||||
func TestPartialFramesMatchWhole(t *testing.T) {
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
seeds := uint64(20)
|
||||
if testing.Short() {
|
||||
seeds = 5
|
||||
}
|
||||
frames, partial := 0, 0
|
||||
changingScenes(t, seeds, func(r, whole *Renderer, s *scene.Scene, step int, what string) {
|
||||
drawn, err := r.drawFrame(s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.held = drawn || r.held // as presenting it does
|
||||
frames++
|
||||
part := "whole"
|
||||
switch r.redrew {
|
||||
case redrewPart:
|
||||
partial++
|
||||
part = r.part.String()
|
||||
case redrewNothing:
|
||||
part = "nothing"
|
||||
}
|
||||
got, _ := r.readBack(t)
|
||||
if err := whole.draw(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want, _ := whole.readBack(t)
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Fatalf("step %d (%s), redrew %s: %d bytes differ from the frame drawn whole", step, what, part, differing(got, want))
|
||||
}
|
||||
})
|
||||
if partial < frames/3 {
|
||||
t.Errorf("%d frames of %d drawn in part", partial, frames)
|
||||
}
|
||||
}
|
||||
|
||||
// TestPresentsInPart presents random scenes changing a little at a time,
|
||||
// each drawn only where it changed, with that as the dirty rectangle, in a
|
||||
// window that shows: DXGI copies the rest from the last frame into the
|
||||
// buffer presented. Once the swap chain flipped again, that buffer, back,
|
||||
// must hold the frame drawn whole.
|
||||
func TestPresentsInPart(t *testing.T) {
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
seeds := uint64(6)
|
||||
if testing.Short() {
|
||||
seeds = 2
|
||||
}
|
||||
// presented holds the frames presented, drawn whole.
|
||||
var presented [][]byte
|
||||
partial := 0
|
||||
changingScenes(t, seeds, func(r, whole *Renderer, s *scene.Scene, step int, what string) {
|
||||
if step == 0 {
|
||||
const swShowNoActivate = 4
|
||||
user32.NewProc("ShowWindow").Call(r.hwnd, swShowNoActivate)
|
||||
presented = presented[:0]
|
||||
}
|
||||
if err := r.Render(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
switch r.redrew {
|
||||
case redrewNothing:
|
||||
return // nothing presented: the swap chain did not flip
|
||||
case redrewPart:
|
||||
partial++
|
||||
}
|
||||
if err := whole.draw(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want, _ := whole.readBack(t)
|
||||
presented = append(presented, want)
|
||||
// The back buffer now holds the frame presented before, as DXGI
|
||||
// completed it.
|
||||
if n := len(presented); n >= 2 {
|
||||
if got, _ := r.readBack(t); !bytes.Equal(got, presented[n-2]) {
|
||||
t.Fatalf("step %d (%s): the frame before, presented, differs in %d bytes from it drawn whole", step, what, differing(got, presented[n-2]))
|
||||
}
|
||||
}
|
||||
})
|
||||
if partial == 0 {
|
||||
t.Error("no frame was presented in part")
|
||||
}
|
||||
}
|
||||
|
||||
func differing(a, b []byte) (n int) {
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
n++
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
Reference in new issue
Block a user