gui: Speed up rendering of large tables that are only partly visible.
[pspp] / src / output / cairo.c
index a1445bcfe1c5b3763797a88ca5ba1b8061b59ced..896f3d5fe7cdc2a62fa561f3776d7625b9cbb37d 100644 (file)
@@ -928,6 +928,18 @@ xr_driver_create (cairo_t *cairo, struct string_map *options)
   return xr;
 }
 
+/* Destroy XR, which should have been created with xr_driver_create().  Any
+   cairo_t added to XR is not destroyed, because it is owned by the client. */
+void
+xr_driver_destroy (struct xr_driver *xr)
+{
+  if (xr != NULL)
+    {
+      xr->cairo = NULL;
+      output_driver_destroy (&xr->driver);
+    }
+}
+
 static struct xr_rendering *
 xr_rendering_create_text (struct xr_driver *xr, const char *text, cairo_t *cr)
 {
@@ -990,8 +1002,11 @@ xr_rendering_measure (struct xr_rendering *r, int *w, int *h)
     }
 }
 
+/* Draws onto CR at least the region of R that is enclosed in (X,Y)-(X+W,Y+H),
+   and possibly some additional parts. */
 void
-xr_rendering_draw (struct xr_rendering *r, cairo_t *cr)
+xr_rendering_draw (struct xr_rendering *r, cairo_t *cr,
+                   int x, int y, int w, int h)
 {
   if (r->chart == NULL)
     {
@@ -999,7 +1014,8 @@ xr_rendering_draw (struct xr_rendering *r, cairo_t *cr)
 
       xr_set_cairo (xr, cr);
       xr->y = 0;
-      render_page_draw (r->page);
+      render_page_draw_region (r->page,
+                               x * 1024, y * 1024, w * 1024, h * 1024);
     }
   else
     xr_draw_chart (r->chart, cr, 0, 0, CHART_WIDTH, CHART_HEIGHT);