wayland/shm: Advertise support for RGB565

Doesn't hurt to support it, could save memory bandwidth would any client
use it without degrading visual quality.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
This commit is contained in:
Jonas Ådahl 2019-09-18 16:18:58 +02:00 committed by Robert Mader
parent 5a8e4da2a8
commit 2d6040e2a3
3 changed files with 25 additions and 1 deletions

View File

@ -57,6 +57,7 @@
#include "cogl/cogl-egl.h" #include "cogl/cogl-egl.h"
#include "meta/util.h" #include "meta/util.h"
#include "wayland/meta-wayland-dma-buf.h" #include "wayland/meta-wayland-dma-buf.h"
#include "wayland/meta-wayland-private.h"
#ifdef HAVE_NATIVE_BACKEND #ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-drm-buffer-gbm.h" #include "backends/native/meta-drm-buffer-gbm.h"
@ -205,6 +206,10 @@ shm_format_to_cogl_pixel_format (enum wl_shm_format shm_format,
components = COGL_TEXTURE_COMPONENTS_RGB; components = COGL_TEXTURE_COMPONENTS_RGB;
break; break;
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN #elif G_BYTE_ORDER == G_LITTLE_ENDIAN
case WL_SHM_FORMAT_RGB565:
format = COGL_PIXEL_FORMAT_RGB_565;
components = COGL_TEXTURE_COMPONENTS_RGB;
break;
case WL_SHM_FORMAT_ARGB8888: case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888_PRE; format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
break; break;
@ -736,3 +741,19 @@ meta_wayland_buffer_class_init (MetaWaylandBufferClass *klass)
NULL, NULL, NULL, NULL, NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
} }
void
meta_wayland_init_shm (MetaWaylandCompositor *compositor)
{
static const enum wl_shm_format shm_formats[] = {
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
WL_SHM_FORMAT_RGB565,
#endif
};
int i;
wl_display_init_shm (compositor->wayland_display);
for (i = 0; i < G_N_ELEMENTS (shm_formats); i++)
wl_display_add_shm_format (compositor->wayland_display, shm_formats[i]);
}

View File

@ -91,4 +91,6 @@ void meta_wayland_buffer_process_damage (MetaWaylandBuff
CoglScanout * meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer, CoglScanout * meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
CoglOnscreen *onscreen); CoglOnscreen *onscreen);
void meta_wayland_init_shm (MetaWaylandCompositor *compositor);
#endif /* META_WAYLAND_BUFFER_H */ #endif /* META_WAYLAND_BUFFER_H */

View File

@ -31,6 +31,7 @@
#include "clutter/clutter.h" #include "clutter/clutter.h"
#include "clutter/wayland/clutter-wayland-compositor.h" #include "clutter/wayland/clutter-wayland-compositor.h"
#include "core/main-private.h" #include "core/main-private.h"
#include "wayland/meta-wayland-buffer.h"
#include "wayland/meta-wayland-data-device.h" #include "wayland/meta-wayland-data-device.h"
#include "wayland/meta-wayland-dma-buf.h" #include "wayland/meta-wayland-dma-buf.h"
#include "wayland/meta-wayland-egl-stream.h" #include "wayland/meta-wayland-egl-stream.h"
@ -428,7 +429,7 @@ meta_wayland_compositor_setup (MetaWaylandCompositor *compositor)
compositor, compositor_bind)) compositor, compositor_bind))
g_error ("Failed to register the global wl_compositor"); g_error ("Failed to register the global wl_compositor");
wl_display_init_shm (compositor->wayland_display); meta_wayland_init_shm (compositor);
meta_wayland_outputs_init (compositor); meta_wayland_outputs_init (compositor);
meta_wayland_data_device_manager_init (compositor); meta_wayland_data_device_manager_init (compositor);