wayland/shm: Send error if client uses unsupported format
Instead of rendering incorrectly (we fell back on some arbitrary format), just send an error. https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
This commit is contained in:
parent
d6b5f89a1c
commit
5a8e4da2a8
@ -186,15 +186,15 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
|
shm_format_to_cogl_pixel_format (enum wl_shm_format shm_format,
|
||||||
CoglPixelFormat *format_out,
|
CoglPixelFormat *format_out,
|
||||||
CoglTextureComponents *components_out)
|
CoglTextureComponents *components_out)
|
||||||
{
|
{
|
||||||
CoglPixelFormat format;
|
CoglPixelFormat format;
|
||||||
CoglTextureComponents components = COGL_TEXTURE_COMPONENTS_RGBA;
|
CoglTextureComponents components = COGL_TEXTURE_COMPONENTS_RGBA;
|
||||||
|
|
||||||
switch (wl_shm_buffer_get_format (shm_buffer))
|
switch (shm_format)
|
||||||
{
|
{
|
||||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
case WL_SHM_FORMAT_ARGB8888:
|
case WL_SHM_FORMAT_ARGB8888:
|
||||||
@ -214,14 +214,36 @@ shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
g_warn_if_reached ();
|
return FALSE;
|
||||||
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_out)
|
if (format_out)
|
||||||
*format_out = format;
|
*format_out = format;
|
||||||
if (components_out)
|
if (components_out)
|
||||||
*components_out = components;
|
*components_out = components;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
shm_buffer_get_cogl_pixel_format (struct wl_shm_buffer *shm_buffer,
|
||||||
|
CoglPixelFormat *format_out,
|
||||||
|
CoglTextureComponents *components_out)
|
||||||
|
{
|
||||||
|
CoglPixelFormat cogl_format;
|
||||||
|
CoglTextureComponents cogl_components;
|
||||||
|
|
||||||
|
if (!shm_format_to_cogl_pixel_format (wl_shm_buffer_get_format (shm_buffer),
|
||||||
|
&cogl_format,
|
||||||
|
&cogl_components))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (format_out)
|
||||||
|
*format_out = cogl_format;
|
||||||
|
if (components_out)
|
||||||
|
*components_out = cogl_components;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -243,7 +265,12 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
|
|||||||
stride = wl_shm_buffer_get_stride (shm_buffer);
|
stride = wl_shm_buffer_get_stride (shm_buffer);
|
||||||
width = wl_shm_buffer_get_width (shm_buffer);
|
width = wl_shm_buffer_get_width (shm_buffer);
|
||||||
height = wl_shm_buffer_get_height (shm_buffer);
|
height = wl_shm_buffer_get_height (shm_buffer);
|
||||||
shm_buffer_get_cogl_pixel_format (shm_buffer, &format, &components);
|
if (!shm_buffer_get_cogl_pixel_format (shm_buffer, &format, &components))
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Invalid shm pixel format");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (*texture &&
|
if (*texture &&
|
||||||
cogl_texture_get_width (*texture) == width &&
|
cogl_texture_get_width (*texture) == width &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user