X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/065a9ace10d7fd973253eca4bbeb6d67946e1a92..e58bcab15300f856acd6d571076f220cab34f55d:/src/mapcache.c?ds=sidebyside diff --git a/src/mapcache.c b/src/mapcache.c index eded74a3..7b731bc3 100644 --- a/src/mapcache.c +++ b/src/mapcache.c @@ -25,6 +25,7 @@ #include #include #include +#include "globals.h" #include "mapcache.h" #include "preferences.h" @@ -41,7 +42,7 @@ static List *queue_tail = NULL; static int queue_count = 0; static guint32 queue_size = 0; -static guint32 max_queue_size = VIK_CONFIG_MAPCACHE_SIZE; +static guint32 max_queue_size = VIK_CONFIG_MAPCACHE_SIZE * 1024 * 1024; static GHashTable *cache = NULL; @@ -51,22 +52,19 @@ static GMutex *mc_mutex = NULL; #define HASHKEY_FORMAT_STRING "%d-%d-%d-%d-%d-%d-%.3f-%.3f" #define HASHKEY_FORMAT_STRING_NOSHRINK_NOR_ALPHA "%d-%d-%d-%d-%d-" -#define VIKING_PREFERENCES_GROUP_KEY "viking.globals" -#define VIKING_PREFERENCES_NAMESPACE "viking.globals." - static VikLayerParamScale params_scales[] = { /* min, max, step, digits (decimal places) */ - { 1, 300, 1, 0 }, + { 1, 1024, 1, 0 }, }; static VikLayerParam prefs[] = { - { VIKING_PREFERENCES_NAMESPACE "mapcache_size", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Mapcache memory size (MB):"), VIK_LAYER_WIDGET_HSCALE, params_scales, NULL }, + { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_NAMESPACE "mapcache_size", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("Map cache memory size (MB):"), VIK_LAYER_WIDGET_HSCALE, params_scales, NULL, NULL }, }; void a_mapcache_init () { VikLayerParamData tmp; - tmp.u = VIK_CONFIG_MAPCACHE_SIZE / 1024 / 1024; + tmp.u = VIK_CONFIG_MAPCACHE_SIZE; a_preferences_register(prefs, tmp, VIKING_PREFERENCES_GROUP_KEY); mc_mutex = g_mutex_new(); @@ -126,7 +124,7 @@ static void list_add_entry ( gchar *key ) } } -void a_mapcache_add ( GdkPixbuf *pixbuf, gint x, gint y, gint z, guint8 type, guint zoom, guint8 alpha, gdouble xshrinkfactor, gdouble yshrinkfactor ) +void a_mapcache_add ( GdkPixbuf *pixbuf, gint x, gint y, gint z, guint16 type, guint zoom, guint8 alpha, gdouble xshrinkfactor, gdouble yshrinkfactor ) { gchar *key = g_strdup_printf ( HASHKEY_FORMAT_STRING, x, y, z, type, zoom, alpha, xshrinkfactor, yshrinkfactor ); static int tmp = 0; @@ -154,17 +152,17 @@ void a_mapcache_add ( GdkPixbuf *pixbuf, gint x, gint y, gint z, guint8 type, gu } g_mutex_unlock(mc_mutex); - if ( (++tmp == 100 )) { g_print("DEBUG: queue count=%d %u\n", queue_count, queue_size ); tmp=0; } + if ( (++tmp == 100 )) { g_print("DEBUG: queue count=%d size=%u\n", queue_count, queue_size ); tmp=0; } } -GdkPixbuf *a_mapcache_get ( gint x, gint y, gint z, guint8 type, guint zoom, guint8 alpha, gdouble xshrinkfactor, gdouble yshrinkfactor ) +GdkPixbuf *a_mapcache_get ( gint x, gint y, gint z, guint16 type, guint zoom, guint8 alpha, gdouble xshrinkfactor, gdouble yshrinkfactor ) { static char key[48]; g_snprintf ( key, sizeof(key), HASHKEY_FORMAT_STRING, x, y, z, type, zoom, alpha, xshrinkfactor, yshrinkfactor ); return g_hash_table_lookup ( cache, key ); } -void a_mapcache_remove_all_shrinkfactors ( gint x, gint y, gint z, guint8 type, guint zoom ) +void a_mapcache_remove_all_shrinkfactors ( gint x, gint y, gint z, guint16 type, guint zoom ) { char key[40]; List *loop = queue_tail;