Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Video: convert sprite pixels to display format

remove the old (unused) ConvertToVideoFormat method in Video and have the CreateSprite method automatically convert the sprite
  • Loading branch information...
commit 0c63add2f657141b038af99726180c9cdc0100ed 1 parent e839414
@bradallred bradallred authored
View
1  gemrb/core/Video.h
@@ -151,7 +151,6 @@ class GEM_EXPORT Video : public Plugin {
/** Return GemRB window screenshot.
* It's generated from the momentary back buffer */
virtual Sprite2D* GetScreenshot( Region r ) = 0;
- virtual void ConvertToVideoFormat(Sprite2D* sprite) = 0;
/** This function Draws the Border of a Rectangle as described by the Region parameter. The Color used to draw the rectangle is passes via the Color parameter. */
virtual void DrawRect(const Region& rgn, const Color& color, bool fill = true, bool clipped = false) = 0;
/** this function draws a clipped sprite */
View
18 gemrb/plugins/SDLVideo/SDLVideo.cpp
@@ -308,6 +308,10 @@ Sprite2D* SDLVideoDriver::CreateSprite(int w, int h, int bpp, ieDword rMask,
if (cK) {
spr->SetColorKey(index);
}
+ // 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);
@wjp Owner
wjp added a note

This may be dangerous. BlitGameSprite (and maybe other locations too) assumes sprites are either indexed or 32bpp.

@wjp Owner
wjp added a note

This conversion breaks alpha fog of war (at least in BG2 running in 32bpp).

@bradallred Owner

I suppose then we should comment this out (with comment) until I get time to assess options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
return spr;
}
@@ -834,20 +838,6 @@ Sprite2D* SDLVideoDriver::GetScreenshot( Region r )
return screenshot;
}
-void SDLVideoDriver::ConvertToVideoFormat(Sprite2D* sprite)
-{
- if (!sprite->BAM) {
- // TODO: is this really true and if so should we move this to SDLSurfaceSprite2D::ConvertFormatTo()?
- SDL_Surface* ss = ((SDLSurfaceSprite2D*)sprite)->GetSurface();
- if (ss->format->Amask != 0) //Surface already converted
- {
- return;
- }
- SDL_PixelFormat* fmt = disp->format;
- sprite->ConvertFormatTo(fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask);
- }
-}
-
/** This function Draws the Border of a Rectangle as described by the Region parameter. The Color used to draw the rectangle is passes via the Color parameter. */
void SDLVideoDriver::DrawRect(const Region& rgn, const Color& color, bool fill, bool clipped)
{
View
1  gemrb/plugins/SDLVideo/SDLVideo.h
@@ -101,7 +101,6 @@ class SDLVideoDriver : public Video {
void SetCursor(Sprite2D* up, Sprite2D* down);
void SetDragCursor(Sprite2D* drag);
Sprite2D* GetScreenshot( Region r );
- void ConvertToVideoFormat(Sprite2D* sprite);
/** This function Draws the Border of a Rectangle as described by the Region parameter. The Color used to draw the rectangle is passes via the Color parameter. */
void DrawRect(const Region& rgn, const Color& color, bool fill = true, bool clipped = false);
void DrawRectSprite(const Region& rgn, const Color& color, const Sprite2D* sprite);
Please sign in to comment.
Something went wrong with that request. Please try again.