Make gbm optional
Now it's only required by the native backend. The cursor code is getting quite messy, but it was already considerable messy to start with.
This commit is contained in:
parent
60ab11ecbf
commit
d88c8d9ced
@ -201,7 +201,7 @@ AC_SUBST(XWAYLAND_PATH)
|
|||||||
|
|
||||||
PKG_CHECK_MODULES(MUTTER, $MUTTER_PC_MODULES)
|
PKG_CHECK_MODULES(MUTTER, $MUTTER_PC_MODULES)
|
||||||
|
|
||||||
PKG_CHECK_MODULES(MUTTER_NATIVE_BACKEND, [clutter-egl-1.0 libdrm libsystemd libinput gudev-1.0], [have_native_backend=yes], [have_native_backend=no])
|
PKG_CHECK_MODULES(MUTTER_NATIVE_BACKEND, [clutter-egl-1.0 libdrm libsystemd libinput gudev-1.0 gbm >= 10.3], [have_native_backend=yes], [have_native_backend=no])
|
||||||
if test $have_native_backend = yes; then
|
if test $have_native_backend = yes; then
|
||||||
AC_DEFINE([HAVE_NATIVE_BACKEND],[1],[Define if you want to enable the native (KMS) backend based on systemd])
|
AC_DEFINE([HAVE_NATIVE_BACKEND],[1],[Define if you want to enable the native (KMS) backend based on systemd])
|
||||||
fi
|
fi
|
||||||
|
@ -29,8 +29,11 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
CoglTexture2D *texture;
|
CoglTexture2D *texture;
|
||||||
struct gbm_bo *bo;
|
|
||||||
int hot_x, hot_y;
|
int hot_x, hot_y;
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
|
struct gbm_bo *bo;
|
||||||
|
#endif
|
||||||
} MetaCursorImage;
|
} MetaCursorImage;
|
||||||
|
|
||||||
struct _MetaCursorReference {
|
struct _MetaCursorReference {
|
||||||
@ -44,8 +47,10 @@ CoglTexture *meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor
|
|||||||
int *hot_x,
|
int *hot_x,
|
||||||
int *hot_y);
|
int *hot_y);
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
struct gbm_bo *meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
struct gbm_bo *meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
||||||
int *hot_x,
|
int *hot_x,
|
||||||
int *hot_y);
|
int *hot_y);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* META_CURSOR_PRIVATE_H */
|
#endif /* META_CURSOR_PRIVATE_H */
|
||||||
|
@ -56,8 +56,11 @@ static void
|
|||||||
meta_cursor_image_free (MetaCursorImage *image)
|
meta_cursor_image_free (MetaCursorImage *image)
|
||||||
{
|
{
|
||||||
cogl_object_unref (image->texture);
|
cogl_object_unref (image->texture);
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
if (image->bo)
|
if (image->bo)
|
||||||
gbm_bo_destroy (image->bo);
|
gbm_bo_destroy (image->bo);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -139,10 +142,10 @@ load_cursor_on_client (MetaCursor cursor)
|
|||||||
meta_prefs_get_cursor_size ());
|
meta_prefs_get_cursor_size ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
static void
|
static void
|
||||||
get_hardware_cursor_size (uint64_t *cursor_width, uint64_t *cursor_height)
|
get_hardware_cursor_size (uint64_t *cursor_width, uint64_t *cursor_height)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NATIVE_BACKEND
|
|
||||||
MetaBackend *meta_backend = meta_get_backend ();
|
MetaBackend *meta_backend = meta_get_backend ();
|
||||||
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (meta_backend);
|
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (meta_backend);
|
||||||
|
|
||||||
@ -151,11 +154,12 @@ get_hardware_cursor_size (uint64_t *cursor_width, uint64_t *cursor_height)
|
|||||||
meta_cursor_renderer_native_get_cursor_size (META_CURSOR_RENDERER_NATIVE (renderer), cursor_width, cursor_height);
|
meta_cursor_renderer_native_get_cursor_size (META_CURSOR_RENDERER_NATIVE (renderer), cursor_width, cursor_height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
static void
|
static void
|
||||||
meta_cursor_image_load_gbm_buffer (struct gbm_device *gbm,
|
meta_cursor_image_load_gbm_buffer (struct gbm_device *gbm,
|
||||||
MetaCursorImage *image,
|
MetaCursorImage *image,
|
||||||
@ -193,20 +197,21 @@ meta_cursor_image_load_gbm_buffer (struct gbm_device *gbm,
|
|||||||
else
|
else
|
||||||
meta_warning ("HW cursor for format %d not supported\n", gbm_format);
|
meta_warning ("HW cursor for format %d not supported\n", gbm_format);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
static struct gbm_device *
|
static struct gbm_device *
|
||||||
get_gbm_device (void)
|
get_gbm_device (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NATIVE_BACKEND
|
|
||||||
MetaBackend *meta_backend = meta_get_backend ();
|
MetaBackend *meta_backend = meta_get_backend ();
|
||||||
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (meta_backend);
|
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (meta_backend);
|
||||||
|
|
||||||
if (META_IS_CURSOR_RENDERER_NATIVE (renderer))
|
if (META_IS_CURSOR_RENDERER_NATIVE (renderer))
|
||||||
return meta_cursor_renderer_native_get_gbm_device (META_CURSOR_RENDERER_NATIVE (renderer));
|
return meta_cursor_renderer_native_get_gbm_device (META_CURSOR_RENDERER_NATIVE (renderer));
|
||||||
#endif
|
else
|
||||||
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_image_load_from_xcursor_image (MetaCursorImage *image,
|
meta_cursor_image_load_from_xcursor_image (MetaCursorImage *image,
|
||||||
@ -214,16 +219,13 @@ meta_cursor_image_load_from_xcursor_image (MetaCursorImage *image,
|
|||||||
{
|
{
|
||||||
uint width, height, rowstride;
|
uint width, height, rowstride;
|
||||||
CoglPixelFormat cogl_format;
|
CoglPixelFormat cogl_format;
|
||||||
uint32_t gbm_format;
|
|
||||||
ClutterBackend *clutter_backend;
|
ClutterBackend *clutter_backend;
|
||||||
CoglContext *cogl_context;
|
CoglContext *cogl_context;
|
||||||
struct gbm_device *gbm;
|
|
||||||
|
|
||||||
width = xc_image->width;
|
width = xc_image->width;
|
||||||
height = xc_image->height;
|
height = xc_image->height;
|
||||||
rowstride = width * 4;
|
rowstride = width * 4;
|
||||||
|
|
||||||
gbm_format = GBM_FORMAT_ARGB8888;
|
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
|
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
|
||||||
#else
|
#else
|
||||||
@ -242,13 +244,15 @@ meta_cursor_image_load_from_xcursor_image (MetaCursorImage *image,
|
|||||||
(uint8_t *) xc_image->pixels,
|
(uint8_t *) xc_image->pixels,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gbm = get_gbm_device ();
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
|
struct gbm_device *gbm = get_gbm_device ();
|
||||||
if (gbm)
|
if (gbm)
|
||||||
meta_cursor_image_load_gbm_buffer (gbm,
|
meta_cursor_image_load_gbm_buffer (gbm,
|
||||||
image,
|
image,
|
||||||
(uint8_t *) xc_image->pixels,
|
(uint8_t *) xc_image->pixels,
|
||||||
width, height, rowstride,
|
width, height, rowstride,
|
||||||
gbm_format);
|
GBM_FORMAT_ARGB8888);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaCursorReference *
|
MetaCursorReference *
|
||||||
@ -277,13 +281,8 @@ meta_cursor_image_load_from_buffer (MetaCursorImage *image,
|
|||||||
int hot_x,
|
int hot_x,
|
||||||
int hot_y)
|
int hot_y)
|
||||||
{
|
{
|
||||||
struct gbm_device *gbm = get_gbm_device ();
|
|
||||||
|
|
||||||
ClutterBackend *backend;
|
ClutterBackend *backend;
|
||||||
CoglContext *cogl_context;
|
CoglContext *cogl_context;
|
||||||
uint32_t gbm_format;
|
|
||||||
uint64_t cursor_width, cursor_height;
|
|
||||||
uint width, height;
|
|
||||||
|
|
||||||
image->hot_x = hot_x;
|
image->hot_x = hot_x;
|
||||||
image->hot_y = hot_y;
|
image->hot_y = hot_y;
|
||||||
@ -293,11 +292,17 @@ meta_cursor_image_load_from_buffer (MetaCursorImage *image,
|
|||||||
|
|
||||||
image->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, NULL);
|
image->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, NULL);
|
||||||
|
|
||||||
width = cogl_texture_get_width (COGL_TEXTURE (image->texture));
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
height = cogl_texture_get_height (COGL_TEXTURE (image->texture));
|
struct gbm_device *gbm = get_gbm_device ();
|
||||||
|
|
||||||
if (gbm)
|
if (gbm)
|
||||||
{
|
{
|
||||||
|
uint32_t gbm_format;
|
||||||
|
uint64_t cursor_width, cursor_height;
|
||||||
|
uint width, height;
|
||||||
|
|
||||||
|
width = cogl_texture_get_width (COGL_TEXTURE (image->texture));
|
||||||
|
height = cogl_texture_get_height (COGL_TEXTURE (image->texture));
|
||||||
|
|
||||||
struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get (buffer);
|
struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get (buffer);
|
||||||
if (shm_buffer)
|
if (shm_buffer)
|
||||||
{
|
{
|
||||||
@ -352,6 +357,7 @@ meta_cursor_image_load_from_buffer (MetaCursorImage *image,
|
|||||||
meta_warning ("Importing HW cursor from wl_buffer failed\n");
|
meta_warning ("Importing HW cursor from wl_buffer failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaCursorReference *
|
MetaCursorReference *
|
||||||
@ -381,6 +387,7 @@ meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
|
|||||||
return COGL_TEXTURE (cursor->image.texture);
|
return COGL_TEXTURE (cursor->image.texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
struct gbm_bo *
|
struct gbm_bo *
|
||||||
meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
||||||
int *hot_x,
|
int *hot_x,
|
||||||
@ -392,6 +399,7 @@ meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
|
|||||||
*hot_y = cursor->image.hot_y;
|
*hot_y = cursor->image.hot_y;
|
||||||
return cursor->image.bo;
|
return cursor->image.bo;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
MetaCursor
|
MetaCursor
|
||||||
meta_cursor_reference_get_meta_cursor (MetaCursorReference *cursor)
|
meta_cursor_reference_get_meta_cursor (MetaCursorReference *cursor)
|
||||||
|
Loading…
Reference in New Issue
Block a user