v0.1.0 d9218d6

targets_test.go RawHistoryFolder

1package vulkan
2
3import (
4	"image/color"
5	"testing"
6
7	"github.com/bnema/neferwl/internal/ports"
8)
9
10// Frames drawn into exported targets reach their dmabufs: another renderer
11// importing a target (as KMS scans it out) sees the frame, and readback
12// reads the target drawn last.
13func TestExportTargets(t *testing.T) {
14	r, err := New(64, 32)
15	if err != nil {
16		t.Skipf("Vulkan unavailable: %v", err)
17	}
18	defer r.Close()
19	bufs, err := r.ExportTargets(2, nil)
20	if err != nil {
21		t.Skipf("no exportable targets: %v", err)
22	}
23	defer func() {
24		for _, b := range bufs {
25			b.Planes[0].File.Close()
26		}
27	}()
28	if len(bufs) != 2 || bufs[0].Width != 64 || bufs[0].Format != fourccXRGB || bufs[0].Planes[0].Stride < 64*4 {
29		t.Fatalf("targets %+v", bufs)
30	}
31	colors := []string{"#ff0000", "#0000ff"}
32	for i, c := range colors {
33		r.UseTarget(i)
34		if err := render(r, ports.Scene{Background: c}, nil); err != nil {
35			t.Fatal(err)
36		}
37	}
38	if got := r.Pixels().At(3, 3); got != (color.RGBA{0, 0, 255, 255}) {
39		t.Fatalf("readback of the last target %v", got)
40	}
41	// Import target 0 as a client buffer, like the display would.
42	viewer, err := New(64, 32)
43	if err != nil {
44		t.Fatal(err)
45	}
46	defer viewer.Close()
47	b := bufs[0]
48	b.ID = 1
49	importable := false
50	for _, f := range viewer.DMABuf().Formats {
51		importable = importable || f.Format == b.Format && f.Modifier == b.Modifier
52	}
53	if !importable {
54		t.Skipf("modifier %#x not importable", b.Modifier)
55	}
56	scene := ports.Scene{Background: "#000000", Windows: []ports.SceneWindow{{ID: 1, Rect: ports.Rect{W: 64, H: 32}}}}
57	contents := map[ports.WindowID]ports.SurfaceContent{1: {ID: 1, Width: 64, Height: 32, Opaque: true, DMABuf: &b}}
58	if err := render(viewer, scene, contents); err != nil {
59		t.Fatal(err)
60	}
61	if got := viewer.Pixels().At(10, 10); got != (color.RGBA{255, 0, 0, 255}) {
62		t.Fatalf("target 0 as seen by the display %v", got)
63	}
64}

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 26

Tags 10

↑↓ moveenter openesc close