]>
Commit | Line | Data |
---|---|---|
d2ec7e24 GH |
1 | #include "qemu-pixman.h" |
2 | ||
3 | int qemu_pixman_get_type(int rshift, int gshift, int bshift) | |
4 | { | |
5 | int type = PIXMAN_TYPE_OTHER; | |
6 | ||
7 | if (rshift > gshift && gshift > bshift) { | |
8 | if (bshift == 0) { | |
9 | type = PIXMAN_TYPE_ARGB; | |
10 | } else { | |
11 | #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0, 21, 8) | |
12 | type = PIXMAN_TYPE_RGBA; | |
13 | #endif | |
14 | } | |
15 | } else if (rshift < gshift && gshift < bshift) { | |
16 | if (rshift == 0) { | |
17 | type = PIXMAN_TYPE_ABGR; | |
18 | } else { | |
19 | type = PIXMAN_TYPE_BGRA; | |
20 | } | |
21 | } | |
22 | return type; | |
23 | } | |
24 | ||
25 | pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf) | |
26 | { | |
27 | pixman_format_code_t format; | |
28 | int type; | |
29 | ||
30 | type = qemu_pixman_get_type(pf->rshift, pf->gshift, pf->bshift); | |
31 | format = PIXMAN_FORMAT(pf->bits_per_pixel, type, | |
32 | pf->abits, pf->rbits, pf->gbits, pf->bbits); | |
33 | if (!pixman_format_supported_source(format)) { | |
34 | return 0; | |
35 | } | |
36 | return format; | |
37 | } | |
38 | ||
39 | pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format, | |
40 | int width) | |
41 | { | |
42 | pixman_image_t *image = pixman_image_create_bits(format, width, 1, NULL, 0); | |
43 | assert(image != NULL); | |
44 | return image; | |
45 | } | |
46 | ||
47 | void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb, | |
48 | int width, int y) | |
49 | { | |
50 | pixman_image_composite(PIXMAN_OP_SRC, fb, NULL, linebuf, | |
51 | 0, y, 0, 0, 0, 0, width, 1); | |
52 | } | |
53 | ||
d9a86569 GH |
54 | pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format, |
55 | pixman_image_t *image) | |
56 | { | |
57 | pixman_image_t *mirror; | |
58 | ||
59 | mirror = pixman_image_create_bits(format, | |
60 | pixman_image_get_width(image), | |
61 | pixman_image_get_height(image), | |
62 | NULL, | |
63 | pixman_image_get_stride(image)); | |
64 | return mirror; | |
65 | } | |
66 | ||
d2ec7e24 GH |
67 | void qemu_pixman_image_unref(pixman_image_t *image) |
68 | { | |
69 | if (image == NULL) { | |
70 | return; | |
71 | } | |
72 | pixman_image_unref(image); | |
73 | } |