diff options
author | Werner Almesberger <werner@almesberger.net> | 2016-08-24 14:07:45 -0300 |
---|---|---|
committer | Werner Almesberger <werner@almesberger.net> | 2016-08-24 14:19:21 -0300 |
commit | bd9943d473ab96c5d37b0944ed33a1f6766d62e5 (patch) | |
tree | 59f27d8fa71f981928293bc8e55e7c0415d08db2 /gui | |
parent | c58e2ecd39de8f433c787a8feb558509e664ac88 (diff) | |
download | eeshow-bd9943d473ab96c5d37b0944ed33a1f6766d62e5.tar.gz eeshow-bd9943d473ab96c5d37b0944ed33a1f6766d62e5.tar.bz2 eeshow-bd9943d473ab96c5d37b0944ed33a1f6766d62e5.zip |
remove global gfx state (pass context as argument)
Diffstat (limited to 'gui')
-rw-r--r-- | gui/common.h | 7 | ||||
-rw-r--r-- | gui/gui.c | 2 | ||||
-rw-r--r-- | gui/index.c | 18 | ||||
-rw-r--r-- | gui/render.c | 63 |
4 files changed, 46 insertions, 44 deletions
diff --git a/gui/common.h b/gui/common.h index c823dd5..cf03953 100644 --- a/gui/common.h +++ b/gui/common.h @@ -18,6 +18,7 @@ #include <gtk/gtk.h> #include "gfx/cro.h" +#include "gfx/gfx.h" #include "file/git-hist.h" #include "kicad/lib.h" #include "kicad/sch.h" @@ -32,8 +33,8 @@ struct gui_sheet { const struct sheet *sch; struct gui_ctx *ctx; /* back link */ struct gui_hist *hist; /* back link */ - struct cro_ctx *gfx_ctx; - struct cro_ctx *gfx_ctx_extra; + struct gfx *gfx; + struct gfx *gfx_extra; int w, h; /* in eeschema coordinates */ int xmin, ymin; @@ -44,7 +45,7 @@ struct gui_sheet { struct aoi *aois; /* areas of interest; in schematics coord */ /* thumbnails, for index */ - struct cro_ctx *gfx_ctx_thumb; /* NULL if not yet rendered */ + struct gfx *gfx_thumb; /* NULL if not yet rendered */ cairo_surface_t *thumb_surf; /* for caching */ unsigned thumb_w, thumb_h; /* size for which we cached */ struct overlay *thumb_over; /* thumb overlay */ @@ -169,7 +169,7 @@ static struct gui_sheet *get_sheets(struct gui_ctx *ctx, struct gui_hist *hist, new->sch = sheet; new->ctx = ctx; new->hist = hist; - new->gfx_ctx_thumb = NULL; + new->gfx_thumb = NULL; new->thumb_surf = NULL; new->rendered = 0; diff --git a/gui/index.c b/gui/index.c index 2477cb7..8a6e4b5 100644 --- a/gui/index.c +++ b/gui/index.c @@ -266,13 +266,13 @@ static void index_render_sheet(const struct gui_ctx *ctx, uint32_t *data; int stride; - if (!sheet->gfx_ctx_thumb) { + if (!sheet->gfx_thumb) { char *argv[] = { "index", NULL }; - gfx_init(&cro_canvas_ops, 1, argv); - sch_render(sheet->sch); - cro_canvas_end(gfx_ctx, NULL, NULL, NULL, NULL); - sheet->gfx_ctx_thumb = gfx_ctx; + sheet->gfx_thumb = gfx_init(&cro_canvas_ops, 1, argv); + sch_render(sheet->sch, sheet->gfx_thumb); + cro_canvas_end(gfx_user(sheet->gfx_thumb), + NULL, NULL, NULL, NULL); } if (ctx->old_hist && ctx->diff_mode == diff_delta) { @@ -295,7 +295,7 @@ static void index_render_sheet(const struct gui_ctx *ctx, sheet->thumb_surf = NULL; } - record_bbox((const struct record *) sheet->gfx_ctx_thumb, + record_bbox((const struct record *) gfx_user(sheet->gfx_thumb), &xmin, &ymin, &w, &h); if (!w || !h) return; @@ -306,13 +306,13 @@ static void index_render_sheet(const struct gui_ctx *ctx, xo = -(xmin + w / 2) * f + thumb_w / 2; yo = -(ymin + h / 2) * f + thumb_h / 2; - data = cro_img(sheet->gfx_ctx_thumb, NULL, xo, yo, thumb_w, thumb_h, f, - NULL, &stride); + data = cro_img(gfx_user(sheet->gfx_thumb), NULL, + xo, yo, thumb_w, thumb_h, f, NULL, &stride); if (yellow) paint_yellow(data, thumb_w, thumb_h, stride); - sheet->thumb_surf = cro_img_surface(sheet->gfx_ctx_thumb); + sheet->thumb_surf = cro_img_surface(gfx_user(sheet->gfx_thumb)); sheet->thumb_w = thumb_w; sheet->thumb_h = thumb_h; sheet->thumb_yellow = yellow; diff --git a/gui/render.c b/gui/render.c index 9cf71e9..a5eb8e4 100644 --- a/gui/render.c +++ b/gui/render.c @@ -161,8 +161,9 @@ static void hack(const struct gui_ctx *ctx, cairo_t *cr, areas = changed_sheets(ctx, xo, yo, f); diff_to_canvas(cr, ctx->x, ctx->y, ctx->scale, - old->gfx_ctx, show_extra ? old->gfx_ctx_extra : NULL, - new->gfx_ctx, show_extra ? new->gfx_ctx_extra : NULL, areas); + gfx_user(old->gfx), show_extra ? gfx_user(old->gfx_extra) : NULL, + gfx_user(new->gfx), show_extra ? gfx_user(new->gfx_extra) : NULL, + areas); free_areas(&areas); } @@ -184,15 +185,17 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, if (!ctx->old_hist || ctx->diff_mode == diff_new) { highlight_glabel(ctx, sheet, cr, x, y, f); if (show_extra) - cro_canvas_draw(sheet->gfx_ctx_extra, cr, x, y, f); - cro_canvas_draw(sheet->gfx_ctx, cr, x, y, f); + cro_canvas_draw(gfx_user(sheet->gfx_extra), + cr, x, y, f); + cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f); } else if (ctx->diff_mode == diff_old) { sheet = find_corresponding_sheet(ctx->old_hist->sheets, ctx->new_hist->sheets, ctx->curr_sheet); highlight_glabel(ctx, sheet, cr, x, y, f); if (show_extra) - cro_canvas_draw(sheet->gfx_ctx_extra, cr, x, y, f); - cro_canvas_draw(sheet->gfx_ctx, cr, x, y, f); + cro_canvas_draw(gfx_user(sheet->gfx_extra), + cr, x, y, f); + cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f); } else if (use_delta) { struct area *areas = changed_sheets(ctx, x, y, f); const struct area *area; @@ -207,16 +210,16 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, /* @@@ fix geometry later */ if (show_extra) { - cro_canvas_draw(ctx->delta_ab.gfx_ctx_extra, cr, - x, y, f); - cro_canvas_draw(ctx->delta_a.gfx_ctx_extra, cr, - x, y, f); - cro_canvas_draw(ctx->delta_b.gfx_ctx_extra, cr, - x, y, f); + cro_canvas_draw(gfx_user(ctx->delta_ab.gfx_extra), + cr, x, y, f); + cro_canvas_draw(gfx_user(ctx->delta_a.gfx_extra), + cr, x, y, f); + cro_canvas_draw(gfx_user(ctx->delta_b.gfx_extra), + cr, x, y, f); } - cro_canvas_draw(ctx->delta_ab.gfx_ctx, cr, x, y, f); - cro_canvas_draw(ctx->delta_a.gfx_ctx, cr, x, y, f); - cro_canvas_draw(ctx->delta_b.gfx_ctx, cr, x, y, f); + cro_canvas_draw(gfx_user(ctx->delta_ab.gfx), cr, x, y, f); + cro_canvas_draw(gfx_user(ctx->delta_a.gfx), cr, x, y, f); + cro_canvas_draw(gfx_user(ctx->delta_b.gfx), cr, x, y, f); } else { hack(ctx, cr, x, y, f); } @@ -249,19 +252,17 @@ void render_sheet(struct gui_sheet *sheet) { char *argv[] = { "gui", NULL }; - gfx_init(&cro_canvas_ops, 1, argv); + sheet->gfx = gfx_init(&cro_canvas_ops, 1, argv); if (sheet->hist && sheet->hist->pl) /* @@@ no pl_render for delta */ - pl_render(sheet->hist->pl, sheet->hist->sch_ctx.sheets, - sheet->sch); - sch_render(sheet->sch); - cro_canvas_end(gfx_ctx, + pl_render(sheet->hist->pl, sheet->gfx, + sheet->hist->sch_ctx.sheets, sheet->sch); + sch_render(sheet->sch, sheet->gfx); + cro_canvas_end(gfx_user(sheet->gfx), &sheet->w, &sheet->h, &sheet->xmin, &sheet->ymin); - sheet->gfx_ctx = gfx_ctx; - gfx_init(&cro_canvas_ops, 1, argv); - sch_render_extra(sheet->sch); - cro_canvas_end(gfx_ctx, NULL, NULL, NULL, NULL); - sheet->gfx_ctx_extra = gfx_ctx; + sheet->gfx_extra = gfx_init(&cro_canvas_ops, 1, argv); + sch_render_extra(sheet->sch, sheet->gfx_extra); + cro_canvas_end(gfx_user(sheet->gfx_extra), NULL, NULL, NULL, NULL); sheet->rendered = 1; // gfx_end(); @@ -293,13 +294,13 @@ void render_delta(struct gui_ctx *ctx) render_sheet(&ctx->delta_b); render_sheet(&ctx->delta_ab); - cro_color_override(ctx->delta_ab.gfx_ctx, COLOR_LIGHT_GREY); - cro_color_override(ctx->delta_b.gfx_ctx, COLOR_RED); - cro_color_override(ctx->delta_a.gfx_ctx, COLOR_GREEN2); + cro_color_override(gfx_user(ctx->delta_ab.gfx), COLOR_LIGHT_GREY); + cro_color_override(gfx_user(ctx->delta_b.gfx), COLOR_RED); + cro_color_override(gfx_user(ctx->delta_a.gfx), COLOR_GREEN2); - cro_color_override(ctx->delta_ab.gfx_ctx_extra, COLOR_LIGHT_GREY); - cro_color_override(ctx->delta_b.gfx_ctx_extra, COLOR_RED); - cro_color_override(ctx->delta_a.gfx_ctx_extra, COLOR_GREEN2); + cro_color_override(gfx_user(ctx->delta_ab.gfx_extra), COLOR_LIGHT_GREY); + cro_color_override(gfx_user(ctx->delta_b.gfx_extra), COLOR_RED); + cro_color_override(gfx_user(ctx->delta_a.gfx_extra), COLOR_GREEN2); // @@@ clean up when leaving sheet #endif |