Commit 3f6433b8 authored by Manuel Stoeckl's avatar Manuel Stoeckl
Browse files

Add a few 30-bit wl_shm formats

Register WL_SHM_FORMAT_ARGB2101010 and its XRGB,ABGR, and XBGR variants.
These (little-endian) formats are only advertised on little endian
machines, where there exist matching (native-endian) QImage formats.
parent 00f112f4
......@@ -71,8 +71,12 @@ void ShmClientBufferPrivate::buffer_destroy_callback(wl_listener *listener, void
static bool alphaChannelFromFormat(uint32_t format)
{
switch (format) {
case WL_SHM_FORMAT_ABGR2101010:
case WL_SHM_FORMAT_ARGB2101010:
case WL_SHM_FORMAT_ARGB8888:
return true;
case WL_SHM_FORMAT_XBGR2101010:
case WL_SHM_FORMAT_XRGB2101010:
case WL_SHM_FORMAT_XRGB8888:
default:
return false;
......@@ -82,6 +86,16 @@ static bool alphaChannelFromFormat(uint32_t format)
static QImage::Format imageFormatForShmFormat(uint32_t format)
{
switch (format) {
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
case WL_SHM_FORMAT_ARGB2101010:
return QImage::Format_A2RGB30_Premultiplied;
case WL_SHM_FORMAT_XRGB2101010:
return QImage::Format_RGB30;
case WL_SHM_FORMAT_ABGR2101010:
return QImage::Format_A2BGR30_Premultiplied;
case WL_SHM_FORMAT_XBGR2101010:
return QImage::Format_BGR30;
#endif
case WL_SHM_FORMAT_ARGB8888:
return QImage::Format_ARGB32_Premultiplied;
case WL_SHM_FORMAT_XRGB8888:
......@@ -158,6 +172,12 @@ QImage ShmClientBuffer::data() const
ShmClientBufferIntegration::ShmClientBufferIntegration(Display *display)
: ClientBufferIntegration(display)
{
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
wl_display_add_shm_format(*display, WL_SHM_FORMAT_ARGB2101010);
wl_display_add_shm_format(*display, WL_SHM_FORMAT_XRGB2101010);
wl_display_add_shm_format(*display, WL_SHM_FORMAT_ABGR2101010);
wl_display_add_shm_format(*display, WL_SHM_FORMAT_XBGR2101010);
#endif
wl_display_init_shm(*display);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment