Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 5 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
6 gemrb/plugins/SDLVideo/SDL20Video.cpp
@@ -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)
View
41 gemrb/plugins/SDLVideo/SDLSurfaceSprite2D.cpp
@@ -33,17 +33,14 @@ SDLSurfaceSprite2D::SDLSurfaceSprite2D (int Width, int Height, int Bpp, void* pi
{
surface = SDL_CreateRGBSurfaceFrom( pixels, Width, Height, Bpp < 8 ? 8 : Bpp, Width * ( Bpp / 8 ),
rmask, gmask, bmask, amask );
- SetSurfaceRLE(true);
- colorkeyIdx = 0;
}
SDLSurfaceSprite2D::SDLSurfaceSprite2D(const SDLSurfaceSprite2D &obj)
: Sprite2D(obj)
{
- // SDL_ConvertSurface should copy colorkey/palette/pixels
+ // SDL_ConvertSurface should copy colorkey/palette/pixels/surface RLE
surface = SDL_ConvertSurface(obj.surface, obj.surface->format, obj.surface->flags);
pixels = surface->pixels;
- colorkeyIdx = obj.colorkeyIdx;
}
SDLSurfaceSprite2D* SDLSurfaceSprite2D::copy() const
@@ -85,9 +82,6 @@ void SDLSurfaceSprite2D::SetPalette(Color* pal)
ieDword SDLSurfaceSprite2D::GetColorKey() const
{
- if (surface->format->palette) {
- return colorkeyIdx;
- }
ieDword ck = 0;
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_GetColorKey(surface, &ck);
@@ -99,20 +93,19 @@ ieDword SDLSurfaceSprite2D::GetColorKey() const
void SDLSurfaceSprite2D::SetColorKey(ieDword ck)
{
- if (surface->format->palette) {
- colorkeyIdx = ck;
- // convert the index to a pixel value
- const Color* cols = GetPaletteColors();
- assert(cols);
- Color c = cols[ck];
- ck = SDL_MapRGB(surface->format, c.r, c.g, c.b);
- }
#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
+
+ // 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
@@ -162,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);
-}
-
}
View
3 gemrb/plugins/SDLVideo/SDLSurfaceSprite2D.h
@@ -31,9 +31,6 @@ namespace GemRB {
class SDLSurfaceSprite2D : public Sprite2D {
private:
SDL_Surface* surface;
- ieByte colorkeyIdx;
-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);
View
7 gemrb/plugins/SDLVideo/SDLVideo.cpp
@@ -338,10 +338,14 @@ Sprite2D* SDLVideoDriver::CreateSprite(int w, int h, int bpp, ieDword rMask,
if (cK) {
spr->SetColorKey(index);
}
+ /*
+ there is at least one place (BlitGameSprite) that requires 8 or 32bpp sprites
+ untill we support 16bpp fully we cannot do this
+
// make sure colorkey is set prior to conversion
SDL_PixelFormat* fmt = backBuf->format;
spr->ConvertFormatTo(fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask);
-
+ */
return spr;
}
@@ -407,6 +411,7 @@ void SDLVideoDriver::BlitTile(const Sprite2D* spr, const Sprite2D* mask, int x,
const Uint8* mask_data = NULL;
Uint32 ck = 0;
if (mask) {
+ mask_data = (Uint8*) mask->pixels;
ck = mask->GetColorKey();
}

No commit comments for this range

Something went wrong with that request. Please try again.