Permalink
Browse files

SDLSprite: we only ever want RLE for colorkey/alpha blits

no need to have a method for this just set it when we set colorkey/alpha
  • Loading branch information...
1 parent 420838c commit cf92617129c9cfeb0f40d5f148ed13e018036225 @bradallred bradallred committed Jul 8, 2013
@@ -771,7 +771,11 @@ bool SDL20VideoDriver::ToggleGrabInput()
bool SDL20VideoDriver::SetSurfaceAlpha(SDL_Surface* surface, unsigned short alpha)
{
- return (SDL_SetSurfaceAlphaMod(surface, alpha) == 0);
+ bool ret = SDL_SetSurfaceAlphaMod(surface, alpha);
+ if (ret == GEM_OK) {
+ SDL_SetSurfaceRLE(surface, SDL_TRUE);
+ }
+ return ret;
}
float SDL20VideoDriver::ScaleCoordinateHorizontal(float x)
@@ -96,10 +96,16 @@ void SDLSurfaceSprite2D::SetColorKey(ieDword ck)
#if SDL_VERSION_ATLEAST(1,3,0)
// SDL 2 will enforce SDL_RLEACCEL
SDL_SetColorKey(surface, SDL_TRUE, ck);
+ SDL_SetSurfaceRLE(surface, SDL_TRUE);
#else
SDL_SetColorKey(surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, ck);
#endif
- SetSurfaceRLE(true);
+
+ // regardless of rle or the success of SDL_SetSurfaceRLE
+ // we must keep RLE false because SDL hides the actual RLE data from us (see SDL_BlitMap)
+ // and we are left to access the pixels in decoded form (updated by SDL_UnlockSurface).
+ // SDL Blits will make use of RLE acceleration, but our internal blitters cannot.
+ assert(RLE == false);
}
Color SDLSurfaceSprite2D::GetPixel(unsigned short x, unsigned short y) const
@@ -149,22 +155,4 @@ bool SDLSurfaceSprite2D::ConvertFormatTo(int bpp, ieDword rmask, ieDword gmask,
return false;
}
-void SDLSurfaceSprite2D::SetSurfaceRLE(bool rle)
-{
-#if SDL_VERSION_ATLEAST(1,3,0)
- SDL_SetSurfaceRLE(surface, rle);
-#else
- if (rle) {
- surface->flags |= SDL_RLEACCEL;
- } else {
- surface->flags &= ~SDL_RLEACCEL;
- }
-#endif
- // regardless of rle or the success of SDL_SetSurfaceRLE
- // we must keep RLE false because SDL hides the actual RLE data from us (see SDL_BlitMap)
- // and we are left to access the pixels in decoded form (updated by SDL_UnlockSurface).
- // SDL Blits will make use of RLE acceleration, but our internal blitters cannot.
- assert(RLE == false);
-}
-
}
@@ -31,8 +31,6 @@ namespace GemRB {
class SDLSurfaceSprite2D : public Sprite2D {
private:
SDL_Surface* surface;
-private:
- void SetSurfaceRLE(bool);
public:
SDLSurfaceSprite2D(int Width, int Height, int Bpp, void* pixels,
ieDword rmask = 0, ieDword gmask = 0, ieDword bmask = 0, ieDword amask = 0);

0 comments on commit cf92617

Please sign in to comment.