ui/app: (wasm) replace TypedArrayOf with the CopyBytes* API

syscall/js.TypedArrayOf is going away in Go 1.13 and is replaced by
the CopyBytesToGo, CopyBytesToJS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-05-23 10:17:15 +02:00
parent edec032ae6
commit c3ea85801c
2 changed files with 37 additions and 10 deletions
+2 -6
View File
@@ -245,9 +245,7 @@ func (f *Functions) RenderbufferStorage(target, internalformat Enum, width, heig
func (f *Functions) ReadPixels(x, y, width, height int, format, ty Enum, data []byte) {
f.resizeByteBuffer(len(data))
f.Ctx.Call("readPixels", x, y, width, height, int(format), int(ty), f.byteBuf)
sub := f.byteBuf.Call("subarray", 0, len(data))
d := js.TypedArrayOf(data)
d.Call("set", sub)
js.CopyBytesToGo(data, f.byteBuf)
}
func (f *Functions) Scissor(x, y, width, height int32) {
f.Ctx.Call("scissor", x, y, width, height)
@@ -294,9 +292,7 @@ func (f *Functions) byteArrayOf(data []byte) js.Value {
return js.Null()
}
f.resizeByteBuffer(len(data))
s := js.TypedArrayOf(data)
f.byteBuf.Call("set", s)
s.Release()
js.CopyBytesToJS(f.byteBuf, data)
return f.byteBuf
}