1
0
Fork 0

cursor-renderer-native: fallback to texture cursor

In some cases the hardware cursor is invisible when Mutter is launched from the
TTY, due to drmModeSetCursor2 failing without a fallback being set.

This patch captures the return value of drmModeSetCursor2 and in case of an
error, enables the texture based fallback. It adds a `broken` state, that is
checked in should_have_hw_cursor() and
meta_cursor_renderer_native_realize_cursor_from_*() to avoid copying every
cursor into a gbm buffer when we know it will fail every single time.

https://bugzilla.gnome.org/show_bug.cgi?id=770020
This commit is contained in:
Jente Hidskes 2017-03-24 22:12:54 +01:00 committed by Jonas Ådahl
parent 42c0809216
commit 0d5274b3b7

View file

@ -65,6 +65,7 @@ struct _MetaCursorRendererNativePrivate
{
gboolean hw_state_invalidated;
gboolean has_hw_cursor;
gboolean hw_cursor_broken;
MetaCursorSprite *last_cursor;
guint animation_timeout_id;
@ -185,8 +186,13 @@ set_crtc_cursor (MetaCursorRendererNative *native,
handle = gbm_bo_get_handle (bo);
meta_cursor_sprite_get_hotspot (cursor_sprite, &hot_x, &hot_y);
drmModeSetCursor2 (priv->drm_fd, crtc->crtc_id, handle.u32,
priv->cursor_width, priv->cursor_height, hot_x, hot_y);
if (drmModeSetCursor2 (priv->drm_fd, crtc->crtc_id, handle.u32,
priv->cursor_width, priv->cursor_height,
hot_x, hot_y) < 0)
{
priv->has_hw_cursor = FALSE;
priv->hw_cursor_broken = TRUE;
}
if (cursor_priv->pending_bo_state == META_CURSOR_GBM_BO_STATE_SET)
{
@ -311,8 +317,13 @@ static gboolean
should_have_hw_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
CoglTexture *texture;
if (priv->hw_cursor_broken)
return FALSE;
if (!cursor_sprite)
return FALSE;
@ -528,7 +539,7 @@ meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *r
CoglTexture *texture;
uint width, height;
if (!priv->gbm)
if (!priv->gbm || priv->hw_cursor_broken)
return;
/* Destroy any previous pending cursor buffer; we'll always either fail (which
@ -621,7 +632,7 @@ meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *ren
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
if (!priv->gbm)
if (!priv->gbm || priv->hw_cursor_broken)
return;
invalidate_pending_cursor_sprite_gbm_bo (cursor_sprite);