Better context drawing origin semantics; also chaser fix for foreground frame hotspot left broken in r3401

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3407 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-08 21:50:16 +00:00
parent 4ad67018fa
commit 939fc2e5db
8 changed files with 41 additions and 22 deletions
+9
View File
@@ -164,6 +164,13 @@ typedef struct line
POINT first, second;
} LINE;
static inline POINT
MAKE_POINT (COORD x, COORD y)
{
POINT pt = {x, y};
return pt;
}
static inline bool
pointsEqual (POINT p1, POINT p2)
{
@@ -278,6 +285,8 @@ extern BOOLEAN SetContextClipRect (RECT *pRect);
// The returned rect is always filled in. If the context cliprect
// is undefined, the returned rect has foreground frame dimensions.
extern BOOLEAN GetContextClipRect (RECT *pRect);
// The actual origin will be orgOffset + context ClipRect.corner
extern POINT SetContextOrigin (POINT orgOffset);
extern TIME_VALUE DrawablesIntersect (INTERSECT_CONTROL *pControl0,
INTERSECT_CONTROL *pControl1, TIME_VALUE max_time_val);
+6
View File
@@ -249,6 +249,12 @@ GetContextClipRect (RECT *lpRect)
return (_pCurContext->ClipRect.extent.width != 0);
}
POINT
SetContextOrigin (POINT orgOffset)
{
// XXX: This is a hack, kind of. But that's what the original did.
return SetFrameHot (_CurFramePtr, orgOffset);
}
FRAME
SetContextFontEffect (FRAME EffectFrame)
+5 -3
View File
@@ -363,6 +363,7 @@ RepairMeleeFrame (RECT *pRect)
RECT r;
CONTEXT OldContext;
RECT OldRect;
POINT oldOrigin;
r.corner.x = pRect->corner.x + SAFE_X;
r.corner.y = pRect->corner.y + SAFE_Y;
@@ -376,8 +377,9 @@ RepairMeleeFrame (RECT *pRect)
OldContext = SetContext (SpaceContext);
GetContextClipRect (&OldRect);
SetContextClipRect (&r);
SetFrameHot (Screen,
MAKE_HOT_SPOT (r.corner.x - SAFE_X, r.corner.y - SAFE_Y));
// Offset the origin so that we draw the correct gfx in the cliprect
oldOrigin = SetContextOrigin (MAKE_POINT (-r.corner.x + SAFE_X,
-r.corner.y + SAFE_Y));
BatchGraphics ();
DrawMeleeIcon (0); /* Entire melee screen */
@@ -413,7 +415,7 @@ RepairMeleeFrame (RECT *pRect)
DrawPickFrame (pMeleeState);
UnbatchGraphics ();
SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));
SetContextOrigin (oldOrigin);
SetContextClipRect (&OldRect);
SetContext (OldContext);
}
+3 -3
View File
@@ -128,10 +128,10 @@ RenderTopography (FRAME DstFrame, BYTE *pTopoData, int w, int h)
BYTE *pSrc;
BYTE *xlat_tab;
BYTE *cbase;
HOT_SPOT OldHot;
POINT oldOrigin;
RECT ClipRect;
OldHot = SetFrameHot (DstFrame, MAKE_HOT_SPOT (0, 0));
oldOrigin = SetContextOrigin (MAKE_POINT (0, 0));
GetContextClipRect (&ClipRect);
SetContextClipRect (NULL);
@@ -201,7 +201,7 @@ RenderTopography (FRAME DstFrame, BYTE *pTopoData, int w, int h)
}
SetContextClipRect (&ClipRect);
SetFrameHot (DstFrame, OldHot);
SetContextOrigin (oldOrigin);
}
SetContextFGFrame (OldFrame);
+5 -3
View File
@@ -287,6 +287,7 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
COUNT which_space;
long diameter;
RECT r, old_r;
POINT oldOrigin;
STAMP s;
FRAME star_frame;
STAR_DESC *SDPtr;
@@ -312,8 +313,9 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
SetContextClipRect (pClipRect);
pClipRect->corner.x -= old_r.corner.x;
pClipRect->corner.y -= old_r.corner.y;
SetFrameHot (Screen,
MAKE_HOT_SPOT (pClipRect->corner.x, pClipRect->corner.y));
// Offset the origin so that we draw the correct gfx in the cliprect
oldOrigin = SetContextOrigin (MAKE_POINT (-pClipRect->corner.x,
-pClipRect->corner.y));
}
if (transition_pending)
@@ -548,7 +550,7 @@ printf ("%s\n", buf);
if (pClipRect)
{
SetContextClipRect (&old_r);
SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));
SetContextOrigin (oldOrigin);
}
if (race_update == 0)
+1 -1
View File
@@ -107,7 +107,7 @@ LoadKernel (int argc, char *argv[])
SetContext (ScreenContext);
SetContextFGFrame (Screen);
SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));
SetContextOrigin (MAKE_POINT (0, 0));
hResIndex = (RESOURCE_INDEX) InitResourceSystem ();
if (hResIndex == 0)
+9 -9
View File
@@ -139,6 +139,8 @@ InitShipStatus (SHIP_INFO *SIPtr, STARSHIP *StarShipPtr, RECT *pClipRect)
COORD y = 0; // default, for Melee menu
STAMP Stamp;
CONTEXT OldContext;
RECT oldClipRect;
POINT oldOrigin;
if (StarShipPtr) // set during battle
{
@@ -149,14 +151,16 @@ InitShipStatus (SHIP_INFO *SIPtr, STARSHIP *StarShipPtr, RECT *pClipRect)
OldContext = SetContext (StatusContext);
if (pClipRect)
{
GetContextClipRect (&r);
GetContextClipRect (&oldClipRect);
r = oldClipRect;
r.corner.x += pClipRect->corner.x;
r.corner.y += (pClipRect->corner.y & ~1);
r.extent = pClipRect->extent;
r.extent.height += pClipRect->corner.y & 1;
SetContextClipRect (&r);
SetFrameHot (Screen, MAKE_HOT_SPOT (
pClipRect->corner.x, (pClipRect->corner.y & ~1)));
// Offset the origin so that we draw into the cliprect
oldOrigin = SetContextOrigin (MAKE_POINT (-pClipRect->corner.x,
-(pClipRect->corner.y & ~1)));
}
BatchGraphics ();
@@ -291,12 +295,8 @@ InitShipStatus (SHIP_INFO *SIPtr, STARSHIP *StarShipPtr, RECT *pClipRect)
if (pClipRect)
{
SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));
r.corner.x = SPACE_WIDTH + SAFE_X;
r.corner.y = SAFE_Y;
r.extent.width = STATUS_WIDTH;
r.extent.height = STATUS_HEIGHT;
SetContextClipRect (&r);
SetContextOrigin (oldOrigin);
SetContextClipRect (&oldClipRect);
}
SetContext (OldContext);
+3 -3
View File
@@ -144,7 +144,7 @@ PauseGame (void)
STAMP s;
CONTEXT OldContext;
FRAME F;
HOT_SPOT OldHot;
POINT oldOrigin;
RECT OldRect;
if (ActivityFrame == 0
@@ -159,7 +159,7 @@ PauseGame (void)
LockMutex (GraphicsLock);
OldContext = SetContext (ScreenContext);
OldHot = SetFrameHot (Screen, MAKE_HOT_SPOT (0, 0));
oldOrigin = SetContextOrigin (MAKE_POINT (0, 0));
GetContextClipRect (&OldRect);
SetContextClipRect (NULL);
@@ -204,7 +204,7 @@ PauseGame (void)
ClearSystemRect ();
SetContextClipRect (&OldRect);
SetFrameHot (Screen, OldHot);
SetContextOrigin (oldOrigin);
SetContext (OldContext);
WaitForNoInput (ONE_SECOND / 4, TRUE);