]>
Commit | Line | Data |
---|---|---|
daa8e5a0 GH |
1 | /* |
2 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
3 | * See the COPYING file in the top-level directory. | |
4 | */ | |
5 | ||
0b087861 PM |
6 | #include "qemu-common.h" |
7 | #include "ui/console.h" | |
d2ec7e24 GH |
8 | |
9 | int qemu_pixman_get_type(int rshift, int gshift, int bshift) | |
10 | { | |
11 | int type = PIXMAN_TYPE_OTHER; | |
12 | ||
13 | if (rshift > gshift && gshift > bshift) { | |
14 | if (bshift == 0) { | |
15 | type = PIXMAN_TYPE_ARGB; | |
16 | } else { | |
17 | #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0, 21, 8) | |
18 | type = PIXMAN_TYPE_RGBA; | |
19 | #endif | |
20 | } | |
21 | } else if (rshift < gshift && gshift < bshift) { | |
22 | if (rshift == 0) { | |
23 | type = PIXMAN_TYPE_ABGR; | |
24 | } else { | |
fbddfc72 | 25 | #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0, 16, 0) |
d2ec7e24 | 26 | type = PIXMAN_TYPE_BGRA; |
6e72719e | 27 | #endif |
d2ec7e24 GH |
28 | } |
29 | } | |
30 | return type; | |
31 | } | |
32 | ||
33 | pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf) | |
34 | { | |
35 | pixman_format_code_t format; | |
36 | int type; | |
37 | ||
38 | type = qemu_pixman_get_type(pf->rshift, pf->gshift, pf->bshift); | |
39 | format = PIXMAN_FORMAT(pf->bits_per_pixel, type, | |
40 | pf->abits, pf->rbits, pf->gbits, pf->bbits); | |
41 | if (!pixman_format_supported_source(format)) { | |
42 | return 0; | |
43 | } | |
44 | return format; | |
45 | } | |
46 | ||
47 | pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format, | |
48 | int width) | |
49 | { | |
50 | pixman_image_t *image = pixman_image_create_bits(format, width, 1, NULL, 0); | |
51 | assert(image != NULL); | |
52 | return image; | |
53 | } | |
54 | ||
55 | void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb, | |
bc210eb1 | 56 | int width, int x, int y) |
d2ec7e24 GH |
57 | { |
58 | pixman_image_composite(PIXMAN_OP_SRC, fb, NULL, linebuf, | |
bc210eb1 | 59 | x, y, 0, 0, 0, 0, width, 1); |
d2ec7e24 GH |
60 | } |
61 | ||
d9a86569 GH |
62 | pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format, |
63 | pixman_image_t *image) | |
64 | { | |
65 | pixman_image_t *mirror; | |
66 | ||
67 | mirror = pixman_image_create_bits(format, | |
68 | pixman_image_get_width(image), | |
69 | pixman_image_get_height(image), | |
70 | NULL, | |
71 | pixman_image_get_stride(image)); | |
72 | return mirror; | |
73 | } | |
74 | ||
d2ec7e24 GH |
75 | void qemu_pixman_image_unref(pixman_image_t *image) |
76 | { | |
77 | if (image == NULL) { | |
78 | return; | |
79 | } | |
80 | pixman_image_unref(image); | |
81 | } |