mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-15 08:56:26 -05:00
render: introduce pixman renderer
This commit is contained in:
parent
9de93a866f
commit
0d90dddfab
8 changed files with 522 additions and 0 deletions
59
render/pixman/pixel_format.c
Normal file
59
render/pixman/pixel_format.c
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#include <drm_fourcc.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "render/pixman.h"
|
||||
|
||||
static const struct wlr_pixman_pixel_format formats[] = {
|
||||
{
|
||||
.drm_format = DRM_FORMAT_ARGB8888,
|
||||
#if WLR_BIG_ENDIAN
|
||||
.pixman_format = PIXMAN_b8g8r8a8,
|
||||
#else
|
||||
.pixman_format = PIXMAN_a8r8g8b8,
|
||||
#endif
|
||||
},
|
||||
{
|
||||
.drm_format = DRM_FORMAT_XBGR8888,
|
||||
#if WLR_BIG_ENDIAN
|
||||
.pixman_format = PIXMAN_r8g8b8x8,
|
||||
#else
|
||||
.pixman_format = PIXMAN_x8b8g8r8,
|
||||
#endif
|
||||
},
|
||||
{
|
||||
.drm_format = DRM_FORMAT_XRGB8888,
|
||||
#if WLR_BIG_ENDIAN
|
||||
.pixman_format = PIXMAN_b8g8r8x8,
|
||||
#else
|
||||
.pixman_format = PIXMAN_x8r8g8b8,
|
||||
#endif
|
||||
},
|
||||
{
|
||||
.drm_format = DRM_FORMAT_ABGR8888,
|
||||
#if WLR_BIG_ENDIAN
|
||||
.pixman_format = PIXMAN_r8g8b8a8,
|
||||
#else
|
||||
.pixman_format = PIXMAN_a8b8g8r8,
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
pixman_format_code_t get_pixman_format_from_drm(uint32_t fmt) {
|
||||
for (size_t i = 0; i < sizeof(formats) / sizeof(*formats); ++i) {
|
||||
if (formats[i].drm_format == fmt) {
|
||||
return formats[i].pixman_format;
|
||||
}
|
||||
}
|
||||
|
||||
wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" has no pixman equivalent", fmt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint32_t *get_pixman_drm_formats(size_t *len) {
|
||||
static uint32_t drm_formats[sizeof(formats) / sizeof(formats[0])];
|
||||
*len = sizeof(formats) / sizeof(formats[0]);
|
||||
for (size_t i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
|
||||
drm_formats[i] = formats[i].drm_format;
|
||||
}
|
||||
return drm_formats;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue