mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
backends: Move HW cursor inhibitors to MetaBackend
We are aiming for a split of HW and SW cursor rendering management. Given the HW plane is a limited resource and the amount of cursor renderers may be >1 (due to tablets, even though we currently use an always-software cursor renderer there), it would ideally be able to switch between renderers. Being MetaCursorRenderer not really a singleton, having cursor inhibitor accounting here doesn't pan out. Make it MetaBackend API so all cursor renderers get the same picture. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403
This commit is contained in:
parent
8a2b529ca3
commit
05f385c8ee
@ -196,4 +196,12 @@ GList * meta_backend_get_gpus (MetaBackend *backend);
|
||||
WacomDeviceDatabase * meta_backend_get_wacom_database (MetaBackend *backend);
|
||||
#endif
|
||||
|
||||
void meta_backend_add_hw_cursor_inhibitor (MetaBackend *backend,
|
||||
MetaHwCursorInhibitor *inhibitor);
|
||||
|
||||
void meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend,
|
||||
MetaHwCursorInhibitor *inhibitor);
|
||||
|
||||
gboolean meta_backend_is_hw_cursors_inhibited (MetaBackend *backend);
|
||||
|
||||
#endif /* META_BACKEND_PRIVATE_H */
|
||||
|
@ -53,6 +53,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "backends/meta-cursor-renderer.h"
|
||||
#include "backends/meta-cursor-tracker-private.h"
|
||||
#include "backends/meta-idle-monitor-private.h"
|
||||
#include "backends/meta-input-settings-private.h"
|
||||
@ -150,6 +151,7 @@ struct _MetaBackendPrivate
|
||||
ClutterActor *stage;
|
||||
|
||||
GList *gpus;
|
||||
GList *hw_cursor_inhibitors;
|
||||
|
||||
gboolean is_pointer_position_initialized;
|
||||
|
||||
@ -1503,3 +1505,40 @@ meta_backend_get_wacom_database (MetaBackend *backend)
|
||||
return priv->wacom_db;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
meta_backend_add_hw_cursor_inhibitor (MetaBackend *backend,
|
||||
MetaHwCursorInhibitor *inhibitor)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
|
||||
priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors,
|
||||
inhibitor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_remove_hw_cursor_inhibitor (MetaBackend *backend,
|
||||
MetaHwCursorInhibitor *inhibitor)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
|
||||
priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors,
|
||||
inhibitor);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_backend_is_hw_cursors_inhibited (MetaBackend *backend)
|
||||
{
|
||||
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||
GList *l;
|
||||
|
||||
for (l = priv->hw_cursor_inhibitors; l; l = l->next)
|
||||
{
|
||||
MetaHwCursorInhibitor *inhibitor = l->data;
|
||||
|
||||
if (meta_hw_cursor_inhibitor_is_cursor_inhibited (inhibitor))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ static guint signals[LAST_SIGNAL];
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRenderer, meta_cursor_renderer, G_TYPE_OBJECT);
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
meta_hw_cursor_inhibitor_is_cursor_inhibited (MetaHwCursorInhibitor *inhibitor)
|
||||
{
|
||||
MetaHwCursorInhibitorInterface *iface =
|
||||
@ -475,46 +475,6 @@ meta_cursor_renderer_is_overlay_visible (MetaCursorRenderer *renderer)
|
||||
return meta_overlay_is_visible (priv->stage_overlay);
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_renderer_add_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
|
||||
MetaHwCursorInhibitor *inhibitor)
|
||||
{
|
||||
MetaCursorRendererPrivate *priv =
|
||||
meta_cursor_renderer_get_instance_private (renderer);
|
||||
|
||||
priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors,
|
||||
inhibitor);
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
|
||||
MetaHwCursorInhibitor *inhibitor)
|
||||
{
|
||||
MetaCursorRendererPrivate *priv =
|
||||
meta_cursor_renderer_get_instance_private (renderer);
|
||||
|
||||
priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors,
|
||||
inhibitor);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer)
|
||||
{
|
||||
MetaCursorRendererPrivate *priv =
|
||||
meta_cursor_renderer_get_instance_private (renderer);
|
||||
GList *l;
|
||||
|
||||
for (l = priv->hw_cursor_inhibitors; l; l = l->next)
|
||||
{
|
||||
MetaHwCursorInhibitor *inhibitor = l->data;
|
||||
|
||||
if (meta_hw_cursor_inhibitor_is_cursor_inhibited (inhibitor))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ClutterInputDevice *
|
||||
meta_cursor_renderer_get_input_device (MetaCursorRenderer *renderer)
|
||||
{
|
||||
|
@ -41,6 +41,8 @@ struct _MetaHwCursorInhibitorInterface
|
||||
gboolean (* is_cursor_inhibited) (MetaHwCursorInhibitor *inhibitor);
|
||||
};
|
||||
|
||||
gboolean meta_hw_cursor_inhibitor_is_cursor_inhibited (MetaHwCursorInhibitor *inhibitor);
|
||||
|
||||
#define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
|
||||
META, CURSOR_RENDERER, GObject);
|
||||
@ -66,14 +68,6 @@ MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer
|
||||
|
||||
gboolean meta_cursor_renderer_is_overlay_visible (MetaCursorRenderer *renderer);
|
||||
|
||||
void meta_cursor_renderer_add_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
|
||||
MetaHwCursorInhibitor *inhibitor);
|
||||
|
||||
void meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
|
||||
MetaHwCursorInhibitor *inhibitor);
|
||||
|
||||
gboolean meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer);
|
||||
|
||||
graphene_rect_t meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite);
|
||||
|
||||
|
@ -83,19 +83,6 @@ get_backend (MetaScreenCastAreaStreamSrc *area_src)
|
||||
return meta_screen_cast_get_backend (screen_cast);
|
||||
}
|
||||
|
||||
static MetaCursorRenderer *
|
||||
get_cursor_renderer (MetaScreenCastAreaStreamSrc *area_src)
|
||||
{
|
||||
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (area_src);
|
||||
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
|
||||
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
|
||||
MetaScreenCast *screen_cast =
|
||||
meta_screen_cast_session_get_screen_cast (session);
|
||||
MetaBackend *backend = meta_screen_cast_get_backend (screen_cast);
|
||||
|
||||
return meta_backend_get_cursor_renderer (backend);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_screen_cast_area_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
||||
int *width,
|
||||
@ -202,14 +189,14 @@ cursor_changed (MetaCursorTracker *cursor_tracker,
|
||||
static void
|
||||
inhibit_hw_cursor (MetaScreenCastAreaStreamSrc *area_src)
|
||||
{
|
||||
MetaCursorRenderer *cursor_renderer;
|
||||
MetaHwCursorInhibitor *inhibitor;
|
||||
MetaBackend *backend;
|
||||
|
||||
g_return_if_fail (!area_src->hw_cursor_inhibited);
|
||||
|
||||
cursor_renderer = get_cursor_renderer (area_src);
|
||||
backend = get_backend (area_src);
|
||||
inhibitor = META_HW_CURSOR_INHIBITOR (area_src);
|
||||
meta_cursor_renderer_add_hw_cursor_inhibitor (cursor_renderer, inhibitor);
|
||||
meta_backend_add_hw_cursor_inhibitor (backend, inhibitor);
|
||||
|
||||
area_src->hw_cursor_inhibited = TRUE;
|
||||
}
|
||||
@ -217,14 +204,14 @@ inhibit_hw_cursor (MetaScreenCastAreaStreamSrc *area_src)
|
||||
static void
|
||||
uninhibit_hw_cursor (MetaScreenCastAreaStreamSrc *area_src)
|
||||
{
|
||||
MetaCursorRenderer *cursor_renderer;
|
||||
MetaHwCursorInhibitor *inhibitor;
|
||||
MetaBackend *backend;
|
||||
|
||||
g_return_if_fail (area_src->hw_cursor_inhibited);
|
||||
|
||||
cursor_renderer = get_cursor_renderer (area_src);
|
||||
backend = get_backend (area_src);
|
||||
inhibitor = META_HW_CURSOR_INHIBITOR (area_src);
|
||||
meta_cursor_renderer_remove_hw_cursor_inhibitor (cursor_renderer, inhibitor);
|
||||
meta_backend_remove_hw_cursor_inhibitor (backend, inhibitor);
|
||||
|
||||
area_src->hw_cursor_inhibited = FALSE;
|
||||
}
|
||||
|
@ -236,30 +236,17 @@ cursor_changed (MetaCursorTracker *cursor_tracker,
|
||||
sync_cursor_state (monitor_src);
|
||||
}
|
||||
|
||||
static MetaCursorRenderer *
|
||||
get_cursor_renderer (MetaScreenCastMonitorStreamSrc *monitor_src)
|
||||
{
|
||||
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
|
||||
MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
|
||||
MetaScreenCastSession *session = meta_screen_cast_stream_get_session (stream);
|
||||
MetaScreenCast *screen_cast =
|
||||
meta_screen_cast_session_get_screen_cast (session);
|
||||
MetaBackend *backend = meta_screen_cast_get_backend (screen_cast);
|
||||
|
||||
return meta_backend_get_cursor_renderer (backend);
|
||||
}
|
||||
|
||||
static void
|
||||
inhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src)
|
||||
{
|
||||
MetaCursorRenderer *cursor_renderer;
|
||||
MetaHwCursorInhibitor *inhibitor;
|
||||
MetaBackend *backend;
|
||||
|
||||
g_return_if_fail (!monitor_src->hw_cursor_inhibited);
|
||||
|
||||
cursor_renderer = get_cursor_renderer (monitor_src);
|
||||
backend = get_backend (monitor_src);
|
||||
inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src);
|
||||
meta_cursor_renderer_add_hw_cursor_inhibitor (cursor_renderer, inhibitor);
|
||||
meta_backend_add_hw_cursor_inhibitor (backend, inhibitor);
|
||||
|
||||
monitor_src->hw_cursor_inhibited = TRUE;
|
||||
}
|
||||
@ -267,14 +254,14 @@ inhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src)
|
||||
static void
|
||||
uninhibit_hw_cursor (MetaScreenCastMonitorStreamSrc *monitor_src)
|
||||
{
|
||||
MetaCursorRenderer *cursor_renderer;
|
||||
MetaHwCursorInhibitor *inhibitor;
|
||||
MetaBackend *backend;
|
||||
|
||||
g_return_if_fail (monitor_src->hw_cursor_inhibited);
|
||||
|
||||
cursor_renderer = get_cursor_renderer (monitor_src);
|
||||
backend = get_backend (monitor_src);
|
||||
inhibitor = META_HW_CURSOR_INHIBITOR (monitor_src);
|
||||
meta_cursor_renderer_remove_hw_cursor_inhibitor (cursor_renderer, inhibitor);
|
||||
meta_backend_remove_hw_cursor_inhibitor (backend, inhibitor);
|
||||
|
||||
monitor_src->hw_cursor_inhibited = FALSE;
|
||||
}
|
||||
|
@ -872,6 +872,10 @@ should_have_hw_cursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
GList *gpus)
|
||||
{
|
||||
MetaCursorRendererNative *cursor_renderer_native =
|
||||
META_CURSOR_RENDERER_NATIVE (renderer);
|
||||
MetaCursorRendererNativePrivate *priv =
|
||||
meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);
|
||||
CoglTexture *texture;
|
||||
MetaMonitorTransform transform;
|
||||
float scale;
|
||||
@ -880,7 +884,7 @@ should_have_hw_cursor (MetaCursorRenderer *renderer,
|
||||
if (!cursor_sprite)
|
||||
return FALSE;
|
||||
|
||||
if (meta_cursor_renderer_is_hw_cursors_inhibited (renderer))
|
||||
if (meta_backend_is_hw_cursors_inhibited (priv->backend))
|
||||
return FALSE;
|
||||
|
||||
for (l = gpus; l; l = l->next)
|
||||
|
Loading…
Reference in New Issue
Block a user