X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Fsdl_lightmap.cpp;h=d8bdcde7cb259f9297a4fa8a59e71bcec681eebb;hb=5742dd7bfaf2fa8ffdb812bbc150826554959c98;hp=040189cddd99172cc7694f974d791b98e4901031;hpb=ca967dcf4ee89f99880355be00782d1cd047be6a;p=supertux.git diff --git a/src/video/sdl_lightmap.cpp b/src/video/sdl_lightmap.cpp index 040189cdd..d8bdcde7c 100644 --- a/src/video/sdl_lightmap.cpp +++ b/src/video/sdl_lightmap.cpp @@ -112,6 +112,10 @@ namespace SDL if(LIGHTMAP_DIV == 1) { int bpp = screen->format->BytesPerPixel; + if(SDL_MUSTLOCK(screen)) + { + SDL_LockSurface(screen); + } Uint8 *pixel = (Uint8 *) screen->pixels; int loc = 0; for(int y = 0;y < height;y++) { @@ -174,10 +178,18 @@ namespace SDL } pixel += screen->pitch - width * bpp; } + if(SDL_MUSTLOCK(screen)) + { + SDL_UnlockSurface(screen); + } } else { int bpp = screen->format->BytesPerPixel; + if(SDL_MUSTLOCK(screen)) + { + SDL_LockSurface(screen); + } Uint8 *div_pixel = (Uint8 *) screen->pixels; int loc = 0; for(int y = 0;y < height;y++) { @@ -281,6 +293,10 @@ namespace SDL } div_pixel += (screen->pitch - width * bpp) * LIGHTMAP_DIV; } + if(SDL_MUSTLOCK(screen)) + { + SDL_UnlockSurface(screen); + } } } @@ -293,6 +309,10 @@ namespace SDL int blit_width = src_rect->w / LIGHTMAP_DIV; int blit_height = src_rect->h / LIGHTMAP_DIV; int bpp = src->format->BytesPerPixel; + if(SDL_MUSTLOCK(src)) + { + SDL_LockSurface(src); + } Uint8 *pixel = (Uint8 *) src->pixels + srcy * src->pitch + srcx * bpp; int loc = dsty * width + dstx; for(int y = 0;y < blit_height;y++) { @@ -351,12 +371,20 @@ namespace SDL pixel += (src->pitch - blit_width * bpp) * LIGHTMAP_DIV; loc += width - blit_width; } + if(SDL_MUSTLOCK(src)) + { + SDL_UnlockSurface(src); + } } /*void Lightmap::light_blit(SDL_Surface *src, SDL_Rect *src_rect, int dstx, int dsty) { int bpp = src->format->BytesPerPixel; - Uint8 *pixel = (Uint8 *) src->pixels + src_rect->y * src->pitch + src_rect->x * bpp; + if(SDL_MUSTLOCK(src)) + { + SDL_LockSurface(src); + } + Uint8 *pixel = (Uint8 *) src->pixels + src_rect->y * src->pitch + src_rect->x * bpp; int loc = dsty * width + dstx; for(int y = 0;y < src_rect->h;y++) { for(int x = 0;x < src_rect->w;x++, pixel += bpp, loc++) { @@ -414,6 +442,10 @@ namespace SDL pixel += src->pitch - src_rect->w * bpp; loc += width - src_rect->w; } + if(SDL_MUSTLOCK(src)) + { + SDL_UnlockSurface(src); + } }*/ void