X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Fsdl_renderer.cpp;h=dede6c8321187d7fd2abed18f87411b3b9e32dbe;hb=93b7ae7078d70db7279aa063397b9ae3589a1635;hp=6e8797c6ab69e54f5ea80edc39c29161e4463874;hpb=5bd825749c3dc21471f35abc23e7a12bc4348b67;p=supertux.git diff --git a/src/video/sdl_renderer.cpp b/src/video/sdl_renderer.cpp index 6e8797c6a..dede6c832 100644 --- a/src/video/sdl_renderer.cpp +++ b/src/video/sdl_renderer.cpp @@ -52,6 +52,14 @@ namespace int alpha = (int) (alpha_factor * 256); SDL_Surface *dst = SDL_CreateRGBSurface(src->flags, src->w, src->h, src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); int bpp = dst->format->BytesPerPixel; + if(SDL_MUSTLOCK(src)) + { + SDL_LockSurface(src); + } + if(SDL_MUSTLOCK(dst)) + { + SDL_LockSurface(dst); + } for(int y = 0;y < dst->h;y++) { for(int x = 0;x < dst->w;x++) { Uint8 *srcpixel = (Uint8 *) src->pixels + y * src->pitch + x * bpp; @@ -106,6 +114,14 @@ namespace } } } + if(SDL_MUSTLOCK(dst)) + { + SDL_UnlockSurface(dst); + } + if(SDL_MUSTLOCK(src)) + { + SDL_UnlockSurface(src); + } return dst; } } @@ -212,11 +228,11 @@ namespace SDL { if(alpha == 255) { - SDL_SetAlpha(transform, 0, 0); + SDL_SetAlpha(transform, SDL_RLEACCEL, 0); } else { - SDL_SetAlpha(transform, SDL_SRCALPHA, alpha); + SDL_SetAlpha(transform, SDL_SRCALPHA | SDL_RLEACCEL, alpha); } } /*else @@ -275,26 +291,45 @@ namespace SDL dst_rect.y = (int) request.pos.y * numerator / denominator; Uint8 alpha = 0; - if(!(transform->flags & SDL_SRCALPHA)) - { - alpha = 255; - SDL_SetAlpha(transform, SDL_SRCALPHA, (Uint8) (request.alpha * 255)); - } - else if(!transform->format->Amask) + if(request.alpha != 1.0) { - alpha = transform->format->alpha; - SDL_SetAlpha(transform, SDL_SRCALPHA, (Uint8) (request.alpha * alpha)); + if(!transform->format->Amask) + { + if(transform->flags & SDL_SRCALPHA) + { + alpha = transform->format->alpha; + } + else + { + alpha = 255; + } + SDL_SetAlpha(transform, SDL_SRCALPHA, (Uint8) (request.alpha * alpha)); + } + /*else + { + transform = apply_alpha(transform, request.alpha); + }*/ } SDL_BlitSurface(transform, &src_rect, screen, &dst_rect); - if(alpha == 255) - { - SDL_SetAlpha(transform, 0, 0); - } - else if(!transform->format->Amask) + if(request.alpha != 1.0) { - SDL_SetAlpha(transform, SDL_SRCALPHA, alpha); + if(!transform->format->Amask) + { + if(alpha == 255) + { + SDL_SetAlpha(transform, SDL_RLEACCEL, 0); + } + else + { + SDL_SetAlpha(transform, SDL_SRCALPHA | SDL_RLEACCEL, alpha); + } + } + /*else + { + SDL_FreeSurface(transform); + }*/ } } @@ -326,7 +361,7 @@ namespace SDL SDL_Surface *temp = SDL_CreateRGBSurface(screen->flags, rect.w, rect.h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); SDL_FillRect(temp, 0, color); - SDL_SetAlpha(temp, SDL_SRCALPHA, a); + SDL_SetAlpha(temp, SDL_SRCALPHA | SDL_RLEACCEL, a); SDL_BlitSurface(temp, 0, screen, &rect); SDL_FreeSurface(temp); } @@ -334,15 +369,6 @@ namespace SDL } void - Renderer::draw_text(const DrawingRequest& request) - { - const TextRequest* textrequest = (TextRequest*) request.request_data; - - textrequest->font->draw(this, textrequest->text, request.pos, - textrequest->alignment, request.drawing_effect, request.alpha); - } - - void Renderer::draw_filled_rect(const DrawingRequest& request) { const FillRectRequest* fillrectrequest @@ -364,7 +390,7 @@ namespace SDL SDL_Surface *temp = SDL_CreateRGBSurface(screen->flags, rect.w, rect.h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); SDL_FillRect(temp, 0, color); - SDL_SetAlpha(temp, SDL_SRCALPHA, a); + SDL_SetAlpha(temp, SDL_SRCALPHA | SDL_RLEACCEL, a); SDL_BlitSurface(temp, 0, screen, &rect); SDL_FreeSurface(temp); }