app/headless: add lower-level backend tests

Add a series of low level gpu.Backend tests to assure the correct behaviour of
Backends. The immediate use is debugging of the Direct3D port, in the future
for developing new backends.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-23 11:38:02 +01:00
parent 55c74d3159
commit 7ff2f60412
8 changed files with 441 additions and 10 deletions
+8 -3
View File
@@ -127,18 +127,23 @@ func (w *Window) Screenshot() (*image.RGBA, error) {
if err != nil {
return nil, err
}
flipImageY(img)
return img, nil
}
func flipImageY(img *image.RGBA) {
// Flip image in y-direction. OpenGL's origin is in the lower
// left corner.
row := make([]uint8, img.Stride)
for y := 0; y < w.size.Y/2; y++ {
y1 := w.size.Y - y - 1
sy := img.Bounds().Dy()
for y := 0; y < sy/2; y++ {
y1 := sy - y - 1
dest := img.PixOffset(0, y1)
src := img.PixOffset(0, y)
copy(row, img.Pix[dest:])
copy(img.Pix[dest:], img.Pix[src:src+len(row)])
copy(img.Pix[src:], row)
}
return img, nil
}
func contextDo(ctx context, f func() error) error {