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