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...
1 parent e839414 commit 0c63add2f657141b038af99726180c9cdc0100ed @bradallred bradallred committed Jun 21, 2013
Showing with 4 additions and 16 deletions.
  1. +0 −1 gemrb/core/Video.h
  2. +4 −14 gemrb/plugins/SDLVideo/SDLVideo.cpp
  3. +0 −1 gemrb/plugins/SDLVideo/SDLVideo.h
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
GemRB member
wjp added a note Jul 6, 2013

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

@wjp
GemRB member
wjp added a note Jul 6, 2013

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

@bradallred
GemRB member

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);

0 comments on commit 0c63add

Please sign in to comment.