summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolly Ross <sross@redhat.com>2016-02-24 15:59:58 -0500
committerSolly Ross <sross@redhat.com>2016-02-24 16:29:34 -0500
commit7bc383e8b6f6da10cb3f335123fe561674a6723d (patch)
treeae11ad21efbdea8a09aee6f82b8cd316eac4cefe
parent670dbddb54264fd0082d0aca1b3acb0f1814b1d2 (diff)
downloadnovnc-7bc383e8b6f6da10cb3f335123fe561674a6723d.tar.gz
Make sure to copy arrays when using render queue
This commit ensures that input arrays are copied to new storage when they are pushed onto the render queue. This ensures that they are not overwritten before they are eventually used. Fixes #571
-rw-r--r--include/display.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/include/display.js b/include/display.js
index 6bf89bd..a492817 100644
--- a/include/display.js
+++ b/include/display.js
@@ -471,9 +471,14 @@ var Display;
blitImage: function (x, y, width, height, arr, offset, from_queue) {
if (this._renderQ.length !== 0 && !from_queue) {
+ // NB(directxman12): it's technically more performant here to use preallocated arrays,
+ // but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
+ // this probably isn't getting called *nearly* as much
+ var new_arr = new Uint8Array(width * height * 4);
+ new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
this.renderQ_push({
'type': 'blit',
- 'data': arr,
+ 'data': new_arr,
'x': x,
'y': y,
'width': width,
@@ -488,9 +493,14 @@ var Display;
blitRgbImage: function (x, y , width, height, arr, offset, from_queue) {
if (this._renderQ.length !== 0 && !from_queue) {
+ // NB(directxman12): it's technically more performant here to use preallocated arrays,
+ // but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
+ // this probably isn't getting called *nearly* as much
+ var new_arr = new Uint8Array(width * height * 4);
+ new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
this.renderQ_push({
'type': 'blitRgb',
- 'data': arr,
+ 'data': new_arr,
'x': x,
'y': y,
'width': width,
@@ -506,7 +516,7 @@ var Display;
blitRgbxImage: function (x, y, width, height, arr, offset, from_queue) {
if (this._renderQ.length !== 0 && !from_queue) {
- // NB(directxman12): it's technically more performant here to use preallocated arrays, but it
+ // NB(directxman12): it's technically more performant here to use preallocated arrays,
// but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
// this probably isn't getting called *nearly* as much
var new_arr = new Uint8Array(width * height * 4);