diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/frame.c | 13 | ||||
-rw-r--r-- | src/frame.h | 1 | ||||
-rw-r--r-- | src/narrative_window.c | 4 | ||||
-rw-r--r-- | src/render.c | 27 | ||||
-rw-r--r-- | src/render.h | 5 | ||||
-rw-r--r-- | src/sc_editor.c | 2 | ||||
-rw-r--r-- | src/slideshow.c | 25 |
7 files changed, 36 insertions, 41 deletions
diff --git a/src/frame.c b/src/frame.c index 8c670bc..9f23d17 100644 --- a/src/frame.c +++ b/src/frame.c @@ -78,6 +78,19 @@ struct frame *frame_new() } +void frame_free(struct frame *fr) +{ + int i; + + free(fr->boxes); + for ( i=0; i<fr->num_children; i++ ) { + frame_free(fr->children[i]); + } + free(fr->children); + free(fr); +} + + void renew_frame(struct frame *fr) { int i; diff --git a/src/frame.h b/src/frame.h index 68d8649..b5679da 100644 --- a/src/frame.h +++ b/src/frame.h @@ -93,6 +93,7 @@ struct frame extern struct frame *frame_new(void); +extern void frame_free(struct frame *fr); extern struct frame *add_subframe(struct frame *fr); extern void renew_frame(struct frame *fr); extern void show_hierarchy(struct frame *fr, const char *t); diff --git a/src/narrative_window.c b/src/narrative_window.c index 81b23c8..f8e68b0 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -231,12 +231,14 @@ static cairo_surface_t *render_thumbnail(int w, int h, void *bvp, void *vp) SCBlock *scblocks = bvp; cairo_surface_t *surf; SCBlock *stylesheets[2]; + struct frame *top; scblocks = sc_block_child(scblocks); stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; surf = render_sc(scblocks, w, h, 1024.0, 768.0, stylesheets, NULL, - p->is, ISZ_THUMBNAIL, 0); + p->is, ISZ_THUMBNAIL, 0, &top); + frame_free(top); return surf; } diff --git a/src/render.c b/src/render.c index d24d437..3bdc4ca 100644 --- a/src/render.c +++ b/src/render.c @@ -403,7 +403,7 @@ static int recursive_wrap_and_draw(struct frame *fr, cairo_t *cr, } -static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, +static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, cairo_t *cr, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, @@ -441,7 +441,8 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, scin = sc_interp_new(pc, top); if ( scin == NULL ) { fprintf(stderr, "Failed to set up interpreter.\n"); - return; + frame_free(top); + return NULL; } sc_interp_set_callbacks(scin, cbl); @@ -465,34 +466,30 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, sc_interp_destroy(scin); cairo_font_options_destroy(fopts); g_object_unref(pc); + + return top; } -/** - * render_slide: - * @s: A slide. - * @w: Width of bitmap to output - * @h: Height of bitmap to produce - * @ww: Logical width of the rendering area - * @hh: Logical height of the rendering area - * - * Render the entire slide. - */ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, - int slide_number) + int slide_number, struct frame **ptop) { cairo_surface_t *surf; cairo_t *cr; + struct frame *top; surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); cr = cairo_create(surf); cairo_scale(cr, w/log_w, h/log_h); - render_sc_to_surface(scblocks, surf, cr, log_w, log_h, - stylesheets, cbl, is, isz,slide_number); + top = render_sc_to_surface(scblocks, surf, cr, log_w, log_h, + stylesheets, cbl, is, isz,slide_number); cairo_destroy(cr); + + *ptop = top; + return surf; } diff --git a/src/render.h b/src/render.h index 386df63..3938ca1 100644 --- a/src/render.h +++ b/src/render.h @@ -1,7 +1,7 @@ /* * render.h * - * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2015 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -30,12 +30,13 @@ #include "presentation.h" #include "imagestore.h" #include "sc_interp.h" +#include "frame.h" extern cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, - int slide_number); + int slide_number, struct frame **ptop); extern int export_pdf(struct presentation *p, const char *filename); diff --git a/src/sc_editor.c b/src/sc_editor.c index 95351e2..93a1245 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -75,7 +75,7 @@ static void rerender(SCEditor *e) e->surface = render_sc(e->scblocks, e->w, e->h, e->log_w, e->log_h, e->stylesheets, e->cbl, e->is, ISZ_EDITOR, - e->slidenum); + e->slidenum, &e->top); } diff --git a/src/slideshow.c b/src/slideshow.c index b156a06..8124268 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -53,7 +53,7 @@ struct _slideshow struct inhibit_sys *inhibit; int linked; cairo_surface_t *surface; - struct frame top; + struct frame *top; }; @@ -85,7 +85,8 @@ void slideshow_rerender(SlideShow *ss) ss->surface = render_sc(ss->cur_slide->scblocks, ss->slide_width, ss->slide_height, ss->p->slide_width, ss->p->slide_height, - stylesheets, NULL, ss->p->is, ISZ_SLIDESHOW, n); + stylesheets, NULL, ss->p->is, ISZ_SLIDESHOW, n, + &ss->top); } @@ -268,26 +269,6 @@ SlideShow *try_start_slideshow(SlideWindow *sw, struct presentation *p) ss->inhibit = inhibit_prepare(); } - ss->top.children = NULL; - ss->top.num_children = 0; - ss->top.max_children = 0; - ss->top.lines = NULL; - ss->top.n_lines = 0; - ss->top.max_lines = 0; - ss->top.pad_l = 0; - ss->top.pad_r = 0; - ss->top.pad_t = 0; - ss->top.pad_b = 0; - ss->top.x = 0.0; - ss->top.y = 0.0; - ss->top.w = slide_width; - ss->top.h = slide_height; - ss->top.grad = GRAD_NONE; - ss->top.bgcol[0] = 1.0; - ss->top.bgcol[1] = 1.0; - ss->top.bgcol[2] = 1.0; - ss->top.bgcol[3] = 1.0; - ss->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); ss->drawingarea = gtk_drawing_area_new(); |