FlushGraphics now blocks until the requested graphics are drawn

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@387 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2002-12-09 22:05:29 +00:00
parent f0524f8540
commit f9807bf16d
11 changed files with 35 additions and 19 deletions
+2
View File
@@ -61,7 +61,9 @@ ConfirmExit (void)
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
DrawStamp (&s);
ClearSemaphore (GraphicsSem);
FlushGraphics ();
SetSemaphore (GraphicsSem);
{
INPUT_STATE PressState;
@@ -81,6 +81,7 @@ FlushGraphics (void)
DrawCommand.Type = TFB_DRAWCOMMANDTYPE_FLUSHGRAPHICS;
DrawCommand.image = 0;
TFB_EnqueueDrawCommand(&DrawCommand);
WaitCondVar (RenderingCond);
}
void
+15 -10
View File
@@ -155,18 +155,23 @@ TFB_DrawCommandQueue_Push (TFB_DrawCommandQueue* myQueue,
TFB_DrawCommand* Command)
{
Lock_DCQ ();
if (myQueue->FullSize < DCQ_MAX - 1)
while (myQueue->FullSize >= DCQ_MAX - 1)
{
DCQ[myQueue->InsertionPoint] = *Command;
myQueue->InsertionPoint = (myQueue->InsertionPoint + 1) % DCQ_MAX;
myQueue->FullSize++;
Synchronize_DCQ ();
int old_depth, i;
fprintf (stderr, "DCQ overload. Sleeping until renderer is done.\n");
// Restore the DCQ locking level. I *think* this is
// always 1, but...
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 ();
}
else
{
fprintf (stderr, "DCQ overload. Adjust your livelock deterrence constants!\n");
}
DCQ[myQueue->InsertionPoint] = *Command;
myQueue->InsertionPoint = (myQueue->InsertionPoint + 1) % DCQ_MAX;
myQueue->FullSize++;
Synchronize_DCQ ();
Unlock_DCQ ();
}
@@ -537,14 +537,14 @@ TFB_FlushGraphics () // Only call from main thread!!
{
TFB_SwapBuffers(); // if fading, redraw every frame
}
else
else
{
SDL_Delay(1);
SDL_Delay(1);
}
last_fade = current_fade;
last_transition = current_transition;
BroadcastCondVar (RenderingCond);
return;
}
@@ -556,7 +556,10 @@ TFB_FlushGraphics () // Only call from main thread!!
semval = TimeoutSetSemaphore (GraphicsSem, ONE_SECOND / 10);
if (semval != 0)
{
BroadcastCondVar (RenderingCond);
return;
}
else
SDL_SemPost (GraphicsSem);
}
@@ -776,6 +779,7 @@ TFB_FlushGraphics () // Only call from main thread!!
}
TFB_SwapBuffers();
BroadcastCondVar (RenderingCond);
}
#endif
+1
View File
@@ -45,6 +45,7 @@ QUEUE race_q[NUM_PLAYERS];
SOUND MenuSounds, GameSounds;
FRAME ActivityFrame, status, flagship_status, misc_data;
Semaphore GraphicsSem;
CondVar RenderingCond;
STRING GameStrings;
static MEM_HANDLE
+1 -6
View File
@@ -1004,15 +1004,10 @@ 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);
FlushGraphics ();
SleepThreadUntil (TimeIn + WaitTime);
TimeIn = GetTimeCounter ();
}
+1
View File
@@ -169,6 +169,7 @@ extern FRAME ActivityFrame;
extern SOUND MenuSounds, GameSounds;
extern QUEUE race_q[NUM_PLAYERS];
extern Semaphore GraphicsSem;
extern CondVar RenderingCond;
extern STRING GameStrings;
typedef enum
+2
View File
@@ -174,7 +174,9 @@ PauseGame (void)
F = CaptureDrawable (LoadDisplayPixmap (&r, (FRAME)0));
DrawStamp (&s);
ClearSemaphore (GraphicsSem);
FlushGraphics ();
SetSemaphore (GraphicsSem);
{
BYTE scan;
+1
View File
@@ -221,6 +221,7 @@ main (int argc, char *argv[])
mem_init ();
GraphicsSem = CreateSemaphore (1);
RenderingCond = CreateCondVar ();
init_xform_control ();
TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);