mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
gpu,gpu/internal: support variable strides in ReadPixels
It saves a roundtrip to scratch memory when the CPU fallback renderer downloads rendered materials. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -136,7 +136,7 @@ type Buffer interface {
|
||||
type Framebuffer interface {
|
||||
RenderTarget
|
||||
Release()
|
||||
ReadPixels(src image.Rectangle, pixels []byte) error
|
||||
ReadPixels(src image.Rectangle, pixels []byte, stride int) error
|
||||
}
|
||||
|
||||
type Timer interface {
|
||||
@@ -212,7 +212,7 @@ func (f Features) Has(feats Features) bool {
|
||||
|
||||
func DownloadImage(d Device, f Framebuffer, r image.Rectangle) (*image.RGBA, error) {
|
||||
img := image.NewRGBA(r)
|
||||
if err := f.ReadPixels(r, img.Pix); err != nil {
|
||||
if err := f.ReadPixels(r, img.Pix, img.Stride); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if d.Caps().BottomLeftOrigin {
|
||||
|
||||
Reference in New Issue
Block a user