Changeset 94


Ignore:
Timestamp:
Jun 6, 2009, 5:27:03 PM (5 years ago)
Author:
simon
Message:

add dynamic debug level support to the renderer

Location:
branches/client-library-split
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/client-library-split/main.c

    r93 r94  
    183183    memphis_renderer_set_map (renderer, osm); 
    184184    memphis_renderer_set_rules_set (renderer, ruleset); 
     185    memphis_renderer_set_debug_level (renderer, opts->debug); 
    185186     
    186187    draw (renderer); 
  • branches/client-library-split/memphis-renderer.c

    r93 r94  
    3232  PROP_RULE_SET, 
    3333  PROP_RESOLUTION, 
    34   PROP_ZOOM_LEVEL 
     34  PROP_ZOOM_LEVEL, 
     35  PROP_DEBUG_LEVEL 
    3536}; 
    3637 
     
    5657} 
    5758 
    58 /* does not obey resolution settings 
     59/* does not obey resolution settings! 
    5960 * creates a png of the whole data of unpredictable size. 
    6061 * probably not a very useful function for a generic library. */ 
     
    7273 
    7374  if (priv->debug_level > 1) 
    74     fprintf(stdout, "renderCairo\n"); 
     75    fprintf (stdout, "renderCairo\n"); 
    7576 
    7677  info = g_new (renderInfo, 1); 
     
    8384  min = coord2xy (osm->minlat, osm->minlon, info->zoom); 
    8485  max = coord2xy (osm->maxlat, osm->maxlon, info->zoom); 
    85   int w = (int) ceil (max.x-min.x); 
    86   int h = (int) ceil (min.y-max.y); 
    87  
    88   info->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); 
    89   info->cr = cairo_create(info->surface); 
    90  
    91   cairo_rectangle(info->cr, 0, 0, w, h); 
    92   cairo_set_source_rgb(info->cr, 
     86  int w = (int) ceil (max.x - min.x); 
     87  int h = (int) ceil (min.y - max.y); 
     88 
     89  info->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h); 
     90  info->cr = cairo_create (info->surface); 
     91 
     92  cairo_rectangle (info->cr, 0, 0, w, h); 
     93  cairo_set_source_rgb (info->cr, 
    9394      (double)ruleset->background[0] / 255.0, 
    9495      (double)ruleset->background[1] / 255.0, 
    9596      (double)ruleset->background[2] / 255.0); 
    96   cairo_fill(info->cr); 
    97  
    98   renderCairoRun(info, priv->debug_level); 
     97  cairo_fill (info->cr); 
     98 
     99  renderCairoRun (info, priv->debug_level); 
    99100 
    100101  if (priv->debug_level > 0) { 
    101     fprintf(stdout, " Cairo rendering Z%i to '%s'", info->zoom, filename); 
    102     fflush(stdout); 
     102    fprintf (stdout, " Cairo rendering Z%i to '%s'", info->zoom, filename); 
     103    fflush (stdout); 
    103104  } 
    104   cairo_surface_write_to_png(info->surface, filename); 
    105   cairo_destroy(info->cr); 
    106   cairo_surface_destroy(info->surface); 
     105  cairo_surface_write_to_png (info->surface, filename); 
     106  cairo_destroy (info->cr); 
     107  cairo_surface_destroy (info->surface); 
    107108 
    108109  if (priv->debug_level > 0) 
    109     fprintf(stdout, " done.\n"); 
    110  
    111   g_free(info); 
     110    fprintf (stdout, " done.\n"); 
     111 
     112  g_free (info); 
    112113} 
    113114 
     
    197198} 
    198199 
     200void 
     201memphis_renderer_set_debug_level (MemphisRenderer *self, gint8 debug_level) 
     202{ 
     203  g_return_if_fail (MEMPHIS_IS_RENDERER (self)); 
     204 
     205  MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
     206  priv->debug_level = debug_level; 
     207} 
     208 
     209gint8 
     210memphis_renderer_get_debug_level (MemphisRenderer *self) 
     211{ 
     212  g_return_val_if_fail (MEMPHIS_IS_RENDERER (self), 0); 
     213 
     214  MemphisRendererPrivate *priv = MEMPHIS_RENDERER_GET_PRIVATE (self); 
     215  return priv->debug_level; 
     216} 
    199217 
    200218static void 
     
    237255      case PROP_RULE_SET: 
    238256        g_value_set_object (value, priv->rules); 
     257        break; 
     258      case PROP_DEBUG_LEVEL: 
     259        g_value_set_int (value, priv->debug_level); 
    239260        break; 
    240261      default: 
     
    263284      case PROP_RULE_SET: 
    264285        memphis_renderer_set_rules_set (self, g_value_get_object (value)); 
     286        break; 
     287      case PROP_DEBUG_LEVEL: 
     288        memphis_renderer_set_debug_level (self, g_value_get_int (value)); 
    265289        break; 
    266290      default: 
     
    338362  */ 
    339363  g_object_class_install_property (object_class, 
    340       PROP_ZOOM_LEVEL, 
     364      PROP_RULE_SET, 
    341365      g_param_spec_object ("rule-set", 
    342366        "A MemphisRuleSet", 
    343367        "Memphis rendering rules", 
    344368        MEMPHIS_TYPE_RULESET, 
     369        G_PARAM_READWRITE)); 
     370 
     371  /** 
     372  * MemphisRenderer:rule-set: 
     373  * 
     374  * A MemphisRuleSet. 
     375  * 
     376  * Since: 0.1 
     377  */ 
     378  g_object_class_install_property (object_class, 
     379      PROP_DEBUG_LEVEL, 
     380      g_param_spec_int ("debug-level", 
     381        "Debug level", 
     382        "The renderer debug level", 
     383        0, 
     384        2, 
     385        1, 
    345386        G_PARAM_READWRITE)); 
    346387 
  • branches/client-library-split/memphis-renderer.h

    r93 r94  
    6767void memphis_renderer_set_zoom_level (MemphisRenderer *renderer, 
    6868    guint zoom_level); 
     69void memphis_renderer_set_debug_level (MemphisRenderer *renderer, 
     70    gint8 debug_level); 
    6971void memphis_renderer_set_map (MemphisRenderer *renderer, 
    7072    MemphisMap* map); 
     
    7476guint memphis_renderer_get_resolution (MemphisRenderer *renderer); 
    7577guint memphis_renderer_get_zoom_level (MemphisRenderer *renderer); 
     78gint8 memphis_renderer_get_debug_level (MemphisRenderer *renderer); 
    7679MemphisMap* memphis_renderer_get_map (MemphisRenderer *renderer); 
    7780MemphisRuleSet* memphis_renderer_get_rule_set (MemphisRenderer *renderer); 
Note: See TracChangeset for help on using the changeset viewer.