Gfxlib cleanup: DISPLAY_INTERFACE removed

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3466 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-24 21:35:45 +00:00
parent ce1dd1aea7
commit a41e2837f8
13 changed files with 58 additions and 199 deletions
-8
View File
@@ -290,10 +290,6 @@ SOURCE=..\..\src\libs\graphics\sdl\2xscalers_sse.c
# End Source File
# Begin Source File
SOURCE=..\..\src\libs\graphics\sdl\3do_blt.c
# End Source File
# Begin Source File
SOURCE=..\..\src\libs\graphics\sdl\3do_funcs.c
# End Source File
# Begin Source File
@@ -439,10 +435,6 @@ SOURCE=..\..\src\libs\graphics\dcqueue.h
# End Source File
# Begin Source File
SOURCE=..\..\src\libs\graphics\display.h
# End Source File
# Begin Source File
SOURCE=..\..\src\libs\graphics\drawable.c
# End Source File
# Begin Source File
+7 -1
View File
@@ -133,8 +133,14 @@ buildColorRgba (BYTE r, BYTE g, BYTE b, BYTE a)
typedef BYTE CREATE_FLAGS;
// WANT_MASK is deprecated (and non-functional). It used to generate a bitmap
// of changed pixels for a target DRAWABLE, so that DRAW_SUBTRACTIVE could
// paint background pixels over them, i.e. a revert draw. The backgrounds
// are fully erased now instead.
#define WANT_MASK (CREATE_FLAGS)(1 << 0)
#define WANT_PIXMAP (CREATE_FLAGS)(1 << 1)
// MAPPED_TO_DISPLAY is deprecated but still checked by LoadDisplayPixmap().
// Its former use was to indicate a pre-scaled graphic for the display.
#define MAPPED_TO_DISPLAY (CREATE_FLAGS)(1 << 2)
#define WANT_ALPHA (CREATE_FLAGS)(1 << 3)
@@ -334,7 +340,7 @@ extern BOOLEAN InstallGraphicResTypes (void);
extern DRAWABLE LoadGraphicFile (const char *pStr);
extern FONT LoadFontFile (const char *pStr);
extern void *LoadGraphicInstance (RESOURCE res);
extern DRAWABLE LoadDisplayPixmap (RECT *area, FRAME frame);
extern DRAWABLE LoadDisplayPixmap (const RECT *area, FRAME frame);
extern FRAME SetContextFontEffect (FRAME EffectFrame);
extern FONT SetContextFont (FONT Font);
extern BOOLEAN DestroyFont (FONT FontRef);
+2 -8
View File
@@ -117,15 +117,11 @@ extern GRAPHICS_STATUS _GraphicsStatusFlags;
#define GRAPHICS_VISIBLE (GRAPHICS_STATUS)(1 << 1)
#define CONTEXT_ACTIVE (GRAPHICS_STATUS)(1 << 2)
#define DRAWABLE_ACTIVE (GRAPHICS_STATUS)(1 << 3)
#define DISPLAY_ACTIVE (GRAPHICS_STATUS)(1 << 5)
#define DeactivateGraphics() (_GraphicsStatusFlags &= ~GRAPHICS_ACTIVE)
#define ActivateGraphics() (_GraphicsStatusFlags |= GRAPHICS_ACTIVE)
#define GraphicsActive() (_GraphicsStatusFlags & GRAPHICS_ACTIVE)
#define DeactivateVisible() (_GraphicsStatusFlags &= ~GRAPHICS_VISIBLE)
#define ActivateVisible() (_GraphicsStatusFlags |= GRAPHICS_VISIBLE)
#define DeactivateDisplay() (_GraphicsStatusFlags &= ~DISPLAY_ACTIVE)
#define ActivateDisplay() (_GraphicsStatusFlags |= DISPLAY_ACTIVE)
#define DisplayActive() (_GraphicsStatusFlags & DISPLAY_ACTIVE)
#define DeactivateContext() (_GraphicsStatusFlags &= ~CONTEXT_ACTIVE)
#define ActivateContext() (_GraphicsStatusFlags |= CONTEXT_ACTIVE)
#define ContextActive() (_GraphicsStatusFlags & CONTEXT_ACTIVE)
@@ -133,10 +129,8 @@ extern GRAPHICS_STATUS _GraphicsStatusFlags;
#define ActivateDrawable() (_GraphicsStatusFlags |= DRAWABLE_ACTIVE)
#define DrawableActive() (_GraphicsStatusFlags & DRAWABLE_ACTIVE)
#define SYSTEM_ACTIVE (GRAPHICS_STATUS)( \
DISPLAY_ACTIVE | CONTEXT_ACTIVE | \
DRAWABLE_ACTIVE \
)
#define SYSTEM_ACTIVE (GRAPHICS_STATUS)(CONTEXT_ACTIVE | DRAWABLE_ACTIVE)
#define GraphicsSystemActive() \
((_GraphicsStatusFlags & SYSTEM_ACTIVE) == SYSTEM_ACTIVE)
#define GraphicsStatus() \
-50
View File
@@ -1,50 +0,0 @@
//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 _DISPLAY_H
#define _DISPLAY_H
typedef struct
{
CREATE_FLAGS DisplayFlags;
BYTE DisplayDepth;
COUNT DisplayWidth;
COUNT DisplayHeight;
DRAWABLE (*alloc_image) (COUNT NumFrames, DRAWABLE_TYPE DrawableType,
CREATE_FLAGS flags, SIZE width, SIZE height);
void (*read_display) (RECT *pRect, FRAME DstFramePtr);
} DISPLAY_INTERFACE;
extern DISPLAY_INTERFACE *_pCurDisplay;
extern void (* mask_func_array[]) (RECT *pClipRect, PRIMITIVE *PrimPtr);
#define AllocDrawableImage (*_pCurDisplay->alloc_image)
#define ReadDisplay (*_pCurDisplay->read_display)
#define GetDisplayFlags() (_pCurDisplay->DisplayFlags)
#define GetDisplayDepth() (_pCurDisplay->DisplayDepth)
#define GetDisplayWidth() (_pCurDisplay->DisplayWidth)
#define GetDisplayHeight() (_pCurDisplay->DisplayHeight)
#endif /* _DISPLAY_H */
+9 -10
View File
@@ -16,7 +16,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gfxintrn.h"
#include "libs/gfxlib.h"
#include "libs/graphics/context.h"
#include "libs/graphics/drawable.h"
#include "libs/memlib.h"
#include "tfb_draw.h"
#include <math.h>
@@ -61,17 +63,17 @@ CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth, SIZE *pheight)
{
DRAWABLE Drawable;
if (!DisplayActive ())
return (0);
// TODO: ScreenWidth and ScreenHeight should be passed in
// instead of returned.
Drawable = _request_drawable (1, SCREEN_DRAWABLE,
(CreateFlags & (WANT_PIXMAP | (GetDisplayFlags () & WANT_MASK))),
GetDisplayWidth (), GetDisplayHeight ());
(CreateFlags & (WANT_PIXMAP | WANT_MASK)),
ScreenWidth, ScreenHeight);
if (Drawable)
{
FRAME F;
if ((F = CaptureDrawable (Drawable)) == 0)
F = CaptureDrawable (Drawable);
if (F == 0)
DestroyDrawable (Drawable);
else
{
@@ -126,9 +128,6 @@ CreateDrawable (CREATE_FLAGS CreateFlags, SIZE width, SIZE height, COUNT
{
DRAWABLE Drawable;
if (!DisplayActive ())
return (0);
Drawable = _request_drawable (num_frames, RAM_DRAWABLE,
(CreateFlags & (WANT_MASK | WANT_PIXMAP
| WANT_ALPHA | MAPPED_TO_DISPLAY)),
-4
View File
@@ -23,10 +23,6 @@
#include "libs/misc.h"
// for TFB_DEBUG_HALT
DISPLAY_INTERFACE *_pCurDisplay; //Not a function. Probably has to be initialized...
void (*mask_func_array[]) (RECT *pClipRect, PRIMITIVE *PrimPtr)
= { 0 };
int ScreenWidth;
int ScreenHeight;
-1
View File
@@ -27,7 +27,6 @@
#include "context.h"
#include "drawable.h"
#include "font.h"
#include "display.h"
#endif /* _GFXINTRN_H */
+36 -28
View File
@@ -16,42 +16,50 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gfxintrn.h"
/*
LoadDisplay---Drawable
Allocate a chunk of memory and read from the display into that
chunk of memory.
LoadDisplayPixmapDrawable()
LoadDisplayMaskDrawable()
LoadDisplayPixmapMaskDrawable()
*/
#include "libs/gfxlib.h"
#include "libs/graphics/drawable.h"
#include "libs/log.h"
// Reads a piece of screen into a passed FRAME or a newly created one
DRAWABLE
LoadDisplayPixmap (RECT *area, FRAME frame)
LoadDisplayPixmap (const RECT *area, FRAME frame)
{
// TODO: This should just return a FRAME instead of DRAWABLE
DRAWABLE buffer = GetFrameParentDrawable (frame);
COUNT index = GetFrameIndex (frame);
COUNT index;
if (buffer || (buffer = CreateDrawable (
WANT_PIXMAP | MAPPED_TO_DISPLAY,
area->extent.width,
area->extent.height,
1))
)
if (!buffer)
{ // asked to create a new DRAWABLE instead
buffer = CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY,
area->extent.width, area->extent.height, 1);
if (!buffer)
return NULL;
index = 0;
}
else
{
frame = SetAbsFrameIndex (CaptureDrawable (buffer), index);
ReadDisplay (area, frame);
ReleaseDrawable (frame);
index = GetFrameIndex (frame);
}
return (buffer);
frame = SetAbsFrameIndex (CaptureDrawable (buffer), index);
if (_CurFramePtr->Type != SCREEN_DRAWABLE
|| frame->Type == SCREEN_DRAWABLE
|| !(GetFrameParentDrawable (frame)->Flags & MAPPED_TO_DISPLAY))
{
log_add (log_Warning, "Unimplemented function activated: "
"LoadDisplayPixmap()");
}
else
{
TFB_Image *img = frame->image;
TFB_DrawScreen_CopyToImage (img, area, TFB_SCREEN_MAIN);
}
ReleaseDrawable (frame);
return buffer;
}
-74
View File
@@ -1,74 +0,0 @@
//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.
*/
#ifdef GFXMODULE_SDL
#include "sdl_common.h"
#include "libs/graphics/tfb_draw.h"
#include "libs/log.h"
static void
read_screen (RECT *lpRect, FRAME DstFramePtr)
{
if (_CurFramePtr->Type != SCREEN_DRAWABLE
|| DstFramePtr->Type == SCREEN_DRAWABLE
|| !(GetFrameParentDrawable (DstFramePtr)->Flags
& MAPPED_TO_DISPLAY))
{
log_add (log_Warning, "Unimplemented function activated: "
"read_screen()");
}
else
{
TFB_Image *img = DstFramePtr->image;
TFB_DrawScreen_CopyToImage (img, lpRect, TFB_SCREEN_MAIN);
}
}
static DRAWABLE
alloc_image (COUNT NumFrames, DRAWABLE_TYPE DrawableType, CREATE_FLAGS
flags, SIZE width, SIZE height)
{
/* dodge compiler warnings */
(void)DrawableType;
(void)flags;
(void)width;
(void)height;
return AllocDrawable (NumFrames);
}
static DISPLAY_INTERFACE DisplayInterface =
{
/* .DisplayFlags = */ WANT_MASK,
/* .DisplayDepth = */ 16,
/* .DisplayWidth = */ 320,
/* .DisplayHeight = */ 240,
/* .alloc_iamge = */ alloc_image,
/* .read_display = */ read_screen,
};
void
LoadDisplay (DISPLAY_INTERFACE **pDisplay)
{
*pDisplay = &DisplayInterface;
}
#endif
+2 -8
View File
@@ -26,23 +26,17 @@
#include "libs/graphics/tfb_draw.h"
//Status: Not entirely unimplemented!
// Status: Ignored
BOOLEAN
InitGraphics (int argc, char* argv[], COUNT KbytesRequired)
// Kbytes should only matter if we wanted to port Starcon2 to the
// hand-helds...
{
BOOLEAN ret;
LoadDisplay (&_pCurDisplay);
ActivateDisplay ();
(void) argc; /* lint */
(void) argv; /* lint */
(void) KbytesRequired; /* lint */
ret = TRUE;
return (ret);
return TRUE;
}
// Status: Unimplemented
+1 -3
View File
@@ -835,9 +835,7 @@ _request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType,
{
DRAWABLE Drawable;
Drawable = AllocDrawableImage (
NumFrames, DrawableType, flags, width, height
);
Drawable = AllocDrawable (NumFrames);
if (Drawable)
{
int imgw, imgh;
+1 -1
View File
@@ -1,4 +1,4 @@
uqm_CFILES="3do_blt.c 3do_funcs.c 3do_getbody.c opengl.c
uqm_CFILES="3do_funcs.c 3do_getbody.c opengl.c
palette.c
primitives.c pure.c sdl_common.c
scalers.c 2xscalers.c
-3
View File
@@ -46,9 +46,6 @@ extern SDL_Surface *SDL_Screens[TFB_GFX_NUMSCREENS];
extern SDL_Surface *format_conv_surf;
void ScreenOrigin (FRAME Display, COORD sx, COORD sy);
void LoadDisplay (DISPLAY_INTERFACE **pDisplay);
SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface);
void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
SDL_Rect *dstrect, int blend_numer, int blend_denom);