From da350fac54cccf6f511aa4cbb4f8bedae6b606df Mon Sep 17 00:00:00 2001 From: "Felix H. Dahlke" Date: Wed, 17 Jul 2013 10:01:13 +0200 Subject: [PATCH] Fix SDL_surface refcount test and initialise refcount to 1 --- src/library_sdl.js | 2 ++ tests/runner.py | 2 +- tests/sdl_surface_refcount.c | 11 ++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/library_sdl.js b/src/library_sdl.js index 34c9551a3..ee62139c1 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -275,6 +275,8 @@ var LibrarySDL = { {{{ makeSetValue('surf+Runtime.QUANTUM_SIZE*5', '0', 'buffer', 'void*') }}} // SDL_Surface.pixels {{{ makeSetValue('surf+Runtime.QUANTUM_SIZE*6', '0', '0', 'i32*') }}} // SDL_Surface.offset + {{{ makeSetValue('surf+Runtime.QUANTUM_SIZE*14', '0', '1', 'i32') }}} + {{{ makeSetValue('pixelFormat + SDL.structs.PixelFormat.format', '0', '-2042224636', 'i32') }}} // SDL_PIXELFORMAT_RGBA8888 {{{ makeSetValue('pixelFormat + SDL.structs.PixelFormat.palette', '0', '0', 'i32') }}} // TODO {{{ makeSetValue('pixelFormat + SDL.structs.PixelFormat.BitsPerPixel', '0', 'bpp * 8', 'i8') }}} diff --git a/tests/runner.py b/tests/runner.py index 6daa9c36b..b2dff6f46 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -13173,7 +13173,7 @@ Press any key to continue.''' self.btest('sdl_alloctext.c', expected='1', args=['-O2', '-s', 'TOTAL_MEMORY=' + str(1024*1024*8)]) def test_sdl_surface_refcount(self): - self.btest('sdl_surface_refcount.c', expected='1') + self.btest('sdl_surface_refcount.c', expected='0') def test_glbegin_points(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) diff --git a/tests/sdl_surface_refcount.c b/tests/sdl_surface_refcount.c index 4e9b48967..c4314ebf3 100644 --- a/tests/sdl_surface_refcount.c +++ b/tests/sdl_surface_refcount.c @@ -1,14 +1,15 @@ #include +#include int main(int argc, char *argv[]) { - SDL_Init(SDL_INIT_VIDEO); - SDL_Surface *screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); - SDL_Surface *reference = screen; + SDL_Surface* surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 10, 10, 32, + 0, 0, 0, 0); + SDL_Surface *reference = surface; reference->refcount++; - SDL_FreeSurface(screen); + SDL_FreeSurface(surface); SDL_FreeSurface(reference); - int result = 1; + int result = surface->refcount; REPORT_RESULT(); return 0; }