pixman-renderer: track Pixman formats in pixel format table
Adds a Pixman format field to the pixel format table, and
adjusts the shm format handling code in the Pixman renderer
to use this table.
Pixman formats have been registered only for specific 565, 8888,
and 2101010 layouts, as these have corresponding DRM format codes
and are commonly used.
Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c
index 9c19a55..9064cb6 100644
--- a/libweston/pixel-formats.c
+++ b/libweston/pixel-formats.c
@@ -65,6 +65,8 @@
.bits.a = a_, \
.component_type = PIXEL_COMPONENT_TYPE_FIXED
+#define PIXMAN_FMT(fmt) .pixman_format = (PIXMAN_ ## fmt)
+
#include "shared/weston-egl-ext.h"
/**
@@ -171,6 +173,7 @@
# if __BYTE_ORDER == __LITTLE_ENDIAN
GL_FORMAT(GL_RGB),
GL_TYPE(GL_UNSIGNED_SHORT_5_6_5),
+ PIXMAN_FMT(r5g6b5),
#endif
},
{
@@ -194,6 +197,11 @@
.bpp = 32,
GL_FORMAT(GL_BGRA_EXT),
GL_TYPE(GL_UNSIGNED_BYTE),
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(x8r8g8b8),
+#else
+ PIXMAN_FMT(b8g8r8x8),
+#endif
},
{
DRM_FORMAT(ARGB8888),
@@ -203,12 +211,22 @@
.bpp = 32,
GL_FORMAT(GL_BGRA_EXT),
GL_TYPE(GL_UNSIGNED_BYTE),
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(a8r8g8b8),
+#else
+ PIXMAN_FMT(b8g8r8a8),
+#endif
},
{
DRM_FORMAT(XBGR8888),
BITS_RGBA_FIXED(8, 8, 8, 0),
GL_FORMAT(GL_RGBA),
GL_TYPE(GL_UNSIGNED_BYTE),
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(x8b8g8r8),
+#else
+ PIXMAN_FMT(r8g8b8x8),
+#endif
},
{
DRM_FORMAT(ABGR8888),
@@ -216,35 +234,66 @@
.opaque_substitute = DRM_FORMAT_XBGR8888,
GL_FORMAT(GL_RGBA),
GL_TYPE(GL_UNSIGNED_BYTE),
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(a8b8g8r8),
+#else
+ PIXMAN_FMT(r8g8b8a8),
+#endif
},
{
DRM_FORMAT(RGBX8888),
BITS_RGBA_FIXED(8, 8, 8, 0),
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(r8g8b8x8),
+#else
+ PIXMAN_FMT(x8b8g8r8),
+#endif
},
{
DRM_FORMAT(RGBA8888),
BITS_RGBA_FIXED(8, 8, 8, 8),
.opaque_substitute = DRM_FORMAT_RGBX8888,
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(r8g8b8a8),
+#else
+ PIXMAN_FMT(a8b8g8r8),
+#endif
},
{
DRM_FORMAT(BGRX8888),
BITS_RGBA_FIXED(8, 8, 8, 0),
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(b8g8r8x8),
+#else
+ PIXMAN_FMT(x8r8g8b8),
+#endif
},
{
DRM_FORMAT(BGRA8888),
BITS_RGBA_FIXED(8, 8, 8, 8),
.opaque_substitute = DRM_FORMAT_BGRX8888,
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(b8g8r8a8),
+#else
+ PIXMAN_FMT(a8r8g8b8),
+#endif
},
{
DRM_FORMAT(XRGB2101010),
BITS_RGBA_FIXED(10, 10, 10, 0),
.depth = 30,
.bpp = 32,
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(x2r10g10b10),
+#endif
},
{
DRM_FORMAT(ARGB2101010),
BITS_RGBA_FIXED(10, 10, 10, 2),
.opaque_substitute = DRM_FORMAT_XRGB2101010,
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ PIXMAN_FMT(a2r10g10b10),
+#endif
},
{
DRM_FORMAT(XBGR2101010),
@@ -252,6 +301,7 @@
# if __BYTE_ORDER == __LITTLE_ENDIAN
GL_FORMAT(GL_RGBA),
GL_TYPE(GL_UNSIGNED_INT_2_10_10_10_REV_EXT),
+ PIXMAN_FMT(x2b10g10r10),
#endif
},
{
@@ -261,6 +311,7 @@
# if __BYTE_ORDER == __LITTLE_ENDIAN
GL_FORMAT(GL_RGBA),
GL_TYPE(GL_UNSIGNED_INT_2_10_10_10_REV_EXT),
+ PIXMAN_FMT(a2b10g10r10),
#endif
},
{
@@ -448,6 +499,22 @@
}
WL_EXPORT const struct pixel_format_info *
+pixel_format_get_info_by_index(unsigned int index)
+{
+ if (index >= ARRAY_LENGTH(pixel_format_table))
+ return NULL;
+
+ return &pixel_format_table[index];
+}
+
+WL_EXPORT unsigned int
+pixel_format_get_info_count(void)
+{
+ return ARRAY_LENGTH(pixel_format_table);
+}
+
+
+WL_EXPORT const struct pixel_format_info *
pixel_format_get_info_by_drm_name(const char *drm_format_name)
{
const struct pixel_format_info *info;