diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-07 15:34:43 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-07 15:34:43 -0700 |
commit | 520367f881fd7cefd3ca3c0f9c3c85b6da6fb5fa (patch) | |
tree | bbbea30db12eea1619841740ffa233cc5bf1c9f7 /src/library_sdl.js | |
parent | 139faf06772e4dff96aeebd9f885a1c2f8e8fb02 (diff) |
when Module.screenIsReadOnly is set, do not constantly read the SDL screen pixels
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r-- | src/library_sdl.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index 02585aa6..7c0593b2 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -883,6 +883,14 @@ var LibrarySDL = { surfData.locked++; if (surfData.locked > 1) return 0; + // Mark in C/C++-accessible SDL structure + // SDL_Surface has the following fields: Uint32 flags, SDL_PixelFormat *format; int w, h; Uint16 pitch; void *pixels; ... + // So we have fields all of the same size, and 5 of them before us. + // TODO: Use macros like in library.js + {{{ makeSetValue('surf', '5*Runtime.QUANTUM_SIZE', 'surfData.buffer', 'void*') }}}; + + if (surf == SDL.screen && Module.screenIsReadOnly && surfData.image) return 0; + surfData.image = surfData.ctx.getImageData(0, 0, surfData.width, surfData.height); if (surf == SDL.screen) { var data = surfData.image.data; @@ -925,12 +933,6 @@ var LibrarySDL = { } } - // Mark in C/C++-accessible SDL structure - // SDL_Surface has the following fields: Uint32 flags, SDL_PixelFormat *format; int w, h; Uint16 pitch; void *pixels; ... - // So we have fields all of the same size, and 5 of them before us. - // TODO: Use macros like in library.js - {{{ makeSetValue('surf', '5*Runtime.QUANTUM_SIZE', 'surfData.buffer', 'void*') }}}; - return 0; }, |