2012-11-13 09:38:06 +01:00
|
|
|
/*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
2012-09-25 16:23:24 +02:00
|
|
|
#ifndef QEMU_PIXMAN_H
|
|
|
|
#define QEMU_PIXMAN_H
|
|
|
|
|
2023-08-30 11:38:25 +02:00
|
|
|
#ifdef CONFIG_PIXMAN
|
2012-09-25 16:23:24 +02:00
|
|
|
#include <pixman.h>
|
2023-10-25 14:15:24 +02:00
|
|
|
#else
|
|
|
|
#include "pixman-minimal.h"
|
2023-08-30 11:38:25 +02:00
|
|
|
#endif
|
2012-09-25 16:23:24 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* pixman image formats are defined to be native endian,
|
|
|
|
* that means host byte order on qemu. So we go define
|
|
|
|
* fixed formats here for cases where it is needed, like
|
|
|
|
* feeding libjpeg / libpng and writing screenshots.
|
|
|
|
*/
|
|
|
|
|
2022-03-23 16:57:17 +01:00
|
|
|
#if HOST_BIG_ENDIAN
|
2012-09-25 16:23:24 +02:00
|
|
|
# define PIXMAN_BE_r8g8b8 PIXMAN_r8g8b8
|
2015-01-16 14:44:59 +01:00
|
|
|
# define PIXMAN_BE_x8r8g8b8 PIXMAN_x8r8g8b8
|
|
|
|
# define PIXMAN_BE_a8r8g8b8 PIXMAN_a8r8g8b8
|
|
|
|
# define PIXMAN_BE_b8g8r8x8 PIXMAN_b8g8r8x8
|
|
|
|
# define PIXMAN_BE_b8g8r8a8 PIXMAN_b8g8r8a8
|
|
|
|
# define PIXMAN_BE_r8g8b8x8 PIXMAN_r8g8b8x8
|
|
|
|
# define PIXMAN_BE_r8g8b8a8 PIXMAN_r8g8b8a8
|
|
|
|
# define PIXMAN_BE_x8b8g8r8 PIXMAN_x8b8g8r8
|
|
|
|
# define PIXMAN_BE_a8b8g8r8 PIXMAN_a8b8g8r8
|
2018-03-13 18:17:28 +01:00
|
|
|
# define PIXMAN_LE_r8g8b8 PIXMAN_b8g8r8
|
|
|
|
# define PIXMAN_LE_a8r8g8b8 PIXMAN_b8g8r8a8
|
2015-04-14 08:56:21 +02:00
|
|
|
# define PIXMAN_LE_x8r8g8b8 PIXMAN_b8g8r8x8
|
2023-09-14 03:31:51 +02:00
|
|
|
# define PIXMAN_LE_a8b8g8r8 PIXMAN_r8g8b8a8
|
|
|
|
# define PIXMAN_LE_x8b8g8r8 PIXMAN_r8g8b8x8
|
2012-09-25 16:23:24 +02:00
|
|
|
#else
|
|
|
|
# define PIXMAN_BE_r8g8b8 PIXMAN_b8g8r8
|
2015-01-16 14:44:59 +01:00
|
|
|
# define PIXMAN_BE_x8r8g8b8 PIXMAN_b8g8r8x8
|
|
|
|
# define PIXMAN_BE_a8r8g8b8 PIXMAN_b8g8r8a8
|
|
|
|
# define PIXMAN_BE_b8g8r8x8 PIXMAN_x8r8g8b8
|
|
|
|
# define PIXMAN_BE_b8g8r8a8 PIXMAN_a8r8g8b8
|
|
|
|
# define PIXMAN_BE_r8g8b8x8 PIXMAN_x8b8g8r8
|
|
|
|
# define PIXMAN_BE_r8g8b8a8 PIXMAN_a8b8g8r8
|
|
|
|
# define PIXMAN_BE_x8b8g8r8 PIXMAN_r8g8b8x8
|
|
|
|
# define PIXMAN_BE_a8b8g8r8 PIXMAN_r8g8b8a8
|
2018-03-13 18:17:28 +01:00
|
|
|
# define PIXMAN_LE_r8g8b8 PIXMAN_r8g8b8
|
|
|
|
# define PIXMAN_LE_a8r8g8b8 PIXMAN_a8r8g8b8
|
2015-04-14 08:56:21 +02:00
|
|
|
# define PIXMAN_LE_x8r8g8b8 PIXMAN_x8r8g8b8
|
2023-09-14 03:31:51 +02:00
|
|
|
# define PIXMAN_LE_a8b8g8r8 PIXMAN_a8b8g8r8
|
|
|
|
# define PIXMAN_LE_x8b8g8r8 PIXMAN_x8b8g8r8
|
2012-09-25 16:23:24 +02:00
|
|
|
#endif
|
|
|
|
|
2023-08-30 11:38:10 +02:00
|
|
|
#define QEMU_PIXMAN_COLOR(r, g, b) \
|
|
|
|
{ .red = r << 8, .green = g << 8, .blue = b << 8, .alpha = 0xffff }
|
|
|
|
|
|
|
|
#define QEMU_PIXMAN_COLOR_BLACK QEMU_PIXMAN_COLOR(0x00, 0x00, 0x00)
|
|
|
|
#define QEMU_PIXMAN_COLOR_GRAY QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0xaa)
|
|
|
|
|
2012-09-25 16:23:24 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
2019-01-14 14:08:29 +01:00
|
|
|
typedef struct PixelFormat {
|
|
|
|
uint8_t bits_per_pixel;
|
|
|
|
uint8_t bytes_per_pixel;
|
|
|
|
uint8_t depth; /* color depth in bits */
|
|
|
|
uint32_t rmask, gmask, bmask, amask;
|
|
|
|
uint8_t rshift, gshift, bshift, ashift;
|
|
|
|
uint8_t rmax, gmax, bmax, amax;
|
|
|
|
uint8_t rbits, gbits, bbits, abits;
|
|
|
|
} PixelFormat;
|
|
|
|
|
2014-06-18 09:00:00 +02:00
|
|
|
PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format);
|
2014-06-18 11:31:42 +02:00
|
|
|
pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian);
|
2018-03-13 18:17:28 +01:00
|
|
|
pixman_format_code_t qemu_drm_format_to_pixman(uint32_t drm_format);
|
2021-05-27 01:14:25 +02:00
|
|
|
uint32_t qemu_pixman_to_drm_format(pixman_format_code_t pixman);
|
2012-09-25 16:23:24 +02:00
|
|
|
int qemu_pixman_get_type(int rshift, int gshift, int bshift);
|
2015-01-09 08:49:20 +01:00
|
|
|
bool qemu_pixman_check_format(DisplayChangeListener *dcl,
|
|
|
|
pixman_format_code_t format);
|
2012-09-25 16:23:24 +02:00
|
|
|
|
2023-08-30 11:38:26 +02:00
|
|
|
#ifdef CONFIG_PIXMAN
|
|
|
|
pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf);
|
2012-09-25 16:23:24 +02:00
|
|
|
pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
|
|
|
|
int width);
|
|
|
|
void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
|
2012-12-14 08:54:24 +01:00
|
|
|
int width, int x, int y);
|
2012-11-02 09:12:49 +01:00
|
|
|
pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
|
|
|
|
pixman_image_t *image);
|
2012-09-25 16:23:24 +02:00
|
|
|
|
2013-03-07 15:23:48 +01:00
|
|
|
pixman_image_t *qemu_pixman_glyph_from_vgafont(int height, const uint8_t *font,
|
|
|
|
unsigned int ch);
|
|
|
|
void qemu_pixman_glyph_render(pixman_image_t *glyph,
|
|
|
|
pixman_image_t *surface,
|
|
|
|
pixman_color_t *fgcol,
|
|
|
|
pixman_color_t *bgcol,
|
|
|
|
int x, int y, int cw, int ch);
|
2023-08-30 11:38:26 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void qemu_pixman_image_unref(pixman_image_t *image);
|
2013-03-06 14:14:17 +01:00
|
|
|
|
2019-11-08 14:31:18 +01:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(pixman_image_t, qemu_pixman_image_unref)
|
|
|
|
|
2012-09-25 16:23:24 +02:00
|
|
|
#endif /* QEMU_PIXMAN_H */
|