1 /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
2 /* cairo - a vector graphics library with display and print output
4 * Copyright (c) 2008 M Joonas Pihlaja
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
29 #include "cairo-composite-rectangles-private.h"
30 #include "cairo-clip-private.h"
31 #include "cairo-error-private.h"
32 #include "cairo-fixed-private.h"
33 #include "cairo-types-private.h"
36 _cairo_nil_destroy (void *abstract)
42 _cairo_nil_scan_converter_generate (void *abstract_converter,
43 cairo_span_renderer_t *renderer)
45 (void) abstract_converter;
47 return _cairo_scan_converter_status (abstract_converter);
51 _cairo_scan_converter_status (void *abstract_converter)
53 cairo_scan_converter_t *converter = abstract_converter;
54 return converter->status;
58 _cairo_scan_converter_set_error (void *abstract_converter,
61 cairo_scan_converter_t *converter = abstract_converter;
62 if (error == CAIRO_STATUS_SUCCESS)
64 if (converter->status == CAIRO_STATUS_SUCCESS) {
65 converter->generate = _cairo_nil_scan_converter_generate;
66 converter->status = error;
68 return converter->status;
72 _cairo_nil_scan_converter_init (cairo_scan_converter_t *converter,
73 cairo_status_t status)
75 converter->destroy = _cairo_nil_destroy;
76 converter->status = CAIRO_STATUS_SUCCESS;
77 status = _cairo_scan_converter_set_error (converter, status);
80 cairo_scan_converter_t *
81 _cairo_scan_converter_create_in_error (cairo_status_t status)
84 static cairo_scan_converter_t nil;\
85 _cairo_nil_scan_converter_init (&nil, status);\
89 case CAIRO_STATUS_SUCCESS:
90 case CAIRO_STATUS_LAST_STATUS:
93 case CAIRO_STATUS_INVALID_RESTORE: RETURN_NIL;
94 case CAIRO_STATUS_INVALID_POP_GROUP: RETURN_NIL;
95 case CAIRO_STATUS_NO_CURRENT_POINT: RETURN_NIL;
96 case CAIRO_STATUS_INVALID_MATRIX: RETURN_NIL;
97 case CAIRO_STATUS_INVALID_STATUS: RETURN_NIL;
98 case CAIRO_STATUS_NULL_POINTER: RETURN_NIL;
99 case CAIRO_STATUS_INVALID_STRING: RETURN_NIL;
100 case CAIRO_STATUS_INVALID_PATH_DATA: RETURN_NIL;
101 case CAIRO_STATUS_READ_ERROR: RETURN_NIL;
102 case CAIRO_STATUS_WRITE_ERROR: RETURN_NIL;
103 case CAIRO_STATUS_SURFACE_FINISHED: RETURN_NIL;
104 case CAIRO_STATUS_SURFACE_TYPE_MISMATCH: RETURN_NIL;
105 case CAIRO_STATUS_PATTERN_TYPE_MISMATCH: RETURN_NIL;
106 case CAIRO_STATUS_INVALID_CONTENT: RETURN_NIL;
107 case CAIRO_STATUS_INVALID_FORMAT: RETURN_NIL;
108 case CAIRO_STATUS_INVALID_VISUAL: RETURN_NIL;
109 case CAIRO_STATUS_FILE_NOT_FOUND: RETURN_NIL;
110 case CAIRO_STATUS_INVALID_DASH: RETURN_NIL;
111 case CAIRO_STATUS_INVALID_DSC_COMMENT: RETURN_NIL;
112 case CAIRO_STATUS_INVALID_INDEX: RETURN_NIL;
113 case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: RETURN_NIL;
114 case CAIRO_STATUS_TEMP_FILE_ERROR: RETURN_NIL;
115 case CAIRO_STATUS_INVALID_STRIDE: RETURN_NIL;
116 case CAIRO_STATUS_FONT_TYPE_MISMATCH: RETURN_NIL;
117 case CAIRO_STATUS_USER_FONT_IMMUTABLE: RETURN_NIL;
118 case CAIRO_STATUS_USER_FONT_ERROR: RETURN_NIL;
119 case CAIRO_STATUS_NEGATIVE_COUNT: RETURN_NIL;
120 case CAIRO_STATUS_INVALID_CLUSTERS: RETURN_NIL;
121 case CAIRO_STATUS_INVALID_SLANT: RETURN_NIL;
122 case CAIRO_STATUS_INVALID_WEIGHT: RETURN_NIL;
123 case CAIRO_STATUS_NO_MEMORY: RETURN_NIL;
124 case CAIRO_STATUS_INVALID_SIZE: RETURN_NIL;
125 case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: RETURN_NIL;
126 case CAIRO_STATUS_DEVICE_TYPE_MISMATCH: RETURN_NIL;
127 case CAIRO_STATUS_DEVICE_ERROR: RETURN_NIL;
128 case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: RETURN_NIL;
129 case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL;
130 case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
134 status = CAIRO_STATUS_NO_MEMORY;
139 static cairo_status_t
140 _cairo_nil_span_renderer_render_rows (
141 void *abstract_renderer,
144 const cairo_half_open_span_t *coverages,
145 unsigned num_coverages)
150 (void) num_coverages;
151 return _cairo_span_renderer_status (abstract_renderer);
154 static cairo_status_t
155 _cairo_nil_span_renderer_finish (void *abstract_renderer)
157 return _cairo_span_renderer_status (abstract_renderer);
161 _cairo_span_renderer_status (void *abstract_renderer)
163 cairo_span_renderer_t *renderer = abstract_renderer;
164 return renderer->status;
168 _cairo_span_renderer_set_error (
169 void *abstract_renderer,
170 cairo_status_t error)
172 cairo_span_renderer_t *renderer = abstract_renderer;
173 if (error == CAIRO_STATUS_SUCCESS) {
176 if (renderer->status == CAIRO_STATUS_SUCCESS) {
177 renderer->render_rows = _cairo_nil_span_renderer_render_rows;
178 renderer->finish = _cairo_nil_span_renderer_finish;
179 renderer->status = error;
181 return renderer->status;
185 _cairo_nil_span_renderer_init (cairo_span_renderer_t *renderer,
186 cairo_status_t status)
188 renderer->destroy = _cairo_nil_destroy;
189 renderer->status = CAIRO_STATUS_SUCCESS;
190 status = _cairo_span_renderer_set_error (renderer, status);
193 cairo_span_renderer_t *
194 _cairo_span_renderer_create_in_error (cairo_status_t status)
196 #define RETURN_NIL {\
197 static cairo_span_renderer_t nil;\
198 _cairo_nil_span_renderer_init (&nil, status);\
202 case CAIRO_STATUS_SUCCESS:
203 case CAIRO_STATUS_LAST_STATUS:
206 case CAIRO_STATUS_INVALID_RESTORE: RETURN_NIL;
207 case CAIRO_STATUS_INVALID_POP_GROUP: RETURN_NIL;
208 case CAIRO_STATUS_NO_CURRENT_POINT: RETURN_NIL;
209 case CAIRO_STATUS_INVALID_MATRIX: RETURN_NIL;
210 case CAIRO_STATUS_INVALID_STATUS: RETURN_NIL;
211 case CAIRO_STATUS_NULL_POINTER: RETURN_NIL;
212 case CAIRO_STATUS_INVALID_STRING: RETURN_NIL;
213 case CAIRO_STATUS_INVALID_PATH_DATA: RETURN_NIL;
214 case CAIRO_STATUS_READ_ERROR: RETURN_NIL;
215 case CAIRO_STATUS_WRITE_ERROR: RETURN_NIL;
216 case CAIRO_STATUS_SURFACE_FINISHED: RETURN_NIL;
217 case CAIRO_STATUS_SURFACE_TYPE_MISMATCH: RETURN_NIL;
218 case CAIRO_STATUS_PATTERN_TYPE_MISMATCH: RETURN_NIL;
219 case CAIRO_STATUS_INVALID_CONTENT: RETURN_NIL;
220 case CAIRO_STATUS_INVALID_FORMAT: RETURN_NIL;
221 case CAIRO_STATUS_INVALID_VISUAL: RETURN_NIL;
222 case CAIRO_STATUS_FILE_NOT_FOUND: RETURN_NIL;
223 case CAIRO_STATUS_INVALID_DASH: RETURN_NIL;
224 case CAIRO_STATUS_INVALID_DSC_COMMENT: RETURN_NIL;
225 case CAIRO_STATUS_INVALID_INDEX: RETURN_NIL;
226 case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: RETURN_NIL;
227 case CAIRO_STATUS_TEMP_FILE_ERROR: RETURN_NIL;
228 case CAIRO_STATUS_INVALID_STRIDE: RETURN_NIL;
229 case CAIRO_STATUS_FONT_TYPE_MISMATCH: RETURN_NIL;
230 case CAIRO_STATUS_USER_FONT_IMMUTABLE: RETURN_NIL;
231 case CAIRO_STATUS_USER_FONT_ERROR: RETURN_NIL;
232 case CAIRO_STATUS_NEGATIVE_COUNT: RETURN_NIL;
233 case CAIRO_STATUS_INVALID_CLUSTERS: RETURN_NIL;
234 case CAIRO_STATUS_INVALID_SLANT: RETURN_NIL;
235 case CAIRO_STATUS_INVALID_WEIGHT: RETURN_NIL;
236 case CAIRO_STATUS_NO_MEMORY: RETURN_NIL;
237 case CAIRO_STATUS_INVALID_SIZE: RETURN_NIL;
238 case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: RETURN_NIL;
239 case CAIRO_STATUS_DEVICE_TYPE_MISMATCH: RETURN_NIL;
240 case CAIRO_STATUS_DEVICE_ERROR: RETURN_NIL;
241 case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: RETURN_NIL;
242 case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL;
243 case CAIRO_STATUS_JBIG2_GLOBAL_MISSING: RETURN_NIL;
247 status = CAIRO_STATUS_NO_MEMORY;