ref: 5174bae840a2b91b2487c779dcebd643777ddb47
parent: cf8a6208b4418f811a94a6db8824a4d8bbd761d4
author: sirjofri <sirjofri@sirjofri.de>
date: Fri Apr 4 16:03:50 EDT 2025
only fetch images if needed
--- a/img.c
+++ b/img.c
@@ -40,11 +40,9 @@
draw(mapimage, r, loaded, nil, ZP);
if (debug) {
snprint(file, sizeof file, "%d / %d", b.x, b.y);
- border(mapimage, rectaddpt(r, pos), 1, display->black, ZP);
- string(mapimage, pos, display->black, ZP, font, file);
- if (!green)
- green = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DGreen);
+ border(mapimage, r, 1, display->black, ZP);
border(mapimage, mapimage->r, 1, green, ZP);
+ string(mapimage, pos, display->black, ZP, font, file);
}
unlockmapimage();
@@ -71,6 +69,9 @@
b.z = from.z;
callbackfunc = cb;
+ if (debug && !green)
+ green = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DGreen);
+
mod = 1;
for (int i = 0; i < b.z; i++)
mod *= 2;
@@ -81,8 +82,8 @@
debugprint("cannot load tiles: no mapimage\n");
return;
}
- numx = Dx(mapimage->r)/tilesize + 1;
- numy = Dy(mapimage->r)/tilesize + 1;
+ numx = Dx(mapimage->r)/tilesize;
+ numy = Dy(mapimage->r)/tilesize;
unlockmapimage();
debugprint("loading tiles from %d/%d\n", from.x, from.y);
--- a/map.c
+++ b/map.c
@@ -176,7 +176,7 @@
newloc = getbundle(gpsoff(), currentloc.z, &drawoffset);
newloc.x -= off.x;
newloc.y -= off.y;
- debugprint("location updated: %f,%f\n", gpsloc.lon, gpsloc.lat);
+ debugprint("location updated: %f,%f", gpsloc.lon, gpsloc.lat);
if (!locequals(¤tloc, &newloc)) {
currentloc = newloc;
needsrequestimage++;
@@ -225,9 +225,9 @@
{
if (needsrequestimage) {
requestimage(currentloc, imageupdated);
+ needsrequestimage = 0;
return;
}
- needsrequestimage = 0;
imageupdated();
}
@@ -253,6 +253,7 @@
unlockmapimage();
locupdated();
+ needsrequestimage++;
debugprint("initimage: %R %p\n", r, mapimage);
}