1
/*
2
 * Copyright © 2011,2013 Intel Corporation
3
 *
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use, copy,
8
 * modify, merge, publish, distribute, sublicense, and/or sell copies
9
 * of the Software, and to permit persons to whom the Software is
10
 * furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be
13
 * included in all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 *
24
 * Author: Chris Wilson <chris@chris-wilson.co.uk>
25
 */
26

            
27
#include "cairo-test.h"
28

            
29
#define TEXT_SIZE 12
30
#define SIZE 60 /* needs to be big to check large area effects (dithering) */
31
#define PAD 2
32

            
33
#define TT_SIZE 100
34
#define TT_PAD 5
35
#define TT_FONT_SIZE 32.0
36

            
37
#define GENERATE_REF 0
38

            
39
static uint32_t data[16] = {
40
    0xffffffff, 0xffffffff,		0xffff0000, 0xffff0000,
41
    0xffffffff, 0xffffffff,		0xffff0000, 0xffff0000,
42

            
43
    0xff00ff00, 0xff00ff00,		0xff0000ff, 0xff0000ff,
44
    0xff00ff00, 0xff00ff00,		0xff0000ff, 0xff0000ff
45
};
46

            
47
static const char *png_filename = "romedalen.png";
48

            
49
static cairo_t *
50
6
paint (cairo_t *cr)
51
{
52
6
    cairo_set_source_rgb (cr, 0, 0, 1);
53
6
    cairo_paint (cr);
54

            
55
6
    cairo_translate (cr, 2, 2);
56
6
    cairo_scale (cr, 0.5, 0.5);
57

            
58
6
    cairo_set_source_rgb (cr, 1, 0, 0);
59
6
    cairo_paint (cr);
60

            
61
6
    return cr;
62
}
63

            
64
static cairo_t *
65
6
paint_alpha (cairo_t *cr)
66
{
67
    cairo_surface_t *surface;
68

            
69
6
    surface = cairo_image_surface_create_for_data ((unsigned char *) data,
70
						   CAIRO_FORMAT_RGB24, 4, 4, 16);
71

            
72
6
    cairo_test_paint_checkered (cr);
73

            
74
6
    cairo_scale (cr, 4, 4);
75

            
76
6
    cairo_set_source_surface (cr, surface, 2 , 2);
77
6
    cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
78
6
    cairo_paint_with_alpha (cr, 0.5);
79

            
80
6
    cairo_surface_finish (surface); /* data will go out of scope */
81
6
    cairo_surface_destroy (surface);
82

            
83
6
    return cr;
84
}
85

            
86
static cairo_t *
87
6
paint_alpha_solid_clip (cairo_t *cr)
88
{
89
6
    cairo_test_paint_checkered (cr);
90

            
91
6
    cairo_rectangle (cr, 2.5, 2.5, 27, 27);
92
6
    cairo_clip (cr);
93

            
94
6
    cairo_set_source_rgb (cr, 1., 0.,0.);
95
6
    cairo_paint_with_alpha (cr, 0.5);
96

            
97
6
    return cr;
98
}
99

            
100
static cairo_t *
101
6
paint_alpha_clip (cairo_t *cr)
102
{
103
    cairo_surface_t *surface;
104

            
105
6
    surface = cairo_image_surface_create_for_data ((unsigned char *) data,
106
						   CAIRO_FORMAT_RGB24, 4, 4, 16);
107

            
108
6
    cairo_test_paint_checkered (cr);
109

            
110
6
    cairo_rectangle (cr, 10.5, 10.5, 11, 11);
111
6
    cairo_clip (cr);
112

            
113
6
    cairo_scale (cr, 4, 4);
114

            
115
6
    cairo_set_source_surface (cr, surface, 2 , 2);
116
6
    cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
117
6
    cairo_paint_with_alpha (cr, 0.5);
118

            
119
6
    cairo_surface_finish (surface); /* data will go out of scope */
120
6
    cairo_surface_destroy (surface);
121

            
122
6
    return cr;
123
}
124

            
125
static cairo_t *
126
6
paint_alpha_clip_mask (cairo_t *cr)
127
{
128
    cairo_surface_t *surface;
129

            
130
6
    surface = cairo_image_surface_create_for_data ((unsigned char *) data,
131
						   CAIRO_FORMAT_RGB24, 4, 4, 16);
132

            
133
6
    cairo_test_paint_checkered (cr);
134

            
135
6
    cairo_move_to (cr, 16, 5);
136
6
    cairo_line_to (cr, 5, 16);
137
6
    cairo_line_to (cr, 16, 27);
138
6
    cairo_line_to (cr, 27, 16);
139
6
    cairo_clip (cr);
140

            
141
6
    cairo_scale (cr, 4, 4);
142

            
143
6
    cairo_set_source_surface (cr, surface, 2 , 2);
144
6
    cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
145
6
    cairo_paint_with_alpha (cr, 0.5);
146

            
147
6
    cairo_surface_finish (surface); /* data will go out of scope */
148
6
    cairo_surface_destroy (surface);
149

            
150
6
    return cr;
151
}
152

            
153
static cairo_t *
154
6
select_font_face (cairo_t *cr)
155
{
156
    /* We draw in the default black, so paint white first. */
157
6
    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
158
6
    cairo_paint (cr);
159

            
160
6
    cairo_set_source_rgb (cr, 0, 0, 0); /* black */
161

            
162
6
    cairo_set_font_size (cr, TEXT_SIZE);
163
6
    cairo_move_to (cr, 0, TEXT_SIZE);
164

            
165
6
    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Serif",
166
			    CAIRO_FONT_SLANT_NORMAL,
167
			    CAIRO_FONT_WEIGHT_NORMAL);
168
6
    cairo_show_text (cr, "i-am-serif");
169

            
170
6
    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
171
			    CAIRO_FONT_SLANT_NORMAL,
172
			    CAIRO_FONT_WEIGHT_NORMAL);
173
6
    cairo_show_text (cr, " i-am-sans");
174

            
175
6
    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans Mono",
176
			    CAIRO_FONT_SLANT_NORMAL,
177
			    CAIRO_FONT_WEIGHT_NORMAL);
178
6
    cairo_show_text (cr, " i-am-mono");
179

            
180
6
    return cr;
181
}
182

            
183
static cairo_t *
184
6
fill_alpha (cairo_t *cr)
185
{
186
6
    const double alpha = 1./3;
187
    int n;
188

            
189
    /* flatten to white */
190
6
    cairo_set_source_rgb (cr, 1, 1, 1);
191
6
    cairo_paint (cr);
192

            
193
    /* square */
194
6
    cairo_rectangle (cr, PAD, PAD, SIZE, SIZE);
195
6
    cairo_set_source_rgba (cr, 1, 0, 0, alpha);
196
6
    cairo_fill (cr);
197

            
198
    /* circle */
199
6
    cairo_translate (cr, SIZE + 2 * PAD, 0);
200
6
    cairo_arc (cr, PAD + SIZE / 2., PAD + SIZE / 2., SIZE / 2., 0, 2 * M_PI);
201
6
    cairo_set_source_rgba (cr, 0, 1, 0, alpha);
202
6
    cairo_fill (cr);
203

            
204
    /* triangle */
205
6
    cairo_translate (cr, 0, SIZE + 2 * PAD);
206
6
    cairo_move_to (cr, PAD + SIZE / 2, PAD);
207
6
    cairo_line_to (cr, PAD + SIZE, PAD + SIZE);
208
6
    cairo_line_to (cr, PAD, PAD + SIZE);
209
6
    cairo_set_source_rgba (cr, 0, 0, 1, alpha);
210
6
    cairo_fill (cr);
211

            
212
    /* star */
213
6
    cairo_translate (cr, -(SIZE + 2 * PAD) + SIZE/2., SIZE/2.);
214
36
    for (n = 0; n < 5; n++) {
215
30
	cairo_line_to (cr,
216
30
		       SIZE/2 * cos (2*n * 2*M_PI / 10),
217
30
		       SIZE/2 * sin (2*n * 2*M_PI / 10));
218

            
219
30
	cairo_line_to (cr,
220
30
		       SIZE/4 * cos ((2*n+1)*2*M_PI / 10),
221
30
		       SIZE/4 * sin ((2*n+1)*2*M_PI / 10));
222
    }
223
6
    cairo_set_source_rgba (cr, 0, 0, 0, alpha);
224
6
    cairo_fill (cr);
225

            
226
6
    return cr;
227
}
228

            
229
static cairo_t *
230
6
self_intersecting (cairo_t *cr)
231
{
232
6
    cairo_set_source_rgb (cr, 1, 1, 1);
233
6
    cairo_paint (cr);
234

            
235
6
    cairo_translate (cr, 1.0, 1.0);
236

            
237
6
    cairo_set_source_rgb (cr, 1, 0, 0); /* red */
238

            
239
    /* First draw the desired shape with a fill */
240
6
    cairo_rectangle (cr, 0.5, 0.5,  4.0, 4.0);
241
6
    cairo_rectangle (cr, 3.5, 3.5,  4.0, 4.0);
242
6
    cairo_rectangle (cr, 3.5, 1.5, -2.0, 2.0);
243
6
    cairo_rectangle (cr, 6.5, 4.5, -2.0, 2.0);
244

            
245
6
    cairo_fill (cr);
246

            
247
    /* Then try the same thing with a stroke */
248
6
    cairo_translate (cr, 0, 10);
249
6
    cairo_move_to (cr, 1.0, 1.0);
250
6
    cairo_rel_line_to (cr,  3.0,  0.0);
251
6
    cairo_rel_line_to (cr,  0.0,  6.0);
252
6
    cairo_rel_line_to (cr,  3.0,  0.0);
253
6
    cairo_rel_line_to (cr,  0.0, -3.0);
254
6
    cairo_rel_line_to (cr, -6.0,  0.0);
255
6
    cairo_close_path (cr);
256

            
257
6
    cairo_set_line_width (cr, 1.0);
258
6
    cairo_stroke (cr);
259

            
260
6
    return cr;
261
}
262

            
263
static void
264
12
draw_text_transform (cairo_t *cr)
265
{
266
    cairo_matrix_t tm;
267

            
268
    /* skew */
269
12
    cairo_matrix_init (&tm, 1, 0,
270
                       -0.25, 1,
271
                       0, 0);
272
12
    cairo_matrix_scale (&tm, TT_FONT_SIZE, TT_FONT_SIZE);
273
12
    cairo_set_font_matrix (cr, &tm);
274

            
275
12
    cairo_new_path (cr);
276
12
    cairo_move_to (cr, 50, TT_SIZE-TT_PAD);
277
12
    cairo_show_text (cr, "A");
278

            
279
    /* rotate and scale */
280
12
    cairo_matrix_init_rotate (&tm, M_PI / 2);
281
12
    cairo_matrix_scale (&tm, TT_FONT_SIZE, TT_FONT_SIZE * 2.0);
282
12
    cairo_set_font_matrix (cr, &tm);
283

            
284
12
    cairo_new_path (cr);
285
12
    cairo_move_to (cr, TT_PAD, TT_PAD + 25);
286
12
    cairo_show_text (cr, "A");
287

            
288
12
    cairo_matrix_init_rotate (&tm, M_PI / 2);
289
12
    cairo_matrix_scale (&tm, TT_FONT_SIZE * 2.0, TT_FONT_SIZE);
290
12
    cairo_set_font_matrix (cr, &tm);
291

            
292
12
    cairo_new_path (cr);
293
12
    cairo_move_to (cr, TT_PAD, TT_PAD + 50);
294
12
    cairo_show_text (cr, "A");
295
12
}
296

            
297
static cairo_t *
298
6
text_transform (cairo_t *cr)
299
{
300
6
    const cairo_test_context_t *ctx = cairo_test_get_context (cr);
301
    cairo_pattern_t *pattern;
302

            
303
6
    cairo_set_source_rgb (cr, 1., 1., 1.);
304
6
    cairo_paint (cr);
305

            
306
6
    cairo_set_source_rgb (cr, 0., 0., 0.);
307

            
308
6
    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
309
			    CAIRO_FONT_SLANT_NORMAL,
310
			    CAIRO_FONT_WEIGHT_NORMAL);
311

            
312
6
    draw_text_transform (cr);
313

            
314
6
    cairo_translate (cr, TT_SIZE, TT_SIZE);
315
6
    cairo_rotate (cr, M_PI);
316

            
317
6
    pattern = cairo_test_create_pattern_from_png (ctx, png_filename);
318
6
    cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
319
6
    cairo_set_source (cr, pattern);
320
6
    cairo_pattern_destroy (pattern);
321

            
322
6
    draw_text_transform (cr);
323

            
324
6
    return cr;
325
}
326

            
327
/* And here begins the recording and replaying... */
328

            
329
static cairo_t *
330
54
record_create (cairo_t *target)
331
{
332
    cairo_surface_t *surface;
333
    cairo_t *cr;
334

            
335
54
    surface = cairo_recording_surface_create (cairo_surface_get_content (cairo_get_target (target)), NULL);
336
54
    cr = cairo_test_create (surface, cairo_test_get_context (target));
337
54
    cairo_surface_destroy (surface);
338

            
339
54
    return cr;
340
}
341

            
342
static cairo_surface_t *
343
54
record_get (cairo_t *target)
344
{
345
    cairo_surface_t *surface;
346

            
347
54
    surface = cairo_surface_reference (cairo_get_target (target));
348
54
    cairo_destroy (target);
349

            
350
54
    return surface;
351
}
352

            
353
static cairo_test_status_t
354
27
record_replay (cairo_t *cr, cairo_t *(*func)(cairo_t *), int width, int height)
355
{
356
    cairo_surface_t *surface;
357
    int x, y;
358

            
359
#if GENERATE_REF
360
    {
361
	cairo_surface_t *image;
362
	uint8_t *data, *tmp;
363
	int stride, bpp;
364

            
365
	surface = cairo_get_target (cr);
366

            
367
	func(cr);
368

            
369
	image = cairo_surface_map_to_image (surface, NULL);
370

            
371
	switch (cairo_image_surface_get_format (image)) {
372
	case CAIRO_FORMAT_ARGB32:
373
	case CAIRO_FORMAT_RGB24:
374
	case CAIRO_FORMAT_RGB30:
375
	    bpp=4;
376
	    break;
377
	case CAIRO_FORMAT_RGB16_565:
378
	    bpp=2;
379
	    break;
380
	case CAIRO_FORMAT_A8:
381
	    bpp=1;
382
	    break;
383
	case CAIRO_FORMAT_A1:
384
	case CAIRO_FORMAT_INVALID:
385
	default:
386
	    return CAIRO_TEST_FAILURE;
387
	}
388

            
389
	data = cairo_image_surface_get_data (image);
390
	stride = cairo_image_surface_get_stride (image);
391

            
392
	tmp = malloc (stride);
393
	if (tmp == NULL)
394
	    return CAIRO_TEST_FAILURE;
395

            
396
	for (y = 0; y < height; y++) {
397
	    uint8_t *row = data + y * stride;
398
	    for (x = 0; x < width/2; x++) {
399
		memcpy (tmp, row + bpp * x, bpp);
400
		memcpy (row + bpp * x, row + bpp * (width - x - 1), bpp);
401
		memcpy (row + bpp * (width - x - 1), tmp, bpp);
402
	    }
403
	}
404

            
405
	for (y = 0; y < height/2; y++) {
406
	    memcpy (tmp, data + y * stride, stride);
407
	    memcpy (data + y * stride, data + (height - y - 1) * stride, stride);
408
	    memcpy (data + (height - y - 1) * stride, tmp, stride);
409
	}
410

            
411
	free (tmp);
412

            
413
	cairo_surface_unmap_image (surface, image);
414
    }
415
#else
416
27
    surface = record_get (func (record_create (cr)));
417

            
418
27
    cairo_scale (cr, -1, -1);
419
27
    cairo_translate (cr, -width, -height);
420
27
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
421
27
    cairo_set_source_surface (cr, surface, 0, 0);
422
27
    cairo_surface_destroy (surface);
423
27
    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_NONE);
424

            
425
627
    for (y = 0; y < height; y += 2) {
426
25962
	for (x = 0; x < width; x += 2) {
427
25362
	    cairo_rectangle (cr, x, y, 2, 2);
428
25362
	    cairo_clip (cr);
429
25362
	    cairo_paint (cr);
430
25362
	    cairo_reset_clip (cr);
431
	}
432
    }
433
#endif
434

            
435
27
    return CAIRO_TEST_SUCCESS;
436
}
437

            
438
static cairo_test_status_t
439
27
record_whole_replay (cairo_t *cr, cairo_t *(*func)(cairo_t *), int width, int height)
440
{
441
    cairo_surface_t *surface;
442

            
443
#if GENERATE_REF
444
    {
445
	cairo_surface_t *image;
446
	uint8_t *data, *tmp;
447
	int stride, bpp;
448
	int x, y;
449

            
450
	surface = cairo_get_target (cr);
451

            
452
	func(cr);
453

            
454
	image = cairo_surface_map_to_image (surface, NULL);
455

            
456
	switch (cairo_image_surface_get_format (image)) {
457
	case CAIRO_FORMAT_ARGB32:
458
	case CAIRO_FORMAT_RGB24:
459
	case CAIRO_FORMAT_RGB30:
460
	    bpp=4;
461
	    break;
462
	case CAIRO_FORMAT_RGB16_565:
463
	    bpp=2;
464
	    break;
465
	case CAIRO_FORMAT_A8:
466
	    bpp=1;
467
	    break;
468
	case CAIRO_FORMAT_A1:
469
	case CAIRO_FORMAT_INVALID:
470
	default:
471
	    return CAIRO_TEST_FAILURE;
472
	}
473

            
474
	data = cairo_image_surface_get_data (image);
475
	stride = cairo_image_surface_get_stride (image);
476

            
477
	tmp = malloc (stride);
478
	if (tmp == NULL)
479
	    return CAIRO_TEST_FAILURE;
480

            
481
	for (y = 0; y < height; y++) {
482
	    uint8_t *row = data + y * stride;
483
	    for (x = 0; x < width/2; x++) {
484
		memcpy (tmp, row + bpp * x, bpp);
485
		memcpy (row + bpp * x, row + bpp * (width - x - 1), bpp);
486
		memcpy (row + bpp * (width - x - 1), tmp, bpp);
487
	    }
488
	}
489

            
490
	for (y = 0; y < height/2; y++) {
491
	    memcpy (tmp, data + y * stride, stride);
492
	    memcpy (data + y * stride, data + (height - y - 1) * stride, stride);
493
	    memcpy (data + (height - y - 1) * stride, tmp, stride);
494
	}
495

            
496
	free (tmp);
497

            
498
	cairo_surface_unmap_image (surface, image);
499
    }
500
#else
501
27
    surface = record_get (func (record_create (cr)));
502

            
503
27
    cairo_scale (cr, -1, -1);
504
27
    cairo_translate (cr, -width, -height);
505
27
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
506
27
    cairo_set_source_surface (cr, surface, 0, 0);
507
27
    cairo_surface_destroy (surface);
508
27
    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_NONE);
509

            
510
27
    cairo_paint (cr);
511
#endif
512

            
513
27
    return CAIRO_TEST_SUCCESS;
514
}
515

            
516
static cairo_test_status_t
517
3
record_paint (cairo_t *cr, int width, int height)
518
{
519
3
    return record_replay (cr, paint, width, height);
520
}
521

            
522
static cairo_test_status_t
523
3
record_paint_alpha (cairo_t *cr, int width, int height)
524
{
525
3
    return record_replay (cr, paint_alpha, width, height);
526
}
527

            
528
static cairo_test_status_t
529
3
record_paint_alpha_solid_clip (cairo_t *cr, int width, int height)
530
{
531
3
    return record_replay (cr, paint_alpha_solid_clip, width, height);
532
}
533

            
534
static cairo_test_status_t
535
3
record_paint_alpha_clip (cairo_t *cr, int width, int height)
536
{
537
3
    return record_replay (cr, paint_alpha_clip, width, height);
538
}
539

            
540
static cairo_test_status_t
541
3
record_paint_alpha_clip_mask (cairo_t *cr, int width, int height)
542
{
543
3
    return record_replay (cr, paint_alpha_clip_mask, width, height);
544
}
545

            
546
static cairo_test_status_t
547
3
record_fill_alpha (cairo_t *cr, int width, int height)
548
{
549
3
    return record_replay (cr, fill_alpha, width, height);
550
}
551

            
552
static cairo_test_status_t
553
3
record_self_intersecting (cairo_t *cr, int width, int height)
554
{
555
3
    return record_replay (cr, self_intersecting, width, height);
556
}
557

            
558
static cairo_test_status_t
559
3
record_select_font_face (cairo_t *cr, int width, int height)
560
{
561
3
    return record_replay (cr, select_font_face, width, height);
562
}
563

            
564
static cairo_test_status_t
565
3
record_text_transform (cairo_t *cr, int width, int height)
566
{
567
3
    return record_replay (cr, text_transform, width, height);
568
}
569

            
570
static cairo_test_status_t
571
3
record_whole_paint (cairo_t *cr, int width, int height)
572
{
573
3
    return record_whole_replay (cr, paint, width, height);
574
}
575

            
576
static cairo_test_status_t
577
3
record_whole_paint_alpha (cairo_t *cr, int width, int height)
578
{
579
3
    return record_whole_replay (cr, paint_alpha, width, height);
580
}
581

            
582
static cairo_test_status_t
583
3
record_whole_paint_alpha_solid_clip (cairo_t *cr, int width, int height)
584
{
585
3
    return record_whole_replay (cr, paint_alpha_solid_clip, width, height);
586
}
587

            
588
static cairo_test_status_t
589
3
record_whole_paint_alpha_clip (cairo_t *cr, int width, int height)
590
{
591
3
    return record_whole_replay (cr, paint_alpha_clip, width, height);
592
}
593

            
594
static cairo_test_status_t
595
3
record_whole_paint_alpha_clip_mask (cairo_t *cr, int width, int height)
596
{
597
3
    return record_whole_replay (cr, paint_alpha_clip_mask, width, height);
598
}
599

            
600
static cairo_test_status_t
601
3
record_whole_fill_alpha (cairo_t *cr, int width, int height)
602
{
603
3
    return record_whole_replay (cr, fill_alpha, width, height);
604
}
605

            
606
static cairo_test_status_t
607
3
record_whole_self_intersecting (cairo_t *cr, int width, int height)
608
{
609
3
    return record_whole_replay (cr, self_intersecting, width, height);
610
}
611

            
612
static cairo_test_status_t
613
3
record_whole_select_font_face (cairo_t *cr, int width, int height)
614
{
615
3
    return record_whole_replay (cr, select_font_face, width, height);
616
}
617

            
618
static cairo_test_status_t
619
3
record_whole_text_transform (cairo_t *cr, int width, int height)
620
{
621
3
    return record_whole_replay (cr, text_transform, width, height);
622
}
623

            
624
1
CAIRO_TEST (recordflip_whole_paint,
625
	    "Test replayed calls to cairo_paint",
626
	    "paint,record", /* keywords */
627
	    NULL, /* requirements */
628
	    8, 8,
629
	    NULL, record_whole_paint)
630
1
CAIRO_TEST (recordflip_whole_paint_alpha,
631
	    "Simple test of cairo_paint_with_alpha",
632
	    "record, paint, alpha", /* keywords */
633
	    NULL, /* requirements */
634
	    32, 32,
635
	    NULL, record_whole_paint_alpha)
636
1
CAIRO_TEST (recordflip_whole_paint_alpha_solid_clip,
637
	    "Simple test of cairo_paint_with_alpha+unaligned clip",
638
	    "record, paint, alpha, clip", /* keywords */
639
	    NULL, /* requirements */
640
	    32, 32,
641
	    NULL, record_whole_paint_alpha_solid_clip)
642
1
CAIRO_TEST (recordflip_whole_paint_alpha_clip,
643
	    "Simple test of cairo_paint_with_alpha+unaligned clip",
644
	    "record, paint, alpha, clip", /* keywords */
645
	    NULL, /* requirements */
646
	    32, 32,
647
	    NULL, record_whole_paint_alpha_clip)
648
1
CAIRO_TEST (recordflip_whole_paint_alpha_clip_mask,
649
	    "Simple test of cairo_paint_with_alpha+triangular clip",
650
	    "record, paint, alpha, clip", /* keywords */
651
	    NULL, /* requirements */
652
	    32, 32,
653
	    NULL, record_whole_paint_alpha_clip_mask)
654
1
CAIRO_TEST (recordflip_whole_fill_alpha,
655
	    "Tests using set_rgba();fill()",
656
	    "record,fill, alpha", /* keywords */
657
	    NULL, /* requirements */
658
	    (2*SIZE + 4*PAD), (2*SIZE + 4*PAD),
659
	    NULL, record_whole_fill_alpha)
660
1
CAIRO_TEST (recordflip_whole_select_font_face,
661
	    "Tests using cairo_select_font_face to draw text in different faces",
662
	    "record, font", /* keywords */
663
	    NULL, /* requirements */
664
	    192, (TEXT_SIZE + 4),
665
	    NULL, record_whole_select_font_face)
666
1
CAIRO_TEST (recordflip_whole_self_intersecting,
667
	    "Test strokes of self-intersecting paths",
668
	    "record, stroke, trap", /* keywords */
669
	    NULL, /* requirements */
670
	    10, 20,
671
	    NULL, record_whole_self_intersecting)
672
1
CAIRO_TEST (recordflip_whole_text_transform,
673
	    "Test various applications of the font matrix",
674
	    "record, text, transform", /* keywords */
675
	    NULL, /* requirements */
676
	    TT_SIZE, TT_SIZE,
677
	    NULL, record_whole_text_transform)
678

            
679

            
680
1
CAIRO_TEST (recordflip_paint,
681
	    "Test replayed calls to cairo_paint",
682
	    "paint,record", /* keywords */
683
	    NULL, /* requirements */
684
	    8, 8,
685
	    NULL, record_paint)
686
1
CAIRO_TEST (recordflip_paint_alpha,
687
	    "Simple test of cairo_paint_with_alpha",
688
	    "record, paint, alpha", /* keywords */
689
	    NULL, /* requirements */
690
	    32, 32,
691
	    NULL, record_paint_alpha)
692
1
CAIRO_TEST (recordflip_paint_alpha_solid_clip,
693
	    "Simple test of cairo_paint_with_alpha+unaligned clip",
694
	    "record, paint, alpha, clip", /* keywords */
695
	    NULL, /* requirements */
696
	    32, 32,
697
	    NULL, record_paint_alpha_solid_clip)
698
1
CAIRO_TEST (recordflip_paint_alpha_clip,
699
	    "Simple test of cairo_paint_with_alpha+unaligned clip",
700
	    "record, paint, alpha, clip", /* keywords */
701
	    NULL, /* requirements */
702
	    32, 32,
703
	    NULL, record_paint_alpha_clip)
704
1
CAIRO_TEST (recordflip_paint_alpha_clip_mask,
705
	    "Simple test of cairo_paint_with_alpha+triangular clip",
706
	    "record, paint, alpha, clip", /* keywords */
707
	    NULL, /* requirements */
708
	    32, 32,
709
	    NULL, record_paint_alpha_clip_mask)
710
1
CAIRO_TEST (recordflip_fill_alpha,
711
	    "Tests using set_rgba();fill()",
712
	    "record,fill, alpha", /* keywords */
713
	    NULL, /* requirements */
714
	    (2*SIZE + 4*PAD), (2*SIZE + 4*PAD),
715
	    NULL, record_fill_alpha)
716
1
CAIRO_TEST (recordflip_select_font_face,
717
	    "Tests using cairo_select_font_face to draw text in different faces",
718
	    "record, font", /* keywords */
719
	    NULL, /* requirements */
720
	    192, (TEXT_SIZE + 4),
721
	    NULL, record_select_font_face)
722
1
CAIRO_TEST (recordflip_self_intersecting,
723
	    "Test strokes of self-intersecting paths",
724
	    "record, stroke, trap", /* keywords */
725
	    NULL, /* requirements */
726
	    10, 20,
727
	    NULL, record_self_intersecting)
728
1
CAIRO_TEST (recordflip_text_transform,
729
	    "Test various applications of the font matrix",
730
	    "record, text, transform", /* keywords */
731
	    NULL, /* requirements */
732
	    TT_SIZE, TT_SIZE,
733
	    NULL, record_text_transform)