From ed1e26d15173b61bbc56c1bd02ea164f8c5b085f Mon Sep 17 00:00:00 2001 From: "p.kosyh" Date: Wed, 13 Apr 2011 18:05:38 +0000 Subject: [PATCH] lock unlock --- src/sdl-instead/graphics.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c index a792c1c..e3106e0 100644 --- a/src/sdl-instead/graphics.c +++ b/src/sdl-instead/graphics.c @@ -593,18 +593,19 @@ img_t gfx_alpha_img(img_t src, int alpha) if (!img) return NULL; SDL_SetAlpha(img, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); - SDL_LockSurface(img); - ptr = (Uint32*)img->pixels; - size = img->w * img->h; - while (size --) { - Uint8 r, g, b, a; - col = *ptr; - SDL_GetRGBA(col, img->format, &r, &g, &b, &a); - col = SDL_MapRGBA(img->format, r, g, b, a * alpha / 255); - *ptr = col; - ptr ++; + if (SDL_LockSurface(img) == 0) { + ptr = (Uint32*)img->pixels; + size = img->w * img->h; + while (size --) { + Uint8 r, g, b, a; + col = *ptr; + SDL_GetRGBA(col, img->format, &r, &g, &b, &a); + col = SDL_MapRGBA(img->format, r, g, b, a * alpha / 255); + *ptr = col; + ptr ++; + } + SDL_UnlockSurface(img); } - SDL_UnlockSurface(img); return img; }