diff options
author | Thomas White <taw@bitwiz.org.uk> | 2015-10-22 21:59:45 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2015-10-22 21:59:45 +0100 |
commit | 4fc3fe9e769b6e88c9323fae0eadd097f5800619 (patch) | |
tree | 84ef6862e35b8ac83ae42ad40d841474f3e3abe2 | |
parent | 9dcbab5217d68d73b20e97e8313882ea6b0ff493 (diff) |
Break down the rendering pipeline a bit more
-rw-r--r-- | src/render.c | 50 | ||||
-rw-r--r-- | src/render.h | 12 |
2 files changed, 45 insertions, 17 deletions
diff --git a/src/render.c b/src/render.c index 651a262..57dff1f 100644 --- a/src/render.c +++ b/src/render.c @@ -399,7 +399,7 @@ int recursive_draw(struct frame *fr, cairo_t *cr, } -static int recursive_wrap(struct frame *fr, ImageStore *is, enum is_size isz) +int recursive_wrap(struct frame *fr, ImageStore *is, enum is_size isz) { int i; @@ -414,23 +414,18 @@ static int recursive_wrap(struct frame *fr, ImageStore *is, enum is_size isz) } -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, - int slide_number) +struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, + SCCallbackList *cbl, ImageStore *is, + enum is_size isz, int slide_number, + cairo_t *cr) { + cairo_font_options_t *fopts; PangoFontMap *fontmap; PangoContext *pc; SCInterpreter *scin; char snum[64]; struct frame *top; - cairo_rectangle(cr, 0.0, 0.0, log_w, log_h); - cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); - cairo_fill(cr); - - cairo_font_options_t *fopts; fopts = cairo_font_options_create(); cairo_font_options_set_hint_style(fopts, CAIRO_HINT_STYLE_FULL); cairo_font_options_set_hint_metrics(fopts, CAIRO_HINT_METRICS_DEFAULT); @@ -446,8 +441,8 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su top->resizable = 0; top->x = 0.0; top->y = 0.0; - top->w = log_w; - top->h = log_h; + top->w = 0.0; /* not needed yet */ + top->h = 0.0; /* not needed yet */ scin = sc_interp_new(pc, top); if ( scin == NULL ) { @@ -461,8 +456,6 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su snprintf(snum, 63, "%i", slide_number); add_macro(scin, "slidenumber", snum); - /* "The rendering pipeline" */ - if ( stylesheets != NULL ) { int i = 0; while ( stylesheets[i] != NULL ) { @@ -471,8 +464,6 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su } } sc_interp_add_blocks(scin, scblocks); - recursive_wrap(top, is, isz); - recursive_draw(top, cr, is, isz); sc_interp_destroy(scin); cairo_font_options_destroy(fopts); @@ -482,6 +473,31 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su } +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, + int slide_number) +{ + struct frame *top; + + cairo_rectangle(cr, 0.0, 0.0, log_w, log_h); + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + cairo_fill(cr); + + top = interp_and_shape(scblocks, stylesheets, cbl, is, isz, + slide_number, cr); + + top->w = log_w; + top->h = log_h; + recursive_wrap(top, is, isz); + + recursive_draw(top, cr, is, isz); + + return top; +} + + cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, diff --git a/src/render.h b/src/render.h index caab9ab..fe8ad84 100644 --- a/src/render.h +++ b/src/render.h @@ -32,12 +32,24 @@ #include "sc_interp.h" #include "frame.h" +/* Convienience function to run the entire pipeline */ 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, struct frame **ptop); +/* Interpret StoryCode and measure boxes. + * Needs to be followed by: wrap_contents() (recursively) + * recursive_draw() + */ +extern struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, + SCCallbackList *cbl, + ImageStore *is, enum is_size isz, + int slide_number, cairo_t *cr); + +extern int recursive_wrap(struct frame *fr, ImageStore *is, enum is_size isz); + extern int export_pdf(struct presentation *p, const char *filename); extern int recursive_draw(struct frame *fr, cairo_t *cr, |