avm2: Copy data for async loadCompressedTextureFromByteArray

The caller might modify the ByteArray immediately after the call,
so we need to copy the ByteArray.
This commit is contained in:
Aaron Hill 2023-11-19 21:58:39 -05:00 committed by Lord-McSweeney
parent 941f87ca8e
commit 24aa9b8fe4
1 changed files with 12 additions and 7 deletions

View File

@ -10,15 +10,20 @@ package flash.display3D.textures {
public function uploadCompressedTextureFromByteArray(data:ByteArray, byteArrayOffset:uint, async:Boolean = false):void {
if (async) {
var self = this;
var copiedData = new ByteArray();
data.position = 0;
data.readBytes(copiedData);
setTimeout(function() {
self.uploadCompressedTextureFromByteArrayInternal(data, byteArrayOffset);
self.uploadCompressedTextureFromByteArrayInternal(copiedData, byteArrayOffset);
self.dispatchEvent(new Event("textureReady"));
}, 0);
} else {
}
else {
this.uploadCompressedTextureFromByteArrayInternal(data, byteArrayOffset);
}
}
private native function uploadCompressedTextureFromByteArrayInternal(data:ByteArray, byteArrayOffset:uint):void
private native function uploadCompressedTextureFromByteArrayInternal(data:ByteArray, byteArrayOffset:uint):void;
}
}