[mutter/wip/carlosg/input-thread: 58/96] backends: Move HW cursor inhibitors to MetaBackend
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 58/96] backends: Move HW cursor inhibitors to MetaBackend
- Date: Tue, 6 Oct 2020 15:50:44 +0000 (UTC)
commit efd0b248cb8693c2516054cf50eb929c3b5c5c85
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jul 13 17:45:41 2020 +0200
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
src/backends/meta-backend-private.h | 8 +++++
src/backends/meta-backend.c | 39 ++++++++++++++++++++
src/backends/meta-cursor-renderer.c | 42 +---------------------
src/backends/meta-cursor-renderer.h | 10 ++----
src/backends/meta-screen-cast-area-stream-src.c | 25 ++++---------
src/backends/meta-screen-cast-monitor-stream-src.c | 25 ++++---------
src/backends/native/meta-cursor-renderer-native.c | 6 +++-
7 files changed, 67 insertions(+), 88 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index b90e17e4a8..7a04e96002 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -198,4 +198,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 */
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 67cb788902..9403afa352 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -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"
@@ -149,6 +150,7 @@ struct _MetaBackendPrivate
ClutterActor *stage;
GList *gpus;
+ GList *hw_cursor_inhibitors;
gboolean is_pointer_position_initialized;
@@ -1538,3 +1540,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;
+}
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
index 7d4228a35c..a0b09c7788 100644
--- a/src/backends/meta-cursor-renderer.c
+++ b/src/backends/meta-cursor-renderer.c
@@ -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)
{
diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h
index b16d5cbe2e..8d23cc6f56 100644
--- a/src/backends/meta-cursor-renderer.h
+++ b/src/backends/meta-cursor-renderer.h
@@ -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);
diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c
index a76352bce1..d465875ef9 100644
--- a/src/backends/meta-screen-cast-area-stream-src.c
+++ b/src/backends/meta-screen-cast-area-stream-src.c
@@ -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,
@@ -199,14 +186,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;
}
@@ -214,14 +201,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;
}
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 8ff40f24a4..b7e573d0a1 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -252,30 +252,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;
}
@@ -283,14 +270,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;
}
diff --git a/src/backends/native/meta-cursor-renderer-native.c
b/src/backends/native/meta-cursor-renderer-native.c
index f37f84cc19..223eec5299 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]