Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Fix issue with canvas parameters #284

Merged
merged 1 commit into from
Oct 29, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/wrappers/CanvasRenderingContext2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
var mixin = scope.mixin;
var registerWrapper = scope.registerWrapper;
var unwrap = scope.unwrap;
var unwrapIfNeeded = scope.unwrapIfNeeded;
var wrap = scope.wrap;

var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;
Expand All @@ -22,7 +23,7 @@
},

drawImage: function() {
arguments[0] = unwrap(arguments[0]);
arguments[0] = unwrapIfNeeded(arguments[0]);
this.impl.drawImage.apply(this.impl, arguments);
},

Expand Down
6 changes: 3 additions & 3 deletions src/wrappers/WebGLRenderingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

var mixin = scope.mixin;
var registerWrapper = scope.registerWrapper;
var unwrap = scope.unwrap;
var unwrapIfNeeded = scope.unwrapIfNeeded;
var wrap = scope.wrap;

var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
Expand All @@ -26,12 +26,12 @@
},

texImage2D: function() {
arguments[5] = unwrap(arguments[5]);
arguments[5] = unwrapIfNeeded(arguments[5]);
this.impl.texImage2D.apply(this.impl, arguments);
},

texSubImage2D: function() {
arguments[6] = unwrap(arguments[6]);
arguments[6] = unwrapIfNeeded(arguments[6]);
this.impl.texSubImage2D.apply(this.impl, arguments);
}
});
Expand Down
15 changes: 15 additions & 0 deletions test/js/HTMLCanvasElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,21 @@ suite('HTMLCanvasElement', function() {
return;
}

var imageData = document.createElement('canvas').getContext('2d').
createImageData(16, 16);
var arrayBufferView = new Uint8Array(16 * 16 * 4);

var img = document.createElement('img');
img.onload = function() {
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,
imageData);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
16, 16, 0,
gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView);

done();
};
img.src = iconUrl;
Expand All @@ -118,11 +128,16 @@ suite('HTMLCanvasElement', function() {
return;
}

var arrayBufferView = new Uint8Array(16 * 16 * 4);

var img = document.createElement('img');
img.onload = function() {
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, img);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0,
16, 16,
gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView);
done();
};
img.src = iconUrl;
Expand Down