Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] Re: (PR#7385) overview isn't updated
Home

[Freeciv-Dev] Re: (PR#7385) overview isn't updated

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7385) overview isn't updated
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sat, 14 Feb 2004 00:12:45 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7385 >

On Tue, Feb 10, 2004 at 10:59:20PM -0800, Jason Short wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7385 >
> 
> Raimar Falke wrote:
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7385 >
> > 
> > On Mon, Feb 09, 2004 at 02:08:27AM -0800, Raimar Falke wrote:
> > 
> >>Alternative suggestions:
> >> - a flag which is set every time the overview (backing store) is
> >> updated and cleared when the backing store is copied to the screen
> > 
> > 
> > Untested patch for this attached.
> 
> A workable concept.  But it won't work for recentering the map (no 
> dirtying), and possibly not for expose events either (although these do 
> seem to work).
> 
> I'd do the interface a bit differently:
> 
>    dirty_overview() => sets dirty flag
>      (or queue_overview_redraw())
> 
>    flush_dirty_overview() => checks dirty flag, calls redraw
>      (or unqueue_overview_redraw())
> 
>    redraw_overview => doesn't check dirty flag
> 
> flush_dirty_overview() can be called from inside unqueue_mapview_updates().
> 
> In future the queue and dirty systems should be merged, though I'm not 
> quite sure how to do this.

Something like this?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "I haven't lost my mind - it's backed up on tape somewhere."

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.76
diff -u -u -r1.76 mapview_common.c
--- client/mapview_common.c     2004/02/13 09:24:40     1.76
+++ client/mapview_common.c     2004/02/14 08:11:08
@@ -34,10 +34,19 @@
 struct canvas mapview_canvas;
 struct overview overview;
 
+/*
+ * Set to TRUE if the backing store is more recent than the version
+ * drawn into overview.window.
+ */
+static bool overview_dirty = FALSE;
+
 static void base_canvas_to_map_pos(int *map_x, int *map_y,
                                   int canvas_x, int canvas_y);
 static void center_tile_overviewcanvas(int map_x, int map_y);
 static void get_mapview_corners(int x[4], int y[4]);
+static void redraw_overview(void);
+static void dirty_overview(void);
+static void flush_dirty_overview(void);
 
 /**************************************************************************
  Refreshes a single tile on the map canvas.
@@ -1517,6 +1526,7 @@
   needed_updates = UPDATE_NONE;
 
   flush_dirty();
+  flush_dirty_overview();
 }
 
 /**************************************************************************
@@ -1572,6 +1582,10 @@
 {
   struct canvas_store *dest = overview.window;
 
+  if (!dest || !overview.store) {
+    return;
+  }
+
   {
     struct canvas_store *src = overview.store;
     int x = overview.map_x0 * OVERVIEW_TILE_WIDTH;
@@ -1601,6 +1615,26 @@
                   dest_x - src_x, dest_y - src_y);
     }
   }
+
+  overview_dirty = FALSE;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
+static void dirty_overview(void)
+{
+  overview_dirty = TRUE;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
+static void flush_dirty_overview(void)
+{
+  if (overview_dirty) {
+    redraw_overview();
+  }
 }
 
 /**************************************************************************
@@ -1756,6 +1790,7 @@
   gui_put_rectangle(overview.store,
                    overview_tile_color(map_x, map_y), base_x, base_y,
                    OVERVIEW_TILE_WIDTH, OVERVIEW_TILE_HEIGHT);
+  dirty_overview();
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]