diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-06-18 13:56:07 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-06-18 13:56:07 -0700 |
commit | 260bb52b54e6f60465b3855445e94bcd3e34266d (patch) | |
tree | 6b21044b49fd7fd4893b10a27814646869de4217 /src | |
parent | 34b58c52cd35f718dfb9fe75ae01bb03ffac06b9 (diff) |
only proxy canvas messages for the module canvas
Diffstat (limited to 'src')
-rw-r--r-- | src/proxyWorker.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/proxyWorker.js b/src/proxyWorker.js index 4b700b61..b542ff1d 100644 --- a/src/proxyWorker.js +++ b/src/proxyWorker.js @@ -53,11 +53,15 @@ document.createElement = function document_createElement(what) { height: canvas.height, data: new Uint8Array(canvas.width*canvas.height*4) }; - postMessage({ target: 'canvas', op: 'resize', width: canvas.width, height: canvas.height }); + if (canvas === Module['canvas']) { + postMessage({ target: 'canvas', op: 'resize', width: canvas.width, height: canvas.height }); + } } }; canvas.getContext = function canvas_getContext(type, attributes) { - postMessage({ target: 'canvas', op: 'getContext', type: type, attributes: attributes }); + if (canvas === Module['canvas']) { + postMessage({ target: 'canvas', op: 'getContext', type: type, attributes: attributes }); + } if (type === '2d') { return { getImageData: function(x, y, w, h) { @@ -73,7 +77,7 @@ document.createElement = function document_createElement(what) { canvas.ensureData(); assert(x == 0 && y == 0 && image.width == canvas.width && image.height == canvas.height); canvas.data.data.set(image.data); // TODO: can we avoid this copy? - if (this === Module['ctx']) { + if (canvas === Module['canvas']) { postMessage({ target: 'canvas', op: 'render', image: canvas.data }); } } |