summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-30 23:01:45 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-08-30 23:13:40 (GMT)
commite5f83a6d3f12984758748d70f827c2ad4e68ef0f (patch)
tree4192a351f6041d8cbfab8a4673dc174901f2948f /gfx
parentd34bd9be49b2fc8d85eba54f1e8e67bc40a0eb67 (diff)
downloadeeshow-e5f83a6d3f12984758748d70f827c2ad4e68ef0f.zip
eeshow-e5f83a6d3f12984758748d70f827c2ad4e68ef0f.tar.gz
eeshow-e5f83a6d3f12984758748d70f827c2ad4e68ef0f.tar.bz2
gfx/: begin to bring some order into post-diff cleanup
Sadly, we need two new partial destructor functions for this, cro_img_reset and cro_img_destroy, plus one for the graphics abstraction, gfx_destroy.
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cro.c17
-rw-r--r--gfx/cro.h2
-rw-r--r--gfx/diff.c14
-rw-r--r--gfx/gfx.c8
-rw-r--r--gfx/gfx.h3
5 files changed, 39 insertions, 5 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index 866eb0c..1a9b593 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -778,6 +778,22 @@ void cro_img_write(cairo_surface_t *s, const char *name)
}
+void cro_img_reset(struct cro_ctx *cc)
+{
+ cairo_surface_destroy(cc->s);
+ cairo_destroy(cc->cr);
+ cc->cr = NULL;
+ cc->s = NULL;
+}
+
+
+void cro_img_destroy(struct cro_ctx *cc)
+{
+ record_destroy(&cc->record);
+ free(cc);
+}
+
+
/* ----- Canvas (using redraw) --------------------------------------------- */
@@ -844,7 +860,6 @@ uint32_t *cro_img(struct cro_ctx *cc, struct cro_ctx *cc_extra,
cairo_set_source_rgba(cr, 1, 1, 1, alpha);
cairo_paint(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-
}
/*
diff --git a/gfx/cro.h b/gfx/cro.h
index 5b22a1b..df32dc3 100644
--- a/gfx/cro.h
+++ b/gfx/cro.h
@@ -41,6 +41,8 @@ void cro_get_size(const struct cro_ctx *cc, int *w, int *h, int *x, int *y);
uint32_t *cro_img_end(struct cro_ctx *cc, int *w, int *h, int *stride);
void cro_img_write(cairo_surface_t *s, const char *name);
+void cro_img_reset(struct cro_ctx *cc);
+void cro_img_destroy(struct cro_ctx *cc);
void cro_canvas_end(struct cro_ctx *cc, int *w, int *h, int *xmin, int *ymin);
void cro_canvas_prepare(cairo_t *cr);
diff --git a/gfx/diff.c b/gfx/diff.c
index 9eb53e6..ba8c62a 100644
--- a/gfx/diff.c
+++ b/gfx/diff.c
@@ -450,6 +450,9 @@ static int diff_end(void *ctx)
assert(diff->gfx);
assert(diff->new_gfx);
+ cro_img_reset(gfx_user(diff->new_gfx));
+ cro_img_reset(gfx_user(diff->gfx));
+
old_cr = make_diff(NULL, 0, 0, diff->scale,
gfx_user(diff->gfx), NULL, gfx_user(diff->new_gfx), NULL, NULL,
&changed);
@@ -457,10 +460,15 @@ static int diff_end(void *ctx)
cro_img_write(s, diff->output_name);
- cairo_surface_destroy(s);
- cairo_destroy(old_cr);
+ cro_img_reset(gfx_user(diff->new_gfx));
+ cro_img_reset(gfx_user(diff->gfx));
+
+ cro_img_destroy(gfx_user(diff->new_gfx));
+ cro_img_destroy(gfx_user(diff->gfx));
+ gfx_destroy(diff->new_gfx);
+ gfx_destroy(diff->gfx);
- gfx_end(diff->new_gfx);
+ free(diff);
return changed;
}
diff --git a/gfx/gfx.c b/gfx/gfx.c
index a75b054..c07d211 100644
--- a/gfx/gfx.c
+++ b/gfx/gfx.c
@@ -148,12 +148,18 @@ void *gfx_user(struct gfx *gfx)
}
+void gfx_destroy(struct gfx *gfx)
+{
+ free(gfx);
+}
+
+
int gfx_end(struct gfx *gfx)
{
int res = 0;
if (gfx->ops->end)
res = gfx->ops->end(gfx->user);
- free(gfx);
+ gfx_destroy(gfx);
return res;
}
diff --git a/gfx/gfx.h b/gfx/gfx.h
index bcc0a3e..c53c661 100644
--- a/gfx/gfx.h
+++ b/gfx/gfx.h
@@ -74,10 +74,13 @@ unsigned gfx_text_width(struct gfx *gfx, const char *s, unsigned size,
struct gfx *gfx_init(const struct gfx_ops *ops);
bool gfx_args(struct gfx *gfx, int argc, char *const *argv);
+
void gfx_sheet_name(struct gfx *gfx, const char *name);
void gfx_new_sheet(struct gfx *gfx);
bool gfx_multi_sheet(struct gfx *gfx);
void *gfx_user(struct gfx *gfx); /* transitional kludge */
+
+void gfx_destroy(struct gfx *gfx);
int gfx_end(struct gfx *gfx);
#endif /* !GFX_GFX_H */