[Freeciv-Dev] (PR#3453) canvas and canvas_store structures
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Here's an update of this patch. The only changes are to gui-sdl: an
update was needed because the gui-sdl code has changed. I've also
merged struct canvas_store with struct Sdl.
jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.30
diff -u -r1.30 mapview_common.c
--- client/mapview_common.c 2003/02/17 02:11:25 1.30
+++ client/mapview_common.c 2003/02/20 22:48:18
@@ -29,6 +29,8 @@
#include "mapview_common.h"
#include "tilespec.h"
+struct canvas mapview_canvas;
+
/**************************************************************************
Refreshes a single tile on the map canvas.
**************************************************************************/
@@ -504,7 +506,7 @@
width, height, height_unit,
draw);
} else {
- gui_put_sprite(NULL, canvas_x, canvas_y,
+ gui_put_sprite(mapview_canvas.store, canvas_x, canvas_y,
sprites.black_tile, offset_x, offset_y, width, height);
}
}
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.21
diff -u -r1.21 mapview_common.h
--- client/mapview_common.h 2003/02/07 08:35:02 1.21
+++ client/mapview_common.h 2003/02/20 22:48:18
@@ -19,7 +19,18 @@
#include "colors_g.h"
struct unit;
-typedef void canvas_t;
+struct canvas_store;
+
+struct canvas {
+#if 0 /* These values are still in the GUI. */
+ int map_x0, map_y0;
+ int width, height;
+ int tile_width, tile_height;
+#endif
+ struct canvas_store *store;
+};
+
+extern struct canvas mapview_canvas;
/*
The bottom row of the map was sometimes hidden.
Index: client/gui-gtk/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.h,v
retrieving revision 1.11
diff -u -r1.11 graphics.h
--- client/gui-gtk/graphics.h 2002/09/28 03:33:09 1.11
+++ client/gui-gtk/graphics.h 2003/02/20 22:48:18
@@ -26,6 +26,11 @@
int height;
};
+struct canvas_store
+{
+ GdkPixmap *pixmap;
+};
+
typedef struct Sprite SPRITE;
void create_overlay_unit (GtkWidget *pixcomm, int i);
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.128
diff -u -r1.128 gui_main.c
--- client/gui-gtk/gui_main.c 2003/02/12 22:49:51 1.128
+++ client/gui-gtk/gui_main.c 2003/02/20 22:48:20
@@ -918,6 +918,8 @@
map_canvas_store_twidth * NORMAL_TILE_WIDTH,
map_canvas_store_theight * NORMAL_TILE_HEIGHT,
-1);
+ mapview_canvas.store = fc_malloc(sizeof(*mapview_canvas.store));
+ mapview_canvas.store->pixmap = map_canvas_store;
overview_canvas_store = gdk_pixmap_new(root_window,
overview_canvas_store_width,
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.156
diff -u -r1.156 mapview.c
--- client/gui-gtk/mapview.c 2003/02/17 02:11:25 1.156
+++ client/gui-gtk/mapview.c 2003/02/20 22:48:21
@@ -717,6 +717,7 @@
tile_width*NORMAL_TILE_WIDTH,
tile_height*NORMAL_TILE_HEIGHT,
-1 );
+ mapview_canvas.store->pixmap = map_canvas_store;
gdk_gc_set_foreground(fill_bg_gc, colors_standard[COLOR_STD_BLACK]);
gdk_draw_rectangle(map_canvas_store, fill_bg_gc, TRUE,
@@ -1171,13 +1172,12 @@
/**************************************************************************
Draw some or all of a sprite onto the mapview or citydialog canvas.
**************************************************************************/
-void gui_put_sprite(canvas_t *pcanvas, int canvas_x, int canvas_y,
+void gui_put_sprite(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y,
struct Sprite *sprite,
int offset_x, int offset_y, int width, int height)
{
- GdkPixmap *pm = pcanvas ? pcanvas : map_canvas_store;
-
- pixmap_put_sprite(pm, canvas_x, canvas_y,
+ pixmap_put_sprite(pcanvas_store->pixmap, canvas_x, canvas_y,
sprite, offset_x, offset_y, width, height);
}
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.35
diff -u -r1.35 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 2003/02/12 22:49:51 1.35
+++ client/gui-gtk-2.0/dialogs.c 2003/02/20 22:48:23
@@ -2277,9 +2277,11 @@
***********************************************************************/
void popdown_all_game_dialogs(void)
{
+#if 0
GList *res;
res = gtk_window_list_toplevels();
g_list_foreach(res, nuke_children, toplevel);
g_list_free(res);
+#endif
}
Index: client/gui-gtk-2.0/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/graphics.h,v
retrieving revision 1.2
diff -u -r1.2 graphics.h
--- client/gui-gtk-2.0/graphics.h 2002/10/13 23:23:31 1.2
+++ client/gui-gtk-2.0/graphics.h 2003/02/20 22:48:23
@@ -26,6 +26,11 @@
int height;
};
+struct canvas_store
+{
+ GdkPixmap *pixmap;
+};
+
typedef struct Sprite SPRITE;
void create_overlay_unit (GtkWidget *pixcomm, int i);
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.44
diff -u -r1.44 mapview.c
--- client/gui-gtk-2.0/mapview.c 2003/02/17 02:11:25 1.44
+++ client/gui-gtk-2.0/mapview.c 2003/02/20 22:48:24
@@ -29,6 +29,7 @@
#include "government.h" /* government_graphic() */
#include "log.h"
#include "map.h"
+#include "mem.h"
#include "player.h"
#include "rand.h"
#include "support.h"
@@ -722,6 +723,11 @@
tile_height * NORMAL_TILE_HEIGHT,
-1);
+ if (!mapview_canvas.store) {
+ mapview_canvas.store = fc_malloc(sizeof(*mapview_canvas.store));
+ }
+ mapview_canvas.store->pixmap = map_canvas_store;
+
gdk_gc_set_foreground(fill_bg_gc, colors_standard[COLOR_STD_BLACK]);
gdk_draw_rectangle(map_canvas_store, fill_bg_gc, TRUE, 0, 0, -1, -1);
update_map_canvas_scrollbars_size();
@@ -1244,13 +1250,12 @@
/**************************************************************************
Draw some or all of a sprite onto the mapview or citydialog canvas.
**************************************************************************/
-void gui_put_sprite(canvas_t *pcanvas, int canvas_x, int canvas_y,
+void gui_put_sprite(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y,
struct Sprite *sprite,
int offset_x, int offset_y, int width, int height)
{
- GdkPixmap *pm = pcanvas ? pcanvas : map_canvas_store;
-
- pixmap_put_sprite(pm, canvas_x, canvas_y,
+ pixmap_put_sprite(pcanvas_store->pixmap, canvas_x, canvas_y,
sprite, offset_x, offset_y, width, height);
}
Index: client/gui-sdl/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/graphics.c,v
retrieving revision 1.12
diff -u -r1.12 graphics.c
--- client/gui-sdl/graphics.c 2003/02/19 23:03:39 1.12
+++ client/gui-sdl/graphics.c 2003/02/20 22:48:25
@@ -70,7 +70,7 @@
#include "patrol_cursor.xbm"
#include "patrol_cursor_mask.xbm"
-struct Sdl Main;
+struct canvas_store Main;
static SDL_Surface *pIntro_gfx = NULL;
/*static SDL_Surface *pLogo_gfx = NULL;*/
@@ -751,6 +751,8 @@
Main.map = NULL;
Main.text = NULL;
Main.rects_count = 0;
+
+ mapview_canvas.store = &Main;
if (SDL_WasInit(SDL_INIT_AUDIO)) {
error = (SDL_InitSubSystem(iFlags) < 0);
Index: client/gui-sdl/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/graphics.h,v
retrieving revision 1.6
diff -u -r1.6 graphics.h
--- client/gui-sdl/graphics.h 2003/02/19 23:03:39 1.6
+++ client/gui-sdl/graphics.h 2003/02/20 22:48:26
@@ -36,7 +36,7 @@
#define GET_SURF(s) fc__extension((SDL_Surface *)s)
#define GET_SPRI(s) fc__extension((struct Sprite *)s)
-struct Sdl {
+struct canvas_store {
int rects_count; /* update rect. list counter */
SDL_Rect rects[RECT_LIMIT]; /* update rect. list */
SDL_Surface *screen; /* main screen buffer */
Index: client/gui-sdl/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/gui_main.h,v
retrieving revision 1.8
diff -u -r1.8 gui_main.h
--- client/gui-sdl/gui_main.h 2003/02/19 23:03:39 1.8
+++ client/gui-sdl/gui_main.h 2003/02/20 22:48:26
@@ -47,7 +47,7 @@
#define CF_CIV3_CITY_TEXT_STYLE 0x10000
#define CF_DRAW_MAP_DITHER 0x20000
-extern struct Sdl Main;
+extern struct canvas_store Main;
extern struct GUI *pSellected_Widget;
extern Uint32 SDL_Client_Flags;
Index: client/gui-sdl/gui_string.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/gui_string.c,v
retrieving revision 1.5
diff -u -r1.5 gui_string.c
--- client/gui-sdl/gui_string.c 2003/02/19 23:03:39 1.5
+++ client/gui-sdl/gui_string.c 2003/02/20 22:48:26
@@ -43,7 +43,6 @@
#define FONT_WITH_PATH "theme/tahoma.ttf"
extern char *pDataPath;
-extern struct Sdl Main;
/* =================================================== */
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.22
diff -u -r1.22 mapview.c
--- client/gui-sdl/mapview.c 2003/02/19 23:03:39 1.22
+++ client/gui-sdl/mapview.c 2003/02/20 22:48:27
@@ -195,15 +195,13 @@
/**************************************************************************
Draw some or all of a sprite onto the mapview or citydialog canvas.
**************************************************************************/
-void gui_put_sprite(canvas_t *pCanvas, int canvas_x, int canvas_y,
+void gui_put_sprite(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y,
struct Sprite *sprite,
int offset_x, int offset_y, int width, int height)
{
- SDL_Surface *pSurf = pCanvas ? pCanvas : Main.map;
-
/* FIXME: handle partial-sprite draws. */
- assert(pCanvas == NULL);
- blit_entire_src(GET_SURF(sprite), pSurf, canvas_x, canvas_y);
+ blit_entire_src(GET_SURF(sprite), pcanvas_store->map, canvas_x, canvas_y);
}
/**************************************************************************
Index: client/gui-stub/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/mapview.c,v
retrieving revision 1.26
diff -u -r1.26 mapview.c
--- client/gui-stub/mapview.c 2003/02/07 08:35:03 1.26
+++ client/gui-stub/mapview.c 2003/02/20 22:48:28
@@ -207,7 +207,8 @@
/**************************************************************************
Draw some or all of a sprite onto the mapview or citydialog canvas.
**************************************************************************/
-void gui_put_sprite(canvas_t *pcanvas, int canvas_x, int canvas_y,
+void gui_put_sprite(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y,
struct Sprite *sprite,
int offset_x, int offset_y, int width, int height)
{
Index: client/gui-win32/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/graphics.h,v
retrieving revision 1.5
diff -u -r1.5 graphics.h
--- client/gui-win32/graphics.h 2002/12/07 09:59:18 1.5
+++ client/gui-win32/graphics.h 2003/02/20 22:48:28
@@ -35,6 +35,13 @@
int height;
int cache_id;
};
+
+struct canvas_store
+{
+ HDC hdc;
+ HBITMAP bitmap;
+};
+
void draw_sprite(struct Sprite *sprite,HDC hdc,int x, int y);
void draw_sprite_part(struct Sprite *sprite,HDC hdc,
int x, int y, int w, int h,int xsrc,int ysrc);
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.56
diff -u -r1.56 mapview.c
--- client/gui-win32/mapview.c 2003/02/17 02:11:26 1.56
+++ client/gui-win32/mapview.c 2003/02/20 22:48:29
@@ -113,6 +113,12 @@
if (mapstorebitmap) DeleteObject(mapstorebitmap);
mapstorebitmap=newbmp;
ReleaseDC(map_window,hdc);
+
+ if (!mapview_canvas.store) {
+ mapview_canvas.store = fc_malloc(sizeof(*mapview_canvas.store));
+ }
+ mapview_canvas.store->hdc = NULL;
+ mapview_canvas.store->bitmap = mapstorebitmap;
map_view_width=(map_win_width+NORMAL_TILE_WIDTH-1)/NORMAL_TILE_WIDTH;
map_view_height=(map_win_height+NORMAL_TILE_HEIGHT-1)/NORMAL_TILE_HEIGHT;
@@ -1355,7 +1361,8 @@
/**************************************************************************
Draw some or all of a sprite onto the mapview or citydialog canvas.
**************************************************************************/
-void gui_put_sprite(canvas_t *pcanvas, int canvas_x, int canvas_y,
+void gui_put_sprite(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y,
struct Sprite *sprite,
int offset_x, int offset_y, int width, int height)
{
@@ -1363,9 +1370,8 @@
HBITMAP old;
/* FIXME: we don't want to have to recreate the hdc each time! */
- assert(pcanvas == NULL);
- hdc = CreateCompatibleDC(NULL);
- old = SelectObject(hdc, mapstorebitmap);
+ hdc = CreateCompatibleDC(pcanvas_store->hdc);
+ old = SelectObject(hdc, panvas_store->bitmap);
pixmap_put_overlay_tile_draw(hdc, canvas_x, canvas_y,
sprite, offset_x, offset_y,
Index: client/gui-xaw/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/graphics.h,v
retrieving revision 1.8
diff -u -r1.8 graphics.h
--- client/gui-xaw/graphics.h 2001/01/30 23:38:53 1.8
+++ client/gui-xaw/graphics.h 2003/02/20 22:48:29
@@ -24,6 +24,10 @@
int has_mask;
};
+struct canvas_store {
+ Pixmap pixmap;
+};
+
Pixmap create_overlay_unit(int i);
extern struct Sprite *intro_gfx_sprite;
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.123
diff -u -r1.123 mapview.c
--- client/gui-xaw/mapview.c 2003/02/17 02:11:26 1.123
+++ client/gui-xaw/mapview.c 2003/02/20 22:48:30
@@ -30,6 +30,7 @@
#include "game.h"
#include "government.h" /* government_graphic() */
#include "map.h"
+#include "mem.h"
#include "player.h"
#include "rand.h"
#include "support.h"
@@ -594,6 +595,11 @@
map_canvas_store_twidth*NORMAL_TILE_WIDTH,
map_canvas_store_theight*NORMAL_TILE_HEIGHT,
display_depth);
+
+ if (!mapview_canvas.store) {
+ mapview_canvas.store = fc_malloc(sizeof(*mapview_canvas.store));
+ }
+ mapview_canvas.store->pixmap = map_canvas_store;
}
/**************************************************************************
@@ -647,13 +653,12 @@
/**************************************************************************
Draw some or all of a sprite onto the mapview or citydialog canvas.
**************************************************************************/
-void gui_put_sprite(canvas_t *pcanvas, int canvas_x, int canvas_y,
+void gui_put_sprite(struct canvas_store *pcanvas_store,
+ int canvas_x, int canvas_y,
struct Sprite *sprite,
int offset_x, int offset_y, int width, int height)
{
- Pixmap pm = pcanvas ? *(Pixmap*)pcanvas : map_canvas_store;
-
- pixmap_put_sprite(pm, canvas_x, canvas_y,
+ pixmap_put_sprite(pcanvas_store->pixmap, canvas_x, canvas_y,
sprite, offset_x, offset_y, width, height);
}
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.31
diff -u -r1.31 mapview_g.h
--- client/include/mapview_g.h 2003/02/07 08:35:03 1.31
+++ client/include/mapview_g.h 2003/02/20 22:48:30
@@ -44,7 +44,7 @@
int offset_x, int offset_y, int offset_y_unit,
int width, int height, int height_unit,
enum draw_type draw);
-void gui_put_sprite(canvas_t *pcanvas,
+void gui_put_sprite(struct canvas_store *pcanvas_store,
int canvas_x, int canvas_y,
struct Sprite *sprite,
int offset_x, int offset_y,
|
|