internal/restorable: integrate ReadPixels into internal/atlas

Updates #805
This commit is contained in:
Hajime Hoshi 2024-01-13 18:12:32 +09:00
parent c5d0ec3de7
commit e804f9e58c
2 changed files with 9 additions and 14 deletions

View File

@ -546,8 +546,15 @@ func (i *Image) readPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte
return nil return nil
} }
r := i.regionWithPadding() if err := i.backend.restorable.Image.ReadPixels(graphicsDriver, []graphicsdriver.PixelsArgs{
return i.backend.restorable.ReadPixels(graphicsDriver, pixels, region.Add(r.Min)) {
Pixels: pixels,
Region: region.Add(i.regionWithPadding().Min),
},
}); err != nil {
return err
}
return nil
} }
// Deallocate deallocates the internal state. // Deallocate deallocates the internal state.

View File

@ -144,15 +144,3 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
} }
i.Image.DrawTriangles(imgs, vertices, indices, blend, dstRegion, srcRegions, shader.shader, uniforms, fillRule) i.Image.DrawTriangles(imgs, vertices, indices, blend, dstRegion, srcRegions, shader.shader, uniforms, fillRule)
} }
func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte, region image.Rectangle) error {
if err := i.Image.ReadPixels(graphicsDriver, []graphicsdriver.PixelsArgs{
{
Pixels: pixels,
Region: region,
},
}); err != nil {
return err
}
return nil
}