Fix:Core:Made graphics more flexible
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 26 Nov 2009 12:35:21 +0000 (12:35 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 26 Nov 2009 12:35:21 +0000 (12:35 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2800 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/attr_def.h
navit/navit/graphics.c
navit/navit/graphics.h
navit/navit/navit.c

index fcb82b6..7512213 100644 (file)
@@ -129,6 +129,7 @@ ATTR(flags_town)
 ATTR(flags_street)
 ATTR(flags_house_number)
 ATTR(use_camera)
+ATTR(flags_graphics)
 ATTR2(0x00027500,type_rel_abs_begin)
 /* These attributes are int that can either hold relative              *
  * or absolute values. A relative value is indicated by                *
index 343c390..5335955 100644 (file)
@@ -1746,7 +1746,7 @@ static void xdisplay_draw(struct displaylist *display_list, struct graphics *gra
 extern void *route_selection;
 
 static void
-do_draw(struct displaylist *displaylist, int cancel)
+do_draw(struct displaylist *displaylist, int cancel, int flags)
 {
        struct item *item;
        int count,max=16384,workload=0;
@@ -1798,11 +1798,13 @@ do_draw(struct displaylist *displaylist, int cancel)
        profile(1,"process_selection\n");
        event_remove_idle(displaylist->idle_ev);
        displaylist->idle_ev=NULL;
+       callback_destroy(displaylist->idle_cb);
+       displaylist->idle_cb=NULL;
        displaylist->busy=0;
        graphics_process_selection(displaylist->dc.gra, displaylist);
        profile(1,"draw\n");
        if (! cancel) 
-               graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, 1);
+               graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, flags);
        map_rect_destroy(displaylist->mr);
        map_selection_destroy(displaylist->sel);
        mapset_close(displaylist->msh);
@@ -1845,7 +1847,7 @@ void graphics_displaylist_draw(struct graphics *gra, struct displaylist *display
                gra->meth.draw_mode(gra->priv, draw_mode_end);
 }
 
-static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb)
+static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
 {
        int order=transform_get_order(trans);
 
@@ -1853,7 +1855,7 @@ static void graphics_load_mapset(struct graphics *gra, struct displaylist *displ
        if (displaylist->busy) {
                if (async == 1)
                        return;
-               do_draw(displaylist, 1);
+               do_draw(displaylist, 1, flags);
        }
        xdisplay_free(displaylist->dl);
        dbg(1,"order=%d\n", order);
@@ -1870,9 +1872,10 @@ static void graphics_load_mapset(struct graphics *gra, struct displaylist *displ
        displaylist->layout=l;
        if (async) {
                if (! displaylist->idle_cb)
-                       displaylist->idle_cb=callback_new_2(callback_cast(do_draw), displaylist, 0);
+                       displaylist->idle_cb=callback_new_3(callback_cast(do_draw), displaylist, 0, flags);
                displaylist->idle_ev=event_add_idle(50, displaylist->idle_cb);
-       }
+       } else
+               do_draw(displaylist, 0, flags);
 }
 /**
  * FIXME
@@ -1880,11 +1883,9 @@ static void graphics_load_mapset(struct graphics *gra, struct displaylist *displ
  * @returns <>
  * @author Martin Schaller (04/2008)
 */
-void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb)
+void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
 {
-       graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb);
-       if (! async)
-               do_draw(displaylist, 0);
+       graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb, flags);
 }
 
 int
@@ -1892,7 +1893,7 @@ graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist)
 {
        if (!displaylist->busy)
                return 0;
-       do_draw(displaylist, 1);
+       do_draw(displaylist, 1, 0);
        return 1;
 }
 
index 02adecf..f0b8160 100644 (file)
@@ -171,7 +171,7 @@ void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
 char *graphics_icon_path(char *icon);
 void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t);
 void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int callback);
-void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb);
+void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags);
 int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
 struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
index 9c8475f..63b06ec 100644 (file)
@@ -136,6 +136,7 @@ struct navit {
        int pitch;
        int follow_cursor;
        int prevTs;
+       int graphics_flags;
 };
 
 struct gui *main_loop_gui;
@@ -198,7 +199,7 @@ navit_draw_async(struct navit *this_, int async)
                navit_vehicle_draw(this_, nv, NULL);
                l=g_list_next(l);
        }
-       graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL);
+       graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1);
 }
 
 void
@@ -219,7 +220,7 @@ void
 navit_draw_displaylist(struct navit *this_)
 {
        if (this_->ready == 3)
-               graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, 1);
+               graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags|1);
 }
 
 static void
@@ -456,7 +457,7 @@ navit_motion_timeout(struct navit *this_)
                graphics_displaylist_move(this_->displaylist, dx, dy);
 #endif
                graphics_draw_cancel(this_->gra, this_->displaylist);
-               graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, 0);
+               graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, this_->graphics_flags);
                transform_destroy(tr);
                this_->moved=1;
        }
@@ -1641,6 +1642,10 @@ navit_set_attr_do(struct navit *this_, struct attr *attr, int init)
                attr_updated=(this_->drag_bitmap != !!attr->u.num);
                this_->drag_bitmap=!!attr->u.num;
                break;
+       case attr_flags_graphics:
+               attr_updated=(this_->graphics_flags != attr->u.num);
+               this_->graphics_flags=attr->u.num;
+               break;
        case attr_follow:
                if (!this_->vehicle)
                        return 0;