/work/workdir/UnpackedTarball/cairo/src/cairo-spans.c
Line | Count | Source (jump to first uncovered line) |
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 |
3 | | * |
4 | | * Copyright (c) 2008 M Joonas Pihlaja |
5 | | * |
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 |
13 | | * conditions: |
14 | | * |
15 | | * The above copyright notice and this permission notice shall be |
16 | | * included in all copies or substantial portions of the Software. |
17 | | * |
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. |
26 | | */ |
27 | | #include "cairoint.h" |
28 | | |
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" |
34 | | |
35 | | static void |
36 | | _cairo_nil_destroy (void *abstract) |
37 | 0 | { |
38 | 0 | (void) abstract; |
39 | 0 | } |
40 | | |
41 | | static cairo_status_t |
42 | | _cairo_nil_scan_converter_generate (void *abstract_converter, |
43 | | cairo_span_renderer_t *renderer) |
44 | 0 | { |
45 | 0 | (void) abstract_converter; |
46 | 0 | (void) renderer; |
47 | 0 | return _cairo_scan_converter_status (abstract_converter); |
48 | 0 | } |
49 | | |
50 | | cairo_status_t |
51 | | _cairo_scan_converter_status (void *abstract_converter) |
52 | 0 | { |
53 | 0 | cairo_scan_converter_t *converter = abstract_converter; |
54 | 0 | return converter->status; |
55 | 0 | } |
56 | | |
57 | | cairo_status_t |
58 | | _cairo_scan_converter_set_error (void *abstract_converter, |
59 | | cairo_status_t error) |
60 | 0 | { |
61 | 0 | cairo_scan_converter_t *converter = abstract_converter; |
62 | 0 | if (error == CAIRO_STATUS_SUCCESS) |
63 | 0 | ASSERT_NOT_REACHED; |
64 | 0 | if (converter->status == CAIRO_STATUS_SUCCESS) { |
65 | 0 | converter->generate = _cairo_nil_scan_converter_generate; |
66 | 0 | converter->status = error; |
67 | 0 | } |
68 | 0 | return converter->status; |
69 | 0 | } |
70 | | |
71 | | static void |
72 | | _cairo_nil_scan_converter_init (cairo_scan_converter_t *converter, |
73 | | cairo_status_t status) |
74 | 0 | { |
75 | 0 | converter->destroy = _cairo_nil_destroy; |
76 | 0 | converter->status = CAIRO_STATUS_SUCCESS; |
77 | 0 | status = _cairo_scan_converter_set_error (converter, status); |
78 | 0 | } |
79 | | |
80 | | cairo_scan_converter_t * |
81 | | _cairo_scan_converter_create_in_error (cairo_status_t status) |
82 | 0 | { |
83 | 0 | #define RETURN_NIL {\ |
84 | 0 | static cairo_scan_converter_t nil;\ |
85 | 0 | _cairo_nil_scan_converter_init (&nil, status);\ |
86 | 0 | return &nil;\ |
87 | 0 | } |
88 | 0 | switch (status) { |
89 | 0 | case CAIRO_STATUS_SUCCESS: |
90 | 0 | case CAIRO_STATUS_LAST_STATUS: |
91 | 0 | ASSERT_NOT_REACHED; |
92 | 0 | break; |
93 | 0 | case CAIRO_STATUS_INVALID_RESTORE: RETURN_NIL; |
94 | 0 | case CAIRO_STATUS_INVALID_POP_GROUP: RETURN_NIL; |
95 | 0 | case CAIRO_STATUS_NO_CURRENT_POINT: RETURN_NIL; |
96 | 0 | case CAIRO_STATUS_INVALID_MATRIX: RETURN_NIL; |
97 | 0 | case CAIRO_STATUS_INVALID_STATUS: RETURN_NIL; |
98 | 0 | case CAIRO_STATUS_NULL_POINTER: RETURN_NIL; |
99 | 0 | case CAIRO_STATUS_INVALID_STRING: RETURN_NIL; |
100 | 0 | case CAIRO_STATUS_INVALID_PATH_DATA: RETURN_NIL; |
101 | 0 | case CAIRO_STATUS_READ_ERROR: RETURN_NIL; |
102 | 0 | case CAIRO_STATUS_WRITE_ERROR: RETURN_NIL; |
103 | 0 | case CAIRO_STATUS_SURFACE_FINISHED: RETURN_NIL; |
104 | 0 | case CAIRO_STATUS_SURFACE_TYPE_MISMATCH: RETURN_NIL; |
105 | 0 | case CAIRO_STATUS_PATTERN_TYPE_MISMATCH: RETURN_NIL; |
106 | 0 | case CAIRO_STATUS_INVALID_CONTENT: RETURN_NIL; |
107 | 0 | case CAIRO_STATUS_INVALID_FORMAT: RETURN_NIL; |
108 | 0 | case CAIRO_STATUS_INVALID_VISUAL: RETURN_NIL; |
109 | 0 | case CAIRO_STATUS_FILE_NOT_FOUND: RETURN_NIL; |
110 | 0 | case CAIRO_STATUS_INVALID_DASH: RETURN_NIL; |
111 | 0 | case CAIRO_STATUS_INVALID_DSC_COMMENT: RETURN_NIL; |
112 | 0 | case CAIRO_STATUS_INVALID_INDEX: RETURN_NIL; |
113 | 0 | case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: RETURN_NIL; |
114 | 0 | case CAIRO_STATUS_TEMP_FILE_ERROR: RETURN_NIL; |
115 | 0 | case CAIRO_STATUS_INVALID_STRIDE: RETURN_NIL; |
116 | 0 | case CAIRO_STATUS_FONT_TYPE_MISMATCH: RETURN_NIL; |
117 | 0 | case CAIRO_STATUS_USER_FONT_IMMUTABLE: RETURN_NIL; |
118 | 0 | case CAIRO_STATUS_USER_FONT_ERROR: RETURN_NIL; |
119 | 0 | case CAIRO_STATUS_NEGATIVE_COUNT: RETURN_NIL; |
120 | 0 | case CAIRO_STATUS_INVALID_CLUSTERS: RETURN_NIL; |
121 | 0 | case CAIRO_STATUS_INVALID_SLANT: RETURN_NIL; |
122 | 0 | case CAIRO_STATUS_INVALID_WEIGHT: RETURN_NIL; |
123 | 0 | case CAIRO_STATUS_NO_MEMORY: RETURN_NIL; |
124 | 0 | case CAIRO_STATUS_INVALID_SIZE: RETURN_NIL; |
125 | 0 | case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: RETURN_NIL; |
126 | 0 | case CAIRO_STATUS_DEVICE_TYPE_MISMATCH: RETURN_NIL; |
127 | 0 | case CAIRO_STATUS_DEVICE_ERROR: RETURN_NIL; |
128 | 0 | case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: RETURN_NIL; |
129 | 0 | case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL; |
130 | 0 | case CAIRO_STATUS_JBIG2_GLOBAL_MISSING: |
131 | 0 | case CAIRO_STATUS_PNG_ERROR: |
132 | 0 | case CAIRO_STATUS_FREETYPE_ERROR: |
133 | 0 | case CAIRO_STATUS_WIN32_GDI_ERROR: |
134 | 0 | case CAIRO_STATUS_TAG_ERROR: |
135 | 0 | case CAIRO_STATUS_DWRITE_ERROR: |
136 | 0 | default: |
137 | 0 | break; |
138 | 0 | } |
139 | 0 | status = CAIRO_STATUS_NO_MEMORY; |
140 | 0 | RETURN_NIL; |
141 | 0 | #undef RETURN_NIL |
142 | 0 | } |
143 | | |
144 | | static cairo_status_t |
145 | | _cairo_nil_span_renderer_render_rows ( |
146 | | void *abstract_renderer, |
147 | | int y, |
148 | | int height, |
149 | | const cairo_half_open_span_t *coverages, |
150 | | unsigned num_coverages) |
151 | 0 | { |
152 | 0 | (void) y; |
153 | 0 | (void) height; |
154 | 0 | (void) coverages; |
155 | 0 | (void) num_coverages; |
156 | 0 | return _cairo_span_renderer_status (abstract_renderer); |
157 | 0 | } |
158 | | |
159 | | static cairo_status_t |
160 | | _cairo_nil_span_renderer_finish (void *abstract_renderer) |
161 | 0 | { |
162 | 0 | return _cairo_span_renderer_status (abstract_renderer); |
163 | 0 | } |
164 | | |
165 | | cairo_status_t |
166 | | _cairo_span_renderer_status (void *abstract_renderer) |
167 | 0 | { |
168 | 0 | cairo_span_renderer_t *renderer = abstract_renderer; |
169 | 0 | return renderer->status; |
170 | 0 | } |
171 | | |
172 | | cairo_status_t |
173 | | _cairo_span_renderer_set_error ( |
174 | | void *abstract_renderer, |
175 | | cairo_status_t error) |
176 | 0 | { |
177 | 0 | cairo_span_renderer_t *renderer = abstract_renderer; |
178 | 0 | if (error == CAIRO_STATUS_SUCCESS) { |
179 | 0 | ASSERT_NOT_REACHED; |
180 | 0 | } |
181 | 0 | if (renderer->status == CAIRO_STATUS_SUCCESS) { |
182 | 0 | renderer->render_rows = _cairo_nil_span_renderer_render_rows; |
183 | 0 | renderer->finish = _cairo_nil_span_renderer_finish; |
184 | 0 | renderer->status = error; |
185 | 0 | } |
186 | 0 | return renderer->status; |
187 | 0 | } |
188 | | |
189 | | static void |
190 | | _cairo_nil_span_renderer_init (cairo_span_renderer_t *renderer, |
191 | | cairo_status_t status) |
192 | 0 | { |
193 | 0 | renderer->destroy = _cairo_nil_destroy; |
194 | 0 | renderer->status = CAIRO_STATUS_SUCCESS; |
195 | 0 | status = _cairo_span_renderer_set_error (renderer, status); |
196 | 0 | } |
197 | | |
198 | | cairo_span_renderer_t * |
199 | | _cairo_span_renderer_create_in_error (cairo_status_t status) |
200 | 0 | { |
201 | 0 | #define RETURN_NIL {\ |
202 | 0 | static cairo_span_renderer_t nil;\ |
203 | 0 | _cairo_nil_span_renderer_init (&nil, status);\ |
204 | 0 | return &nil;\ |
205 | 0 | } |
206 | 0 | switch (status) { |
207 | 0 | case CAIRO_STATUS_SUCCESS: |
208 | 0 | case CAIRO_STATUS_LAST_STATUS: |
209 | 0 | ASSERT_NOT_REACHED; |
210 | 0 | break; |
211 | 0 | case CAIRO_STATUS_INVALID_RESTORE: RETURN_NIL; |
212 | 0 | case CAIRO_STATUS_INVALID_POP_GROUP: RETURN_NIL; |
213 | 0 | case CAIRO_STATUS_NO_CURRENT_POINT: RETURN_NIL; |
214 | 0 | case CAIRO_STATUS_INVALID_MATRIX: RETURN_NIL; |
215 | 0 | case CAIRO_STATUS_INVALID_STATUS: RETURN_NIL; |
216 | 0 | case CAIRO_STATUS_NULL_POINTER: RETURN_NIL; |
217 | 0 | case CAIRO_STATUS_INVALID_STRING: RETURN_NIL; |
218 | 0 | case CAIRO_STATUS_INVALID_PATH_DATA: RETURN_NIL; |
219 | 0 | case CAIRO_STATUS_READ_ERROR: RETURN_NIL; |
220 | 0 | case CAIRO_STATUS_WRITE_ERROR: RETURN_NIL; |
221 | 0 | case CAIRO_STATUS_SURFACE_FINISHED: RETURN_NIL; |
222 | 0 | case CAIRO_STATUS_SURFACE_TYPE_MISMATCH: RETURN_NIL; |
223 | 0 | case CAIRO_STATUS_PATTERN_TYPE_MISMATCH: RETURN_NIL; |
224 | 0 | case CAIRO_STATUS_INVALID_CONTENT: RETURN_NIL; |
225 | 0 | case CAIRO_STATUS_INVALID_FORMAT: RETURN_NIL; |
226 | 0 | case CAIRO_STATUS_INVALID_VISUAL: RETURN_NIL; |
227 | 0 | case CAIRO_STATUS_FILE_NOT_FOUND: RETURN_NIL; |
228 | 0 | case CAIRO_STATUS_INVALID_DASH: RETURN_NIL; |
229 | 0 | case CAIRO_STATUS_INVALID_DSC_COMMENT: RETURN_NIL; |
230 | 0 | case CAIRO_STATUS_INVALID_INDEX: RETURN_NIL; |
231 | 0 | case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: RETURN_NIL; |
232 | 0 | case CAIRO_STATUS_TEMP_FILE_ERROR: RETURN_NIL; |
233 | 0 | case CAIRO_STATUS_INVALID_STRIDE: RETURN_NIL; |
234 | 0 | case CAIRO_STATUS_FONT_TYPE_MISMATCH: RETURN_NIL; |
235 | 0 | case CAIRO_STATUS_USER_FONT_IMMUTABLE: RETURN_NIL; |
236 | 0 | case CAIRO_STATUS_USER_FONT_ERROR: RETURN_NIL; |
237 | 0 | case CAIRO_STATUS_NEGATIVE_COUNT: RETURN_NIL; |
238 | 0 | case CAIRO_STATUS_INVALID_CLUSTERS: RETURN_NIL; |
239 | 0 | case CAIRO_STATUS_INVALID_SLANT: RETURN_NIL; |
240 | 0 | case CAIRO_STATUS_INVALID_WEIGHT: RETURN_NIL; |
241 | 0 | case CAIRO_STATUS_NO_MEMORY: RETURN_NIL; |
242 | 0 | case CAIRO_STATUS_INVALID_SIZE: RETURN_NIL; |
243 | 0 | case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: RETURN_NIL; |
244 | 0 | case CAIRO_STATUS_DEVICE_TYPE_MISMATCH: RETURN_NIL; |
245 | 0 | case CAIRO_STATUS_DEVICE_ERROR: RETURN_NIL; |
246 | 0 | case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: RETURN_NIL; |
247 | 0 | case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL; |
248 | 0 | case CAIRO_STATUS_JBIG2_GLOBAL_MISSING: RETURN_NIL; |
249 | 0 | case CAIRO_STATUS_PNG_ERROR: RETURN_NIL; |
250 | 0 | case CAIRO_STATUS_FREETYPE_ERROR: RETURN_NIL; |
251 | 0 | case CAIRO_STATUS_WIN32_GDI_ERROR: RETURN_NIL; |
252 | 0 | case CAIRO_STATUS_TAG_ERROR: RETURN_NIL; |
253 | 0 | case CAIRO_STATUS_DWRITE_ERROR: RETURN_NIL; |
254 | 0 | default: |
255 | 0 | break; |
256 | 0 | } |
257 | 0 | status = CAIRO_STATUS_NO_MEMORY; |
258 | 0 | RETURN_NIL; |
259 | 0 | #undef RETURN_NIL |
260 | 0 | } |