internal/graphicsdriver: replace Pixels with ReadPixels

Now preparing a byte slice is the caller's responsibility.
This commit is contained in:
Hajime Hoshi
2022-02-27 17:41:19 +09:00
parent 1cb7633ff6
commit b22309a0e5
9 changed files with 33 additions and 35 deletions

View File

@@ -236,7 +236,7 @@ func (c *context) bindFramebufferImpl(f framebufferNative) {
gl.bindFramebuffer.Invoke(gles.FRAMEBUFFER, js.Value(f))
}
func (c *context) framebufferPixels(f *framebuffer, width, height int) []byte {
func (c *context) framebufferPixels(buf []byte, f *framebuffer, width, height int) {
gl := c.gl
c.bindFramebuffer(f.native)
@@ -244,8 +244,7 @@ func (c *context) framebufferPixels(f *framebuffer, width, height int) []byte {
l := 4 * width * height
p := jsutil.TemporaryUint8ArrayFromUint8Slice(l, nil)
gl.readPixels.Invoke(0, 0, width, height, gles.RGBA, gles.UNSIGNED_BYTE, p)
return uint8ArrayToSlice(p, l)
copy(buf, uint8ArrayToSlice(p, l))
}
func (c *context) framebufferPixelsToBuffer(f *framebuffer, buffer buffer, width, height int) {