~ubuntu-branches/ubuntu/saucy/pixman/saucy-security

« back to all changes in this revision

Viewing changes to test/oob-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2009-09-28 18:12:47 UTC
  • mfrom: (1.1.8 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090928181247-3iehog63i50htejf
Tags: 0.16.2-1
* New upstream release (closes: #546849).
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include "pixman.h"
 
4
 
 
5
typedef struct
 
6
{
 
7
    int                         width;
 
8
    int                         height;
 
9
    int                         stride;
 
10
    pixman_format_code_t        format;
 
11
    
 
12
} image_info_t;
 
13
 
 
14
typedef struct
 
15
{
 
16
    pixman_op_t         op;
 
17
    
 
18
    image_info_t        src;
 
19
    image_info_t        dest;
 
20
 
 
21
    int                 src_x;
 
22
    int                 src_y;
 
23
    int                 dest_x;
 
24
    int                 dest_y;
 
25
    int                 width;
 
26
    int                 height;
 
27
} composite_info_t;
 
28
 
 
29
const composite_info_t info[] =
 
30
{
 
31
    {
 
32
        PIXMAN_OP_SRC,
 
33
        {  3, 6, 16, PIXMAN_a8r8g8b8 },
 
34
        {  5, 7, 20, PIXMAN_x8r8g8b8 },
 
35
        1, 8,
 
36
        1, -1,
 
37
        1, 8
 
38
    },
 
39
    {
 
40
        PIXMAN_OP_SRC,
 
41
        { 7, 5, 36, PIXMAN_a8r8g8b8 },
 
42
        { 6, 5, 28, PIXMAN_x8r8g8b8 },
 
43
        8, 5,
 
44
        5, 3,
 
45
        1, 2
 
46
    },
 
47
    {
 
48
        PIXMAN_OP_OVER,
 
49
        { 10, 10, 40, PIXMAN_a2b10g10r10 },
 
50
        { 10, 10, 40, PIXMAN_a2b10g10r10 },
 
51
        0, 0,
 
52
        0, 0,
 
53
        10, 10
 
54
    },
 
55
    {
 
56
        PIXMAN_OP_OVER,
 
57
        { 10, 10, 40, PIXMAN_x2b10g10r10 },
 
58
        { 10, 10, 40, PIXMAN_x2b10g10r10 },
 
59
        0, 0,
 
60
        0, 0,
 
61
        10, 10
 
62
    },
 
63
};
 
64
 
 
65
static pixman_image_t *
 
66
make_image (const image_info_t *info)
 
67
{
 
68
    char *data = malloc (info->stride * info->height);
 
69
    int i;
 
70
 
 
71
    for (i = 0; i < info->height * info->stride; ++i)
 
72
        data[i] = (i % 255) ^ (((i % 16) << 4) | (i & 0xf0));
 
73
 
 
74
    return pixman_image_create_bits (info->format, info->width, info->height, (uint32_t *)data, info->stride);
 
75
}
 
76
    
 
77
static void
 
78
test_composite (const composite_info_t *info)
 
79
{
 
80
    pixman_image_t *src = make_image (&info->src);
 
81
    pixman_image_t *dest = make_image (&info->dest);
 
82
 
 
83
    pixman_image_composite (PIXMAN_OP_SRC, src, NULL, dest,
 
84
                            info->src_x, info->src_y,
 
85
                            0, 0,
 
86
                            info->dest_x, info->dest_y,
 
87
                            info->width, info->height);
 
88
}
 
89
 
 
90
 
 
91
 
 
92
int
 
93
main (int argc, char **argv)
 
94
{
 
95
    int i;
 
96
 
 
97
    for (i = 0; i < sizeof (info) / sizeof (info[0]); ++i)
 
98
        test_composite (&info[i]);
 
99
    
 
100
    return 0;
 
101
}