SetFlashRect bugfixes and speed workarounds

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@87 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2002-09-27 20:03:38 +00:00
parent 83f7223a50
commit 5f247e4dcb
5 changed files with 83 additions and 16 deletions
@@ -83,6 +83,8 @@ enum
TFB_DRAWCOMMANDTYPE_SCISSORDISABLE,
TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER,
TFB_DRAWCOMMANDTYPE_DELETEIMAGE,
TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS,
TFB_DRAWCOMMANDTYPE_SKIPGRAPHICS
};
typedef struct tfb_palette
@@ -136,6 +138,8 @@ void TFB_DrawCommandQueue_Push (TFB_DrawCommandQueue* myQueue,
int TFB_DrawCommandQueue_Pop (TFB_DrawCommandQueue* myQueue,
TFB_DrawCommand* Command);
void TFB_DrawCommandQueue_Clear (TFB_DrawCommandQueue* myQueue);
extern TFB_DrawCommandQueue *DrawCommandQueue;
// The TFB_Enqueue* functions are necessary, because only the
+13 -1
View File
@@ -48,7 +48,7 @@ InitGraphics (int argc, char* argv[], COUNT KbytesRequired)
void
UninitGraphics () // Also probably empty
{
HFree (DrawCommandQueue);
// HFree (DrawCommandQueue); This is static now!
mem_uninit ();
}
@@ -75,10 +75,22 @@ UnbatchGraphics (void)
void
FlushGraphics (void)
{
TFB_DrawCommand DrawCommand;
TFB_BatchReset ();
continuity_break = 1;
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS;
DrawCommand.image = 0;
TFB_EnqueueDrawCommand(&DrawCommand);
}
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?!? :)
@@ -197,6 +197,19 @@ TFB_DrawCommandQueue_Pop (TFB_DrawCommandQueue *myQueue, TFB_DrawCommand *target
return 1;
}
void
TFB_DrawCommandQueue_Clear (TFB_DrawCommandQueue *myQueue)
{
Lock_DCQ ();
myQueue->Size = 0;
myQueue->Front = 0;
myQueue->Back = 0;
myQueue->Batching = 0;
myQueue->FullSize = 0;
myQueue->InsertionPoint = 0;
Unlock_DCQ ();
}
void
TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand)
{
+36 -5
View File
@@ -402,8 +402,28 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
dst_getpix = getpixel_for (dst);
putpix = putpixel_for (dst);
SDL_LockSurface (src);
SDL_LockSurface (dst);
if (SDL_MUSTLOCK(src))
{
if (SDL_LockSurface (src) == -1)
{
printf("Couldn't lock src!\n");
}
else
{
printf("Locked src.\n");
}
}
if (SDL_MUSTLOCK(dst))
{
if (SDL_LockSurface (dst) == -1)
{
printf("Couldn't lock dst!\n");
}
else
{
printf("Locked dst.\n");
}
}
if (blend_denom < 0)
{
@@ -515,10 +535,15 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
}
}
}
if (SDL_MUSTLOCK(dst))
{
SDL_UnlockSurface (dst);
}
if (SDL_MUSTLOCK(src))
{
SDL_UnlockSurface (src);
}
}
void
TFB_ComputeFPS ()
@@ -562,6 +587,7 @@ TFB_FlushGraphics () // Only call from main thread!!
int semval;
int commands_handled;
BOOLEAN livelock_deterrence;
BOOLEAN done;
// This is technically a locking violation on DrawCommandQueue->Size,
// but it is likely to not be very destructive.
@@ -619,7 +645,8 @@ TFB_FlushGraphics () // Only call from main thread!!
livelock_deterrence = TRUE;
}
while (TRUE)
done = FALSE;
while (!done)
{
TFB_DrawCommand DC;
TFB_Image *DC_image;
@@ -799,8 +826,12 @@ TFB_FlushGraphics () // Only call from main thread!!
HFree (DC_image);
DC_image = 0;
break;
case TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS:
done = TRUE;
break;
case TFB_DRAWCOMMANDTYPE_SKIPGRAPHICS:
TFB_DrawCommandQueue_Clear (DrawCommandQueue);
}
if (DC_image)
UnlockMutex (DC_image->mutex);
}
+10 -3
View File
@@ -932,7 +932,7 @@ int flash_rect_func(void *data)
{
#define NORMAL_STRENGTH 4
#define NORMAL_F_STRENGTH 0
DWORD TimeIn;
DWORD TimeIn, WaitTime;
SIZE strength, fstrength, incr;
Task task = (Task)data;
@@ -940,6 +940,7 @@ int flash_rect_func(void *data)
incr = 1;
strength = NORMAL_STRENGTH;
TimeIn = GetTimeCounter ();
WaitTime = ONE_SECOND / 16;
while (!Task_ReadState(task, TASK_EXIT))
{
CONTEXT OldContext;
@@ -1002,10 +1003,16 @@ int flash_rect_func(void *data)
SetGraphicStrength (4, 4);
UnbatchGraphics ();
FlushGraphics ();
/* ACK, cheap hack, oh well, blame Michael Martin until he fixes it */
if (flash_rect.extent.width > 250)
{
SkipGraphics ();
}
}
SetContext (OldContext);
ClearSemaphore (GraphicsSem);
SleepThreadUntil (TimeIn + (ONE_SECOND / 16));
SleepThreadUntil (TimeIn + WaitTime);
TimeIn = GetTimeCounter ();
}
@@ -1045,7 +1052,7 @@ SetFlashRect (PRECT pRect, FRAME f)
flash_rect.extent.width = 0;
if (flash_task)
{
Task_SetState (flash_task, TASK_EXIT);
ConcludeTask (flash_task);
}
}
else