summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-08-16 17:27:13 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-08-16 17:27:13 +0000
commit57f7243fe7e65237848bcfe81acdf045f76f7fa5 (patch)
tree7a335d4d404842f8b1081d8ea7d81258982ad1a4
parent8f242044df9debf8ad576980ebd6d1e8562d44b0 (diff)
downloadnavit-57f7243fe7e65237848bcfe81acdf045f76f7fa5.tar.gz
Add:Core:And another batch of android updates
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2470 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r--navit/graphics.c36
-rw-r--r--navit/graphics.h4
2 files changed, 29 insertions, 11 deletions
diff --git a/navit/graphics.c b/navit/graphics.c
index 80d7d8043..25d027420 100644
--- a/navit/graphics.c
+++ b/navit/graphics.c
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+#include "config.h"
#include "debug.h"
#include "string.h"
#include "draw_info.h"
@@ -1400,6 +1401,20 @@ get_font(struct graphics *gra, int size)
return gra->font[size];
}
+char *
+graphics_icon_path(char *icon)
+{
+ dbg(0,"enter %s\n",icon);
+ if (icon[0] == '/')
+ return g_strdup(icon);
+ else
+#ifdef HAVE_API_ANDROID
+ return g_strdup_printf("res/drawable/%s", icon);
+#else
+ return g_strdup_printf("%s/xpm/%s", navit_sharedir, icon);
+#endif
+}
+
static void
displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc)
@@ -1412,7 +1427,7 @@ displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc
struct element *e=dc->e;
struct graphics_image *img=dc->img;
struct point p;
- char path[PATH_MAX];
+ char *path;
di->displayed=1;
if (! gc) {
@@ -1503,11 +1518,9 @@ displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc
case element_icon:
if (count) {
if (!img) {
- if (e->u.icon.src[0] == '/')
- strcpy(path,e->u.icon.src);
- else
- sprintf(path,"%s/xpm/%s", navit_sharedir, e->u.icon.src);
+ path=graphics_icon_path(e->u.icon.src);
img=graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation);
+ g_free(path);
if (img)
dc->img=img;
else
@@ -1577,7 +1590,7 @@ graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transfor
#endif
struct graphics_gc *gc = NULL;
struct graphics_image *img;
- char path[PATH_MAX];
+ char *path;
es=itm->elements;
c.x=0;
c.y=0;
@@ -1625,11 +1638,9 @@ graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transfor
# endif
break;
case element_icon:
- if (e->u.icon.src[0] == '/')
- strcpy(path,e->u.icon.src);
- else
- sprintf(path,"%s/xpm/%s", navit_sharedir, e->u.icon.src);
+ path=graphics_icon_path(e->u.icon.src);
img=graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation);
+ g_free(path);
if (! img)
dbg(0,"failed to load icon '%s'\n", e->u.icon.src);
else {
@@ -1702,6 +1713,7 @@ do_draw(struct displaylist *displaylist, int cancel)
struct coord ca[max];
struct attr attr;
+ profile(0,NULL);
while (!cancel) {
if (!displaylist->msh)
displaylist->msh=mapset_open(displaylist->ms);
@@ -1743,10 +1755,12 @@ do_draw(struct displaylist *displaylist, int cancel)
displaylist->sel=NULL;
displaylist->m=NULL;
}
+ profile(1,"process_selection\n");
event_remove_idle(displaylist->idle_ev);
displaylist->idle_ev=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);
map_rect_destroy(displaylist->mr);
@@ -1756,7 +1770,9 @@ do_draw(struct displaylist *displaylist, int cancel)
displaylist->sel=NULL;
displaylist->m=NULL;
displaylist->msh=NULL;
+ profile(1,"callback\n");
callback_call_1(displaylist->cb, cancel);
+ profile(0,"end\n");
}
/**
diff --git a/navit/graphics.h b/navit/graphics.h
index 447243b96..8136dc03d 100644
--- a/navit/graphics.h
+++ b/navit/graphics.h
@@ -128,6 +128,7 @@ struct graphics_image;
struct item;
struct itemgra;
struct layout;
+struct mapset;
struct point;
struct point_rect;
struct transformation;
@@ -135,6 +136,7 @@ void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int alpha, int wraparound);
+void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int alpha, int wraparound);
void graphics_init(struct graphics *this_);
void *graphics_get_data(struct graphics *this_, char *type);
void graphics_add_callback(struct graphics *this_, struct callback *cb);
@@ -161,10 +163,10 @@ void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc
void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy);
void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate);
void graphics_overlay_disable(struct graphics *this_, int disable);
-void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int alpha, int wraparound);
void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
int graphics_draw_drag(struct graphics *this_, struct point *p);
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);