2
* Copyright Ā© 2006 Keith Packard
3
* Copyright Ā© 2007 Adrian Johnson
5
* This library is free software; you can redistribute it and/or
6
* modify it either under the terms of the GNU Lesser General Public
7
* License version 2.1 as published by the Free Software Foundation
8
* (the "LGPL") or, at your option, under the terms of the Mozilla
9
* Public License Version 1.1 (the "MPL"). If you do not alter this
10
* notice, a recipient may use your version of this file under either
11
* the MPL or the LGPL.
13
* You should have received a copy of the LGPL along with this library
14
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
* You should have received a copy of the MPL along with this library
17
* in the file COPYING-MPL-1.1
19
* The contents of this file are subject to the Mozilla Public License
20
* Version 1.1 (the "License"); you may not use this file except in
21
* compliance with the License. You may obtain a copy of the License at
22
* http://www.mozilla.org/MPL/
24
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
26
* the specific language governing rights and limitations.
28
* The Original Code is the cairo graphics library.
30
* The Initial Developer of the Original Code is Keith Packard
33
* Keith Packard <keithp@keithp.com>
34
* Adrian Johnson <ajohnson@redneon.com>
39
#include "cairo-analysis-surface-private.h"
40
#include "cairo-paginated-private.h"
41
#include "cairo-region-private.h"
42
#include "cairo-meta-surface-private.h"
49
cairo_surface_t *target;
51
cairo_bool_t first_op;
52
cairo_bool_t has_supported;
53
cairo_bool_t has_unsupported;
55
cairo_region_t supported_region;
56
cairo_region_t fallback_region;
57
cairo_rectangle_int_t current_clip;
58
cairo_box_t page_bbox;
63
} cairo_analysis_surface_t;
65
static cairo_int_status_t
66
_analyze_meta_surface_pattern (cairo_analysis_surface_t *surface,
67
cairo_pattern_t *pattern)
69
cairo_surface_t *analysis = &surface->base;
70
cairo_surface_pattern_t *surface_pattern;
71
cairo_status_t status;
72
cairo_bool_t old_has_ctm;
73
cairo_matrix_t old_ctm, p2d;
74
cairo_rectangle_int_t old_clip;
75
cairo_rectangle_int_t meta_extents;
79
assert (pattern->type == CAIRO_PATTERN_TYPE_SURFACE);
80
surface_pattern = (cairo_surface_pattern_t *) pattern;
81
assert (_cairo_surface_is_meta (surface_pattern->surface));
83
old_width = surface->width;
84
old_height = surface->height;
85
old_clip = surface->current_clip;
86
status = _cairo_surface_get_extents (surface_pattern->surface, &meta_extents);
87
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
90
surface->width = meta_extents.width;
91
surface->height = meta_extents.height;
92
surface->current_clip.x = 0;
93
surface->current_clip.y = 0;
94
surface->current_clip.width = surface->width;
95
surface->current_clip.height = surface->height;
96
old_ctm = surface->ctm;
97
old_has_ctm = surface->has_ctm;
98
p2d = pattern->matrix;
99
status = cairo_matrix_invert (&p2d);
100
/* _cairo_pattern_set_matrix guarantees invertibility */
101
assert (status == CAIRO_STATUS_SUCCESS);
103
cairo_matrix_multiply (&surface->ctm, &p2d, &surface->ctm);
104
surface->has_ctm = !_cairo_matrix_is_identity (&surface->ctm);
106
status = _cairo_meta_surface_replay_and_create_regions (surface_pattern->surface,
108
if (status == CAIRO_STATUS_SUCCESS)
109
status = analysis->status;
111
surface->ctm = old_ctm;
112
surface->has_ctm = old_has_ctm;
113
surface->current_clip = old_clip;
114
surface->width = old_width;
115
surface->height = old_height;
120
static cairo_int_status_t
121
_add_operation (cairo_analysis_surface_t *surface,
122
cairo_rectangle_int_t *rect,
123
cairo_int_status_t backend_status)
125
cairo_int_status_t status;
128
if (rect->width == 0 || rect->height == 0) {
129
/* Even though the operation is not visible we must be careful
130
* to not allow unsupported operations to be replayed to the
131
* backend during CAIRO_PAGINATED_MODE_RENDER */
132
if (backend_status == CAIRO_STATUS_SUCCESS ||
133
backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY)
135
return CAIRO_STATUS_SUCCESS;
139
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
143
_cairo_box_from_rectangle (&bbox, rect);
145
if (surface->has_ctm) {
147
_cairo_matrix_transform_bounding_box_fixed (&surface->ctm, &bbox, NULL);
149
if (bbox.p1.x == bbox.p2.x || bbox.p1.y == bbox.p2.y) {
150
/* Even though the operation is not visible we must be
151
* careful to not allow unsupported operations to be
152
* replayed to the backend during
153
* CAIRO_PAGINATED_MODE_RENDER */
154
if (backend_status == CAIRO_STATUS_SUCCESS ||
155
backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY)
157
return CAIRO_STATUS_SUCCESS;
161
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
165
_cairo_box_round_to_rectangle (&bbox, rect);
168
if (surface->first_op) {
169
surface->first_op = FALSE;
170
surface->page_bbox = bbox;
172
if (bbox.p1.x < surface->page_bbox.p1.x)
173
surface->page_bbox.p1.x = bbox.p1.x;
174
if (bbox.p1.y < surface->page_bbox.p1.y)
175
surface->page_bbox.p1.y = bbox.p1.y;
176
if (bbox.p2.x > surface->page_bbox.p2.x)
177
surface->page_bbox.p2.x = bbox.p2.x;
178
if (bbox.p2.y > surface->page_bbox.p2.y)
179
surface->page_bbox.p2.y = bbox.p2.y;
182
/* If the operation is completely enclosed within the fallback
183
* region there is no benefit in emitting a native operation as
184
* the fallback image will be painted on top.
186
if (_cairo_region_contains_rectangle (&surface->fallback_region, rect) == PIXMAN_REGION_IN)
187
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
189
if (backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) {
190
/* A status of CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY indicates
191
* that the backend only supports this operation if the
192
* transparency removed. If the extents of this operation does
193
* not intersect any other native operation, the operation is
194
* natively supported and the backend will blend the
195
* transparency into the white background.
197
if (_cairo_region_contains_rectangle (&surface->supported_region, rect) == PIXMAN_REGION_OUT)
198
backend_status = CAIRO_STATUS_SUCCESS;
201
if (backend_status == CAIRO_STATUS_SUCCESS) {
202
/* Add the operation to the supported region. Operations in
203
* this region will be emitted as native operations.
205
surface->has_supported = TRUE;
206
status = _cairo_region_union_rect (&surface->supported_region,
207
&surface->supported_region,
212
/* Add the operation to the unsupported region. This region will
213
* be painted as an image after all native operations have been
216
surface->has_unsupported = TRUE;
217
status = _cairo_region_union_rect (&surface->fallback_region,
218
&surface->fallback_region,
221
/* The status CAIRO_INT_STATUS_IMAGE_FALLBACK is used to indicate
222
* unsupported operations to the meta surface as using
223
* CAIRO_INT_STATUS_UNSUPPORTED would cause cairo-surface to
224
* invoke the cairo-surface-fallback path then return
225
* CAIRO_STATUS_SUCCESS.
227
if (status == CAIRO_STATUS_SUCCESS)
228
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
233
static cairo_status_t
234
_cairo_analysis_surface_finish (void *abstract_surface)
236
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
238
_cairo_region_fini (&surface->supported_region);
239
_cairo_region_fini (&surface->fallback_region);
241
cairo_surface_destroy (surface->target);
243
return CAIRO_STATUS_SUCCESS;
246
static cairo_int_status_t
247
_cairo_analysis_surface_intersect_clip_path (void *abstract_surface,
248
cairo_path_fixed_t *path,
249
cairo_fill_rule_t fill_rule,
251
cairo_antialias_t antialias)
253
cairo_analysis_surface_t *surface = abstract_surface;
254
double x1, y1, x2, y2;
255
cairo_rectangle_int_t extent;
258
surface->current_clip.x = 0;
259
surface->current_clip.y = 0;
260
surface->current_clip.width = surface->width;
261
surface->current_clip.height = surface->height;
263
cairo_status_t status;
265
status = _cairo_path_fixed_bounds (path, &x1, &y1, &x2, &y2, tolerance);
269
extent.x = floor (x1);
270
extent.y = floor (y1);
271
extent.width = ceil (x2) - extent.x;
272
extent.height = ceil (y2) - extent.y;
274
_cairo_rectangle_intersect (&surface->current_clip, &extent);
277
return CAIRO_STATUS_SUCCESS;
280
static cairo_int_status_t
281
_cairo_analysis_surface_get_extents (void *abstract_surface,
282
cairo_rectangle_int_t *rectangle)
284
cairo_analysis_surface_t *surface = abstract_surface;
286
return _cairo_surface_get_extents (surface->target, rectangle);
289
static cairo_int_status_t
290
_cairo_analysis_surface_paint (void *abstract_surface,
292
cairo_pattern_t *source)
294
cairo_analysis_surface_t *surface = abstract_surface;
295
cairo_status_t status, backend_status;
296
cairo_rectangle_int_t extents;
298
if (!surface->target->backend->paint)
299
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
301
backend_status = (*surface->target->backend->paint) (surface->target, op,
304
if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN)
305
backend_status = _analyze_meta_surface_pattern (surface, source);
307
status = _cairo_surface_get_extents (&surface->base, &extents);
308
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
311
if (_cairo_operator_bounded_by_source (op)) {
312
cairo_rectangle_int_t source_extents;
313
status = _cairo_pattern_get_extents (source, &source_extents);
317
_cairo_rectangle_intersect (&extents, &source_extents);
320
_cairo_rectangle_intersect (&extents, &surface->current_clip);
322
status = _add_operation (surface, &extents, backend_status);
327
static cairo_int_status_t
328
_cairo_analysis_surface_mask (void *abstract_surface,
330
cairo_pattern_t *source,
331
cairo_pattern_t *mask)
333
cairo_analysis_surface_t *surface = abstract_surface;
334
cairo_int_status_t status, backend_status;
335
cairo_rectangle_int_t extents;
337
if (!surface->target->backend->mask)
338
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
340
backend_status = (*surface->target->backend->mask) (surface->target, op,
343
if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN) {
344
cairo_int_status_t backend_source_status = CAIRO_STATUS_SUCCESS;
345
cairo_int_status_t backend_mask_status = CAIRO_STATUS_SUCCESS;
347
if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
348
cairo_surface_pattern_t *surface_pattern = (cairo_surface_pattern_t *) source;
349
if (_cairo_surface_is_meta (surface_pattern->surface)) {
350
backend_source_status =
351
_analyze_meta_surface_pattern (surface, source);
352
if (backend_source_status != CAIRO_STATUS_SUCCESS &&
353
backend_source_status != CAIRO_INT_STATUS_IMAGE_FALLBACK)
354
return backend_source_status;
358
if (mask->type == CAIRO_PATTERN_TYPE_SURFACE) {
359
cairo_surface_pattern_t *surface_pattern = (cairo_surface_pattern_t *) mask;
360
if (_cairo_surface_is_meta (surface_pattern->surface)) {
361
backend_mask_status =
362
_analyze_meta_surface_pattern (surface, mask);
363
if (backend_mask_status != CAIRO_STATUS_SUCCESS &&
364
backend_mask_status != CAIRO_INT_STATUS_IMAGE_FALLBACK)
365
return backend_status;
369
backend_status = CAIRO_STATUS_SUCCESS;
371
if (backend_source_status == CAIRO_INT_STATUS_IMAGE_FALLBACK ||
372
backend_mask_status == CAIRO_INT_STATUS_IMAGE_FALLBACK)
374
backend_status = CAIRO_INT_STATUS_IMAGE_FALLBACK;
378
status = _cairo_surface_get_extents (&surface->base, &extents);
379
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
382
if (_cairo_operator_bounded_by_source (op)) {
383
cairo_rectangle_int_t source_extents;
384
status = _cairo_pattern_get_extents (source, &source_extents);
388
_cairo_rectangle_intersect (&extents, &source_extents);
390
status = _cairo_pattern_get_extents (mask, &source_extents);
394
_cairo_rectangle_intersect (&extents, &source_extents);
397
_cairo_rectangle_intersect (&extents, &surface->current_clip);
399
status = _add_operation (surface, &extents, backend_status);
404
static cairo_int_status_t
405
_cairo_analysis_surface_stroke (void *abstract_surface,
407
cairo_pattern_t *source,
408
cairo_path_fixed_t *path,
409
cairo_stroke_style_t *style,
411
cairo_matrix_t *ctm_inverse,
413
cairo_antialias_t antialias)
415
cairo_analysis_surface_t *surface = abstract_surface;
416
cairo_status_t status, backend_status;
418
cairo_rectangle_int_t extents;
420
if (!surface->target->backend->stroke)
421
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
423
backend_status = (*surface->target->backend->stroke) (surface->target, op,
426
tolerance, antialias);
428
if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN)
429
backend_status = _analyze_meta_surface_pattern (surface, source);
431
status = _cairo_surface_get_extents (&surface->base, &extents);
432
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
435
if (_cairo_operator_bounded_by_source (op)) {
436
cairo_rectangle_int_t source_extents;
437
status = _cairo_pattern_get_extents (source, &source_extents);
441
_cairo_rectangle_intersect (&extents, &source_extents);
444
_cairo_rectangle_intersect (&extents, &surface->current_clip);
446
if (_cairo_operator_bounded_by_mask (op)) {
449
_cairo_box_from_rectangle (&box, &extents);
451
_cairo_traps_init (&traps);
452
_cairo_traps_limit (&traps, &box);
453
status = _cairo_path_fixed_stroke_to_traps (path,
459
_cairo_traps_fini (&traps);
463
_cairo_traps_extents (&traps, &box);
464
_cairo_traps_fini (&traps);
466
_cairo_box_round_to_rectangle (&box, &extents);
469
status = _add_operation (surface, &extents, backend_status);
474
static cairo_int_status_t
475
_cairo_analysis_surface_fill (void *abstract_surface,
477
cairo_pattern_t *source,
478
cairo_path_fixed_t *path,
479
cairo_fill_rule_t fill_rule,
481
cairo_antialias_t antialias)
483
cairo_analysis_surface_t *surface = abstract_surface;
484
cairo_status_t status, backend_status;
486
cairo_rectangle_int_t extents;
488
if (!surface->target->backend->fill)
489
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
491
backend_status = (*surface->target->backend->fill) (surface->target, op,
492
source, path, fill_rule,
493
tolerance, antialias);
495
if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN)
496
backend_status = _analyze_meta_surface_pattern (surface, source);
498
status = _cairo_surface_get_extents (&surface->base, &extents);
499
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
502
if (_cairo_operator_bounded_by_source (op)) {
503
cairo_rectangle_int_t source_extents;
504
status = _cairo_pattern_get_extents (source, &source_extents);
508
_cairo_rectangle_intersect (&extents, &source_extents);
511
_cairo_rectangle_intersect (&extents, &surface->current_clip);
513
if (_cairo_operator_bounded_by_mask (op)) {
516
_cairo_box_from_rectangle (&box, &extents);
518
_cairo_traps_init (&traps);
519
_cairo_traps_limit (&traps, &box);
520
status = _cairo_path_fixed_fill_to_traps (path,
525
_cairo_traps_fini (&traps);
529
_cairo_traps_extents (&traps, &box);
530
_cairo_traps_fini (&traps);
532
_cairo_box_round_to_rectangle (&box, &extents);
535
status = _add_operation (surface, &extents, backend_status);
540
static cairo_int_status_t
541
_cairo_analysis_surface_show_glyphs (void *abstract_surface,
543
cairo_pattern_t *source,
544
cairo_glyph_t *glyphs,
546
cairo_scaled_font_t *scaled_font,
547
int *remaining_glyphs)
549
cairo_analysis_surface_t *surface = abstract_surface;
550
cairo_status_t status, backend_status;
551
cairo_rectangle_int_t extents, glyph_extents;
553
/* Adapted from _cairo_surface_show_glyphs */
554
if (surface->target->backend->show_glyphs)
555
backend_status = (*surface->target->backend->show_glyphs) (surface->target, op,
560
else if (surface->target->backend->show_text_glyphs)
561
backend_status = surface->target->backend->show_text_glyphs (surface->target, op,
569
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
571
if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN)
572
backend_status = _analyze_meta_surface_pattern (surface, source);
574
status = _cairo_surface_get_extents (&surface->base, &extents);
575
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
578
if (_cairo_operator_bounded_by_source (op)) {
579
cairo_rectangle_int_t source_extents;
580
status = _cairo_pattern_get_extents (source, &source_extents);
584
_cairo_rectangle_intersect (&extents, &source_extents);
587
_cairo_rectangle_intersect (&extents, &surface->current_clip);
589
if (_cairo_operator_bounded_by_mask (op)) {
590
status = _cairo_scaled_font_glyph_device_extents (scaled_font,
597
_cairo_rectangle_intersect (&extents, &glyph_extents);
600
status = _add_operation (surface, &extents, backend_status);
606
_cairo_analysis_surface_has_show_text_glyphs (void *abstract_surface)
608
cairo_analysis_surface_t *surface = abstract_surface;
610
return cairo_surface_has_show_text_glyphs (surface->target);
613
static cairo_int_status_t
614
_cairo_analysis_surface_show_text_glyphs (void *abstract_surface,
616
cairo_pattern_t *source,
619
cairo_glyph_t *glyphs,
621
const cairo_text_cluster_t *clusters,
623
cairo_text_cluster_flags_t cluster_flags,
624
cairo_scaled_font_t *scaled_font)
626
cairo_analysis_surface_t *surface = abstract_surface;
627
cairo_status_t status, backend_status;
628
cairo_rectangle_int_t extents, glyph_extents;
630
/* Adapted from _cairo_surface_show_glyphs */
631
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
632
if (surface->target->backend->show_text_glyphs)
633
backend_status = surface->target->backend->show_text_glyphs (surface->target, op,
637
clusters, num_clusters, cluster_flags,
639
if (backend_status == CAIRO_INT_STATUS_UNSUPPORTED && surface->target->backend->show_glyphs) {
640
int remaining_glyphs = num_glyphs;
641
backend_status = surface->target->backend->show_glyphs (surface->target, op,
646
glyphs += num_glyphs - remaining_glyphs;
647
num_glyphs = remaining_glyphs;
648
if (remaining_glyphs == 0)
649
backend_status = CAIRO_STATUS_SUCCESS;
652
if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN)
653
backend_status = _analyze_meta_surface_pattern (surface, source);
655
status = _cairo_surface_get_extents (&surface->base, &extents);
656
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
659
if (_cairo_operator_bounded_by_source (op)) {
660
cairo_rectangle_int_t source_extents;
661
status = _cairo_pattern_get_extents (source, &source_extents);
665
_cairo_rectangle_intersect (&extents, &source_extents);
668
_cairo_rectangle_intersect (&extents, &surface->current_clip);
670
if (_cairo_operator_bounded_by_mask (op)) {
671
status = _cairo_scaled_font_glyph_device_extents (scaled_font,
678
_cairo_rectangle_intersect (&extents, &glyph_extents);
681
status = _add_operation (surface, &extents, backend_status);
686
static const cairo_surface_backend_t cairo_analysis_surface_backend = {
687
CAIRO_INTERNAL_SURFACE_TYPE_ANALYSIS,
688
NULL, /* create_similar */
689
_cairo_analysis_surface_finish,
690
NULL, /* acquire_source_image */
691
NULL, /* release_source_image */
692
NULL, /* acquire_dest_image */
693
NULL, /* release_dest_image */
694
NULL, /* clone_similar */
695
NULL, /* composite */
696
NULL, /* fill_rectangles */
697
NULL, /* composite_trapezoids */
698
NULL, /* copy_page */
699
NULL, /* show_page */
700
NULL, /* set_clip_region */
701
_cairo_analysis_surface_intersect_clip_path,
702
_cairo_analysis_surface_get_extents,
703
NULL, /* old_show_glyphs */
704
NULL, /* get_font_options */
706
NULL, /* mark_dirty_rectangle */
707
NULL, /* scaled_font_fini */
708
NULL, /* scaled_glyph_fini */
709
_cairo_analysis_surface_paint,
710
_cairo_analysis_surface_mask,
711
_cairo_analysis_surface_stroke,
712
_cairo_analysis_surface_fill,
713
_cairo_analysis_surface_show_glyphs,
715
NULL, /* is_similar */
717
NULL, /* fill_stroke */
718
NULL, /* create_solid_pattern_surface */
719
_cairo_analysis_surface_has_show_text_glyphs,
720
_cairo_analysis_surface_show_text_glyphs
724
_cairo_analysis_surface_create (cairo_surface_t *target,
728
cairo_analysis_surface_t *surface;
730
surface = malloc (sizeof (cairo_analysis_surface_t));
732
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
734
/* I believe the content type here is truly arbitrary. I'm quite
735
* sure nothing will ever use this value. */
736
_cairo_surface_init (&surface->base, &cairo_analysis_surface_backend,
737
CAIRO_CONTENT_COLOR_ALPHA);
739
surface->width = width;
740
surface->height = height;
741
cairo_matrix_init_identity (&surface->ctm);
742
surface->has_ctm = FALSE;
744
surface->target = cairo_surface_reference (target);
745
surface->first_op = TRUE;
746
surface->has_supported = FALSE;
747
surface->has_unsupported = FALSE;
749
surface->page_bbox.p1.x = 0;
750
surface->page_bbox.p1.y = 0;
751
surface->page_bbox.p2.x = 0;
752
surface->page_bbox.p2.y = 0;
754
_cairo_region_init (&surface->supported_region);
755
_cairo_region_init (&surface->fallback_region);
757
if (width == -1 && height == -1) {
758
surface->current_clip.x = CAIRO_RECT_INT_MIN;
759
surface->current_clip.y = CAIRO_RECT_INT_MIN;
760
surface->current_clip.width = CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN;
761
surface->current_clip.height = CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN;
763
surface->current_clip.x = 0;
764
surface->current_clip.y = 0;
765
surface->current_clip.width = width;
766
surface->current_clip.height = height;
769
return &surface->base;
773
_cairo_analysis_surface_set_ctm (cairo_surface_t *abstract_surface,
776
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
779
surface->has_ctm = !_cairo_matrix_is_identity (&surface->ctm);
783
_cairo_analysis_surface_get_ctm (cairo_surface_t *abstract_surface,
786
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
793
_cairo_analysis_surface_get_supported (cairo_surface_t *abstract_surface)
795
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
797
return &surface->supported_region;
801
_cairo_analysis_surface_get_unsupported (cairo_surface_t *abstract_surface)
803
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
805
return &surface->fallback_region;
809
_cairo_analysis_surface_has_supported (cairo_surface_t *abstract_surface)
811
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
813
return surface->has_supported;
817
_cairo_analysis_surface_has_unsupported (cairo_surface_t *abstract_surface)
819
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
821
return surface->has_unsupported;
825
_cairo_analysis_surface_get_bounding_box (cairo_surface_t *abstract_surface,
828
cairo_analysis_surface_t *surface = (cairo_analysis_surface_t *) abstract_surface;
830
*bbox = surface->page_bbox;
833
/* null surface type: a surface that does nothing (has no side effects, yay!) */
835
static cairo_int_status_t
836
_return_success (void)
838
return CAIRO_STATUS_SUCCESS;
841
/* These typedefs are just to silence the compiler... */
842
typedef cairo_int_status_t
843
(*_set_clip_region_func) (void *surface,
844
cairo_region_t *region);
845
typedef cairo_int_status_t
846
(*_paint_func) (void *surface,
848
cairo_pattern_t *source);
850
typedef cairo_int_status_t
851
(*_mask_func) (void *surface,
853
cairo_pattern_t *source,
854
cairo_pattern_t *mask);
856
typedef cairo_int_status_t
857
(*_stroke_func) (void *surface,
859
cairo_pattern_t *source,
860
cairo_path_fixed_t *path,
861
cairo_stroke_style_t *style,
863
cairo_matrix_t *ctm_inverse,
865
cairo_antialias_t antialias);
867
typedef cairo_int_status_t
868
(*_fill_func) (void *surface,
870
cairo_pattern_t *source,
871
cairo_path_fixed_t *path,
872
cairo_fill_rule_t fill_rule,
874
cairo_antialias_t antialias);
876
typedef cairo_int_status_t
877
(*_show_glyphs_func) (void *surface,
879
cairo_pattern_t *source,
880
cairo_glyph_t *glyphs,
882
cairo_scaled_font_t *scaled_font,
883
int *remaining_glyphs);
885
static const cairo_surface_backend_t cairo_null_surface_backend = {
886
CAIRO_INTERNAL_SURFACE_TYPE_NULL,
888
NULL, /* create_similar */
890
NULL, /* acquire_source_image */
891
NULL, /* release_source_image */
892
NULL, /* acquire_dest_image */
893
NULL, /* release_dest_image */
894
NULL, /* clone_similar */
895
NULL, /* composite */
896
NULL, /* fill_rectangles */
897
NULL, /* composite_trapezoids */
898
NULL, /* copy_page */
899
NULL, /* show_page */
900
(_set_clip_region_func) _return_success, /* set_clip_region */
901
NULL, /* intersect_clip_path */
902
NULL, /* get_extents */
903
NULL, /* old_show_glyphs */
904
NULL, /* get_font_options */
906
NULL, /* mark_dirty_rectangle */
907
NULL, /* scaled_font_fini */
908
NULL, /* scaled_glyph_fini */
909
(_paint_func) _return_success, /* paint */
910
(_mask_func) _return_success, /* mask */
911
(_stroke_func) _return_success, /* stroke */
912
(_fill_func) _return_success, /* fill */
913
(_show_glyphs_func) _return_success, /* show_glyphs */
915
NULL, /* is_similar */
917
NULL, /* fill_stroke */
918
NULL, /* create_solid_pattern_surface */
919
NULL, /* has_show_text_glyphs */
920
NULL /* show_text_glyphs */
924
_cairo_null_surface_create (cairo_content_t content)
926
cairo_surface_t *surface;
928
surface = malloc (sizeof (cairo_surface_t));
929
if (surface == NULL) {
930
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
933
_cairo_surface_init (surface, &cairo_null_surface_backend, content);