Add CopyContextRect() gfxlib call, which should eventually replace direct LoadDisplayPixmap() calls; this also scratches off a FlashContext to-do
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3488 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -345,6 +345,9 @@ extern BOOLEAN GetContextClipRect (RECT *pRect);
|
||||
extern POINT SetContextOrigin (POINT orgOffset);
|
||||
extern DrawMode SetContextDrawMode (DrawMode);
|
||||
extern DrawMode GetContextDrawMode (void);
|
||||
// 'area' may be NULL to copy the entire CONTEXT cliprect
|
||||
// 'area' is relative to the CONTEXT cliprect
|
||||
extern DRAWABLE CopyContextRect (const RECT* area);
|
||||
|
||||
extern TIME_VALUE DrawablesIntersect (INTERSECT_CONTROL *pControl0,
|
||||
INTERSECT_CONTROL *pControl1, TIME_VALUE max_time_val);
|
||||
|
||||
@@ -344,6 +344,38 @@ FixContextFontEffect (void)
|
||||
UnsetContextFBkFlags (FBK_DIRTY);
|
||||
}
|
||||
|
||||
// 'area' may be NULL to copy the entire CONTEXT cliprect
|
||||
// 'area' is relative to the CONTEXT cliprect
|
||||
DRAWABLE
|
||||
CopyContextRect (const RECT* area)
|
||||
{
|
||||
RECT clipRect;
|
||||
RECT fgRect;
|
||||
RECT r;
|
||||
|
||||
if (!ContextActive () || !_CurFramePtr)
|
||||
return NULL;
|
||||
|
||||
fgRect = _get_context_fg_rect ();
|
||||
GetContextClipRect (&clipRect);
|
||||
r = clipRect;
|
||||
if (area)
|
||||
{ // a portion of the context
|
||||
r.corner.x += area->corner.x;
|
||||
r.corner.y += area->corner.y;
|
||||
r.extent = area->extent;
|
||||
}
|
||||
// TODO: Should this take CONTEXT origin into account too?
|
||||
// validate the rect
|
||||
if (!BoxIntersect (&r, &fgRect, &r))
|
||||
return NULL;
|
||||
|
||||
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
|
||||
return LoadDisplayPixmap (&r, NULL);
|
||||
else
|
||||
return CopyFrameRect (_CurFramePtr, &r);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
const char *
|
||||
GetContextName (CONTEXT context)
|
||||
|
||||
+3
-16
@@ -533,32 +533,19 @@ static void
|
||||
Flash_grabOriginal (FlashContext *context)
|
||||
{
|
||||
CONTEXT oldGfxContext;
|
||||
RECT clipRect;
|
||||
RECT grabRect;
|
||||
|
||||
if (context->original != (FRAME) 0)
|
||||
DestroyDrawable (ReleaseDrawable (context->original));
|
||||
|
||||
// XXX: This assumes that FlashContext.gfxContext is an on-screen CONTEXT
|
||||
// (i.e. it's foreground frame is Screen). LoadDisplayPixmap() would
|
||||
// not work with an off-screen context.
|
||||
// TODO: Get rid of LoadDisplayPixmap(). It does not take CONTEXT
|
||||
// clip-rect into account.
|
||||
LockMutex (GraphicsLock);
|
||||
oldGfxContext = SetContext (context->gfxContext);
|
||||
// FlashContext.rect is relative to the CONTEXT clip-rect
|
||||
grabRect = context->rect;
|
||||
GetContextClipRect (&clipRect);
|
||||
grabRect.corner.x += clipRect.corner.x;
|
||||
grabRect.corner.y += clipRect.corner.y;
|
||||
context->original = CaptureDrawable (LoadDisplayPixmap (
|
||||
&grabRect, (FRAME) 0));
|
||||
context->original = CaptureDrawable (CopyContextRect (&context->rect));
|
||||
SetContext (oldGfxContext);
|
||||
UnlockMutex (GraphicsLock);
|
||||
FlushGraphics ();
|
||||
// LoadDisplayPixmap only queues the command to read
|
||||
// CopyContextRect() may have queued the command to read
|
||||
// a rectangle from the screen; a FlushGraphics()
|
||||
// is necessary to ensure that it can actually be used.
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
||||
@@ -78,11 +78,6 @@
|
||||
*
|
||||
* Limitations:
|
||||
*
|
||||
* 1) Highlight and overlay flashing modes read the original gfxContext
|
||||
* contents, but they do so with LoadDisplayPixmap(). This means that these
|
||||
* modes can currently only be used with on-screen CONTEXTs (i.e. CONTEXTs
|
||||
* that have Screen as foreground FRAME);
|
||||
*
|
||||
* 2) Functions that draw to the gfxContext or read the original gfxContext
|
||||
* contents, which is most of them, must be called with gfxContext having
|
||||
* the same clip-rect as it did when other drawing functions were called.
|
||||
|
||||
+2
-8
@@ -112,18 +112,12 @@ SeedRandomNumbers (void)
|
||||
}
|
||||
|
||||
STAMP
|
||||
SaveContextFrame (RECT *saveRect)
|
||||
SaveContextFrame (const RECT *saveRect)
|
||||
{
|
||||
STAMP s;
|
||||
RECT r;
|
||||
|
||||
GetContextClipRect (&r);
|
||||
if (saveRect)
|
||||
{ // a portion of the context
|
||||
r.corner.x += saveRect->corner.x;
|
||||
r.corner.y += saveRect->corner.y;
|
||||
r.extent = saveRect->extent;
|
||||
|
||||
s.origin = saveRect->corner;
|
||||
}
|
||||
else
|
||||
@@ -132,7 +126,7 @@ SaveContextFrame (RECT *saveRect)
|
||||
s.origin.y = 0;
|
||||
}
|
||||
|
||||
s.frame = CaptureDrawable (LoadDisplayPixmap (&r, NULL));
|
||||
s.frame = CaptureDrawable (CopyContextRect (saveRect));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ extern void DrawStarConBox (RECT *pRect, SIZE BorderWidth,
|
||||
extern DWORD SeedRandomNumbers (void);
|
||||
|
||||
// saveRect can be NULL to save the entire context frame
|
||||
extern STAMP SaveContextFrame (RECT *saveRect);
|
||||
extern STAMP SaveContextFrame (const RECT *saveRect);
|
||||
|
||||
#endif /* _UTIL_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user