spice: switch to pixman
[qemu/opensuse.git] / qemu-pixman.c
blob71a9ea43a6e32dab6f3d0333d540eed388c29a39
1 #include "qemu-pixman.h"
3 int qemu_pixman_get_type(int rshift, int gshift, int bshift)
5 int type = PIXMAN_TYPE_OTHER;
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
15 } else if (rshift < gshift && gshift < bshift) {
16 if (rshift == 0) {
17 type = PIXMAN_TYPE_ABGR;
18 } else {
19 type = PIXMAN_TYPE_BGRA;
22 return type;
25 pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf)
27 pixman_format_code_t format;
28 int type;
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;
36 return format;
39 pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
40 int width)
42 pixman_image_t *image = pixman_image_create_bits(format, width, 1, NULL, 0);
43 assert(image != NULL);
44 return image;
47 void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
48 int width, int y)
50 pixman_image_composite(PIXMAN_OP_SRC, fb, NULL, linebuf,
51 0, y, 0, 0, 0, 0, width, 1);
54 pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
55 pixman_image_t *image)
57 pixman_image_t *mirror;
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;
67 void qemu_pixman_image_unref(pixman_image_t *image)
69 if (image == NULL) {
70 return;
72 pixman_image_unref(image);