Streamlined and refactored DCQ interface

The DrawCommands have changed slightly, and a battery of interface
routines for enqueuing commands has been added to gfx_common.c.  This
code is relatively independent of the underlying graphics library, and
has been taken out of the sdl/3do* files.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@545 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2003-01-12 18:50:41 +00:00
parent 1b7a8c8827
commit 0a6d03fcae
11 changed files with 298 additions and 232 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.2:
- DCQ is now accessed uniformly by routines in gfx_common.c
- Fixed OpenGL colors on MacOS X -Mika
- Added a sane cmd-line naming scheme: --opt=(pc|3do) see --help for more -PBlue
- Added new font effect (PC-lander messages), and set colors for text -PBlue
+164
View File
@@ -43,3 +43,167 @@ SetGraphicStrength (int numerator, int denominator)
BlendNumerator = numerator;
BlendDenominator = denominator;
}
void
TFB_Draw_Line (int x1, int y1, int x2, int y2, int r, int g, int b, SCREEN dest)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_LINE;
DC.x = x1;
DC.y = y1;
DC.w = x2;
DC.h = y2;
DC.r = r;
DC.g = g;
DC.b = b;
DC.image = 0;
DC.UsePalette = FALSE;
DC.destBuffer = dest;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
}
void
TFB_Draw_Rect (PRECT rect, int r, int g, int b, SCREEN dest)
{
RECT locRect;
TFB_DrawCommand DC;
if (!rect)
{
locRect.corner.x = locRect.corner.y = 0;
locRect.extent.width = SCREEN_WIDTH;
locRect.extent.height = SCREEN_HEIGHT;
rect = &locRect;
}
DC.Type = TFB_DRAWCOMMANDTYPE_RECTANGLE;
DC.x = rect->corner.x;
DC.y = rect->corner.y;
DC.w = rect->extent.width;
DC.h = rect->extent.height;
DC.r = r;
DC.g = g;
DC.b = b;
DC.image = 0;
DC.UsePalette = FALSE;
DC.destBuffer = dest;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
}
void
TFB_Draw_Image (TFB_ImageStruct *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, SCREEN dest)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_IMAGE;
DC.image = img;
DC.x = x;
DC.y = y;
DC.UseScaling = scaled;
if (palette != NULL)
{
int i;
for (i = 0; i < 256; i++)
{
DC.Palette[i] = palette[i];
}
DC.UsePalette = TRUE;
}
else
{
DC.UsePalette = FALSE;
}
DC.destBuffer = dest;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
}
void
TFB_Draw_CopyToImage (TFB_ImageStruct *img, PRECT lpRect, SCREEN src)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_COPYTOIMAGE;
DC.x = lpRect->corner.x;
DC.y = lpRect->corner.y;
DC.w = lpRect->extent.width;
DC.h = lpRect->extent.height;
DC.image = img;
DC.srcBuffer = src;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
}
void
TFB_Draw_Copy (PRECT r, SCREEN src, SCREEN dest)
{
RECT locRect;
TFB_DrawCommand DC;
if (!r)
{
locRect.corner.x = locRect.corner.y = 0;
locRect.extent.width = SCREEN_WIDTH;
locRect.extent.height = SCREEN_HEIGHT;
r = &locRect;
}
DC.Type = TFB_DRAWCOMMANDTYPE_COPY;
DC.x = r->corner.x;
DC.y = r->corner.y;
DC.w = r->extent.width;
DC.h = r->extent.height;
DC.image = 0;
DC.srcBuffer = src;
DC.destBuffer = dest;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
}
void
TFB_Draw_DeleteImage (TFB_ImageStruct *img)
{
if (img)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_DELETEIMAGE;
DC.image = img;
TFB_EnqueueDrawCommand (&DC);
}
}
void
TFB_Draw_WaitForSignal (void)
{
TFB_DrawCommand DrawCommand;
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_SENDSIGNAL;
DrawCommand.image = 0;
// We need to lock the mutex before enqueueing the DC to prevent races
LockSignalMutex ();
Lock_DCQ ();
TFB_BatchReset ();
TFB_EnqueueDrawCommand(&DrawCommand);
Unlock_DCQ();
WaitForSignal ();
}
+25 -4
View File
@@ -42,6 +42,13 @@ enum
#define TFB_GFXFLAGS_SCALE_BILINEAR (1<<3)
#define TFB_GFXFLAGS_SCALE_BIADAPT (1<<4)
#define TFB_GFX_NUMSCREENS 3
typedef enum {
TFB_SCREEN_MAIN,
TFB_SCREEN_EXTRA,
TFB_SCREEN_TRANSITION
} SCREEN;
int TFB_InitGraphics (int driver, int flags, int width, int height, int bpp);
void TFB_UninitGraphics (void);
@@ -76,14 +83,15 @@ enum
TFB_DRAWCOMMANDTYPE_LINE,
TFB_DRAWCOMMANDTYPE_RECTANGLE,
TFB_DRAWCOMMANDTYPE_IMAGE,
TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER,
TFB_DRAWCOMMANDTYPE_COPY,
TFB_DRAWCOMMANDTYPE_COPYTOIMAGE,
TFB_DRAWCOMMANDTYPE_SCISSORENABLE,
TFB_DRAWCOMMANDTYPE_SCISSORDISABLE,
TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER,
TFB_DRAWCOMMANDTYPE_DELETEIMAGE,
TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS,
TFB_DRAWCOMMANDTYPE_SKIPGRAPHICS
TFB_DRAWCOMMANDTYPE_SENDSIGNAL,
};
typedef struct tfb_palette
@@ -107,11 +115,24 @@ typedef struct tfb_drawcommand
int b;
TFB_Palette Palette[256];
BOOLEAN UsePalette;
BOOLEAN UseScaling;
int BlendNumerator;
int BlendDenominator;
DWORD thread;
SCREEN srcBuffer;
SCREEN destBuffer;
} TFB_DrawCommand;
// Drawing commands (native to the queue)
void TFB_Draw_Line (int x1, int y1, int x2, int y2, int r, int g, int b, SCREEN dest);
void TFB_Draw_Rect (PRECT rect, int r, int g, int b, SCREEN dest);
void TFB_Draw_Image (TFB_ImageStruct *img, int x, int y, BOOLEAN scaled, TFB_Palette *palette, SCREEN dest);
void TFB_Draw_Copy (PRECT r, SCREEN src, SCREEN dest);
void TFB_Draw_CopyToImage (TFB_ImageStruct *img, PRECT lpRect, SCREEN src);
void TFB_Draw_DeleteImage (TFB_ImageStruct *img);
void TFB_Draw_WaitForSignal (void);
// Queue Stuff
typedef struct tfb_drawcommandqueue
+39 -83
View File
@@ -43,26 +43,21 @@ blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
TFB_DrawCommand DrawCommand;
int x, y;
BOOLEAN scaled, paletted;
TFB_Palette palette[256];
// DrawCommand = HMalloc (sizeof (TFB_DrawCommand));
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_IMAGE;
DrawCommand.x = pClipRect->corner.x -
GetFrameHotX (_CurFramePtr);
DrawCommand.y = pClipRect->corner.y -
GetFrameHotY (_CurFramePtr);
DrawCommand.w = img->NormalImg->w;
DrawCommand.h = img->NormalImg->h;
x = pClipRect->corner.x - GetFrameHotX (_CurFramePtr);
y = pClipRect->corner.y - GetFrameHotY (_CurFramePtr);
scaled = FALSE;
if (gscale != 0 && gscale != 256)
{
DrawCommand.x += (GetFrameHotX (SrcFramePtr) *
x += (GetFrameHotX (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
DrawCommand.y += (GetFrameHotY (SrcFramePtr) *
y += (GetFrameHotY (SrcFramePtr) *
((1 << 8) - gscale)) >> 8;
DrawCommand.w = (DrawCommand.w * gscale) >> 8;
DrawCommand.h = (DrawCommand.h * gscale) >> 8;
scaled = TRUE;
if (img->ScaledImg)
{
@@ -119,42 +114,40 @@ blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
}
}
DrawCommand.image = (TFB_ImageStruct*) img;
DrawCommand.UsePalette = FALSE;
paletted = FALSE;
if (GetPrimType (PrimPtr) == STAMPFILL_PRIM)
{
int i;
int i, r, g, b;
DWORD c32k;
c32k = GetPrimColor (PrimPtr) >> 8; // shift out color index
DrawCommand.r = (c32k >> (10 - (8 - 5))) & 0xF8;
DrawCommand.g = (c32k >> (5 - (8 - 5))) & 0xF8;
DrawCommand.b = (c32k << (8 - 5)) & 0xF8;
r = (c32k >> (10 - (8 - 5))) & 0xF8;
g = (c32k >> (5 - (8 - 5))) & 0xF8;
b = (c32k << (8 - 5)) & 0xF8;
for (i = 0; i < 256; ++i)
{
DrawCommand.Palette[i].r = DrawCommand.r;
DrawCommand.Palette[i].g = DrawCommand.g;
DrawCommand.Palette[i].b = DrawCommand.b;
palette[i].r = r;
palette[i].g = g;
palette[i].b = b;
}
DrawCommand.UsePalette = TRUE;
paletted = TRUE;
}
else
{
if (img->NormalImg->format->palette && img->colormap_index != -1)
{
TFB_ColorMapToRGB (DrawCommand.Palette, img->colormap_index);
DrawCommand.UsePalette = TRUE;
TFB_ColorMapToRGB (palette, img->colormap_index);
paletted = TRUE;
}
}
DrawCommand.BlendNumerator = BlendNumerator;
DrawCommand.BlendDenominator = BlendDenominator;
UnlockMutex (img->mutex);
TFB_EnqueueDrawCommand(&DrawCommand);
TFB_Draw_Image ((TFB_ImageStruct *)img, x, y, scaled,
(paletted ? palette : NULL),
TFB_SCREEN_MAIN);
}
else
{
@@ -196,34 +189,23 @@ fillrect_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
TFB_DrawCommand DrawCommand;
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_RECTANGLE;
DrawCommand.x = pClipRect->corner.x - GetFrameHotX (_CurFramePtr);
DrawCommand.y = pClipRect->corner.y - GetFrameHotY (_CurFramePtr);
DrawCommand.w = pClipRect->extent.width;
DrawCommand.h = pClipRect->extent.height;
DrawCommand.r = r;
DrawCommand.g = g;
DrawCommand.b = b;
RECT rect;
rect.corner.x = pClipRect->corner.x - GetFrameHotX (_CurFramePtr);
rect.corner.y = pClipRect->corner.y - GetFrameHotY (_CurFramePtr);
rect.extent.width = pClipRect->extent.width;
rect.extent.height = pClipRect->extent.height;
if (gscale && GetPrimType (PrimPtr) != POINT_PRIM)
{
DrawCommand.w = (DrawCommand.w * gscale) >> 8;
DrawCommand.h = (DrawCommand.h * gscale) >> 8;
DrawCommand.x += (pClipRect->extent.width -
DrawCommand.w) >> 1;
DrawCommand.y += (pClipRect->extent.height -
DrawCommand.h) >> 1;
rect.extent.width = (rect.extent.width * gscale) >> 8;
rect.extent.height = (rect.extent.height * gscale) >> 8;
rect.corner.x += (pClipRect->extent.width -
rect.extent.width) >> 1;
rect.corner.y += (pClipRect->extent.height -
rect.extent.height) >> 1;
}
DrawCommand.image = 0;
DrawCommand.UsePalette = FALSE;
DrawCommand.BlendNumerator = BlendNumerator;
DrawCommand.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand(&DrawCommand);
TFB_Draw_Rect (&rect, r, g, b, TFB_SCREEN_MAIN);
}
else
{
@@ -273,26 +255,11 @@ line_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_LINE;
DC.x = x1;
DC.y = y1;
DC.w = x2;
DC.h = y2;
DC.r = r;
DC.g = g;
DC.b = b;
DC.image = 0;
DC.UsePalette = FALSE;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand(&DC);
TFB_Draw_Line (x1, y1, x2, y2, r, g, b, TFB_SCREEN_MAIN);
}
else
{
// Maybe we should do something about this?
}
}
@@ -309,20 +276,9 @@ read_screen (PRECT lpRect, FRAMEPTR DstFramePtr)
}
else
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER;
DC.x = lpRect->corner.x;
DC.y = lpRect->corner.y;
DC.w = lpRect->extent.width;
DC.h = lpRect->extent.height;
DC.image = (TFB_ImageStruct *) ((BYTE *) DstFramePtr +
TFB_ImageStruct *img = (TFB_ImageStruct *) ((BYTE *) DstFramePtr +
DstFramePtr->DataOffs);
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
TFB_Draw_CopyToImage (img, lpRect, TFB_SCREEN_MAIN);
}
}
+4 -65
View File
@@ -53,7 +53,6 @@ UninitGraphics () // Also probably empty
//mem_uninit ();
}
/* Batching and Unbatching functions. A "Batch" is a collection of
DrawCommands that will never be flipped to the screen half-rendered.
BatchGraphics and UnbatchGraphics function vaguely like a non-blocking
@@ -74,26 +73,11 @@ UnbatchGraphics (void)
been processed. */
void
FlushGraphics (void)
FlushGraphics ()
{
TFB_DrawCommand DrawCommand;
TFB_BatchReset ();
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS;
DrawCommand.image = 0;
// We need to lock the mutex before quein the DC to prevent races
LockSignalMutex ();
TFB_EnqueueDrawCommand(&DrawCommand);
WaitForSignal ();
TFB_Draw_WaitForSignal ();
}
void
SkipGraphics (void)
{
TFB_DrawCommand DrawCommand;
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_SKIPGRAPHICS;
DrawCommand.image = 0;
TFB_EnqueueDrawCommand(&DrawCommand);
}
// Status: Ignored (only used in fmv.c)
void
SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :)
@@ -189,58 +173,13 @@ ScreenTransition (int TransType, PRECT pRect)
void
DrawFromExtraScreen (PRECT r) //No scaling?
{
RECT locRect;
TFB_DrawCommand DC;
if (!r)
{
locRect.corner.x = locRect.corner.y = 0;
locRect.extent.width = SCREEN_WIDTH;
locRect.extent.height = SCREEN_HEIGHT;
r = &locRect;
}
DC.Type = TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER;
DC.x = r->corner.x;
DC.y = r->corner.y;
DC.w = r->extent.width;
DC.h = r->extent.height;
DC.image = 0;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
TFB_Draw_Copy(r, TFB_SCREEN_EXTRA, TFB_SCREEN_MAIN);
}
void
LoadIntoExtraScreen (PRECT r)
{
RECT locRect;
TFB_DrawCommand DC;
if (!r)
{
locRect.corner.x = locRect.corner.y = 0;
locRect.extent.width = SCREEN_WIDTH;
locRect.extent.height = SCREEN_HEIGHT;
r = &locRect;
}
// fprintf (stderr, "LoadIntoExtraScreen (%d, %d, {%d, %d})\n", r->corner.x, r->corner.y, r->extent.width, r->extent.height);
// DC = HMalloc (sizeof (TFB_DrawCommand));
DC.Type = TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER;
DC.x = r->corner.x;
DC.y = r->corner.y;
DC.w = r->extent.width;
DC.h = r->extent.height;
DC.image = 0;
DC.BlendNumerator = BlendNumerator;
DC.BlendDenominator = BlendDenominator;
TFB_EnqueueDrawCommand (&DC);
TFB_Draw_Copy(r, TFB_SCREEN_MAIN, TFB_SCREEN_EXTRA);
}
// Status: Ignored
@@ -524,12 +524,12 @@ _ReleaseCelData (MEM_HANDLE handle)
{
if (FramePtr->DataOffs)
{
TFB_Image *img;
TFB_ImageStruct *img;
img = (TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs);
img = (TFB_ImageStruct *)((BYTE *)FramePtr + FramePtr->DataOffs);
FramePtr->DataOffs = 0;
TFB_FreeImage (img);
TFB_Draw_DeleteImage (img);
}
}
}
@@ -664,12 +664,12 @@ _ReleaseFontData (MEM_HANDLE handle)
{
if (FramePtr->DataOffs)
{
TFB_Image *img;
TFB_ImageStruct *img;
img = (TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs);
img = (TFB_ImageStruct *)((BYTE *)FramePtr + FramePtr->DataOffs);
FramePtr->DataOffs = 0;
TFB_FreeImage (img);
TFB_Draw_DeleteImage (img);
}
}
}
+1 -1
View File
@@ -225,7 +225,7 @@ TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand)
}
DrawCommand->thread = CurrentThreadID ();
if (DrawCommand->Type <= TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER
if (DrawCommand->Type <= TFB_DRAWCOMMANDTYPE_COPYTOIMAGE
&& TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
{
static RECT scissor_rect;
+18 -23
View File
@@ -40,11 +40,25 @@ static BOOLEAN upload_transitiontexture = FALSE;
#define A_MASK 0xff000000
#endif
static SDL_Surface *
Create_Screen ()
{
SDL_Surface *result = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32,
R_MASK, G_MASK, B_MASK, 0x00000000);
if (result == NULL)
{
fprintf (stderr, "Couldn't create screen buffer: %s\n", SDL_GetError());
exit (-1);
}
}
int
TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
{
char VideoName[256];
int videomode_flags;
int i;
GraphicsDriver = driver;
@@ -124,32 +138,13 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
glGetString (GL_RENDERER), glGetString (GL_VERSION));
}
SDL_Screen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32,
R_MASK, G_MASK, B_MASK, 0x00000000);
if (SDL_Screen == NULL)
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
{
fprintf (stderr, "Couldn't create back buffer: %s\n", SDL_GetError());
exit (-1);
SDL_Screens[i] = Create_Screen ();
}
ExtraScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32,
R_MASK, G_MASK, B_MASK, 0x00000000);
if (ExtraScreen == NULL)
{
fprintf (stderr, "Couldn't create workspace buffer: %s\n", SDL_GetError());
exit (-1);
}
TransitionScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32,
R_MASK, G_MASK, B_MASK, 0x00000000);
if (TransitionScreen == NULL)
{
fprintf (stderr, "Couldn't create transition buffer: %s\n", SDL_GetError());
exit (-1);
}
SDL_Screen = SDL_Screens[0];
TransitionScreen = SDL_Screens[2];
format_conv_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32,
R_MASK, G_MASK, B_MASK, A_MASK);
+21 -7
View File
@@ -97,6 +97,16 @@ typedef union
)
#endif
static SDL_Surface *
Create_Screen (SDL_Surface *template)
{
SDL_Surface *newsurf = SDL_DisplayFormat (template);
if (newsurf == 0) {
fprintf (stderr, "Couldn't create screen buffers: %s\n", SDL_GetError());
exit(-1);
}
return newsurf;
}
int
TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
@@ -104,6 +114,7 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
char VideoName[256];
int videomode_flags;
SDL_Surface *test_extra;
int i;
GraphicsDriver = driver;
gfx_flags = flags;
@@ -177,15 +188,19 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
exit(-1);
}
SDL_Screen = SDL_DisplayFormat (test_extra);
ExtraScreen = SDL_DisplayFormat (test_extra);
TransitionScreen = SDL_DisplayFormat (test_extra);
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
{
SDL_Screens[i] = Create_Screen (test_extra);
}
fade_white = SDL_DisplayFormat (test_extra);
SDL_Screen = SDL_Screens[0];
TransitionScreen = SDL_Screens[2];
fade_white = Create_Screen(test_extra);
SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
fade_black = SDL_DisplayFormat (test_extra);
fade_black = Create_Screen(test_extra);
SDL_FillRect (fade_black, NULL, SDL_MapRGB (fade_black->format, 0, 0, 0));
fade_temp = SDL_DisplayFormat (test_extra);
fade_temp = Create_Screen(test_extra);
SDL_FreeSurface (test_extra);
@@ -199,7 +214,6 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
return 0;
}
// blends two pixels with ratio 50% - 50%
__inline__ Uint32
Scale_BlendPixels (SDL_PixelFormat* fmt, Uint32 pix1, Uint32 pix2)
+12 -39
View File
@@ -29,9 +29,9 @@
SDL_Surface *SDL_Video;
SDL_Surface *SDL_Screen;
SDL_Surface *ExtraScreen;
SDL_Surface *TransitionScreen;
SDL_Surface *SDL_Screens[TFB_GFX_NUMSCREENS];
volatile int TransitionAmount = 255;
SDL_Rect TransitionClipRect;
@@ -159,20 +159,6 @@ TFB_LoadImage (SDL_Surface *img)
return(myImage);
}
void
TFB_FreeImage (TFB_Image *img)
{
if (img)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_DELETEIMAGE;
DC.image = (TFB_ImageStruct*) img;
TFB_EnqueueDrawCommand (&DC);
}
}
void
TFB_SwapBuffers ()
{
@@ -596,8 +582,7 @@ TFB_FlushGraphics () // Only call from main thread!!
targetRect.x = DC.x;
targetRect.y = DC.y;
if ((DC.w != DC_image->NormalImg->w || DC.h != DC_image->NormalImg->h) &&
DC_image->ScaledImg)
if (DC.UseScaling)
surf = DC_image->ScaledImg;
else
surf = DC_image->NormalImg;
@@ -614,7 +599,7 @@ TFB_FlushGraphics () // Only call from main thread!!
}
}
TFB_BlitSurface(surf, NULL, SDL_Screen, &targetRect, DC.BlendNumerator, DC.BlendDenominator);
TFB_BlitSurface(surf, NULL, SDL_Screens[DC.destBuffer], &targetRect, DC.BlendNumerator, DC.BlendDenominator);
break;
}
@@ -655,9 +640,9 @@ TFB_FlushGraphics () // Only call from main thread!!
else if (y2 > r.y + r.h)
y2 = r.y + r.h;
SDL_LockSurface (SDL_Screen);
line (x1, y1, x2, y2, color, screen_plot, SDL_Screen);
SDL_UnlockSurface (SDL_Screen);
SDL_LockSurface (SDL_Screens[DC.destBuffer]);
line (x1, y1, x2, y2, color, screen_plot, SDL_Screens[DC.destBuffer]);
SDL_UnlockSurface (SDL_Screens[DC.destBuffer]);
break;
}
@@ -669,7 +654,7 @@ TFB_FlushGraphics () // Only call from main thread!!
r.w = DC.w;
r.h = DC.h;
SDL_FillRect(SDL_Screen, &r, SDL_MapRGB(SDL_Screen->format, DC.r, DC.g, DC.b));
SDL_FillRect(SDL_Screens[DC.destBuffer], &r, SDL_MapRGB(SDL_Screen->format, DC.r, DC.g, DC.b));
break;
}
case TFB_DRAWCOMMANDTYPE_SCISSORENABLE:
@@ -686,7 +671,7 @@ TFB_FlushGraphics () // Only call from main thread!!
case TFB_DRAWCOMMANDTYPE_SCISSORDISABLE:
SDL_SetClipRect(SDL_Screen, NULL);
break;
case TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER:
case TFB_DRAWCOMMANDTYPE_COPYTOIMAGE:
{
SDL_Rect src, dest;
src.x = dest.x = DC.x;
@@ -694,19 +679,12 @@ TFB_FlushGraphics () // Only call from main thread!!
src.w = DC.w;
src.h = DC.h;
if (DC_image == 0)
{
TFB_BlitSurface(SDL_Screen, &src, ExtraScreen, &dest, DC.BlendNumerator, DC.BlendDenominator);
}
else
{
dest.x = 0;
dest.y = 0;
TFB_BlitSurface(SDL_Screen, &src, DC_image->NormalImg, &dest, DC.BlendNumerator, DC.BlendDenominator);
}
TFB_BlitSurface(SDL_Screens[DC.srcBuffer], &src, DC_image->NormalImg, &dest, DC.BlendNumerator, DC.BlendDenominator);
break;
}
case TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER:
case TFB_DRAWCOMMANDTYPE_COPY:
{
SDL_Rect src, dest;
src.x = dest.x = DC.x;
@@ -714,8 +692,7 @@ TFB_FlushGraphics () // Only call from main thread!!
src.w = DC.w;
src.h = DC.h;
TFB_BlitSurface(ExtraScreen, &src, SDL_Screen, &dest, DC.BlendNumerator, DC.BlendDenominator);
TFB_BlitSurface(SDL_Screens[DC.srcBuffer], &src, SDL_Screens[DC.destBuffer], &dest, DC.BlendNumerator, DC.BlendDenominator);
break;
}
case TFB_DRAWCOMMANDTYPE_DELETEIMAGE:
@@ -735,13 +712,9 @@ TFB_FlushGraphics () // Only call from main thread!!
HFree (DC_image);
DC_image = 0;
break;
case TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS:
// done = TRUE;
// TFB_SwapBuffers ();
case TFB_DRAWCOMMANDTYPE_SENDSIGNAL:
SignalThread (DC.thread);
break;
case TFB_DRAWCOMMANDTYPE_SKIPGRAPHICS:
TFB_DrawCommandQueue_Clear ();
}
if (DC_image)
UnlockMutex (DC_image->mutex);
@@ -29,11 +29,14 @@
#include "libs/input/sdl/input.h"
#include "libs/threadlib.h"
// constants for TFB_InitGraphics
extern SDL_Surface *SDL_Video;
extern SDL_Surface *SDL_Screen;
extern SDL_Surface *ExtraScreen;
extern SDL_Surface *TransitionScreen;
extern SDL_Surface *SDL_Screens[TFB_GFX_NUMSCREENS];
extern volatile int TransitionAmount;
extern SDL_Rect TransitionClipRect;