From 6b901399ce128d44f87a653234d34023575d9dc6 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 19 Aug 2016 21:25:48 -0300 Subject: [PATCH] eeshow/gfx/diff.c (diff_to_canvas): draw caller-supplied areas These are for future highlighting. WIP. --- eeshow/gfx/diff.c | 19 +++++++++---------- eeshow/gfx/diff.h | 12 +++++++++++- eeshow/gui/render.c | 3 ++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/eeshow/gfx/diff.c b/eeshow/gfx/diff.c index 14247ac..c44f02c 100644 --- a/eeshow/gfx/diff.c +++ b/eeshow/gfx/diff.c @@ -47,12 +47,6 @@ #define AREA_FILL 0xffd0f0 - -struct area { - int xa, ya, xb, yb; - struct area *next; -}; - struct diff { void *cr_ctx; uint32_t *new_img; @@ -212,6 +206,7 @@ static void mark_area(struct diff *diff, int x, int y) area->xb = x + diff->frame_radius; area->ya = y - diff->frame_radius; area->yb = y + diff->frame_radius; + area->color = AREA_FILL; area->next = diff->areas; diff->areas = area; @@ -265,7 +260,7 @@ static void show_areas(struct diff *diff, uint32_t *a) for (area = diff->areas; area; area = area->next) complement_box(diff, a, area->xa, area->ya, area->xb, area->yb, - AREA_FILL); + area->color); } @@ -317,7 +312,8 @@ static void merge_coord(int pos_a, int pos_b, int dim_a, int dim_b, void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale, - struct cro_ctx *old, struct cro_ctx *new) + struct cro_ctx *old, struct cro_ctx *new, + const struct area *areas) { int old_xmin, old_ymin, old_w, old_h; int new_xmin, new_ymin, new_w, new_h; @@ -378,9 +374,12 @@ void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale, cairo_surface_flush(s); differences(&diff, img_old, img_new); show_areas(&diff, img_old); - cairo_surface_mark_dirty(s); - free_areas(&diff); + if (areas) { + diff.areas = (struct area *) areas; + show_areas(&diff, img_old); + } + cairo_surface_mark_dirty(s); cairo_set_source_surface(cr, s, 0, 0); cairo_paint(cr); diff --git a/eeshow/gfx/diff.h b/eeshow/gfx/diff.h index 4042ccc..5d7be8e 100644 --- a/eeshow/gfx/diff.h +++ b/eeshow/gfx/diff.h @@ -14,6 +14,8 @@ #ifndef GFX_DIFF_H #define GFX_DIFF_H +#include + #include #include "gfx/gfx.h" @@ -23,7 +25,15 @@ extern const struct gfx_ops diff_ops; +struct area { + int xa, ya, xb, yb; + uint32_t color; + struct area *next; +}; + + void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale, - struct cro_ctx *old, struct cro_ctx *new); + struct cro_ctx *old, struct cro_ctx *new, + const struct area *areas); #endif /* !GFX_DIFF_H */ diff --git a/eeshow/gui/render.c b/eeshow/gui/render.c index 5d217e2..3fa8fa0 100644 --- a/eeshow/gui/render.c +++ b/eeshow/gui/render.c @@ -60,6 +60,7 @@ static inline int cd(int x, float scale) return x * scale; } + static inline int cx(int x, int xo, float scale) { return xo + x * scale; @@ -109,7 +110,7 @@ static void hack(const struct gui_ctx *ctx, cairo_t *cr) ctx->old_hist->sheets, ctx->new_hist->sheets, ctx->curr_sheet); diff_to_canvas(cr, ctx->x, ctx->y, 1.0 / (1 << ctx->zoom), - old->gfx_ctx, new->gfx_ctx); + old->gfx_ctx, new->gfx_ctx, NULL); }