New header file, explicitly for DrawCommands.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@554 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Changes towards version 0.2:
|
||||
- Split away DCQ-specific code into its own header file
|
||||
- Added correct lander font - from fOSSiL
|
||||
- Added support for multiple menu hierarchies, and a few PC hiers. -PBlue
|
||||
- Fixed a potential semaphore race when suspending clock -PhracturedBlue
|
||||
|
||||
@@ -253,6 +253,10 @@ SOURCE=..\sc2code\libs\graphics\drawable.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sc2code\libs\graphics\drawcmd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sc2code\libs\graphics\filegfx.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
//Copyright Paul Reiche, Fred Ford. 1992-2002
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef DRAWCMD_H
|
||||
#define DRAWCMD_H
|
||||
|
||||
enum
|
||||
{
|
||||
TFB_DRAWCOMMANDTYPE_LINE,
|
||||
TFB_DRAWCOMMANDTYPE_RECTANGLE,
|
||||
TFB_DRAWCOMMANDTYPE_IMAGE,
|
||||
|
||||
TFB_DRAWCOMMANDTYPE_COPY,
|
||||
TFB_DRAWCOMMANDTYPE_COPYTOIMAGE,
|
||||
|
||||
TFB_DRAWCOMMANDTYPE_SCISSORENABLE,
|
||||
TFB_DRAWCOMMANDTYPE_SCISSORDISABLE,
|
||||
|
||||
TFB_DRAWCOMMANDTYPE_DELETEIMAGE,
|
||||
TFB_DRAWCOMMANDTYPE_SENDSIGNAL,
|
||||
};
|
||||
|
||||
typedef struct tfb_drawcommand
|
||||
{
|
||||
int Type;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
TFB_ImageStruct *image;
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
TFB_Palette Palette[256];
|
||||
BOOLEAN UsePalette;
|
||||
BOOLEAN UseScaling;
|
||||
int BlendNumerator;
|
||||
int BlendDenominator;
|
||||
DWORD thread;
|
||||
SCREEN srcBuffer;
|
||||
SCREEN destBuffer;
|
||||
} TFB_DrawCommand;
|
||||
|
||||
|
||||
// Queue Stuff
|
||||
|
||||
typedef struct tfb_drawcommandqueue
|
||||
{
|
||||
int Front;
|
||||
int Back;
|
||||
int InsertionPoint;
|
||||
int Batching;
|
||||
volatile int FullSize;
|
||||
volatile int Size;
|
||||
} TFB_DrawCommandQueue;
|
||||
|
||||
void TFB_DrawCommandQueue_Create (void);
|
||||
|
||||
void TFB_BatchGraphics (void);
|
||||
|
||||
void TFB_UnbatchGraphics (void);
|
||||
|
||||
void TFB_BatchReset (void);
|
||||
|
||||
void TFB_DrawCommandQueue_Push (TFB_DrawCommand* Command);
|
||||
|
||||
int TFB_DrawCommandQueue_Pop (TFB_DrawCommand* Command);
|
||||
|
||||
void TFB_DrawCommandQueue_Clear (void);
|
||||
|
||||
extern TFB_DrawCommandQueue DrawCommandQueue;
|
||||
|
||||
void TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand);
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "libs/graphics/gfxintrn.h"
|
||||
#include "libs/input/inpintrn.h"
|
||||
#include "libs/graphics/gfx_common.h"
|
||||
#include "libs/graphics/drawcmd.h"
|
||||
|
||||
PDISPLAY_INTERFACE _pCurDisplay; //Not a function. Probably has to be initialized...
|
||||
|
||||
|
||||
@@ -78,21 +78,6 @@ typedef struct tfb_imagestruct
|
||||
UBYTE data[TFB_IMAGESTRUCT_SIZE];
|
||||
} TFB_ImageStruct;
|
||||
|
||||
enum
|
||||
{
|
||||
TFB_DRAWCOMMANDTYPE_LINE,
|
||||
TFB_DRAWCOMMANDTYPE_RECTANGLE,
|
||||
TFB_DRAWCOMMANDTYPE_IMAGE,
|
||||
|
||||
TFB_DRAWCOMMANDTYPE_COPY,
|
||||
TFB_DRAWCOMMANDTYPE_COPYTOIMAGE,
|
||||
|
||||
TFB_DRAWCOMMANDTYPE_SCISSORENABLE,
|
||||
TFB_DRAWCOMMANDTYPE_SCISSORDISABLE,
|
||||
|
||||
TFB_DRAWCOMMANDTYPE_DELETEIMAGE,
|
||||
TFB_DRAWCOMMANDTYPE_SENDSIGNAL,
|
||||
};
|
||||
|
||||
typedef struct tfb_palette
|
||||
{
|
||||
@@ -102,28 +87,7 @@ typedef struct tfb_palette
|
||||
UBYTE unused;
|
||||
} TFB_Palette;
|
||||
|
||||
typedef struct tfb_drawcommand
|
||||
{
|
||||
int Type;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
TFB_ImageStruct *image;
|
||||
int r;
|
||||
int g;
|
||||
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)
|
||||
// Drawing commands
|
||||
|
||||
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);
|
||||
@@ -133,38 +97,6 @@ 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
|
||||
{
|
||||
int Front;
|
||||
int Back;
|
||||
int InsertionPoint;
|
||||
int Batching;
|
||||
volatile int FullSize;
|
||||
volatile int Size;
|
||||
} TFB_DrawCommandQueue;
|
||||
|
||||
void TFB_DrawCommandQueue_Create (void);
|
||||
|
||||
void TFB_BatchGraphics (void);
|
||||
|
||||
void TFB_UnbatchGraphics (void);
|
||||
|
||||
void TFB_BatchReset (void);
|
||||
|
||||
void TFB_DrawCommandQueue_Push (TFB_DrawCommand* Command);
|
||||
|
||||
int TFB_DrawCommandQueue_Pop (TFB_DrawCommand* Command);
|
||||
|
||||
void TFB_DrawCommandQueue_Clear (void);
|
||||
|
||||
extern TFB_DrawCommandQueue DrawCommandQueue;
|
||||
|
||||
// The TFB_Enqueue* functions are necessary, because only the
|
||||
// main thread can draw to the window.
|
||||
|
||||
void TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand);
|
||||
void TFB_FlushGraphics (void); // Only call from main thread!!
|
||||
|
||||
// CCB Stuff
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "pure.h"
|
||||
#include "opengl.h"
|
||||
#include "primitives.h"
|
||||
#include "graphics/drawcmd.h"
|
||||
|
||||
int batch_depth = 0;
|
||||
static const BOOLEAN pausing_transition = TRUE; // change to FALSE for non-pausing version
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "sdl_common.h"
|
||||
#include "libs/threadlib.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "libs/graphics/drawcmd.h"
|
||||
|
||||
Semaphore DCQ_sem;
|
||||
|
||||
@@ -131,6 +132,24 @@ TFB_BatchReset (void)
|
||||
Unlock_DCQ ();
|
||||
}
|
||||
|
||||
// Wait for the queue to be emptied.
|
||||
static void
|
||||
TFB_WaitForSpace (int requested_slots)
|
||||
{
|
||||
int old_depth, i;
|
||||
fprintf (stderr, "DCQ overload (Size = %d, FullSize = %d, Requested = %d). Sleeping until renderer is done.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize, requested_slots);
|
||||
// Restore the DCQ locking level. I *think* this is
|
||||
// always 1, but...
|
||||
TFB_BatchReset ();
|
||||
old_depth = DCQ_locking_depth;
|
||||
for (i = 0; i < old_depth; i++)
|
||||
Unlock_DCQ ();
|
||||
WaitCondVar (RenderingCond);
|
||||
for (i = 0; i < old_depth; i++)
|
||||
Lock_DCQ ();
|
||||
fprintf (stderr, "DCQ clear (Size = %d, FullSize = %d). Continuing.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize);
|
||||
}
|
||||
|
||||
// Draw Command Queue Stuff
|
||||
|
||||
void
|
||||
@@ -154,18 +173,7 @@ TFB_DrawCommandQueue_Push (TFB_DrawCommand* Command)
|
||||
Lock_DCQ ();
|
||||
while (DrawCommandQueue.FullSize >= DCQ_MAX - 1)
|
||||
{
|
||||
int old_depth, i;
|
||||
fprintf (stderr, "DCQ overload (Size = %d, FullSize = %d). Sleeping until renderer is done.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize);
|
||||
// Restore the DCQ locking level. I *think* this is
|
||||
// always 1, but...
|
||||
TFB_BatchReset ();
|
||||
old_depth = DCQ_locking_depth;
|
||||
for (i = 0; i < old_depth; i++)
|
||||
Unlock_DCQ ();
|
||||
WaitCondVar (RenderingCond);
|
||||
for (i = 0; i < old_depth; i++)
|
||||
Lock_DCQ ();
|
||||
fprintf (stderr, "DCQ clear (Size = %d, FullSize = %d). Continuing.\n", DrawCommandQueue.Size, DrawCommandQueue.FullSize);
|
||||
TFB_WaitForSpace (1);
|
||||
}
|
||||
DCQ[DrawCommandQueue.InsertionPoint] = *Command;
|
||||
DrawCommandQueue.InsertionPoint = (DrawCommandQueue.InsertionPoint + 1) % DCQ_MAX;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "dcqueue.h"
|
||||
#include "options.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "libs/graphics/drawcmd.h"
|
||||
|
||||
SDL_Surface *SDL_Video;
|
||||
SDL_Surface *SDL_Screen;
|
||||
|
||||
Reference in New Issue
Block a user