main bcc9a45

renderer_image_gpu_test.go RawHistoryFolder

1//go:build linux
2
3package ui
4
5import (
6	"image"
7	"image/color"
8	"testing"
9	"time"
10)
11
12// An image added in a frame that uploads no glyph is still copied to the GPU:
13// before the fix it sampled an uninitialized texture and drew nothing. A first
14// text-only frame caches the glyphs and initializes the atlas, so the second
15// frame has nothing to upload but the image.
16func TestRendererGPUImageWithoutNewGlyphs(t *testing.T) {
17	r, tg := gpuRenderer(t)
18	src := image.NewNRGBA(image.Rect(0, 0, 40, 30))
19	for y := range 30 {
20		for x := range 40 {
21			src.SetNRGBA(x, y, color.NRGBA{R: uint8(x * 6), G: uint8(y * 8), B: 0x80, A: 0xff})
22		}
23	}
24	show := false
25	view := func(f *Frame, _ *struct{}) {
26		st := f.Root().Stack()
27		if show {
28			st.Box(Inline("overflow:hidden")).Rect(0, 0, 40, 30).Image(src, Inline("width:100%;height:100%"))
29		}
30		st.Box().Rect(0, 0, 1, 1).Text("x")
31	}
32	r.Resize(40, 30, 1)
33	var out Output
34	var m struct{}
35	ok, err := r.Render(&out, &m, view)
36	if err != nil || !ok {
37		t.Fatalf("text frame: ok=%v err=%v", ok, err)
38	}
39	signalRelease(t, tg, &out)
40	if !readable(t, out.ReleaseFD, time.Second) {
41		t.Fatal("text frame not released")
42	}
43	if err = r.Released(out.Buffer); err != nil {
44		t.Fatal(err)
45	}
46	show = true
47	r.Invalidate()
48	if ok, err = r.Render(&out, &m, view); err != nil || !ok {
49		t.Fatalf("image frame: ok=%v err=%v", ok, err)
50	}
51	img, err := tg.Readback(out.Buffer)
52	if err != nil {
53		t.Fatal(err)
54	}
55	for _, p := range []image.Point{{5, 5}, {20, 15}, {39, 29}} {
56		want, got := src.NRGBAAt(p.X, p.Y), img.NRGBAAt(p.X, p.Y)
57		if got.R != want.R || got.G != want.G || got.B != want.B {
58			t.Fatalf("pixel %v = %+v, want %+v", p, got, want)
59		}
60	}
61}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 12

↑↓ moveenter openesc close