diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-01-29 00:06:59 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-01-29 00:06:59 +0100 |
commit | e03c16edbfcaaa03337899dd2c46208e2f9040a5 (patch) | |
tree | 59d2b1bc2de7dd1b15f2c5df0e992fd4d01458ef /src | |
parent | b4f193ef70435485dbd83b2051cabb85a821dadd (diff) |
Work on rendering pipeline
Diffstat (limited to 'src')
-rw-r--r-- | src/render.c | 46 | ||||
-rw-r--r-- | src/sc_interp.c | 38 | ||||
-rw-r--r-- | src/sc_interp.h | 3 |
3 files changed, 56 insertions, 31 deletions
diff --git a/src/render.c b/src/render.c index 63b3804..49ff5c3 100644 --- a/src/render.c +++ b/src/render.c @@ -1,7 +1,7 @@ /* * render.c * - * Copyright © 2013 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -281,14 +281,35 @@ static int draw_frame(cairo_t *cr, struct frame *fr, ImageStore *is, } +static int recursive_wrap_and_draw(struct frame *fr, cairo_t *cr, + ImageStore *is, enum is_size isz) +{ + int i; + + /* Wrap boxes -> wrap lines */ + wrap_contents(fr); + + /* Actually draw the lines */ + draw_frame(cr, fr, is, isz); + + for ( i=0; i<fr->num_children; i++ ) { + cairo_save(cr); + cairo_translate(cr, fr->children[i]->x, fr->children[i]->y); + recursive_wrap_and_draw(fr->children[i], cr, is, isz); + cairo_restore(cr); + } + + return 0; +} + + static int render_frame(cairo_t *cr, struct frame *fr, ImageStore *is, enum is_size isz, struct slide_constants *scc, struct presentation_constants *pcc, - PangoContext *pc) + PangoContext *pc, SCBlock *scblocks) { SCInterpreter *scin; int i; - SCBlock *bl = fr->scblocks; scin = sc_interp_new(pc, fr); if ( scin == NULL ) { @@ -312,20 +333,9 @@ static int render_frame(cairo_t *cr, struct frame *fr, ImageStore *is, initialise_line(fr->boxes); /* SCBlocks -> frames and wrap boxes (preferably re-using frames) */ - sc_interp_add_blocks(scin, bl); + sc_interp_add_blocks(scin, scblocks, fr->scblocks); - /* Wrap boxes -> wrap lines */ - wrap_contents(fr); - - /* Actually draw the lines */ - draw_frame(cr, fr, is, isz); - - for ( i=0; i<fr->num_children; i++ ) { - cairo_save(cr); - cairo_translate(cr, fr->children[i]->x, fr->children[i]->y); - render_frame(cr, fr->children[i], is, isz, scc, pcc, pc); - cairo_restore(cr); - } + recursive_wrap_and_draw(fr, cr, is, isz); sc_interp_destroy(scin); @@ -416,7 +426,7 @@ cairo_surface_t *render_slide(struct slide *s, int w, double ww, double hh, pango_cairo_update_context(cr, pc); render_frame(cr, s->top, is, isz, s->constants, - s->parent->constants, pc); + s->parent->constants, pc, s->parent->scblocks); cairo_font_options_destroy(fopts); g_object_unref(pc); @@ -479,7 +489,7 @@ int export_pdf(struct presentation *p, const char *filename) s->top->h = w*r; render_frame(cr, s->top, p->is, ISZ_SLIDESHOW, s->constants, - s->parent->constants, pc); + s->parent->constants, pc, s->parent->scblocks); cairo_show_page(cr); diff --git a/src/sc_interp.c b/src/sc_interp.c index 5f025c0..78a5589 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -71,6 +71,8 @@ struct _scinterp struct sc_state *state; int j; /* Index of the current state */ int max_state; + + int output; }; @@ -255,6 +257,8 @@ SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top) scin->s_constants = NULL; scin->p_constants = NULL; + scin->output = 0; + /* FIXME: Determine proper language (somehow...) */ scin->lang = pango_language_from_string("en_GB"); @@ -428,7 +432,6 @@ static int parse_image_option(const char *opt, struct frame *parent, } - static int parse_image_options(const char *opth, struct frame *parent, double *wp, double *hp, char **filenamep) { @@ -497,12 +500,16 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin) } } else if ( strcmp(name, "slidenumber")==0) { - char *tmp = malloc(64); - if ( tmp != NULL ) { - snprintf(tmp, 63, "%i", - scin->s_constants->slide_number); - split_words(sc_interp_get_frame(scin)->boxes, - scin->pc, tmp, scin->lang, 0, scin); + if ( scin->s_constants != NULL ) { + char *tmp = malloc(64); + if ( tmp != NULL ) { + snprintf(tmp, 63, "%i", + scin->s_constants->slide_number); + split_words(sc_interp_get_frame(scin)->boxes, + scin->pc, tmp, scin->lang, 0, scin); + } + } else { + printf("No slide constants.\n"); } } else if ( strcmp(name, "f")==0 ) { @@ -538,7 +545,7 @@ static int check_outputs(SCBlock *bl, SCInterpreter *scin) } -int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) +int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl, SCBlock *output) { while ( bl != NULL ) { @@ -546,11 +553,16 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) const char *options = sc_block_options(bl); SCBlock *child = sc_block_child(bl); + if ( bl == output ) { + scin->output = 1; + show_sc_block(bl, ""); + } + if ( child != NULL ) { sc_interp_save(scin); } - if ( (sc_interp_get_frame(scin) != NULL) + if ( scin->output && (sc_interp_get_frame(scin) != NULL) && check_outputs(bl, scin) ) { /* Block handled as output thing */ @@ -565,15 +577,17 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) } else { - fprintf(stderr, "Don't know what to do with this:\n"); - show_sc_block(bl, ""); + //fprintf(stderr, "Don't know what to do with this:\n"); + //show_sc_block(bl, ""); } if ( child != NULL ) { - sc_interp_add_blocks(scin, child); + sc_interp_add_blocks(scin, child, output); sc_interp_restore(scin); } + + if ( bl == output ) return 0; bl = sc_block_next(bl); } diff --git a/src/sc_interp.h b/src/sc_interp.h index 80b1e70..648df91 100644 --- a/src/sc_interp.h +++ b/src/sc_interp.h @@ -37,7 +37,8 @@ extern void sc_interp_destroy(SCInterpreter *scin); extern void sc_interp_save(SCInterpreter *scin); extern void sc_interp_restore(SCInterpreter *scin); -extern int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl); +extern int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl, + SCBlock *last); /* Get the current state of the interpreter */ extern struct frame *sc_interp_get_frame(SCInterpreter *scin); |