Coverage Report

Created: 2026-11-20 08:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qemu/include/ui/qemu-pixman.h
Line
Count
Source
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
6
#ifndef QEMU_PIXMAN_H
7
#define QEMU_PIXMAN_H
8
9
#ifdef CONFIG_PIXMAN
10
#include <pixman.h>
11
#include "qemu-pixman-helpers.h"
12
#else
13
#include "pixman-minimal.h"
14
#endif
15
16
#include "qapi/error.h"
17
18
/*
19
 * pixman image formats are defined to be native endian,
20
 * that means host byte order on qemu.  So we go define
21
 * fixed formats here for cases where it is needed, like
22
 * feeding libjpeg / libpng and writing screenshots.
23
 */
24
25
#if HOST_BIG_ENDIAN
26
# define PIXMAN_BE_r8g8b8     PIXMAN_r8g8b8
27
# define PIXMAN_BE_x8r8g8b8   PIXMAN_x8r8g8b8
28
# define PIXMAN_BE_a8r8g8b8   PIXMAN_a8r8g8b8
29
# define PIXMAN_BE_b8g8r8x8   PIXMAN_b8g8r8x8
30
# define PIXMAN_BE_b8g8r8a8   PIXMAN_b8g8r8a8
31
# define PIXMAN_BE_r8g8b8x8   PIXMAN_r8g8b8x8
32
# define PIXMAN_BE_r8g8b8a8   PIXMAN_r8g8b8a8
33
# define PIXMAN_BE_x8b8g8r8   PIXMAN_x8b8g8r8
34
# define PIXMAN_BE_a8b8g8r8   PIXMAN_a8b8g8r8
35
# define PIXMAN_LE_r8g8b8     PIXMAN_b8g8r8
36
# define PIXMAN_LE_a8r8g8b8   PIXMAN_b8g8r8a8
37
# define PIXMAN_LE_x8r8g8b8   PIXMAN_b8g8r8x8
38
# define PIXMAN_LE_a8b8g8r8   PIXMAN_r8g8b8a8
39
# define PIXMAN_LE_x8b8g8r8   PIXMAN_r8g8b8x8
40
#else
41
0
# define PIXMAN_BE_r8g8b8     PIXMAN_b8g8r8
42
0
# define PIXMAN_BE_x8r8g8b8   PIXMAN_b8g8r8x8
43
27
# define PIXMAN_BE_a8r8g8b8   PIXMAN_b8g8r8a8
44
0
# define PIXMAN_BE_b8g8r8x8   PIXMAN_x8r8g8b8
45
122
# define PIXMAN_BE_b8g8r8a8   PIXMAN_a8r8g8b8
46
0
# define PIXMAN_BE_r8g8b8x8   PIXMAN_x8b8g8r8
47
0
# define PIXMAN_BE_r8g8b8a8   PIXMAN_a8b8g8r8
48
0
# define PIXMAN_BE_x8b8g8r8   PIXMAN_r8g8b8x8
49
0
# define PIXMAN_BE_a8b8g8r8   PIXMAN_r8g8b8a8
50
# define PIXMAN_LE_r8g8b8     PIXMAN_r8g8b8
51
# define PIXMAN_LE_a8r8g8b8   PIXMAN_a8r8g8b8
52
0
# define PIXMAN_LE_x8r8g8b8   PIXMAN_x8r8g8b8
53
# define PIXMAN_LE_a8b8g8r8   PIXMAN_a8b8g8r8
54
# define PIXMAN_LE_x8b8g8r8   PIXMAN_x8b8g8r8
55
#endif
56
57
#define QEMU_PIXMAN_COLOR(r, g, b)                                               \
58
119k
    { .red = r << 8, .green = g << 8, .blue = b << 8, .alpha = 0xffff }
59
60
59.5k
#define QEMU_PIXMAN_COLOR_BLACK QEMU_PIXMAN_COLOR(0x00, 0x00, 0x00)
61
59.5k
#define QEMU_PIXMAN_COLOR_GRAY QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0xaa)
62
63
/* -------------------------------------------------------------------- */
64
65
typedef struct PixelFormat {
66
    uint8_t bits_per_pixel;
67
    uint8_t bytes_per_pixel;
68
    uint8_t depth; /* color depth in bits */
69
    uint32_t rmask, gmask, bmask, amask;
70
    uint8_t rshift, gshift, bshift, ashift;
71
    uint8_t rmax, gmax, bmax, amax;
72
    uint8_t rbits, gbits, bbits, abits;
73
} PixelFormat;
74
75
PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format);
76
pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian);
77
78
static inline PixelFormat qemu_default_pixelformat(int bpp)
79
0
{
80
0
    pixman_format_code_t fmt = qemu_default_pixman_format(bpp, true);
81
0
    PixelFormat pf = qemu_pixelformat_from_pixman(fmt);
82
0
    return pf;
83
0
}
Unexecuted instantiation: input.c:qemu_default_pixelformat
Unexecuted instantiation: ui-qmp-cmds.c:qemu_default_pixelformat
Unexecuted instantiation: util.c:qemu_default_pixelformat
Unexecuted instantiation: ui-hmp-cmds.c:qemu_default_pixelformat
Unexecuted instantiation: console-vc.c:qemu_default_pixelformat
Unexecuted instantiation: udmabuf.c:qemu_default_pixelformat
Unexecuted instantiation: vnc.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-enc-zlib.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-enc-hextile.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-enc-tight.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-enc-zrle.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-auth-vencrypt.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-ws.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-jobs.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-clipboard.c:qemu_default_pixelformat
Unexecuted instantiation: vnc-system.c:qemu_default_pixelformat
Unexecuted instantiation: msmouse.c:qemu_default_pixelformat
Unexecuted instantiation: wctablet.c:qemu_default_pixelformat
Unexecuted instantiation: ramfb.c:qemu_default_pixelformat
Unexecuted instantiation: ramfb-standalone.c:qemu_default_pixelformat
Unexecuted instantiation: cirrus_vga.c:qemu_default_pixelformat
Unexecuted instantiation: cirrus_vga_isa.c:qemu_default_pixelformat
Unexecuted instantiation: xenfb.c:qemu_default_pixelformat
Unexecuted instantiation: vga-pci.c:qemu_default_pixelformat
Unexecuted instantiation: vga-isa.c:qemu_default_pixelformat
Unexecuted instantiation: vmware_vga.c:qemu_default_pixelformat
Unexecuted instantiation: bochs-display.c:qemu_default_pixelformat
Unexecuted instantiation: vga.c:qemu_default_pixelformat
Unexecuted instantiation: acpi-vga.c:qemu_default_pixelformat
Unexecuted instantiation: ati.c:qemu_default_pixelformat
Unexecuted instantiation: ati_2d.c:qemu_default_pixelformat
Unexecuted instantiation: ati_dbg.c:qemu_default_pixelformat
Unexecuted instantiation: hid.c:qemu_default_pixelformat
Unexecuted instantiation: ps2.c:qemu_default_pixelformat
Unexecuted instantiation: virtio-input-hid.c:qemu_default_pixelformat
Unexecuted instantiation: applesmc.c:qemu_default_pixelformat
Unexecuted instantiation: dev-hid.c:qemu_default_pixelformat
Unexecuted instantiation: dev-wacom.c:qemu_default_pixelformat
Unexecuted instantiation: listener.c:qemu_default_pixelformat
Unexecuted instantiation: container-legacy.c:qemu_default_pixelformat
Unexecuted instantiation: pci-quirks.c:qemu_default_pixelformat
Unexecuted instantiation: pci.c:qemu_default_pixelformat
Unexecuted instantiation: igd.c:qemu_default_pixelformat
Unexecuted instantiation: cpr.c:qemu_default_pixelformat
Unexecuted instantiation: device.c:qemu_default_pixelformat
Unexecuted instantiation: migration.c:qemu_default_pixelformat
Unexecuted instantiation: iommufd.c:qemu_default_pixelformat
Unexecuted instantiation: display.c:qemu_default_pixelformat
Unexecuted instantiation: vl.c:qemu_default_pixelformat
Unexecuted instantiation: runstate.c:qemu_default_pixelformat
Unexecuted instantiation: dbus-chardev.c:qemu_default_pixelformat
Unexecuted instantiation: dbus-clipboard.c:qemu_default_pixelformat
Unexecuted instantiation: dbus-console.c:qemu_default_pixelformat
Unexecuted instantiation: dbus-error.c:qemu_default_pixelformat
Unexecuted instantiation: dbus-listener.c:qemu_default_pixelformat
Unexecuted instantiation: dbus.c:qemu_default_pixelformat
Unexecuted instantiation: virtio-gpu-base.c:qemu_default_pixelformat
Unexecuted instantiation: virtio-gpu.c:qemu_default_pixelformat
Unexecuted instantiation: virtio-gpu-udmabuf.c:qemu_default_pixelformat
Unexecuted instantiation: vhost-user-gpu.c:qemu_default_pixelformat
Unexecuted instantiation: virtio-gpu-pci.c:qemu_default_pixelformat
Unexecuted instantiation: vhost-user-gpu-pci.c:qemu_default_pixelformat
Unexecuted instantiation: virtio-vga.c:qemu_default_pixelformat
Unexecuted instantiation: vhost-user-vga.c:qemu_default_pixelformat
Unexecuted instantiation: vmmouse.c:qemu_default_pixelformat
Unexecuted instantiation: console.c:qemu_default_pixelformat
Unexecuted instantiation: cursor.c:qemu_default_pixelformat
Unexecuted instantiation: display-surface.c:qemu_default_pixelformat
Unexecuted instantiation: kbd-state.c:qemu_default_pixelformat
Unexecuted instantiation: qemu-pixman.c:qemu_default_pixelformat
Unexecuted instantiation: vt100.c:qemu_default_pixelformat
Unexecuted instantiation: dbusaudio.c:qemu_default_pixelformat
84
85
pixman_format_code_t qemu_drm_format_to_pixman(uint32_t drm_format);
86
uint32_t qemu_pixman_to_drm_format(pixman_format_code_t pixman);
87
int qemu_pixman_get_type(int rshift, int gshift, int bshift, int endian);
88
bool qemu_pixman_check_format(DisplayChangeListener *dcl,
89
                              pixman_format_code_t format);
90
91
#ifdef CONFIG_PIXMAN
92
pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf, int endian);
93
pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
94
                                           int width);
95
void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
96
                              int width, int x, int y);
97
pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
98
                                          pixman_image_t *image);
99
100
pixman_image_t *qemu_pixman_glyph_from_vgafont(int height, const uint8_t *font,
101
                                               unsigned int ch);
102
void qemu_pixman_glyph_render(pixman_image_t *glyph,
103
                              pixman_image_t *surface,
104
                              pixman_color_t *fgcol,
105
                              pixman_color_t *bgcol,
106
                              int x, int y, int cw, int ch);
107
#endif
108
109
void qemu_pixman_image_unref(pixman_image_t *image);
110
111
#ifdef WIN32
112
typedef HANDLE qemu_pixman_shareable;
113
#define SHAREABLE_NONE (NULL)
114
#define SHAREABLE_TO_PTR(handle) (handle)
115
#define PTR_TO_SHAREABLE(ptr) (ptr)
116
#else
117
typedef int qemu_pixman_shareable;
118
59.8k
#define SHAREABLE_NONE (-1)
119
59.6k
#define SHAREABLE_TO_PTR(handle) GINT_TO_POINTER(handle)
120
59.6k
#define PTR_TO_SHAREABLE(ptr) GPOINTER_TO_INT(ptr)
121
#endif
122
123
bool qemu_pixman_image_new_shareable(
124
    pixman_image_t **image,
125
    qemu_pixman_shareable *handle,
126
    const char *name,
127
    pixman_format_code_t format,
128
    int width,
129
    int height,
130
    int rowstride_bytes,
131
    Error **errp);
132
133
G_DEFINE_AUTOPTR_CLEANUP_FUNC(pixman_image_t, qemu_pixman_image_unref)
134
135
#endif /* QEMU_PIXMAN_H */