diff options
| author | jkoan <jkoan@gmx.de> | 2020-10-14 13:55:26 +0200 |
|---|---|---|
| committer | jkoan <jkoan@gmx.de> | 2020-10-14 13:55:26 +0200 |
| commit | 8bc1ba4bf304e9acb15791ff24d9f117c8732a03 (patch) | |
| tree | 0d374915e58fe9e2c0ccb2136490a23192b82d86 | |
| parent | 05ff46641b4fec3b0025ea1cc9e82f17476bab44 (diff) | |
| download | navit-8bc1ba4bf304e9acb15791ff24d9f117c8732a03.tar.gz | |
fix:graphics:svg_debug:Reformat again to match navit style (Eclipse
brakes things... now astyle)
| -rw-r--r-- | navit/graphics/svg_debug/graphics_svg_debug.c | 195 |
1 files changed, 102 insertions, 93 deletions
diff --git a/navit/graphics/svg_debug/graphics_svg_debug.c b/navit/graphics/svg_debug/graphics_svg_debug.c index 54ea2c6a8..22dc4cbec 100644 --- a/navit/graphics/svg_debug/graphics_svg_debug.c +++ b/navit/graphics/svg_debug/graphics_svg_debug.c @@ -101,11 +101,12 @@ static void svg_debug_graphics_destroy(struct graphics_priv *gr) { static void svg_debug_font_destroy(struct graphics_font_priv *this); void svg_debug_get_text_bbox(struct graphics_priv *gr, - struct graphics_font_priv *font, char *text, int dx, int dy, - struct point *ret, int estimate); + struct graphics_font_priv *font, char *text, int dx, int dy, + struct point *ret, int estimate); static struct graphics_font_methods font_methods = { .font_destroy = - svg_debug_font_destroy, }; + svg_debug_font_destroy, +}; static void resize_callback_do(struct graphics_priv *gr, int w, int h) { dbg(lvl_debug, "resize_callback w:%i h:%i", w, h) @@ -117,7 +118,7 @@ static void svg_debug_font_destroy(struct graphics_font_priv *this) { dbg(lvl_debug, "enter font_destroy"); if (this->graphics_font_proxy.meth.font_destroy) { this->graphics_font_proxy.meth.font_destroy( - this->graphics_font_proxy.priv); + this->graphics_font_proxy.priv); } g_free(this); } @@ -131,8 +132,8 @@ static struct graphics_font_priv* svg_debug_font_new(struct graphics_priv *gr, priv->size = size / 10; if (gr->proxy_graphics_methods->font_new) { priv->graphics_font_proxy.priv = gr->proxy_graphics_methods->font_new( - gr->proxy_priv, &priv->graphics_font_proxy.meth, font, size, - flags); + gr->proxy_priv, &priv->graphics_font_proxy.meth, font, size, + flags); } else { return priv; } @@ -142,8 +143,8 @@ static struct graphics_font_priv* svg_debug_font_new(struct graphics_priv *gr, return NULL; } void svg_debug_get_text_bbox(struct graphics_priv *gr, - struct graphics_font_priv *font, char *text, int dx, int dy, - struct point *ret, int estimate) { + struct graphics_font_priv *font, char *text, int dx, int dy, + struct point *ret, int estimate) { if (gr->proxy_graphics_methods->get_text_bbox) { gr->proxy_graphics_methods->get_text_bbox(gr->proxy_priv, font->graphics_font_proxy.priv, text, dx, dy, ret, estimate); @@ -162,13 +163,13 @@ static void svg_debug_gc_set_linewidth(struct graphics_gc_priv *gc, int w) { gc->linewidth = w; if (gc->graphics_gc_methods_proxy->gc_set_linewidth) { gc->graphics_gc_methods_proxy->gc_set_linewidth( - gc->graphics_gc_priv_proxy, w); + gc->graphics_gc_priv_proxy, w); } } static void svg_debug_gc_set_dashes(struct graphics_gc_priv *gc, int w, - int offset, unsigned char *dash_list, int n) { + int offset, unsigned char *dash_list, int n) { //if(n <= 4){ //for (int i = 0; i < 4; ++i) { // gc->dashed[i]=dash_list[i]; @@ -182,48 +183,49 @@ static void svg_debug_gc_set_dashes(struct graphics_gc_priv *gc, int w, } static void svg_debug_gc_set_foreground(struct graphics_gc_priv *gc, - struct color *c) { + struct color *c) { gc->fg.r = c->r / 256; gc->fg.g = c->g / 256; gc->fg.b = c->b / 256; gc->fg.a = c->a / 256; if (gc->graphics_gc_methods_proxy->gc_set_foreground) { gc->graphics_gc_methods_proxy->gc_set_foreground( - gc->graphics_gc_priv_proxy, c); + gc->graphics_gc_priv_proxy, c); } } static void svg_debug_gc_set_background(struct graphics_gc_priv *gc, - struct color *c) { + struct color *c) { gc->bg.r = c->r / 256; gc->bg.g = c->g / 256; gc->bg.b = c->b / 256; gc->bg.a = c->a / 256; if (gc->graphics_gc_methods_proxy->gc_set_foreground) { gc->graphics_gc_methods_proxy->gc_set_foreground( - gc->graphics_gc_priv_proxy, c); + gc->graphics_gc_priv_proxy, c); } } static void svg_debug_gc_set_texture(struct graphics_gc_priv *gc, - struct graphics_image_priv *img) { + struct graphics_image_priv *img) { gc->img = img; } static struct graphics_gc_methods gc_methods = { .gc_destroy = svg_debug_gc_destroy, .gc_set_linewidth = svg_debug_gc_set_linewidth, - .gc_set_dashes = svg_debug_gc_set_dashes, .gc_set_foreground = - svg_debug_gc_set_foreground, .gc_set_background = - svg_debug_gc_set_background, .gc_set_texture = - svg_debug_gc_set_texture, }; + .gc_set_dashes = svg_debug_gc_set_dashes, .gc_set_foreground = + svg_debug_gc_set_foreground, .gc_set_background = + svg_debug_gc_set_background, .gc_set_texture = + svg_debug_gc_set_texture, +}; static struct graphics_gc_priv* svg_debug_gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) { struct graphics_gc_priv *gc = g_new0(struct graphics_gc_priv, 1); struct graphics_gc_priv *graphics_gc_priv_proxy = g_new0( - struct graphics_gc_priv, 1); + struct graphics_gc_priv, 1); struct graphics_gc_methods *graphics_gc_methods_proxy = g_new0( - struct graphics_gc_methods, 1); + struct graphics_gc_methods, 1); *meth = gc_methods; gc->gr = gr; gc->is_dashed = FALSE; @@ -231,7 +233,7 @@ static struct graphics_gc_priv* svg_debug_gc_new(struct graphics_priv *gr, if (gr->proxy_graphics_methods->gc_new) { gr->proxy_graphics_methods->gc_new(gr->proxy_priv, - graphics_gc_methods_proxy); + graphics_gc_methods_proxy); } gc->graphics_gc_methods_proxy = graphics_gc_methods_proxy; gc->graphics_gc_priv_proxy = graphics_gc_priv_proxy; @@ -244,7 +246,7 @@ void svg_debug_image_destroy(struct graphics_image_priv *img) { g_free(img->data); if (img->graphics_image_methods_proxy->image_destroy) { img->graphics_image_methods_proxy->image_destroy( - img->graphics_image_priv_proxy); + img->graphics_image_priv_proxy); } g_free(img->data); g_free(img->graphics_image_methods_proxy); @@ -253,7 +255,8 @@ void svg_debug_image_destroy(struct graphics_image_priv *img) { } static struct graphics_image_methods image_methods = { .image_destroy = - svg_debug_image_destroy, }; + svg_debug_image_destroy, +}; static struct graphics_image_priv* svg_debug_image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, @@ -288,8 +291,8 @@ static struct graphics_image_priv* svg_debug_image_new(struct graphics_priv *gr, base64_encoded_image = g_base64_encode((guchar*) contents, img_size); base64_data_url = g_malloc0( - strlen(base64_encoded_image) + strlen(data_url_template) - + strlen(image_mime_type) + 1); + strlen(base64_encoded_image) + strlen(data_url_template) + + strlen(image_mime_type) + 1); sprintf(base64_data_url, data_url_template, image_mime_type, base64_encoded_image); g_free(base64_encoded_image); @@ -301,14 +304,14 @@ static struct graphics_image_priv* svg_debug_image_new(struct graphics_priv *gr, } else { dbg(lvl_error, "image_new failed to load %s", path); image_priv->data = - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; image_priv->h = 1; image_priv->w = 1; } if (gr->proxy_graphics_methods->image_new) { image_priv->graphics_image_priv_proxy = - gr->proxy_graphics_methods->image_new(gr->proxy_priv, - graphics_image_methods, path, w, h, hot, rotation); + gr->proxy_graphics_methods->image_new(gr->proxy_priv, + graphics_image_methods, path, w, h, hot, rotation); image_priv->graphics_image_methods_proxy = graphics_image_methods; } if (image_priv->graphics_image_priv_proxy) { @@ -323,14 +326,14 @@ static struct graphics_image_priv* svg_debug_image_new(struct graphics_priv *gr, } static void svg_debug_draw_lines(struct graphics_priv *gr, - struct graphics_gc_priv *gc, struct point *p, int count) { + struct graphics_gc_priv *gc, struct point *p, int count) { const char *line_template_start = "<polyline points=\""; const char *coord_template = "%i,%i "; const char *dashed_template_start = "\" stroke-dasharray=\""; const char *dashed_dasharray = "%i "; const char *dashed_template_end = ""; const char *line_template_end = - "\" style=\"fill:none;stroke:rgb(%i,%i,%i);stroke-width:%i\" />\n"; + "\" style=\"fill:none;stroke:rgb(%i,%i,%i);stroke-width:%i\" />\n"; fprintf(gr->outfile, line_template_start, ""); for (int i = 0; i < count; i++) { @@ -350,13 +353,13 @@ static void svg_debug_draw_lines(struct graphics_priv *gr, if (gr->proxy_graphics_methods->draw_lines) { gr->proxy_graphics_methods->draw_lines(gr->proxy_priv, - gc->graphics_gc_priv_proxy, p, count); + gc->graphics_gc_priv_proxy, p, count); } } static void svg_debug_draw_polygon(struct graphics_priv *gr, - struct graphics_gc_priv *gc, struct point *p, int count) { + struct graphics_gc_priv *gc, struct point *p, int count) { const char *coord_template = "%i,%i "; const char *polygon_template_start = "<polygon points=\"%s"; const char *polygon_template_end = "\" style=\"fill:rgb(%i,%i,%i)\" />\n"; @@ -374,9 +377,9 @@ static void svg_debug_draw_polygon(struct graphics_priv *gr, } static void svg_debug_draw_rectangle(struct graphics_priv *gr, - struct graphics_gc_priv *gc, struct point *p, int w, int h) { + struct graphics_gc_priv *gc, struct point *p, int w, int h) { const char *rectangle_template = - "<rect x=\"%i\" y=\"%i\" width=\"%i\" height=\"%i\" style=\"fill:rgb(%i,%i,%i)\"></rect>\n"; + "<rect x=\"%i\" y=\"%i\" width=\"%i\" height=\"%i\" style=\"fill:rgb(%i,%i,%i)\"></rect>\n"; fprintf(gr->outfile, rectangle_template, p->x, p->y, w, h, gc->fg.r, gc->fg.g, gc->fg.b); @@ -387,46 +390,46 @@ static void svg_debug_draw_rectangle(struct graphics_priv *gr, } static void svg_debug_draw_circle(struct graphics_priv *gr, - struct graphics_gc_priv *gc, struct point *p, int r) { + struct graphics_gc_priv *gc, struct point *p, int r) { const char *circle_template = - "<circle cx=\"%i\" cy=\"%i\" r=\"%i\" fill=\"rgb(%i,%i,%i)\" />\n"; + "<circle cx=\"%i\" cy=\"%i\" r=\"%i\" fill=\"rgb(%i,%i,%i)\" />\n"; fprintf(gr->outfile, circle_template, p->x, p->y, r / 2, gc->fg.r, gc->fg.g, gc->fg.b); if (gr->proxy_graphics_methods->draw_circle) { gr->proxy_graphics_methods->draw_circle(gr->proxy_priv, - gc->graphics_gc_priv_proxy, p, r); + gc->graphics_gc_priv_proxy, p, r); } } static void svg_debug_draw_text(struct graphics_priv *gr, - struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, - struct graphics_font_priv *font, char *text, struct point *p, int dx, - int dy) { + struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, + struct graphics_font_priv *font, char *text, struct point *p, int dx, + int dy) { const char *image_template = - "<text x=\"%i\" y=\"%i\" fill=\"rgb(%i,%i,%i)\" style=\"font-size: %ipt;\">%s</text>\n"; + "<text x=\"%i\" y=\"%i\" fill=\"rgb(%i,%i,%i)\" style=\"font-size: %ipt;\">%s</text>\n"; if (dx == 0x10000 || dy == 0) { fprintf(gr->outfile, image_template, p->x, p->y, fg->fg.r, fg->fg.g, fg->fg.b, font ? font->size : 0, text); } if (gr->proxy_graphics_methods->draw_text && font) { gr->proxy_graphics_methods->draw_text(gr->proxy_priv, - fg->graphics_gc_priv_proxy, bg->graphics_gc_priv_proxy, - font->graphics_font_proxy.priv, text, p, dx, dy); + fg->graphics_gc_priv_proxy, bg->graphics_gc_priv_proxy, + font->graphics_font_proxy.priv, text, p, dx, dy); } } static void svg_debug_draw_image(struct graphics_priv *gr, - struct graphics_gc_priv *fg, struct point *p, - struct graphics_image_priv *img) { + struct graphics_gc_priv *fg, struct point *p, + struct graphics_image_priv *img) { // Write already encoded image to file const char *image_template = - "<image x=\"%i\" y=\"%i\" width=\"%i\" height=\"%i\" xlink:href=\"%s\"></image>\n"; + "<image x=\"%i\" y=\"%i\" width=\"%i\" height=\"%i\" xlink:href=\"%s\"></image>\n"; fprintf(gr->outfile, image_template, p->x, p->y, img->w, img->h, img->data); if (gr->proxy_graphics_methods->draw_image) { gr->proxy_graphics_methods->draw_image(gr->proxy_priv, fg, p, - img->graphics_image_priv_proxy); + img->graphics_image_priv_proxy); } } @@ -437,7 +440,7 @@ static void svg_debug_draw_drag(struct graphics_priv *gr, struct point *p) { } static void svg_debug_background_gc(struct graphics_priv *gr, - struct graphics_gc_priv *gc) { + struct graphics_gc_priv *gc) { if (gr->proxy_graphics_methods->background_gc) { gr->proxy_graphics_methods->background_gc(gr->proxy_priv, gc->graphics_gc_priv_proxy); @@ -445,16 +448,16 @@ static void svg_debug_background_gc(struct graphics_priv *gr, } static void svg_debug_draw_mode(struct graphics_priv *gr, - enum draw_mode_num mode) { + enum draw_mode_num mode) { const char *svg_start_template = - "<svg height=\"%i\" width=\"%i\" xmlns= \"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; + "<svg height=\"%i\" width=\"%i\" xmlns= \"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; const char *svg_end_template = "</svg>\n"; char filename[255]; switch (mode) { case draw_mode_begin: if (gr->outfile) { dbg(lvl_debug, "Finished drawing %s/svg_debug_after_frame_%u.svg", - gr->outputdir, gr->frame) + gr->outputdir, gr->frame) fprintf(gr->outfile, svg_end_template, ""); fclose(gr->outfile); gr->frame += 1; @@ -466,7 +469,7 @@ static void svg_debug_draw_mode(struct graphics_priv *gr, break; case draw_mode_end: dbg(lvl_debug, "Finished drawing %s/svg_debug_after_frame_%u.svg", - gr->outputdir, gr->frame) + gr->outputdir, gr->frame) fprintf(gr->outfile, svg_end_template, ""); fclose(gr->outfile); gr->frame += 1; @@ -492,8 +495,8 @@ static void graphics_svg_debug_overlay_draw_mode(struct graphics_priv *gr, } static struct graphics_priv* graphics_svg_debug_overlay_new( - struct graphics_priv *gr, struct graphics_methods *meth, - struct point *p, int w, int h, int wraparound); + struct graphics_priv *gr, struct graphics_methods *meth, + struct point *p, int w, int h, int wraparound); static int graphics_svg_debug_fullscreen(struct window *win, int on) { struct graphics_priv *graphics_priv = (struct graphics_priv*) win->priv; @@ -502,7 +505,7 @@ static int graphics_svg_debug_fullscreen(struct window *win, int on) { return 0; } proxy_win = graphics_priv->proxy_graphics_methods->get_data( - graphics_priv->proxy_priv, "window"); + graphics_priv->proxy_priv, "window"); if (proxy_win) { return proxy_win->fullscreen(proxy_win, on); } @@ -514,7 +517,7 @@ static gboolean graphics_svg_debug_idle(void *data) { static int first_run = TRUE; if (first_run) { callback_list_call_attr_2(gr->cbl, attr_resize, - GINT_TO_POINTER(gr->width), GINT_TO_POINTER(gr->height)); + GINT_TO_POINTER(gr->width), GINT_TO_POINTER(gr->height)); first_run = FALSE; } return TRUE; @@ -527,7 +530,7 @@ static void graphics_svg_debug_disable_suspend(struct window *w) { return; } proxy_win = graphics_priv->proxy_graphics_methods->get_data( - graphics_priv->proxy_priv, "window"); + graphics_priv->proxy_priv, "window"); if (proxy_win) { proxy_win->disable_suspend(proxy_win); } @@ -551,15 +554,15 @@ static void* svg_debug_get_data(struct graphics_priv *this, char const *type) { } static void svg_debug_image_free(struct graphics_priv *gr, - struct graphics_image_priv *img) { + struct graphics_image_priv *img) { dbg(lvl_debug, "enter image_free"); if (img->graphics_image_methods_proxy->image_destroy) { img->graphics_image_methods_proxy->image_destroy( - img->graphics_image_priv_proxy); + img->graphics_image_priv_proxy); } if (gr->proxy_graphics_methods->image_free) { gr->proxy_graphics_methods->image_free(gr->proxy_priv, - img->graphics_image_priv_proxy); + img->graphics_image_priv_proxy); } g_free(img->graphics_image_methods_proxy); g_free(img->data); @@ -576,34 +579,41 @@ static void graphics_svg_debug_overlay_resize(struct graphics_priv *gr, // TODO } -static struct graphics_methods graphics_methods = { .graphics_destroy = - svg_debug_graphics_destroy, .draw_mode = svg_debug_draw_mode, - .draw_lines = svg_debug_draw_lines, .draw_polygon = - svg_debug_draw_polygon, .draw_rectangle = - svg_debug_draw_rectangle, .draw_circle = svg_debug_draw_circle, - .draw_text = svg_debug_draw_text, - // FIXME: Text size calculation is hard, because the svg is - // interpreted by the viewer, so we don't know its size - - .draw_image = svg_debug_draw_image, .draw_image_warp = NULL, - .draw_drag = svg_debug_draw_drag, .font_new = svg_debug_font_new, - .gc_new = svg_debug_gc_new, .background_gc = svg_debug_background_gc, - .overlay_new = NULL, //graphics_svg_debug_overlay_new, // TODO - .image_new = svg_debug_image_new, .get_data = svg_debug_get_data, - .image_free = svg_debug_image_free, .get_text_bbox = - svg_debug_get_text_bbox, .overlay_disable = NULL, // graphics_svg_debug_overlay_disable, // TODO - .overlay_resize = NULL, // graphics_svg_debug_overlay_resize, // TODO - .set_attr = NULL, // TODO add proxy - .show_native_keyboard = NULL, // TODO add proxy - .hide_native_keyboard = NULL, // TODO add proxy - .get_dpi = NULL, // TODO add proxy - .draw_polygon_with_holes = NULL, // TODO add proxy - - }; +static struct graphics_methods graphics_methods = { + .graphics_destroy = svg_debug_graphics_destroy, + .draw_mode = svg_debug_draw_mode, + .draw_lines = svg_debug_draw_lines, + .draw_polygon = svg_debug_draw_polygon, + .draw_rectangle = svg_debug_draw_rectangle, + .draw_circle = svg_debug_draw_circle, + .draw_text = svg_debug_draw_text, + // FIXME: Text size calculation is hard, because the svg is + // interpreted by the viewer, so we don't know its size + + .draw_image = svg_debug_draw_image, + .draw_image_warp = NULL, + .draw_drag = svg_debug_draw_drag, + .font_new = svg_debug_font_new, + .gc_new = svg_debug_gc_new, + .background_gc = svg_debug_background_gc, + .overlay_new = NULL, //graphics_svg_debug_overlay_new, // TODO + .image_new = svg_debug_image_new, + .get_data = svg_debug_get_data, + .image_free = svg_debug_image_free, + .get_text_bbox = svg_debug_get_text_bbox, + .overlay_disable = NULL, // graphics_svg_debug_overlay_disable, // TODO + .overlay_resize = NULL, // graphics_svg_debug_overlay_resize, // TODO + .set_attr = NULL, // TODO add proxy + .show_native_keyboard = NULL, // TODO add proxy + .hide_native_keyboard = NULL, // TODO add proxy + .get_dpi = NULL, // TODO add proxy + .draw_polygon_with_holes = NULL, // TODO add proxy + +}; static struct graphics_priv* graphics_svg_debug_overlay_new( - struct graphics_priv *gr, struct graphics_methods *meth, - struct point *p, int w, int h, int wraparound) { + struct graphics_priv *gr, struct graphics_methods *meth, + struct point *p, int w, int h, int wraparound) { struct graphics_priv *this = g_new0(struct graphics_priv, 1); *meth = graphics_methods; meth->draw_mode = graphics_svg_debug_overlay_draw_mode; @@ -618,12 +628,12 @@ static struct graphics_priv* graphics_svg_debug_new(struct navit *nav, struct callback_list *cbl) { struct graphics_priv *this = g_new0(struct graphics_priv, 1); struct graphics_methods *proxy_graphics_methods = g_new0( - struct graphics_methods, 1); + struct graphics_methods, 1); struct attr *attr; void *proxy_priv = NULL; struct graphics_priv* (*proxy_gra)(struct navit *nav, - struct graphics_methods *meth, struct attr **attrs, - struct callback_list *cbl); + struct graphics_methods *meth, struct attr **attrs, + struct callback_list *cbl); *meth = graphics_methods; @@ -679,7 +689,7 @@ static struct graphics_priv* graphics_svg_debug_new(struct navit *nav, dbg(lvl_debug, "No Proxied plugin, so do not set functions to NULL") // see comment below callback_list_call_attr_2(cbl, attr_resize, - GINT_TO_POINTER(this->width), GINT_TO_POINTER(this->height)); + GINT_TO_POINTER(this->width), GINT_TO_POINTER(this->height)); return this; } @@ -761,8 +771,7 @@ static struct graphics_priv* graphics_svg_debug_new(struct navit *nav, } // Add resize callback so we get called when window is resized so we can adjust the svg size - struct callback *callback = callback_new_attr_1( - callback_cast(resize_callback_do), attr_resize, this); + struct callback *callback = callback_new_attr_1(callback_cast(resize_callback_do), attr_resize, this); callback_list_add(cbl, callback); return this; } |
