1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-22 20:53:44 +02:00

eeshow/gfx/diff.c (diff_to_canvas): draw caller-supplied areas

These are for future highlighting. WIP.
This commit is contained in:
Werner Almesberger 2016-08-19 21:25:48 -03:00
parent f244fa09c7
commit 6b901399ce
3 changed files with 22 additions and 12 deletions

View File

@ -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);

View File

@ -14,6 +14,8 @@
#ifndef GFX_DIFF_H
#define GFX_DIFF_H
#include <stdint.h>
#include <cairo/cairo.h>
#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 */

View File

@ -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);
}