[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/video.h video/graphic.c v...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src include/video.h video/graphic.c v... |
Date: |
14 Jan 2004 16:42:13 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/14 16:42:12
Modified files:
src/include : video.h
src/video : graphic.c sprite.c video.c
Log message:
Added VideoFree and VideoSaveFree, fixed bug removing surfaces from
PaletteList
Patches:
Index: stratagus/src/include/video.h
diff -u stratagus/src/include/video.h:1.109 stratagus/src/include/video.h:1.110
--- stratagus/src/include/video.h:1.109 Sat Jan 10 09:18:57 2004
+++ stratagus/src/include/video.h Wed Jan 14 16:42:10 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.h,v 1.109 2004/01/09 22:18:57 jsalmon3 Exp $
+// $Id: video.h,v 1.110 2004/01/14 05:42:10 jsalmon3 Exp $
#ifndef __VIDEO_H__
#define __VIDEO_H__
@@ -93,55 +93,6 @@
Graphic* Graphic; ///
graphic pointer to use to run time
} GraphicConfig;
-/**
-** General graphic object type.
-*/
-typedef struct _graphic_type_ {
- /// Draw the object unclipped.
- void (*Draw)(const Graphic* o, unsigned f, int x, int y);
- /// Draw the object unclipped and flipped in X
direction.
- void (*DrawX)(const Graphic* o, unsigned f, int x, int y);
- /// Draw the object clipped to the current clipping.
- void (*DrawClip)(const Graphic* o, unsigned f, int x, int y);
- /// Draw the object clipped and flipped in X
direction.
- void (*DrawClipX)(const Graphic* o, unsigned f, int x, int y);
-
- ///50% Translucide functions
- /// Draw the object unclipped.
- void (*DrawTrans50)(const Graphic* o, unsigned f, int x, int y);
- /// Draw the object unclipped and flipped in X
direction.
- void (*DrawXTrans50)(const Graphic* o, unsigned f, int x, int y);
- /// Draw the object clipped to the current clipping.
- void (*DrawClipTrans50)(const Graphic* o, unsigned f, int x, int y);
- /// Draw the object clipped and flipped in X
direction.
- void (*DrawClipXTrans50)(const Graphic* o, unsigned f, int x, int y);
-
- /// Draw the shadow object clipped to the current
clipping.
- void (*DrawShadowClip)(const Graphic* o, unsigned f, int x, int y);
- /// Draw the shadow object clipped and flipped in X
direction.
- void (*DrawShadowClipX)(const Graphic* o, unsigned f, int x, int y);
- /// Draw part of the object unclipped.
- void (*DrawSub)(const Graphic* o, int gx, int gy,
- int w, int h, int x, int y);
- /// Draw part of the object unclipped and flipped
in X direction.
- void (*DrawSubX)(const Graphic* o, int gx, int gy,
- int w, int h, int x, int y);
- /// Draw part of the object clipped to the current
clipping.
- void (*DrawSubClip)(const Graphic* o, int gx, int gy,
- int w, int h, int x, int y);
- /// Draw part of the object clipped and flipped in
X direction.
- void (*DrawSubClipX)(const Graphic* o, int gx, int gy,
- int w, int h, int x, int y);
-
- /// Draw the object unclipped and zoomed.
- void (*DrawZoom)(const Graphic* o, unsigned f, int x, int y, int z);
-
- // FIXME: add zooming functions.
-
- /// Free the object.
- void (*Free)(Graphic* o);
-} GraphicType;
-
/// Creates a shared hardware palette from an independent
Palette struct.
extern SDL_Palette* VideoCreateSharedPalette(const SDL_Palette* palette);
@@ -156,16 +107,17 @@
typedef struct _palette_link_ PaletteLink;
/**
-** Links all palettes together to join the same palettes.
+** Links all palettes together to join the same palettes.
*/
struct _palette_link_ {
- PaletteLink* Prev; /// Previous
palette
- SDL_Surface* Surface; /// Surface that
contains palette
+ SDL_Surface* Surface; /// Surface that contains palette
+ PaletteLink* Next; /// Previous palette
};
extern PaletteLink* PaletteList; /// List of all used palettes
loaded
extern void VideoPaletteListAdd(SDL_Surface* surface);
+extern void VideoPaletteListRemove(SDL_Surface* surface);
/**
** Video synchronization speed. Synchronization time in
percent.
@@ -528,11 +480,10 @@
extern void VideoDrawShadowClipX(const Graphic*, unsigned frame,
int x, int y);
-// FIXME FIXME FIXME: need to implement all of this
/// Free a graphic object.
-#define VideoFree(o) //((o)->Type->Free)((o))
+extern void VideoFree(Graphic* o);
/// Save (NULL) free a graphic object.
-#define VideoSaveFree(o) // do { if ((o)) ((o)->Type->Free)((o)); } while(0)
+#define VideoSaveFree(o) do { if ((o)) VideoFree((o)); } while(0)
/// Get the width of a single frame of a graphic object
#define VideoGraphicWidth(o) ((o)->Width)
Index: stratagus/src/video/graphic.c
diff -u stratagus/src/video/graphic.c:1.59 stratagus/src/video/graphic.c:1.60
--- stratagus/src/video/graphic.c:1.59 Sat Jan 10 12:10:17 2004
+++ stratagus/src/video/graphic.c Wed Jan 14 16:42:11 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: graphic.c,v 1.59 2004/01/10 01:10:17 jsalmon3 Exp $
+// $Id: graphic.c,v 1.60 2004/01/14 05:42:11 jsalmon3 Exp $
//@{
@@ -436,15 +436,12 @@
/**
** Free graphic object.
*/
-local void FreeGraphic8(Graphic* graphic)
+#ifdef USE_SDL_SURFACE
+local void VideoFree(Graphic* graphic)
{
#ifdef DEBUG
-#ifdef USE_SDL_SURFACE
AllocatedGraphicMemory -=
graphic->Width * graphic->Height *
graphic->Surface->format->BytesPerPixel;
-#else
- AllocatedGraphicMemory -= graphic->Size;
-#endif
AllocatedGraphicMemory -= sizeof(Graphic);
#endif
@@ -455,30 +452,41 @@
}
#endif
-#ifdef USE_SDL_SURFACE
+ VideoPaletteListRemove(graphic->Surface);
SDL_FreeSurface(graphic->Surface);
if (graphic->SurfaceFlip) {
#ifdef DEBUG
AllocatedGraphicMemory -=
graphic->Width * graphic->Height *
graphic->SurfaceFlip->format->BytesPerPixel;
#endif
+ VideoPaletteListRemove(graphic->SurfaceFlip);
SDL_FreeSurface(graphic->SurfaceFlip);
}
+ free(graphic);
+}
#else
+local void FreeGraphic8(Graphic* graphic)
+{
+#ifdef DEBUG
+ AllocatedGraphicMemory -= graphic->Size;
+ AllocatedGraphicMemory -= sizeof(Graphic);
+#endif
+
+#ifdef USE_OPENGL
+ if (graphic->NumTextureNames) {
+ glDeleteTextures(graphic->NumTextureNames,
graphic->TextureNames);
+ free(graphic->TextureNames);
+ }
+#endif
+
VideoFreeSharedPalette(graphic->Pixels);
if (graphic->Palette) {
free(graphic->Palette);
}
free(graphic->Frames);
-#endif
free(graphic);
}
-
-// FIXME: need frame version
-
-// FIXME: need 16 bit palette version
-
-// FIXME: need zooming version
+#endif
/*----------------------------------------------------------------------------
@@ -581,6 +589,7 @@
s = graphic->SurfaceFlip = SDL_ConvertSurface(graphic->Surface,
graphic->Surface->format, SDL_SWSURFACE);
+ VideoPaletteListAdd(graphic->SurfaceFlip);
#ifdef DEBUG
AllocatedGraphicMemory +=
graphic->Width * graphic->Height *
graphic->Surface->format->BytesPerPixel;
@@ -836,9 +845,11 @@
#ifdef USE_SDL_SURFACE
SDL_UnlockSurface(g->Surface);
memcpy(pal, g->Surface->format->palette->colors, sizeof(SDL_Color) *
256);
+ VideoPaletteListRemove(g->Surface);
SDL_FreeSurface(g->Surface);
g->Surface = SDL_CreateRGBSurfaceFrom(data, w, h, 8, w, 0, 0, 0, 0);
+ VideoPaletteListAdd(g->Surface);
SDL_SetPalette(g->Surface, SDL_LOGPAL | SDL_PHYSPAL, pal, 0, 256);
SDL_SetColorKey(g->Surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, 255);
Index: stratagus/src/video/sprite.c
diff -u stratagus/src/video/sprite.c:1.60 stratagus/src/video/sprite.c:1.61
--- stratagus/src/video/sprite.c:1.60 Sat Jan 10 08:57:17 2004
+++ stratagus/src/video/sprite.c Wed Jan 14 16:42:11 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sprite.c,v 1.60 2004/01/09 21:57:17 jsalmon3 Exp $
+// $Id: sprite.c,v 1.61 2004/01/14 05:42:11 jsalmon3 Exp $
//@{
@@ -52,8 +52,10 @@
-- Variables
----------------------------------------------------------------------------*/
+#ifndef USE_SDL_SURFACE
local GraphicType GraphicSprite8Type; /// sprite type 8bit palette
local GraphicType GraphicSprite16Type; /// sprite type 16bit palette
+#endif
#ifdef USE_SDL_SURFACE
global void VideoDrawRawClip(SDL_Surface *surface,
Index: stratagus/src/video/video.c
diff -u stratagus/src/video/video.c:1.84 stratagus/src/video/video.c:1.85
--- stratagus/src/video/video.c:1.84 Sat Jan 10 09:20:35 2004
+++ stratagus/src/video/video.c Wed Jan 14 16:42:11 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: video.c,v 1.84 2004/01/09 22:20:35 jsalmon3 Exp $
+// $Id: video.c,v 1.85 2004/01/14 05:42:11 jsalmon3 Exp $
//@{
@@ -426,11 +426,7 @@
#endif
/**
-** Creates a shared hardware palette from an independend Palette
struct.
-**
-** @param palette System independend RGB palette
structure.
-**
-** @return A palette in hardware
dependend format.
+** FIXME: docu
*/
#ifdef USE_SDL_SURFACE
global void VideoPaletteListAdd(SDL_Surface* surface)
@@ -440,19 +436,35 @@
curlink = malloc(sizeof(PaletteLink));
curlink->Surface = surface;
- curlink->Prev = PaletteList;
+ curlink->Next = PaletteList;
PaletteList = curlink;
}
-global void VideoPaletteListClean()
+/**
+** FIXME: docu
+*/
+global void VideoPaletteListRemove(SDL_Surface* surface)
{
- PaletteLink* curlink;
+ PaletteLink** curlink;
+ PaletteLink* tmp;
- while (PaletteList) {
- curlink = PaletteList->Prev;
+ curlink = &PaletteList;
+ while (*curlink) {
+ if ((*curlink)->Surface == surface) {
+ break;
+ }
+ curlink = &((*curlink)->Next);
+ }
+ DebugCheck(!*curlink);
+ if (*curlink == PaletteList) {
+ tmp = PaletteList->Next;
free(PaletteList);
- PaletteList = curlink;
+ PaletteList = tmp;
+ } else {
+ tmp = *curlink;
+ *curlink = tmp->Next;
+ free(tmp);
}
}
#else
@@ -628,7 +640,7 @@
SDL_SetPalette(curlink->Surface, SDL_LOGPAL |
SDL_PHYSPAL,
colors, 0, 256);
- curlink = curlink->Prev;
+ curlink = curlink->Next;
}
} else {
//
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src include/video.h video/graphic.c v...,
address@hidden <=