Rev 1892 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1892 | serge | 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" |
||
3959 | Serge | 30 | #include "cairo-clip-private.h" |
31 | #include "cairo-error-private.h" |
||
1892 | serge | 32 | #include "cairo-fixed-private.h" |
3959 | Serge | 33 | #include "cairo-types-private.h" |
1892 | serge | 34 | |
35 | static void |
||
36 | _cairo_nil_destroy (void *abstract) |
||
37 | { |
||
38 | (void) abstract; |
||
39 | } |
||
40 | |||
41 | static cairo_status_t |
||
42 | _cairo_nil_scan_converter_generate (void *abstract_converter, |
||
43 | cairo_span_renderer_t *renderer) |
||
44 | { |
||
45 | (void) abstract_converter; |
||
46 | (void) renderer; |
||
47 | return _cairo_scan_converter_status (abstract_converter); |
||
48 | } |
||
49 | |||
50 | cairo_status_t |
||
51 | _cairo_scan_converter_status (void *abstract_converter) |
||
52 | { |
||
53 | cairo_scan_converter_t *converter = abstract_converter; |
||
54 | return converter->status; |
||
55 | } |
||
56 | |||
57 | cairo_status_t |
||
58 | _cairo_scan_converter_set_error (void *abstract_converter, |
||
59 | cairo_status_t error) |
||
60 | { |
||
61 | cairo_scan_converter_t *converter = abstract_converter; |
||
62 | if (error == CAIRO_STATUS_SUCCESS) |
||
63 | ASSERT_NOT_REACHED; |
||
64 | if (converter->status == CAIRO_STATUS_SUCCESS) { |
||
65 | converter->generate = _cairo_nil_scan_converter_generate; |
||
66 | converter->status = error; |
||
67 | } |
||
68 | return converter->status; |
||
69 | } |
||
70 | |||
71 | static void |
||
72 | _cairo_nil_scan_converter_init (cairo_scan_converter_t *converter, |
||
73 | cairo_status_t status) |
||
74 | { |
||
75 | converter->destroy = _cairo_nil_destroy; |
||
76 | converter->status = CAIRO_STATUS_SUCCESS; |
||
77 | status = _cairo_scan_converter_set_error (converter, status); |
||
78 | } |
||
79 | |||
80 | cairo_scan_converter_t * |
||
81 | _cairo_scan_converter_create_in_error (cairo_status_t status) |
||
82 | { |
||
83 | #define RETURN_NIL {\ |
||
84 | static cairo_scan_converter_t nil;\ |
||
85 | _cairo_nil_scan_converter_init (&nil, status);\ |
||
86 | return &nil;\ |
||
87 | } |
||
88 | switch (status) { |
||
89 | case CAIRO_STATUS_SUCCESS: |
||
90 | case CAIRO_STATUS_LAST_STATUS: |
||
91 | ASSERT_NOT_REACHED; |
||
92 | break; |
||
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; |
||
3959 | Serge | 128 | case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: RETURN_NIL; |
129 | case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL; |
||
1892 | serge | 130 | default: |
131 | break; |
||
132 | } |
||
133 | status = CAIRO_STATUS_NO_MEMORY; |
||
134 | RETURN_NIL; |
||
135 | #undef RETURN_NIL |
||
136 | } |
||
137 | |||
138 | static cairo_status_t |
||
139 | _cairo_nil_span_renderer_render_rows ( |
||
140 | void *abstract_renderer, |
||
141 | int y, |
||
142 | int height, |
||
143 | const cairo_half_open_span_t *coverages, |
||
144 | unsigned num_coverages) |
||
145 | { |
||
146 | (void) y; |
||
147 | (void) height; |
||
148 | (void) coverages; |
||
149 | (void) num_coverages; |
||
150 | return _cairo_span_renderer_status (abstract_renderer); |
||
151 | } |
||
152 | |||
153 | static cairo_status_t |
||
154 | _cairo_nil_span_renderer_finish (void *abstract_renderer) |
||
155 | { |
||
156 | return _cairo_span_renderer_status (abstract_renderer); |
||
157 | } |
||
158 | |||
159 | cairo_status_t |
||
160 | _cairo_span_renderer_status (void *abstract_renderer) |
||
161 | { |
||
162 | cairo_span_renderer_t *renderer = abstract_renderer; |
||
163 | return renderer->status; |
||
164 | } |
||
165 | |||
166 | cairo_status_t |
||
167 | _cairo_span_renderer_set_error ( |
||
168 | void *abstract_renderer, |
||
169 | cairo_status_t error) |
||
170 | { |
||
171 | cairo_span_renderer_t *renderer = abstract_renderer; |
||
172 | if (error == CAIRO_STATUS_SUCCESS) { |
||
173 | ASSERT_NOT_REACHED; |
||
174 | } |
||
175 | if (renderer->status == CAIRO_STATUS_SUCCESS) { |
||
176 | renderer->render_rows = _cairo_nil_span_renderer_render_rows; |
||
177 | renderer->finish = _cairo_nil_span_renderer_finish; |
||
178 | renderer->status = error; |
||
179 | } |
||
180 | return renderer->status; |
||
181 | } |
||
182 | |||
183 | static void |
||
184 | _cairo_nil_span_renderer_init (cairo_span_renderer_t *renderer, |
||
185 | cairo_status_t status) |
||
186 | { |
||
187 | renderer->destroy = _cairo_nil_destroy; |
||
188 | renderer->status = CAIRO_STATUS_SUCCESS; |
||
189 | status = _cairo_span_renderer_set_error (renderer, status); |
||
190 | } |
||
191 | |||
192 | cairo_span_renderer_t * |
||
193 | _cairo_span_renderer_create_in_error (cairo_status_t status) |
||
194 | { |
||
195 | #define RETURN_NIL {\ |
||
196 | static cairo_span_renderer_t nil;\ |
||
197 | _cairo_nil_span_renderer_init (&nil, status);\ |
||
198 | return &nil;\ |
||
199 | } |
||
200 | switch (status) { |
||
201 | case CAIRO_STATUS_SUCCESS: |
||
202 | case CAIRO_STATUS_LAST_STATUS: |
||
203 | ASSERT_NOT_REACHED; |
||
204 | break; |
||
205 | case CAIRO_STATUS_INVALID_RESTORE: RETURN_NIL; |
||
206 | case CAIRO_STATUS_INVALID_POP_GROUP: RETURN_NIL; |
||
207 | case CAIRO_STATUS_NO_CURRENT_POINT: RETURN_NIL; |
||
208 | case CAIRO_STATUS_INVALID_MATRIX: RETURN_NIL; |
||
209 | case CAIRO_STATUS_INVALID_STATUS: RETURN_NIL; |
||
210 | case CAIRO_STATUS_NULL_POINTER: RETURN_NIL; |
||
211 | case CAIRO_STATUS_INVALID_STRING: RETURN_NIL; |
||
212 | case CAIRO_STATUS_INVALID_PATH_DATA: RETURN_NIL; |
||
213 | case CAIRO_STATUS_READ_ERROR: RETURN_NIL; |
||
214 | case CAIRO_STATUS_WRITE_ERROR: RETURN_NIL; |
||
215 | case CAIRO_STATUS_SURFACE_FINISHED: RETURN_NIL; |
||
216 | case CAIRO_STATUS_SURFACE_TYPE_MISMATCH: RETURN_NIL; |
||
217 | case CAIRO_STATUS_PATTERN_TYPE_MISMATCH: RETURN_NIL; |
||
218 | case CAIRO_STATUS_INVALID_CONTENT: RETURN_NIL; |
||
219 | case CAIRO_STATUS_INVALID_FORMAT: RETURN_NIL; |
||
220 | case CAIRO_STATUS_INVALID_VISUAL: RETURN_NIL; |
||
221 | case CAIRO_STATUS_FILE_NOT_FOUND: RETURN_NIL; |
||
222 | case CAIRO_STATUS_INVALID_DASH: RETURN_NIL; |
||
223 | case CAIRO_STATUS_INVALID_DSC_COMMENT: RETURN_NIL; |
||
224 | case CAIRO_STATUS_INVALID_INDEX: RETURN_NIL; |
||
225 | case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: RETURN_NIL; |
||
226 | case CAIRO_STATUS_TEMP_FILE_ERROR: RETURN_NIL; |
||
227 | case CAIRO_STATUS_INVALID_STRIDE: RETURN_NIL; |
||
228 | case CAIRO_STATUS_FONT_TYPE_MISMATCH: RETURN_NIL; |
||
229 | case CAIRO_STATUS_USER_FONT_IMMUTABLE: RETURN_NIL; |
||
230 | case CAIRO_STATUS_USER_FONT_ERROR: RETURN_NIL; |
||
231 | case CAIRO_STATUS_NEGATIVE_COUNT: RETURN_NIL; |
||
232 | case CAIRO_STATUS_INVALID_CLUSTERS: RETURN_NIL; |
||
233 | case CAIRO_STATUS_INVALID_SLANT: RETURN_NIL; |
||
234 | case CAIRO_STATUS_INVALID_WEIGHT: RETURN_NIL; |
||
235 | case CAIRO_STATUS_NO_MEMORY: RETURN_NIL; |
||
236 | case CAIRO_STATUS_INVALID_SIZE: RETURN_NIL; |
||
237 | case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: RETURN_NIL; |
||
238 | case CAIRO_STATUS_DEVICE_TYPE_MISMATCH: RETURN_NIL; |
||
239 | case CAIRO_STATUS_DEVICE_ERROR: RETURN_NIL; |
||
3959 | Serge | 240 | case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: RETURN_NIL; |
241 | case CAIRO_STATUS_DEVICE_FINISHED: RETURN_NIL; |
||
1892 | serge | 242 | default: |
243 | break; |
||
244 | } |
||
245 | status = CAIRO_STATUS_NO_MEMORY; |
||
246 | RETURN_NIL; |
||
247 | #undef RETURN_NIL |
||
248 | } |