From: Kaj-Michael Lang Date: Fri, 27 Jul 2007 11:18:21 +0000 (+0300) Subject: Some formating. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f3aee61197173efcb2fffa8b375b5a817148dbe;p=mapper Some formating. Test with using an idle handler when rendering tiles when moving around, on a slow machine the loading/scaling can take so much time that the user notices. --- diff --git a/src/map.c b/src/map.c index 1683868..fe56b38 100644 --- a/src/map.c +++ b/src/map.c @@ -73,6 +73,12 @@ guint _curr_download=0; static osm_location map_loc = {NULL, NULL, NULL}; static GHashTable *map_tile_hash = NULL; +typedef struct _map_tile_rdata map_tile_rdata; +struct _map_tile_rdata { + guint tilex, tiley, zoom; + guint destx, desty; +}; + void map_render_paths(); void map_force_redraw(); gboolean curl_download_timeout(); @@ -590,6 +596,7 @@ map_render_tile(guint tilex, guint tiley, guint destx, guint desty, snprintf(buffer, sizeof(buffer), "%s/%u/%u/%u.jpg", _curr_repo->cache_dir, _zoom + zoff, (tilex >> zoff), (tiley >> zoff)); + pixbuf = gdk_pixbuf_new_from_file(buffer, &error); if (error || !pixbuf) { /* Delete so we try again some other day. */ @@ -633,13 +640,26 @@ map_render_tile(guint tilex, guint tiley, guint destx, guint desty, g_object_unref(pixbuf); } else { gdk_draw_rectangle(_map_pixmap, _map_widget->style->black_gc, - TRUE, destx, desty, TILE_SIZE_PIXELS, - TILE_SIZE_PIXELS); + TRUE, destx, desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS); } vprintf("%s(): return\n", __PRETTY_FUNCTION__); } +gboolean map_render_tile_idle(map_tile_rdata *mtr) +{ +g_printf("IDLE RENDER\n"); +map_render_tile(mtr->tilex, mtr->tiley, mtr->destx, mtr->desty, FALSE); +/* +gtk_widget_queue_draw_area(_map_widget, mtr->destx, mtr->desty, + TILE_SIZE_PIXELS, TILE_SIZE_PIXELS); +*/ + +g_slice_free(map_tile_rdata, mtr); + +return FALSE; +} + gboolean map_download_idle_refresh(ProgressUpdateInfo * pui) { vprintf("%s(%p, %s)\n", __PRETTY_FUNCTION__, pui, pui->src_str); @@ -658,29 +678,17 @@ gboolean map_download_idle_refresh(ProgressUpdateInfo * pui) for (tiley = pui->tiley << zoom_diff, tiley_end = tiley + (1 << zoom_diff); tiley < tiley_end; tiley++) { - if ((tilex - _base_tilex) < 4 - && (tiley - _base_tiley) < 3) { + if ((tilex - _base_tilex) < BUF_WIDTH_TILES && (tiley - _base_tiley) < BUF_HEIGHT_TILES) { map_render_tile(tilex, tiley, - ((tilex - - _base_tilex) - << - TILE_SIZE_P2), - ((tiley - - _base_tiley) - << - TILE_SIZE_P2), + ((tilex - _base_tilex) << TILE_SIZE_P2), + ((tiley - _base_tiley) << TILE_SIZE_P2), TRUE); MACRO_MAP_RENDER_DATA(); gtk_widget_queue_draw_area (_map_widget, - ((tilex - - _base_tilex) << - TILE_SIZE_P2) - _offsetx, - ((tiley - - _base_tiley) << - TILE_SIZE_P2) - _offsety, - TILE_SIZE_PIXELS, - TILE_SIZE_PIXELS); + ((tilex - _base_tilex) << TILE_SIZE_P2) - _offsetx, + ((tiley - _base_tiley) << TILE_SIZE_P2) - _offsety, + TILE_SIZE_PIXELS, TILE_SIZE_PIXELS); } } } @@ -872,24 +880,33 @@ void map_center_unit(guint new_center_unitx, guint new_center_unity) gdk_draw_drawable(_map_pixmap, _gc[COLORABLE_MARK], _map_pixmap, - old_x * - TILE_SIZE_PIXELS, - old_y * - TILE_SIZE_PIXELS, - new_x * - TILE_SIZE_PIXELS, - new_y * - TILE_SIZE_PIXELS, + old_x * TILE_SIZE_PIXELS, + old_y * TILE_SIZE_PIXELS, + new_x * TILE_SIZE_PIXELS, + new_y * TILE_SIZE_PIXELS, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS); } else { +#if 1 + map_tile_rdata *mtr; + + mtr=g_slice_new(map_tile_rdata); + mtr->tilex=new_base_tilex + new_x; + mtr->tiley=new_base_tiley + new_y; + mtr->destx=new_x * TILE_SIZE_PIXELS; + mtr->desty=new_y * TILE_SIZE_PIXELS; + + gdk_draw_rectangle(_map_pixmap, _gc[COLORABLE_MARK_VELOCITY], + TRUE, mtr->destx, mtr->desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS); + + g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_render_tile_idle, mtr,NULL); +#else map_render_tile(new_base_tilex + new_x, new_base_tiley + new_y, - new_x * - TILE_SIZE_PIXELS, - new_y * - TILE_SIZE_PIXELS, + new_x * TILE_SIZE_PIXELS, + new_y * TILE_SIZE_PIXELS, FALSE); +#endif } } }