mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user