aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Vilk <jvilk@cs.umass.edu>2014-01-03 20:04:42 -0500
committerJohn Vilk <jvilk@cs.umass.edu>2014-01-03 20:04:42 -0500
commit5f21294665db19cc072645cb87f8a0e2210141ba (patch)
tree80333f22b839c51113be4684ed5f0894476176f8
parent05299686d45df2b5ee273c464dbf6d4b49d58fb5 (diff)
[SDL] Actually fix SDL_UnlockSurface in IE10/IE11.
The previous revision did not copy over pixel data properly. This time, I have reverted the IE path to the code used in this method prior to the breaking change, and have tested it with JSMESS.
-rw-r--r--src/library_sdl.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 78f6a628..cc969c27 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -1056,23 +1056,27 @@ var LibrarySDL = {
var buffer = surfData.buffer;
#if USE_TYPED_ARRAYS == 2
assert(buffer % 4 == 0, 'Invalid buffer offset: ' + buffer);
- var src;
+ var src = buffer >> 2;
var dst = 0;
var isScreen = surf == SDL.screen;
var num;
if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {
- // IE10/IE11: Canvases are backed by the deprecated CanvasPixelArray,
+ // IE10/IE11: ImageData objects are backed by the deprecated CanvasPixelArray,
// not UInt8ClampedArray. These don't have buffers, so we need to revert
// to copying a byte at a time. We do the undefined check because modern
// browsers do not define CanvasPixelArray anymore.
- src = buffer;
num = data.length;
while (dst < num) {
- data[dst++] = HEAP8[src++];
+ var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
+ data[dst ] = val & 0xff;
+ data[dst+1] = (val >> 8) & 0xff;
+ data[dst+2] = (val >> 16) & 0xff;
+ data[dst+3] = isScreen ? 0xff : ((val >> 24) & 0xff);
+ src++;
+ dst += 4;
}
} else {
var data32 = new Uint32Array(data.buffer);
- src = buffer >> 2;
num = data32.length;
while (dst < num) {
// HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};