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:
parent
941f87ca8e
commit
24aa9b8fe4
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue