summaryrefslogtreecommitdiff
path: root/navit
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-01-02 21:18:55 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-01-02 21:18:55 +0000
commit3945f92da6233b3651311a5e935c18420f2a5183 (patch)
tree2c2a6ce87777d610c48fba35786cecc05815e1b7 /navit
parentce0446ea8122ef70684424258349c9127c56f8a4 (diff)
downloadnavit-3945f92da6233b3651311a5e935c18420f2a5183.tar.gz
Fix:Core:Made some performance critical parts a bit faster
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1881 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r--navit/graphics.c45
-rw-r--r--navit/item.c27
-rw-r--r--navit/item.h1
3 files changed, 54 insertions, 19 deletions
diff --git a/navit/graphics.c b/navit/graphics.c
index 04a89ea2e..c9b9e91a6 100644
--- a/navit/graphics.c
+++ b/navit/graphics.c
@@ -771,12 +771,14 @@ draw_circle(struct point *pnt, int diameter, int scale, int start, int len, stru
end+=1024;
}
while (end > 0) {
- for (i = 0 ; i < 16 ; i++) {
- if (c[i].fowler > start && c[i].fowler < end) {
- res[*pos].x=pnt->x+c[i].x*diameter/20;
- res[*pos].y=pnt->y+c[i].y*diameter/20;
- (*pos)+=dir;
- }
+ i=0;
+ while (i < 16 && c[i].fowler <= start)
+ i++;
+ while (i < 16 && c[i].fowler < end) {
+ res[*pos].x=pnt->x+c[i].x*diameter/20;
+ res[*pos].y=pnt->y+c[i].y*diameter/20;
+ (*pos)+=dir;
+ i++;
}
end-=1024;
start-=1024;
@@ -787,12 +789,14 @@ draw_circle(struct point *pnt, int diameter, int scale, int start, int len, stru
end-=1024;
}
while (end < 1024) {
- for (i = 15 ; i >= 0 ; i--) {
- if (c[i].fowler < start && c[i].fowler > end) {
- res[*pos].x=pnt->x+c[i].x*diameter/20;
- res[*pos].y=pnt->y+c[i].y*diameter/20;
- (*pos)+=dir;
- }
+ i=15;
+ while (i >= 0 && c[i].fowler >= end)
+ i--;
+ while (i >= 0 && c[i].fowler > start) {
+ res[*pos].x=pnt->x+c[i].x*diameter/20;
+ res[*pos].y=pnt->y+c[i].y*diameter/20;
+ (*pos)+=dir;
+ i--;
}
start+=1024;
end+=1024;
@@ -1491,7 +1495,7 @@ static void do_draw_map(struct displaylist *displaylist, struct transformation *
struct coord ca[max];
struct attr attr;
struct map_selection *sel;
- int num=0;
+ struct coord_rect r;
pro=map_projection(m);
conv=map_requires_conversion(m);
@@ -1510,7 +1514,6 @@ static void do_draw_map(struct displaylist *displaylist, struct transformation *
return;
}
while ((item=map_rect_get_item(mr))) {
- num++;
#if 0
if (num < 7599 || num > 7599)
continue;
@@ -1519,33 +1522,37 @@ static void do_draw_map(struct displaylist *displaylist, struct transformation *
if (item->id_hi != 0xb0031 || item->id_lo != 0x20c9aeea)
continue;
#endif
- count=item_coord_get(item, ca, item->type < type_line ? 1: max);
+ count=item_coord_get_with_bbox(item, ca, item->type < type_line ? 1: max, &r);
if (item->type >= type_line && count < 2) {
dbg(1,"poly from map has only %d points\n", count);
continue;
}
+ if (! map_selection_contains_rect(sel, &r))
+ continue;
if (item->type < type_line) {
+#if 0
if (! map_selection_contains_point(sel, &ca[0])) {
dbg(1,"point not visible\n");
continue;
}
+#endif
} else if (item->type < type_area) {
+#if 0
if (! map_selection_contains_polyline(sel, ca, count)) {
dbg(1,"polyline not visible\n");
continue;
}
+#endif
} else {
+#if 0
if (! map_selection_contains_polygon(sel, ca, count)) {
dbg(1,"polygon not visible\n");
continue;
}
+#endif
}
if (count == max)
dbg(0,"point count overflow\n", count);
- if (item->type >= type_line && count < 2) {
- dbg(1,"poly from transform has only %d points\n", count);
- continue;
- }
if (!item_attr_get(item, attr_label, &attr))
attr.u.str=NULL;
if (conv && attr.u.str && attr.u.str[0]) {
diff --git a/navit/item.c b/navit/item.c
index 5de4bf74c..8cd20fee2 100644
--- a/navit/item.c
+++ b/navit/item.c
@@ -54,6 +54,33 @@ item_coord_get(struct item *it, struct coord *c, int count)
}
int
+item_coord_get_with_bbox(struct item *it, struct coord *c, int count, struct coord_rect *r)
+{
+ int i,ret=it->meth->item_coord_get(it->priv_data, c, count);
+ struct coord_rect r2;
+ if (ret <= 0)
+ return ret;
+ if (ret == 1) {
+ r->rl=r->lu=c[0];
+ return ret;
+ }
+ r2.lu=c[0];
+ r2.rl=c[0];
+ for (i = 1 ; i < ret ; i++) {
+ if (r2.lu.x > c[i].x)
+ r2.lu.x=c[i].x;
+ if (r2.rl.x < c[i].x)
+ r2.rl.x=c[i].x;
+ if (r2.rl.y > c[i].y)
+ r2.rl.y=c[i].y;
+ if (r2.lu.y < c[i].y)
+ r2.lu.y=c[i].y;
+ }
+ *r=r2;
+ return ret;
+}
+
+int
item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to)
{
int ret=item_coord_get(it, c, count);
diff --git a/navit/item.h b/navit/item.h
index 7e25e6b4f..3cff0f99a 100644
--- a/navit/item.h
+++ b/navit/item.h
@@ -79,6 +79,7 @@ struct item;
struct item_hash;
void item_coord_rewind(struct item *it);
int item_coord_get(struct item *it, struct coord *c, int count);
+int item_coord_get_with_bbox(struct item *it, struct coord *c, int count, struct coord_rect *r);
int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection pro);
/* does the next returned coordinate mark a node */
int item_coord_is_node(struct item *it);