summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gfx/diff.c19
-rw-r--r--gfx/diff.h12
-rw-r--r--gui/render.c3
3 files changed, 22 insertions, 12 deletions
diff --git a/gfx/diff.c b/gfx/diff.c
index 14247ac..c44f02c 100644
--- a/gfx/diff.c
+++ b/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/gfx/diff.h b/gfx/diff.h
index 4042ccc..5d7be8e 100644
--- a/gfx/diff.h
+++ b/gfx/diff.h
@@ -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 */
diff --git a/gui/render.c b/gui/render.c
index 5d217e2..3fa8fa0 100644
--- a/gui/render.c
+++ b/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);
}