1 /* cairo - a vector graphics library with display and print output
2  *
3  * Copyright © 2005 Red Hat, Inc
4  * Copyright © 2007 Adrian Johnson
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it either under the terms of the GNU Lesser General Public
8  * License version 2.1 as published by the Free Software Foundation
9  * (the "LGPL") or, at your option, under the terms of the Mozilla
10  * Public License Version 1.1 (the "MPL"). If you do not alter this
11  * notice, a recipient may use your version of this file under either
12  * the MPL or the LGPL.
13  *
14  * You should have received a copy of the LGPL along with this library
15  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
17  * You should have received a copy of the MPL along with this library
18  * in the file COPYING-MPL-1.1
19  *
20  * The contents of this file are subject to the Mozilla Public License
21  * Version 1.1 (the "License"); you may not use this file except in
22  * compliance with the License. You may obtain a copy of the License at
23  * http://www.mozilla.org/MPL/
24  *
25  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
26  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
27  * the specific language governing rights and limitations.
28  *
29  * The Original Code is the cairo graphics library.
30  *
31  * The Initial Developer of the Original Code is Red Hat, Inc.
32  *
33  * Contributor(s):
34  *	Carl Worth <cworth@cworth.org>
35  *	Keith Packard <keithp@keithp.com>
36  *	Adrian Johnson <ajohnson@redneon.com>
37  */
38 
39 /* The paginated surface layer exists to provide as much code sharing
40  * as possible for the various paginated surface backends in cairo
41  * (PostScript, PDF, etc.). See cairo-paginated-private.h for
42  * more details on how it works and how to use it.
43  */
44 
45 #include "cairoint.h"
46 
47 #include "cairo-paginated-private.h"
48 #include "cairo-paginated-surface-private.h"
49 #include "cairo-recording-surface-private.h"
50 #include "cairo-analysis-surface-private.h"
51 #include "cairo-error-private.h"
52 
53 static const cairo_surface_backend_t cairo_paginated_surface_backend;
54 
55 static cairo_int_status_t
56 _cairo_paginated_surface_show_page (void *abstract_surface);
57 
58 static cairo_surface_t *
_cairo_paginated_surface_create_similar(void * abstract_surface,cairo_content_t content,int width,int height)59 _cairo_paginated_surface_create_similar (void			*abstract_surface,
60 					 cairo_content_t	 content,
61 					 int			 width,
62 					 int			 height)
63 {
64     cairo_rectangle_t rect;
65     rect.x = rect.y = 0.;
66     rect.width = width;
67     rect.height = height;
68     return cairo_recording_surface_create (content, &rect);
69 }
70 
71 static cairo_surface_t *
_create_recording_surface_for_target(cairo_surface_t * target,cairo_content_t content)72 _create_recording_surface_for_target (cairo_surface_t *target,
73 				      cairo_content_t content)
74 {
75     cairo_rectangle_int_t rect;
76 
77     if (_cairo_surface_get_extents (target, &rect)) {
78 	cairo_rectangle_t recording_extents;
79 
80 	recording_extents.x = rect.x;
81 	recording_extents.y = rect.y;
82 	recording_extents.width = rect.width;
83 	recording_extents.height = rect.height;
84 
85 	return cairo_recording_surface_create (content, &recording_extents);
86     } else {
87 	return cairo_recording_surface_create (content, NULL);
88     }
89 }
90 
91 cairo_surface_t *
_cairo_paginated_surface_create(cairo_surface_t * target,cairo_content_t content,const cairo_paginated_surface_backend_t * backend)92 _cairo_paginated_surface_create (cairo_surface_t				*target,
93 				 cairo_content_t				 content,
94 				 const cairo_paginated_surface_backend_t	*backend)
95 {
96     cairo_paginated_surface_t *surface;
97     cairo_status_t status;
98 
99     surface = malloc (sizeof (cairo_paginated_surface_t));
100     if (unlikely (surface == NULL)) {
101 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
102 	goto FAIL;
103     }
104 
105     _cairo_surface_init (&surface->base,
106 			 &cairo_paginated_surface_backend,
107 			 NULL, /* device */
108 			 content);
109 
110     /* Override surface->base.type with target's type so we don't leak
111      * evidence of the paginated wrapper out to the user. */
112     surface->base.type = target->type;
113 
114     surface->target = cairo_surface_reference (target);
115 
116     surface->content = content;
117     surface->backend = backend;
118 
119     surface->recording_surface = _create_recording_surface_for_target (target, content);
120     status = surface->recording_surface->status;
121     if (unlikely (status))
122 	goto FAIL_CLEANUP_SURFACE;
123 
124     surface->page_num = 1;
125     surface->base.is_clear = TRUE;
126 
127     return &surface->base;
128 
129   FAIL_CLEANUP_SURFACE:
130     cairo_surface_destroy (target);
131     free (surface);
132   FAIL:
133     return _cairo_surface_create_in_error (status);
134 }
135 
136 cairo_bool_t
_cairo_surface_is_paginated(cairo_surface_t * surface)137 _cairo_surface_is_paginated (cairo_surface_t *surface)
138 {
139     return surface->backend == &cairo_paginated_surface_backend;
140 }
141 
142 cairo_surface_t *
_cairo_paginated_surface_get_target(cairo_surface_t * surface)143 _cairo_paginated_surface_get_target (cairo_surface_t *surface)
144 {
145     cairo_paginated_surface_t *paginated_surface;
146 
147     assert (_cairo_surface_is_paginated (surface));
148 
149     paginated_surface = (cairo_paginated_surface_t *) surface;
150 
151     return paginated_surface->target;
152 }
153 
154 static cairo_status_t
_cairo_paginated_surface_finish(void * abstract_surface)155 _cairo_paginated_surface_finish (void *abstract_surface)
156 {
157     cairo_paginated_surface_t *surface = abstract_surface;
158     cairo_status_t status = CAIRO_STATUS_SUCCESS;
159 
160     if (! surface->base.is_clear || surface->page_num == 1) {
161 	/* Bypass some of the sanity checking in cairo-surface.c, as we
162 	 * know that the surface is finished...
163 	 */
164 	status = _cairo_paginated_surface_show_page (surface);
165     }
166 
167      /* XXX We want to propagate any errors from destroy(), but those are not
168       * returned via the api. So we need to explicitly finish the target,
169       * and check the status afterwards. However, we can only call finish()
170       * on the target, if we own it.
171       */
172     if (CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->target->ref_count) == 1)
173 	cairo_surface_finish (surface->target);
174     if (status == CAIRO_STATUS_SUCCESS)
175 	status = cairo_surface_status (surface->target);
176     cairo_surface_destroy (surface->target);
177 
178     cairo_surface_finish (surface->recording_surface);
179     if (status == CAIRO_STATUS_SUCCESS)
180 	status = cairo_surface_status (surface->recording_surface);
181     cairo_surface_destroy (surface->recording_surface);
182 
183     return status;
184 }
185 
186 static cairo_surface_t *
_cairo_paginated_surface_create_image_surface(void * abstract_surface,int width,int height)187 _cairo_paginated_surface_create_image_surface (void	       *abstract_surface,
188 					       int		width,
189 					       int		height)
190 {
191     cairo_paginated_surface_t *surface = abstract_surface;
192     cairo_surface_t *image;
193     cairo_font_options_t options;
194 
195     image = _cairo_image_surface_create_with_content (surface->content,
196 						      width,
197 						      height);
198 
199     cairo_surface_get_font_options (&surface->base, &options);
200     _cairo_surface_set_font_options (image, &options);
201 
202     return image;
203 }
204 
205 static cairo_status_t
_cairo_paginated_surface_acquire_source_image(void * abstract_surface,cairo_image_surface_t ** image_out,void ** image_extra)206 _cairo_paginated_surface_acquire_source_image (void	       *abstract_surface,
207 					       cairo_image_surface_t **image_out,
208 					       void		   **image_extra)
209 {
210     cairo_paginated_surface_t *surface = abstract_surface;
211     cairo_bool_t is_bounded;
212     cairo_surface_t *image;
213     cairo_status_t status;
214     cairo_rectangle_int_t extents;
215 
216     is_bounded = _cairo_surface_get_extents (surface->target, &extents);
217     if (! is_bounded)
218 	return CAIRO_INT_STATUS_UNSUPPORTED;
219 
220     image = _cairo_paginated_surface_create_image_surface (surface,
221 							   extents.width,
222 							   extents.height);
223 
224     status = _cairo_recording_surface_replay (surface->recording_surface, image);
225     if (unlikely (status)) {
226 	cairo_surface_destroy (image);
227 	return status;
228     }
229 
230     *image_out = (cairo_image_surface_t*) image;
231     *image_extra = NULL;
232 
233     return CAIRO_STATUS_SUCCESS;
234 }
235 
236 static void
_cairo_paginated_surface_release_source_image(void * abstract_surface,cairo_image_surface_t * image,void * image_extra)237 _cairo_paginated_surface_release_source_image (void	  *abstract_surface,
238 					       cairo_image_surface_t *image,
239 					       void	       *image_extra)
240 {
241     cairo_surface_destroy (&image->base);
242 }
243 
244 static cairo_int_status_t
_paint_fallback_image(cairo_paginated_surface_t * surface,cairo_rectangle_int_t * rect)245 _paint_fallback_image (cairo_paginated_surface_t *surface,
246 		       cairo_rectangle_int_t     *rect)
247 {
248     double x_scale = surface->base.x_fallback_resolution / surface->target->x_resolution;
249     double y_scale = surface->base.y_fallback_resolution / surface->target->y_resolution;
250     int x, y, width, height;
251     cairo_status_t status;
252     cairo_surface_t *image;
253     cairo_surface_pattern_t pattern;
254     cairo_clip_t clip;
255 
256     x = rect->x;
257     y = rect->y;
258     width = rect->width;
259     height = rect->height;
260     image = _cairo_paginated_surface_create_image_surface (surface,
261 							   ceil (width  * x_scale),
262 							   ceil (height * y_scale));
263     _cairo_surface_set_device_scale (image, x_scale, y_scale);
264     /* set_device_offset just sets the x0/y0 components of the matrix;
265      * so we have to do the scaling manually. */
266     cairo_surface_set_device_offset (image, -x*x_scale, -y*y_scale);
267 
268     status = _cairo_recording_surface_replay (surface->recording_surface, image);
269     if (unlikely (status))
270 	goto CLEANUP_IMAGE;
271 
272     _cairo_pattern_init_for_surface (&pattern, image);
273     cairo_matrix_init (&pattern.base.matrix,
274 		       x_scale, 0, 0, y_scale, -x*x_scale, -y*y_scale);
275     /* the fallback should be rendered at native resolution, so disable
276      * filtering (if possible) to avoid introducing potential artifacts. */
277     pattern.base.filter = CAIRO_FILTER_NEAREST;
278 
279     _cairo_clip_init (&clip);
280     status = _cairo_clip_rectangle (&clip, rect);
281     if (likely (status == CAIRO_STATUS_SUCCESS)) {
282 	status = _cairo_surface_paint (surface->target,
283 				       CAIRO_OPERATOR_SOURCE,
284 				       &pattern.base, &clip);
285     }
286 
287     _cairo_clip_fini (&clip);
288     _cairo_pattern_fini (&pattern.base);
289 
290 CLEANUP_IMAGE:
291     cairo_surface_destroy (image);
292 
293     return status;
294 }
295 
296 static cairo_int_status_t
_paint_page(cairo_paginated_surface_t * surface)297 _paint_page (cairo_paginated_surface_t *surface)
298 {
299     cairo_surface_t *analysis;
300     cairo_status_t status;
301     cairo_bool_t has_supported, has_page_fallback, has_finegrained_fallback;
302 
303     if (unlikely (surface->target->status))
304 	return surface->target->status;
305 
306     analysis = _cairo_analysis_surface_create (surface->target);
307     if (unlikely (analysis->status))
308 	return _cairo_surface_set_error (surface->target, analysis->status);
309 
310     surface->backend->set_paginated_mode (surface->target,
311 	                                  CAIRO_PAGINATED_MODE_ANALYZE);
312     status = _cairo_recording_surface_replay_and_create_regions (surface->recording_surface,
313 								 analysis);
314     if (status || analysis->status) {
315 	if (status == CAIRO_STATUS_SUCCESS)
316 	    status = analysis->status;
317 	goto FAIL;
318     }
319 
320      if (surface->backend->set_bounding_box) {
321 	 cairo_box_t bbox;
322 
323 	 _cairo_analysis_surface_get_bounding_box (analysis, &bbox);
324 	 status = surface->backend->set_bounding_box (surface->target, &bbox);
325 	 if (unlikely (status))
326 	     goto FAIL;
327      }
328 
329     if (surface->backend->set_fallback_images_required) {
330 	cairo_bool_t has_fallbacks = _cairo_analysis_surface_has_unsupported (analysis);
331 
332 	status = surface->backend->set_fallback_images_required (surface->target,
333 								 has_fallbacks);
334 	if (unlikely (status))
335 	    goto FAIL;
336     }
337 
338     /* Finer grained fallbacks are currently only supported for some
339      * surface types */
340     if (surface->backend->supports_fine_grained_fallbacks != NULL &&
341 	surface->backend->supports_fine_grained_fallbacks (surface->target))
342     {
343 	has_supported = _cairo_analysis_surface_has_supported (analysis);
344 	has_page_fallback = FALSE;
345 	has_finegrained_fallback = _cairo_analysis_surface_has_unsupported (analysis);
346     }
347     else
348     {
349 	if (_cairo_analysis_surface_has_unsupported (analysis)) {
350 	    has_supported = FALSE;
351 	    has_page_fallback = TRUE;
352 	} else {
353 	    has_supported = TRUE;
354 	    has_page_fallback = FALSE;
355 	}
356 	has_finegrained_fallback = FALSE;
357     }
358 
359     if (has_supported) {
360 	surface->backend->set_paginated_mode (surface->target,
361 		                              CAIRO_PAGINATED_MODE_RENDER);
362 
363 	status = _cairo_recording_surface_replay_region (surface->recording_surface,
364 							 NULL,
365 							 surface->target,
366 							 CAIRO_RECORDING_REGION_NATIVE);
367 	assert (status != CAIRO_INT_STATUS_UNSUPPORTED);
368 	if (unlikely (status))
369 	    goto FAIL;
370     }
371 
372     if (has_page_fallback) {
373 	cairo_rectangle_int_t extents;
374 	cairo_bool_t is_bounded;
375 
376 	surface->backend->set_paginated_mode (surface->target,
377 		                              CAIRO_PAGINATED_MODE_FALLBACK);
378 
379 	is_bounded = _cairo_surface_get_extents (surface->target, &extents);
380 	if (! is_bounded) {
381 	    status = CAIRO_INT_STATUS_UNSUPPORTED;
382 	    goto FAIL;
383 	}
384 
385 	status = _paint_fallback_image (surface, &extents);
386 	if (unlikely (status))
387 	    goto FAIL;
388     }
389 
390     if (has_finegrained_fallback) {
391         cairo_region_t *region;
392         int num_rects, i;
393 
394 	surface->backend->set_paginated_mode (surface->target,
395 		                              CAIRO_PAGINATED_MODE_FALLBACK);
396 
397 	region = _cairo_analysis_surface_get_unsupported (analysis);
398 
399 	num_rects = cairo_region_num_rectangles (region);
400 	for (i = 0; i < num_rects; i++) {
401 	    cairo_rectangle_int_t rect;
402 
403 	    cairo_region_get_rectangle (region, i, &rect);
404 	    status = _paint_fallback_image (surface, &rect);
405 	    if (unlikely (status))
406 		goto FAIL;
407 	}
408     }
409 
410   FAIL:
411     cairo_surface_destroy (analysis);
412 
413     return _cairo_surface_set_error (surface->target, status);
414 }
415 
416 static cairo_status_t
_start_page(cairo_paginated_surface_t * surface)417 _start_page (cairo_paginated_surface_t *surface)
418 {
419     if (surface->target->status)
420 	return surface->target->status;
421 
422     if (! surface->backend->start_page)
423 	return CAIRO_STATUS_SUCCESS;
424 
425     return _cairo_surface_set_error (surface->target,
426 	                        surface->backend->start_page (surface->target));
427 }
428 
429 static cairo_int_status_t
_cairo_paginated_surface_copy_page(void * abstract_surface)430 _cairo_paginated_surface_copy_page (void *abstract_surface)
431 {
432     cairo_status_t status;
433     cairo_paginated_surface_t *surface = abstract_surface;
434 
435     status = _start_page (surface);
436     if (unlikely (status))
437 	return status;
438 
439     status = _paint_page (surface);
440     if (unlikely (status))
441 	return status;
442 
443     surface->page_num++;
444 
445     /* XXX: It might make sense to add some support here for calling
446      * cairo_surface_copy_page on the target surface. It would be an
447      * optimization for the output, but the interaction with image
448      * fallbacks gets tricky. For now, we just let the target see a
449      * show_page and we implement the copying by simply not destroying
450      * the recording-surface. */
451 
452     cairo_surface_show_page (surface->target);
453     return cairo_surface_status (surface->target);
454 }
455 
456 static cairo_int_status_t
_cairo_paginated_surface_show_page(void * abstract_surface)457 _cairo_paginated_surface_show_page (void *abstract_surface)
458 {
459     cairo_status_t status;
460     cairo_paginated_surface_t *surface = abstract_surface;
461 
462     status = _start_page (surface);
463     if (unlikely (status))
464 	return status;
465 
466     status = _paint_page (surface);
467     if (unlikely (status))
468 	return status;
469 
470     cairo_surface_show_page (surface->target);
471     status = surface->target->status;
472     if (unlikely (status))
473 	return status;
474 
475     status = surface->recording_surface->status;
476     if (unlikely (status))
477 	return status;
478 
479     if (! surface->base.finished) {
480 	cairo_surface_destroy (surface->recording_surface);
481 
482 	surface->recording_surface = _create_recording_surface_for_target (surface->target,
483 									   surface->content);
484 	status = surface->recording_surface->status;
485 	if (unlikely (status))
486 	    return status;
487 
488 	surface->page_num++;
489 	surface->base.is_clear = TRUE;
490     }
491 
492     return CAIRO_STATUS_SUCCESS;
493 }
494 
495 static cairo_bool_t
_cairo_paginated_surface_get_extents(void * abstract_surface,cairo_rectangle_int_t * rectangle)496 _cairo_paginated_surface_get_extents (void	              *abstract_surface,
497 				      cairo_rectangle_int_t   *rectangle)
498 {
499     cairo_paginated_surface_t *surface = abstract_surface;
500 
501     return _cairo_surface_get_extents (surface->target, rectangle);
502 }
503 
504 static void
_cairo_paginated_surface_get_font_options(void * abstract_surface,cairo_font_options_t * options)505 _cairo_paginated_surface_get_font_options (void                  *abstract_surface,
506 					   cairo_font_options_t  *options)
507 {
508     cairo_paginated_surface_t *surface = abstract_surface;
509 
510     cairo_surface_get_font_options (surface->target, options);
511 }
512 
513 static cairo_int_status_t
_cairo_paginated_surface_paint(void * abstract_surface,cairo_operator_t op,const cairo_pattern_t * source,cairo_clip_t * clip)514 _cairo_paginated_surface_paint (void			*abstract_surface,
515 				cairo_operator_t	 op,
516 				const cairo_pattern_t	*source,
517 				cairo_clip_t		*clip)
518 {
519     cairo_paginated_surface_t *surface = abstract_surface;
520 
521     return _cairo_surface_paint (surface->recording_surface, op, source, clip);
522 }
523 
524 static cairo_int_status_t
_cairo_paginated_surface_mask(void * abstract_surface,cairo_operator_t op,const cairo_pattern_t * source,const cairo_pattern_t * mask,cairo_clip_t * clip)525 _cairo_paginated_surface_mask (void		*abstract_surface,
526 			       cairo_operator_t	 op,
527 			       const cairo_pattern_t	*source,
528 			       const cairo_pattern_t	*mask,
529 			       cairo_clip_t		*clip)
530 {
531     cairo_paginated_surface_t *surface = abstract_surface;
532 
533     return _cairo_surface_mask (surface->recording_surface, op, source, mask, clip);
534 }
535 
536 static cairo_int_status_t
_cairo_paginated_surface_stroke(void * abstract_surface,cairo_operator_t op,const cairo_pattern_t * source,cairo_path_fixed_t * path,const cairo_stroke_style_t * style,const cairo_matrix_t * ctm,const cairo_matrix_t * ctm_inverse,double tolerance,cairo_antialias_t antialias,cairo_clip_t * clip)537 _cairo_paginated_surface_stroke (void			*abstract_surface,
538 				 cairo_operator_t	 op,
539 				 const cairo_pattern_t	*source,
540 				 cairo_path_fixed_t	*path,
541 				 const cairo_stroke_style_t	*style,
542 				 const cairo_matrix_t		*ctm,
543 				 const cairo_matrix_t		*ctm_inverse,
544 				 double			 tolerance,
545 				 cairo_antialias_t	 antialias,
546 				 cairo_clip_t		*clip)
547 {
548     cairo_paginated_surface_t *surface = abstract_surface;
549 
550     return _cairo_surface_stroke (surface->recording_surface, op, source,
551 				  path, style,
552 				  ctm, ctm_inverse,
553 				  tolerance, antialias,
554 				  clip);
555 }
556 
557 static cairo_int_status_t
_cairo_paginated_surface_fill(void * abstract_surface,cairo_operator_t op,const cairo_pattern_t * source,cairo_path_fixed_t * path,cairo_fill_rule_t fill_rule,double tolerance,cairo_antialias_t antialias,cairo_clip_t * clip)558 _cairo_paginated_surface_fill (void			*abstract_surface,
559 			       cairo_operator_t		 op,
560 			       const cairo_pattern_t	*source,
561 			       cairo_path_fixed_t	*path,
562 			       cairo_fill_rule_t	 fill_rule,
563 			       double			 tolerance,
564 			       cairo_antialias_t	 antialias,
565 			       cairo_clip_t		*clip)
566 {
567     cairo_paginated_surface_t *surface = abstract_surface;
568 
569     return _cairo_surface_fill (surface->recording_surface, op, source,
570 				path, fill_rule,
571 				tolerance, antialias,
572 				clip);
573 }
574 
575 static cairo_bool_t
_cairo_paginated_surface_has_show_text_glyphs(void * abstract_surface)576 _cairo_paginated_surface_has_show_text_glyphs (void *abstract_surface)
577 {
578     cairo_paginated_surface_t *surface = abstract_surface;
579 
580     return cairo_surface_has_show_text_glyphs (surface->target);
581 }
582 
583 static cairo_int_status_t
_cairo_paginated_surface_show_text_glyphs(void * abstract_surface,cairo_operator_t op,const cairo_pattern_t * source,const char * utf8,int utf8_len,cairo_glyph_t * glyphs,int num_glyphs,const cairo_text_cluster_t * clusters,int num_clusters,cairo_text_cluster_flags_t cluster_flags,cairo_scaled_font_t * scaled_font,cairo_clip_t * clip)584 _cairo_paginated_surface_show_text_glyphs (void			      *abstract_surface,
585 					   cairo_operator_t	       op,
586 					   const cairo_pattern_t      *source,
587 					   const char		      *utf8,
588 					   int			       utf8_len,
589 					   cairo_glyph_t	      *glyphs,
590 					   int			       num_glyphs,
591 					   const cairo_text_cluster_t *clusters,
592 					   int			       num_clusters,
593 					   cairo_text_cluster_flags_t  cluster_flags,
594 					   cairo_scaled_font_t	      *scaled_font,
595 					   cairo_clip_t		      *clip)
596 {
597     cairo_paginated_surface_t *surface = abstract_surface;
598 
599     return _cairo_surface_show_text_glyphs (surface->recording_surface, op, source,
600 					    utf8, utf8_len,
601 					    glyphs, num_glyphs,
602 					    clusters, num_clusters,
603 					    cluster_flags,
604 					    scaled_font,
605 					    clip);
606 }
607 
608 static cairo_surface_t *
_cairo_paginated_surface_snapshot(void * abstract_other)609 _cairo_paginated_surface_snapshot (void *abstract_other)
610 {
611     cairo_paginated_surface_t *other = abstract_other;
612 
613     return _cairo_surface_snapshot (other->recording_surface);
614 }
615 
616 static const cairo_surface_backend_t cairo_paginated_surface_backend = {
617     CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
618     _cairo_paginated_surface_create_similar,
619     _cairo_paginated_surface_finish,
620     _cairo_paginated_surface_acquire_source_image,
621     _cairo_paginated_surface_release_source_image,
622     NULL, /* acquire_dest_image */
623     NULL, /* release_dest_image */
624     NULL, /* clone_similar */
625     NULL, /* composite */
626     NULL, /* fill_rectangles */
627     NULL, /* composite_trapezoids */
628     NULL, /* create_span_renderer */
629     NULL, /* check_span_renderer */
630     _cairo_paginated_surface_copy_page,
631     _cairo_paginated_surface_show_page,
632     _cairo_paginated_surface_get_extents,
633     NULL, /* old_show_glyphs */
634     _cairo_paginated_surface_get_font_options,
635     NULL, /* flush */
636     NULL, /* mark_dirty_rectangle */
637     NULL, /* scaled_font_fini */
638     NULL, /* scaled_glyph_fini */
639     _cairo_paginated_surface_paint,
640     _cairo_paginated_surface_mask,
641     _cairo_paginated_surface_stroke,
642     _cairo_paginated_surface_fill,
643     NULL, /* show_glyphs */
644     _cairo_paginated_surface_snapshot,
645     NULL, /* is_similar */
646     NULL, /* fill_stroke */
647     NULL, /* create_solid_pattern_surface */
648     NULL, /* can_repaint_solid_pattern_surface */
649     _cairo_paginated_surface_has_show_text_glyphs,
650     _cairo_paginated_surface_show_text_glyphs
651 };
652