From d68cc38af6ea48198710dc03d70c22654fd08563 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 6 Dec 2020 19:25:07 -0800 Subject: [PATCH] work --- src/output/cairo.c | 63 ++++++---------------------------------------- 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/src/output/cairo.c b/src/output/cairo.c index 2556ab6fc1..52e38390ba 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -156,7 +156,6 @@ struct xr_driver int headings_height[2]; /* Internal state. */ - struct render_params *params; double font_scale; int char_width, char_height; cairo_t *cairo; @@ -483,54 +482,7 @@ static void xr_set_cairo (struct xr_driver *xr, cairo_t *cairo) { xr->cairo = cairo; - cairo_set_line_width (xr->cairo, xr_to_pt (XR_LINE_WIDTH)); - - xr_measure_fonts (xr->cairo, xr->fonts, &xr->char_width, &xr->char_height); - - for (int i = 0; i < XR_N_FONTS; i++) - { - struct xr_font *font = &xr->fonts[i]; - font->layout = pango_cairo_create_layout (cairo); - pango_layout_set_font_description (font->layout, font->desc); - } - - if (xr->params == NULL) - { - static const struct render_ops xr_render_ops = { - .draw_line = xr_draw_line, - .measure_cell_width = xr_measure_cell_width, - .measure_cell_height = xr_measure_cell_height, - .adjust_break = xr_adjust_break, - .draw_cell = xr_draw_cell, - }; - - xr->params = xmalloc (sizeof *xr->params); - xr->params->ops = &xr_render_ops; - xr->params->aux = xr; - xr->params->size[H] = xr->width; - xr->params->size[V] = xr->length; - xr->params->font_size[H] = xr->char_width; - xr->params->font_size[V] = xr->char_height; - - enum { LW = XR_LINE_WIDTH, LS = XR_LINE_SPACE }; - static const int xr_line_widths[RENDER_N_LINES] = - { - [RENDER_LINE_NONE] = 0, - [RENDER_LINE_SINGLE] = LW, - [RENDER_LINE_DASHED] = LW, - [RENDER_LINE_THICK] = LW * 2, - [RENDER_LINE_THIN] = LW / 2, - [RENDER_LINE_DOUBLE] = 2 * LW + LS, - }; - xr->params->line_widths = xr_line_widths; - - for (int i = 0; i < TABLE_N_AXES; i++) - xr->params->min_break[i] = xr->min_break[i]; - xr->params->supports_margins = true; - xr->params->rtl = render_direction_rtl (); - } - if (!xr->systemcolors) cairo_set_source_rgb (xr->cairo, xr->fg.r / 255.0, xr->fg.g / 255.0, xr->fg.b / 255.0); @@ -625,7 +577,6 @@ xr_destroy (struct output_driver *driver) g_object_unref (font->layout); } - free (xr->params); free (xr); } @@ -700,12 +651,15 @@ xr_submit (struct output_driver *driver, const struct output_item *output_item) xr_driver_next_page (xr, xr->cairo); } - xr_driver_output_item (xr, output_item); - while (xr_driver_need_new_page (xr)) + struct xr_fsm *fsm = xr_fsm_create (output_item, driver->style, xr->cairo); + for (;;) { - cairo_restore (xr->cairo); + int used = xr_fsm_draw_slice (fsm, xr->cairo, xr->length - xr->y); + cairo_translate (xr->cairo, 0, used); + if (xr_fsm_is_empty (fsm)) + break; + cairo_show_page (xr->cairo); - cairo_save (xr->cairo); xr_driver_next_page (xr, xr->cairo); } } @@ -745,8 +699,6 @@ xr_driver_next_page (struct xr_driver *xr, cairo_t *cairo) xr_render_page_heading (xr->cairo, xr->fonts[XR_FONT_PROPORTIONAL].desc, &xr->headings[1], xr->page_number, xr->width, true, xr->length); - - xr_driver_run_fsm (xr); } /* Start rendering OUTPUT_ITEM to XR. Only valid if XR is not in the middle of @@ -1578,6 +1530,7 @@ xr_driver_destroy (struct xr_driver *xr) output_driver_destroy (&xr->driver); } } + static void xr_draw_chart (const struct chart_item *chart_item, cairo_t *cr, double x, double y, double width, double height) -- 2.30.2