127
129
cairo_set_miter_limit (cr2, 100);
129
131
phase = "No path";
130
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
131
errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
132
errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 0, 0, 0);
132
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
133
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
134
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0);
134
136
cairo_save (cr2);
137
139
cairo_move_to (cr2, 200, 400);
138
140
cairo_rel_line_to (cr2, 0., 0.);
139
141
phase = "Degenerate line";
140
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
141
errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
142
errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
142
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
143
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
144
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
144
146
cairo_new_path (cr2);
145
147
cairo_move_to (cr2, 200, 400);
146
148
cairo_rel_curve_to (cr2, 0., 0., 0., 0., 0., 0.);
147
149
phase = "Degenerate curve";
148
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
149
errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
150
errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
150
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
151
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
152
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
152
154
cairo_new_path (cr2);
153
155
cairo_arc (cr2, 200, 400, 0., 0, 2 * M_PI);
154
156
phase = "Degenerate arc (R=0)";
155
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
156
errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
157
errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
157
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
158
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
159
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
159
161
cairo_new_path (cr2);
160
162
cairo_arc (cr2, 200, 400, 10., 0, 0);
161
163
phase = "Degenerate arc (Θ=0)";
162
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
163
errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
164
errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
164
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
165
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0);
166
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
166
168
cairo_new_path (cr2);
167
169
cairo_restore (cr2);
176
178
cairo_move_to (cr2, 200, 400);
177
179
cairo_rel_line_to (cr2, 0, 0);
178
180
phase = "Single 'dot'";
179
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
180
errors += !check_extents (phase, cr2, STROKE, EQUALS, 190, 390, 20, 20);
181
errors += !check_extents (phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
181
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
182
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 190, 390, 20, 20);
183
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0);
183
185
/* Add another dot without starting a new path */
184
186
cairo_move_to (cr2, 100, 500);
185
187
cairo_rel_line_to (cr2, 0, 0);
186
188
phase = "Multiple 'dots'";
187
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
188
errors += !check_extents (phase, cr2, STROKE, EQUALS, 90, 390, 120, 120);
189
errors += !check_extents (phase, cr2, PATH, EQUALS, 100, 400, 100, 100);
189
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
190
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 90, 390, 120, 120);
191
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 100, 400, 100, 100);
191
193
cairo_new_path (cr2);
199
201
cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND);
200
202
cairo_move_to (cr2, 0, 180);
201
203
cairo_line_to (cr2, 750, 180);
202
errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
203
errors += !check_extents (phase, cr2, STROKE, EQUALS, -5, 175, 760, 10);
204
errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 180, 755, 0);
204
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0);
205
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, -5, 175, 760, 10);
206
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 180, 755, 0);
205
207
cairo_new_path (cr2);
206
208
cairo_restore (cr2);
208
210
phase = "Simple rect";
209
211
cairo_save (cr2);
210
212
cairo_rectangle (cr2, 10, 10, 80, 80);
211
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
212
errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
213
errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
213
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
214
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
215
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
214
216
cairo_new_path (cr2);
215
217
cairo_restore (cr2);
218
220
cairo_save (cr2);
219
221
cairo_rectangle (cr2, 10, 10, 10, 10);
220
222
cairo_rectangle (cr2, 20, 20, 10, 10);
221
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 20, 20);
222
errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 30, 30);
223
errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 20, 20);
223
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 20, 20);
224
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 5, 5, 30, 30);
225
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 20, 20);
224
226
cairo_new_path (cr2);
225
227
cairo_restore (cr2);
232
234
cairo_close_path (cr2);
233
235
/* miter joins protrude 5*(1+sqrt(2)) above the top-left corner and to
234
236
the right of the bottom-right corner */
235
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
236
errors += !check_extents (phase, cr2, STROKE, CONTAINS, 0, 5, 95, 95);
237
errors += !check_extents (phase, cr2, PATH, CONTAINS, 10, 10, 80, 80);
237
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
238
errors += !check_extents (ctx, phase, cr2, STROKE, CONTAINS, 0, 5, 95, 95);
239
errors += !check_extents (ctx, phase, cr2, PATH, CONTAINS, 10, 10, 80, 80);
238
240
cairo_new_path (cr2);
239
241
cairo_restore (cr2);
248
250
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD);
249
251
phase = "EVEN_ODD overlapping rectangles";
250
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
251
errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
252
errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
252
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
253
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
254
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
254
256
/* Test other fill rule with the same path. */
256
258
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING);
257
259
phase = "WINDING overlapping rectangles";
258
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 30, 30);
259
errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
260
errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
260
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 30, 30);
261
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
262
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
262
264
/* Now, change the direction of the second rectangle and test both
263
265
* fill rules again. */
268
270
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_EVEN_ODD);
269
271
phase = "EVEN_ODD overlapping rectangles";
270
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
271
errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
272
errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
272
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
273
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
274
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
274
276
/* Test other fill rule with the same path. */
276
278
cairo_set_fill_rule (cr2, CAIRO_FILL_RULE_WINDING);
277
279
phase = "WINDING overlapping rectangles";
278
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
279
errors += !check_extents (phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
280
errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
280
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 15, 30);
281
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 8, 8, 34, 34);
282
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 30, 30);
282
284
cairo_new_path (cr2);
322
324
/* XXX: We'd like to be able to use EQUALS here, but currently
323
325
* when hinting is enabled freetype returns integer extents. See
324
326
* http://cairographics.org/todo */
325
errors += !check_extents (phase, cr2, FILL, APPROX_EQUALS,
327
errors += !check_extents (ctx, phase, cr2, FILL, APPROX_EQUALS,
326
328
0, 0, extents.width, extents.height);
327
errors += !check_extents (phase, cr2, STROKE, APPROX_EQUALS,
329
errors += !check_extents (ctx, phase, cr2, STROKE, APPROX_EQUALS,
328
330
-1, -1, extents.width+2, extents.height+2);
329
errors += !check_extents (phase, cr2, PATH, APPROX_EQUALS,
331
errors += !check_extents (ctx, phase, cr2, PATH, APPROX_EQUALS,
330
332
0, 0, extents.width, extents.height);
331
333
cairo_new_path (cr2);
332
334
cairo_restore (cr2);
335
337
cairo_save (cr2);
336
338
cairo_scale (cr2, 2, 2);
337
339
cairo_rectangle (cr2, 5, 5, 40, 40);
338
errors += !check_extents (phase, cr2, FILL, EQUALS, 5, 5, 40, 40);
339
errors += !check_extents (phase, cr2, STROKE, EQUALS, 0, 0, 50, 50);
340
errors += !check_extents (phase, cr2, PATH, EQUALS, 5, 5, 40, 40);
340
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 5, 5, 40, 40);
341
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 50, 50);
342
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 5, 5, 40, 40);
341
343
cairo_new_path (cr2);
342
344
cairo_restore (cr2);
347
349
cairo_scale (cr2, 2, 2);
348
350
cairo_rectangle (cr2, 5, 5, 40, 40);
349
351
cairo_restore (cr2);
350
errors += !check_extents (phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
351
errors += !check_extents (phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
352
errors += !check_extents (phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
352
errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 10, 10, 80, 80);
353
errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 5, 5, 90, 90);
354
errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 10, 10, 80, 80);
353
355
cairo_new_path (cr2);
354
356
cairo_restore (cr2);
366
368
the axes. With the stroke width added to the rotated path,
367
369
the largest axis-aligned square is a bit over 38 on either side of
369
errors += !check_extents (phase, cr2, FILL, CONTAINS, -35, -35, 35, 35);
370
errors += !check_extents (phase, cr2, STROKE, CONTAINS, -38, -38, 38, 38);
371
errors += !check_extents (phase, cr2, PATH, CONTAINS, -35, -35, 35, 35);
371
errors += !check_extents (ctx, phase, cr2, FILL, CONTAINS, -35, -35, 35, 35);
372
errors += !check_extents (ctx, phase, cr2, STROKE, CONTAINS, -38, -38, 38, 38);
373
errors += !check_extents (ctx, phase, cr2, PATH, CONTAINS, -35, -35, 35, 35);
372
374
cairo_new_path (cr2);
373
375
cairo_restore (cr2);