-#define COMPILE_DATE_STRING "[2003-04-03 23:55]"
+#define COMPILE_DATE_STRING "[2003-04-04 00:11]"
return success;
}
+inline void SDLCreateBitmapContent(Bitmap *new_bitmap,
+ int width, int height, int depth)
+{
+ SDL_Surface *surface_tmp, *surface_native;
+
+ if ((surface_tmp = SDL_CreateRGBSurface(SURFACE_FLAGS, width, height, depth,
+ 0, 0, 0, 0))
+ == NULL)
+ Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+ if ((surface_native = SDL_DisplayFormat(surface_tmp)) == NULL)
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+
+ SDL_FreeSurface(surface_tmp);
+
+ new_bitmap->surface = surface_native;
+}
+
+inline void SDLFreeBitmapPointers(Bitmap *bitmap)
+{
+ if (bitmap->surface)
+ SDL_FreeSurface(bitmap->surface);
+ if (bitmap->surface_masked)
+ SDL_FreeSurface(bitmap->surface_masked);
+ bitmap->surface = NULL;
+ bitmap->surface_masked = NULL;
+}
+
inline void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
int src_x, int src_y,
int width, int height,
inline void SDLInitVideoDisplay(void);
inline void SDLInitVideoBuffer(DrawBuffer **, DrawWindow **, boolean);
inline boolean SDLSetVideoMode(DrawBuffer **, boolean);
+inline void SDLCreateBitmapContent(Bitmap *, int, int, int);
+inline void SDLFreeBitmapPointers(Bitmap *);
inline void SDLCopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int);
inline void SDLFillRectangle(Bitmap *, int, int, int, int, Uint32);
inline void SDLDrawSimpleLine(Bitmap *, int, int, int, int, Uint32);
#if defined(TARGET_SDL)
SDL_QuitSubSystem(SDL_INIT_VIDEO);
#else
-
if (display)
XCloseDisplay(display);
#endif
int real_depth = GetRealDepth(depth);
#ifdef TARGET_SDL
- SDL_Surface *surface_tmp, *surface_native;
-
- if ((surface_tmp = SDL_CreateRGBSurface(SURFACE_FLAGS, width, height,
- real_depth, 0, 0, 0, 0))
- == NULL)
- Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
-
- if ((surface_native = SDL_DisplayFormat(surface_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
-
- SDL_FreeSurface(surface_tmp);
-
- new_bitmap->surface = surface_native;
+ SDLCreateBitmapContent(new_bitmap, width, height, real_depth);
#else
- Pixmap pixmap;
-
- if ((pixmap = XCreatePixmap(display, window->drawable,
- width, height, real_depth))
- == None)
- Error(ERR_EXIT, "cannot create pixmap");
-
- new_bitmap->drawable = pixmap;
-
- if (window == NULL)
- Error(ERR_EXIT, "Window GC needed for Bitmap -- create Window first");
-
- new_bitmap->gc = window->gc;
-
- new_bitmap->line_gc[0] = window->line_gc[0];
- new_bitmap->line_gc[1] = window->line_gc[1];
+ X11CreateBitmapContent(new_bitmap, width, height, real_depth);
#endif
new_bitmap->width = width;
return;
#ifdef TARGET_SDL
- if (bitmap->surface)
- SDL_FreeSurface(bitmap->surface);
- if (bitmap->surface_masked)
- SDL_FreeSurface(bitmap->surface_masked);
- bitmap->surface = NULL;
- bitmap->surface_masked = NULL;
+ SDLFreeBitmapPointers(bitmap);
#else
- /* The X11 version seems to have a memory leak here -- although
- "XFreePixmap()" is called, the corresponding memory seems not
- to be freed (according to "ps"). The SDL version apparently
- does not have this problem. */
-
- if (bitmap->drawable)
- XFreePixmap(display, bitmap->drawable);
- if (bitmap->clip_mask)
- XFreePixmap(display, bitmap->clip_mask);
- if (bitmap->stored_clip_gc)
- XFreeGC(display, bitmap->stored_clip_gc);
- /* the other GCs are only pointers to GCs used elsewhere */
- bitmap->drawable = None;
- bitmap->clip_mask = None;
- bitmap->stored_clip_gc = None;
+ X11FreeBitmapPointers(bitmap);
#endif
if (bitmap->source_filename)
return new_bitmap;
}
+inline void X11CreateBitmapContent(Bitmap *new_bitmap,
+ int width, int height, int depth)
+{
+ Pixmap pixmap;
+
+ if ((pixmap = XCreatePixmap(display, window->drawable, width, height, depth))
+ == None)
+ Error(ERR_EXIT, "cannot create pixmap");
+
+ new_bitmap->drawable = pixmap;
+
+ if (window == NULL)
+ Error(ERR_EXIT, "Window GC needed for Bitmap -- create Window first");
+
+ new_bitmap->gc = window->gc;
+
+ new_bitmap->line_gc[0] = window->line_gc[0];
+ new_bitmap->line_gc[1] = window->line_gc[1];
+}
+
+inline void X11FreeBitmapPointers(Bitmap *bitmap)
+{
+ /* The X11 version seems to have a memory leak here -- although
+ "XFreePixmap()" is called, the corresponding memory seems not
+ to be freed (according to "ps"). The SDL version apparently
+ does not have this problem. */
+
+ if (bitmap->drawable)
+ XFreePixmap(display, bitmap->drawable);
+ if (bitmap->clip_mask)
+ XFreePixmap(display, bitmap->clip_mask);
+ if (bitmap->stored_clip_gc)
+ XFreeGC(display, bitmap->stored_clip_gc);
+ /* the other GCs are only pointers to GCs used elsewhere */
+ bitmap->drawable = None;
+ bitmap->clip_mask = None;
+ bitmap->stored_clip_gc = None;
+}
+
inline void X11CopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
int src_x, int src_y, int width, int height,
int dst_x, int dst_y, int mask_mode)
void X11ZoomBitmap(Bitmap *, Bitmap *);
Bitmap *X11LoadImage(char *);
+inline void X11CreateBitmapContent(Bitmap *, int, int, int);
+inline void X11FreeBitmapPointers(Bitmap *);
inline void X11CopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int);
inline void X11FillRectangle(Bitmap *, int, int, int, int, Pixel);
inline Pixel X11GetPixel(Bitmap *, int, int);