Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2000:
[Freeciv-Dev] [Fwd: gtk redraw patch]
Home

[Freeciv-Dev] [Fwd: gtk redraw patch]

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [Fwd: gtk redraw patch]
From: Paul Zastoupil <paulz@xxxxxxxx>
Date: Fri, 11 Feb 2000 11:27:59 -0800

Karl-Ingo Friese emailed me a patch for speeding up the gtk client.  It
had some extraneous redraws.  This is a quick patch but the speed
improvement is incredible.  I didn't test it extensively but zooming
around the map was so much faster.

I did manage to massage the patch into cvs (it isn't large) and it is
attached.


-----Forwarded Message-----
Hello Paul,

okay, first of all, I did the patch not against the CVS but the latest
develeopment version 1.9.4. I tried CVS, it looks nice but I got several
problems when I tried to compile the thing and I am out of time to look
at this right now. If this causes any problems, sorry, but I doubt that
this will be the case. It is realy a very short patch and most of it is
documentation :-)

File: client/gui-gtk/mapview.c

Short Description: Serious GTK client speedup.

Long Description: Fixes a redraw bug. If map focus changes (rightclick
on
the map, new unit, center) or a resize event is called the map is
redrawn,
then the scrollbars (horizontal and vertical) are updated. Each
scrollbar
update causes another redraw. The patch changes this, so the map is
redrawn
only once instead of three times as before. The current solution solves
this
with a global vairable "no_redraw"; maybe this could be handled another
way
but this was the fastest way on the fly.

Comment: This patch speeds up the gtk client seriousely, still it is
much
slower then the XAW version as it can be experienced especialy on slow
machines. Maybe this should be looked over once again.
Index: mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.40
diff -u -r1.40 mapview.c
--- mapview.c   2000/01/23 03:13:11     1.40
+++ mapview.c   2000/02/11 19:24:08
@@ -94,6 +94,10 @@
 /* used by map_canvas expose func */ 
 int force_full_repaint;
 
+/* this variable prevents that the map is drawn three times,  */
+/* if center_tile_mapcanvas or map_canvas_expose are called   */
+/* might be done without global variable someday              */
+int no_redraw=0;
 
 extern GtkWidget *     toplevel;
 extern GdkWindow *     root_window;
@@ -630,6 +634,7 @@
 void center_tile_mapcanvas(int x, int y)
 {
   int new_map_view_x0, new_map_view_y0;
+  no_redraw=1;
 
   new_map_view_x0=map_adjust_x(x-map_canvas_store_twidth/2);
   new_map_view_y0=map_adjust_y(y-map_canvas_store_theight/2);
@@ -642,6 +647,7 @@
   update_map_canvas(0, 0, map_canvas_store_twidth,map_canvas_store_theight, 1);
   update_map_canvas_scrollbars();
   
+  no_redraw=0;
   refresh_overview_viewrect();
 }
 
@@ -778,6 +784,7 @@
   int tile_width, tile_height;
   gboolean map_resized;
 
+  no_redraw=1;
   gdk_window_get_size( widget->window, &width, &height );
 
   tile_width=(width+NORMAL_TILE_WIDTH-1)/NORMAL_TILE_WIDTH;
@@ -851,6 +858,8 @@
     }
     refresh_overview_canvas();
   }
+
+  no_redraw=0;
   return TRUE;
 }
 
@@ -1380,6 +1389,12 @@
        map.ysize-map_canvas_store_theight : map_view_y0;
   }
 
-  update_map_canvas(0, 0, map_canvas_store_twidth, map_canvas_store_theight, 
1);
-  refresh_overview_viewrect();
+   /* checks the global variable no_redraw to prevent that the map is */
+   /* drawn when not necessary. set in center_tile_mapcanvas and      */
+   /*  map_canvas_expose */
+   if (no_redraw==0) {
+     update_map_canvas(0, 0, map_canvas_store_twidth, 
map_canvas_store_theight,1);
+     refresh_overview_viewrect();
+   }
 }
+

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] [Fwd: gtk redraw patch], Paul Zastoupil <=