mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
wayland: Updates the wayland compositor side support
The compositor side wayland support enabling us to create textures from wayland buffers needed updating since visuals were removed from the wayland protocol. This also fixes the #ifdef guards for the bind_wayland_display extension in cogl-winsys-egl-feature-functions.h since it was mistakenly checking that client-side wayland support had been enabled which won't be the case. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
14ddbd980b
commit
79f20d08b6
@ -493,45 +493,52 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
|
||||
#endif /* defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) */
|
||||
|
||||
#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT
|
||||
static CoglPixelFormat
|
||||
get_buffer_format (struct wl_buffer *buffer)
|
||||
{
|
||||
struct wl_compositor *compositor = buffer->compositor;
|
||||
struct wl_visual *visual = buffer->visual;
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
if (visual == &compositor->premultiplied_argb_visual)
|
||||
return COGL_PIXEL_FORMAT_ARGB_8888_PRE;
|
||||
else if (visual == &compositor->argb_visual)
|
||||
return COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
else if (visual == &compositor->rgb_visual)
|
||||
return COGL_PIXEL_FORMAT_RGB_888;
|
||||
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
if (visual == &compositor->premultiplied_argb_visual)
|
||||
return COGL_PIXEL_FORMAT_BGRA_8888_PRE;
|
||||
else if (visual == &compositor->argb_visual)
|
||||
return COGL_PIXEL_FORMAT_BGRA_8888;
|
||||
else if (visual == &compositor->rgb_visual)
|
||||
return COGL_PIXEL_FORMAT_BGR_888;
|
||||
#endif
|
||||
else
|
||||
g_return_val_if_reached (COGL_PIXEL_FORMAT_ANY);
|
||||
}
|
||||
|
||||
CoglTexture2D *
|
||||
cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
|
||||
struct wl_buffer *buffer,
|
||||
GError **error)
|
||||
{
|
||||
CoglPixelFormat format = get_buffer_format (buffer);
|
||||
|
||||
if (wl_buffer_is_shm (buffer))
|
||||
{
|
||||
int stride = wl_shm_buffer_get_stride (buffer);
|
||||
CoglPixelFormat format;
|
||||
CoglPixelFormat internal_format = COGL_PIXEL_FORMAT_ANY;
|
||||
|
||||
switch (wl_shm_buffer_get_format (buffer))
|
||||
{
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32:
|
||||
format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
|
||||
break;
|
||||
case WL_SHM_FORMAT_ARGB32:
|
||||
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XRGB32:
|
||||
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
internal_format = COGL_PIXEL_FORMAT_RGB_888;
|
||||
break;
|
||||
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32:
|
||||
format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
|
||||
break;
|
||||
case WL_SHM_FORMAT_ARGB32:
|
||||
format = COGL_PIXEL_FORMAT_BGRA_8888;
|
||||
break;
|
||||
case WL_SHM_FORMAT_XRGB32:
|
||||
format = COGL_PIXEL_FORMAT_BGRA_8888;
|
||||
internal_format = COGL_PIXEL_FORMAT_BGR_888;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
g_warn_if_reached ();
|
||||
format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||
}
|
||||
|
||||
return cogl_texture_2d_new_from_data (ctx,
|
||||
buffer->width,
|
||||
buffer->height,
|
||||
format,
|
||||
COGL_PIXEL_FORMAT_ANY,
|
||||
internal_format,
|
||||
stride,
|
||||
wl_shm_buffer_get_data (buffer),
|
||||
error);
|
||||
@ -547,10 +554,11 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
|
||||
EGL_WAYLAND_BUFFER_WL,
|
||||
buffer,
|
||||
NULL);
|
||||
#warning "XXX: without a way to query the format of a wayland buffer we have to guess!"
|
||||
return _cogl_egl_texture_2d_new_from_image (ctx,
|
||||
buffer->width,
|
||||
buffer->height,
|
||||
format,
|
||||
COGL_PIXEL_FORMAT_ARGB_8888_PRE,
|
||||
image,
|
||||
error);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ COGL_WINSYS_FEATURE_BEGIN (image_pixmap,
|
||||
"image_pixmap\0",
|
||||
COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_X11_PIXMAP)
|
||||
COGL_WINSYS_FEATURE_END ()
|
||||
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
||||
#ifdef EGL_WL_bind_wayland_display
|
||||
COGL_WINSYS_FEATURE_BEGIN (bind_wayland_display,
|
||||
"WL\0",
|
||||
"bind_wayland_display\0",
|
||||
|
Loading…
Reference in New Issue
Block a user