[HTML5] Rename heapCopy to heapSlice.
New heapCopy function copies a TypedArray to the heap.
This commit is contained in:
parent
cb1b89dac5
commit
44a662a149
3 changed files with 18 additions and 4 deletions
|
@ -671,7 +671,7 @@ const GodotDisplay = {
|
||||||
document.head.appendChild(link);
|
document.head.appendChild(link);
|
||||||
}
|
}
|
||||||
const old_icon = GodotDisplay.window_icon;
|
const old_icon = GodotDisplay.window_icon;
|
||||||
const png = new Blob([GodotRuntime.heapCopy(HEAPU8, p_ptr, p_len)], { type: 'image/png' });
|
const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' });
|
||||||
GodotDisplay.window_icon = URL.createObjectURL(png);
|
GodotDisplay.window_icon = URL.createObjectURL(png);
|
||||||
link.href = GodotDisplay.window_icon;
|
link.href = GodotDisplay.window_icon;
|
||||||
if (old_icon) {
|
if (old_icon) {
|
||||||
|
@ -711,7 +711,7 @@ const GodotDisplay = {
|
||||||
const shape = GodotRuntime.parseString(p_shape);
|
const shape = GodotRuntime.parseString(p_shape);
|
||||||
const old_shape = GodotDisplayCursor.cursors[shape];
|
const old_shape = GodotDisplayCursor.cursors[shape];
|
||||||
if (p_len > 0) {
|
if (p_len > 0) {
|
||||||
const png = new Blob([GodotRuntime.heapCopy(HEAPU8, p_ptr, p_len)], { type: 'image/png' });
|
const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' });
|
||||||
const url = URL.createObjectURL(png);
|
const url = URL.createObjectURL(png);
|
||||||
GodotDisplayCursor.cursors[shape] = {
|
GodotDisplayCursor.cursors[shape] = {
|
||||||
url: url,
|
url: url,
|
||||||
|
|
|
@ -86,7 +86,7 @@ const GodotHTTPRequest = {
|
||||||
godot_xhr_send: function (xhrId, p_ptr, p_len) {
|
godot_xhr_send: function (xhrId, p_ptr, p_len) {
|
||||||
let data = null;
|
let data = null;
|
||||||
if (p_ptr && p_len) {
|
if (p_ptr && p_len) {
|
||||||
data = GodotRuntime.heapCopy(HEAP8, p_ptr, p_len);
|
data = GodotRuntime.heapSlice(HEAP8, p_ptr, p_len);
|
||||||
}
|
}
|
||||||
GodotHTTPRequest.requests[xhrId].send(data);
|
GodotHTTPRequest.requests[xhrId].send(data);
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,11 +72,16 @@ const GodotRuntime = {
|
||||||
return p_heap.subarray(p_ptr / bytes, p_ptr / bytes + p_len);
|
return p_heap.subarray(p_ptr / bytes, p_ptr / bytes + p_len);
|
||||||
},
|
},
|
||||||
|
|
||||||
heapCopy: function (p_heap, p_ptr, p_len) {
|
heapSlice: function (p_heap, p_ptr, p_len) {
|
||||||
const bytes = p_heap.BYTES_PER_ELEMENT;
|
const bytes = p_heap.BYTES_PER_ELEMENT;
|
||||||
return p_heap.slice(p_ptr / bytes, p_ptr / bytes + p_len);
|
return p_heap.slice(p_ptr / bytes, p_ptr / bytes + p_len);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
heapCopy: function (p_dst, p_src, p_ptr) {
|
||||||
|
const bytes = p_src.BYTES_PER_ELEMENT;
|
||||||
|
return p_dst.set(p_src, p_ptr / bytes);
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Strings
|
* Strings
|
||||||
*/
|
*/
|
||||||
|
@ -84,6 +89,15 @@ const GodotRuntime = {
|
||||||
return UTF8ToString(p_ptr); // eslint-disable-line no-undef
|
return UTF8ToString(p_ptr); // eslint-disable-line no-undef
|
||||||
},
|
},
|
||||||
|
|
||||||
|
parseStringArray: function (p_ptr, p_size) {
|
||||||
|
const strings = [];
|
||||||
|
const ptrs = GodotRuntime.heapSub(HEAP32, p_ptr, p_size); // TODO wasm64
|
||||||
|
ptrs.forEach(function (ptr) {
|
||||||
|
strings.push(GodotRuntime.parseString(ptr));
|
||||||
|
});
|
||||||
|
return strings;
|
||||||
|
},
|
||||||
|
|
||||||
strlen: function (p_str) {
|
strlen: function (p_str) {
|
||||||
return lengthBytesUTF8(p_str); // eslint-disable-line no-undef
|
return lengthBytesUTF8(p_str); // eslint-disable-line no-undef
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue