nbd-server-add: Fix the default for 'writable'
[qemu/opensuse.git] / qemu-pixman.c
blob7547ed74c11769b6c3944065588becfa7c1a761d
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 void qemu_pixman_image_unref(pixman_image_t *image)
56 if (image == NULL) {
57 return;
59 pixman_image_unref(image);