text stringlengths 0 1.47k |
|---|
for i, c := range bars { |
draw.Draw(img, image.Rect(i*bw, h-60, (i+1)*bw, h), image.NewUniform(c), image.Point{}, draw.Src) |
} |
frame(img, img.Bounds().Inset(8), 4, amber) |
text(img, "TECHO5", 40, 100, 8, amber) |
text(img, "red green blue white amber", 40, 210, 3, ink) |
text(img, time.Now().Format("15:04:05"), 40, 290, 6, ink) |
} |
frameN, fenceTimeouts := 0, 0 |
post := func() { |
b := bufs[frameN%len(bufs)] |
frameN++ |
if err := b.Wait(100 * time.Millisecond); err != nil { |
fenceTimeouts++ |
} |
blit(b, img) |
if err := d.Post(*layer, b, format); err != nil { |
fatal("post: %v", err) |
} |
} |
post() |
fmt.Println("posted") |
if *regs { |
time.Sleep(100 * time.Millisecond) |
dumpRegs("after post") |
} |
if *hold > 0 { |
deadline := time.Now().Add(*hold) |
for time.Now().Before(deadline) { |
time.Sleep(*interval) |
if *fill == "" { |
draw.Draw(img, image.Rect(40, 250, w-40, 380), image.NewUniform(bg), image.Point{}, draw.Src) |
text(img, time.Now().Format("15:04:05.000"), 40, 290, 6, ink) |
} |
post() |
} |
fmt.Printf("posted %d frames, %d release fences never signaled\n", frameN, fenceTimeouts) |
} |
} |
// blit writes the landscape image onto the portrait buffer rotated 90 degrees clockwise: |
// landscape (x, y) lands at panel (panelW-1-y, x). Bytes are B, G, R, A (BGRA8888). |
func blit(b *mtkdisp.Buffer, img *image.RGBA) { |
line := b.Pitch * 4 |
for y := 0; y < img.Rect.Dy(); y++ { |
for x := 0; x < img.Rect.Dx(); x++ { |
i := img.PixOffset(x, y) |
px, py := b.Width-1-y, x |
off := py*line + px*4 |
b.Mem[off+0] = img.Pix[i+2] // B |
b.Mem[off+1] = img.Pix[i+1] // G |
b.Mem[off+2] = img.Pix[i+0] // R |
b.Mem[off+3] = img.Pix[i+3] // A |
} |
} |
} |
func frame(img *image.RGBA, r image.Rectangle, t int, c color.RGBA) { |
u := image.NewUniform(c) |
draw.Draw(img, image.Rect(r.Min.X, r.Min.Y, r.Max.X, r.Min.Y+t), u, image.Point{}, draw.Src) |
draw.Draw(img, image.Rect(r.Min.X, r.Max.Y-t, r.Max.X, r.Max.Y), u, image.Point{}, draw.Src) |
draw.Draw(img, image.Rect(r.Min.X, r.Min.Y, r.Min.X+t, r.Max.Y), u, image.Point{}, draw.Src) |
draw.Draw(img, image.Rect(r.Max.X-t, r.Min.Y, r.Max.X, r.Max.Y), u, image.Point{}, draw.Src) |
} |
// text draws with the built-in 7x13 face scaled by an integer factor: crude, and readable from |
// across a desk. A real face comes with the display layer proper. |
func text(img *image.RGBA, s string, x, y, scale int, c color.RGBA) { |
small := image.NewRGBA(image.Rect(0, 0, 7*len(s)+2, 14)) |
d := &font.Drawer{Dst: small, Src: image.NewUniform(c), Face: basicfont.Face7x13, Dot: fixed.P(1, 11)} |
d.DrawString(s) |
for sy := 0; sy < small.Rect.Dy(); sy++ { |
for sx := 0; sx < small.Rect.Dx(); sx++ { |
if small.Pix[small.PixOffset(sx, sy)+3] == 0 { |
continue |
} |
draw.Draw(img, image.Rect(x+sx*scale, y+sy*scale, x+(sx+1)*scale, y+(sy+1)*scale), image.NewUniform(c), image.Point{}, draw.Src) |
} |
} |
} |
func fatal(format string, a ...any) { |
fmt.Fprintf(os.Stderr, "dispprobe: "+format+"\n", a...) |
os.Exit(1) |
} |
# ===== file: cmd/fbprobe/bench_test.go ===== |
//go:build linux |
package main |
import ( |
"encoding/binary" |
"image/color" |
"strings" |
"testing" |
"time" |
) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.