[mutter] cursor-renderer: Centralize hw cursor realization paths
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cursor-renderer: Centralize hw cursor realization paths
- Date: Fri, 15 Jun 2018 19:12:56 +0000 (UTC)
commit 9dcf9782b69de856675891185969b1d3f34c2b7f
Author: Jonas Ådahl <jadahl gmail com>
Date: Wed May 2 14:34:02 2018 +0200
cursor-renderer: Centralize hw cursor realization paths
Use a common entry point into the cursor renderer implementations HW
cursor realization paths for all cursor sprite types. This is in
preparation for realizing at more strategic times.
https://gitlab.gnome.org/GNOME/mutter/issues/77
src/backends/meta-cursor-renderer.c | 21 +++---------
src/backends/meta-cursor-renderer.h | 22 +++----------
src/backends/meta-cursor-sprite-xcursor.c | 7 ++--
src/backends/native/meta-cursor-renderer-native.c | 39 +++++++++++++++++------
src/wayland/meta-wayland-cursor-surface.c | 4 +--
5 files changed, 43 insertions(+), 50 deletions(-)
---
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
index 6b6d35dba..bf10d5e2b 100644
--- a/src/backends/meta-cursor-renderer.c
+++ b/src/backends/meta-cursor-renderer.c
@@ -284,25 +284,12 @@ meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
return priv->displayed_cursor;
}
-#ifdef HAVE_WAYLAND
void
-meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
- MetaCursorSpriteWayland *sprite_wayland)
-{
-
- MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
-
- if (renderer_class->realize_cursor_from_wl_buffer)
- renderer_class->realize_cursor_from_wl_buffer (renderer, sprite_wayland);
-}
-#endif
-
-void
-meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
- MetaCursorSpriteXcursor *sprite_xcursor)
+meta_cursor_renderer_realize_cursor_sprite (MetaCursorRenderer *renderer,
+ MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
- if (renderer_class->realize_cursor_from_xcursor)
- renderer_class->realize_cursor_from_xcursor (renderer, sprite_xcursor);
+ if (renderer_class->realize_cursor_sprite)
+ renderer_class->realize_cursor_sprite (renderer, cursor_sprite);
}
diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h
index 699b20aae..82581995f 100644
--- a/src/backends/meta-cursor-renderer.h
+++ b/src/backends/meta-cursor-renderer.h
@@ -29,11 +29,6 @@
#include <meta/screen.h>
#include "meta-cursor.h"
-#include "backends/meta-cursor-sprite-xcursor.h"
-
-#ifdef HAVE_WAYLAND
-#include "wayland/meta-cursor-sprite-wayland.h"
-#endif
#define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ())
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
@@ -45,12 +40,8 @@ struct _MetaCursorRendererClass
gboolean (* update_cursor) (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
-#ifdef HAVE_WAYLAND
- void (* realize_cursor_from_wl_buffer) (MetaCursorRenderer *renderer,
- MetaCursorSpriteWayland *sprite_wayland);
-#endif
- void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
- MetaCursorSpriteXcursor *sprite_xcursor);
+ void (* realize_cursor_sprite) (MetaCursorRenderer *renderer,
+ MetaCursorSprite *cursor_sprite);
};
MetaCursorRenderer * meta_cursor_renderer_new (void);
@@ -69,13 +60,8 @@ MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer
ClutterRect meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
-#ifdef HAVE_WAYLAND
-void meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
- MetaCursorSpriteWayland *sprite_wayland);
-#endif
-
-void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
- MetaCursorSpriteXcursor *sprite_xcursor);
+void meta_cursor_renderer_realize_cursor_sprite (MetaCursorRenderer *renderer,
+ MetaCursorSprite *cursor_sprite);
void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
diff --git a/src/backends/meta-cursor-sprite-xcursor.c b/src/backends/meta-cursor-sprite-xcursor.c
index 98456ab76..f30446695 100644
--- a/src/backends/meta-cursor-sprite-xcursor.c
+++ b/src/backends/meta-cursor-sprite-xcursor.c
@@ -117,6 +117,7 @@ load_cursor_on_client (MetaCursor cursor, int scale)
static void
load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
{
+ MetaCursorSprite *sprite = META_CURSOR_SPRITE (sprite_xcursor);
MetaBackend *backend = meta_get_backend ();
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (backend);
XcursorImage *xc_image;
@@ -127,7 +128,7 @@ load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
CoglTexture2D *texture;
CoglError *error = NULL;
- g_assert (!meta_cursor_sprite_get_cogl_texture (META_CURSOR_SPRITE (sprite_xcursor)));
+ g_assert (!meta_cursor_sprite_get_cogl_texture (sprite));
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
width = (int) xc_image->width;
@@ -155,13 +156,13 @@ load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
cogl_error_free (error);
}
- meta_cursor_sprite_set_texture (META_CURSOR_SPRITE (sprite_xcursor),
+ meta_cursor_sprite_set_texture (sprite,
COGL_TEXTURE (texture),
xc_image->xhot, xc_image->yhot);
g_clear_pointer (&texture, cogl_object_unref);
- meta_cursor_renderer_realize_cursor_from_xcursor (renderer, sprite_xcursor);
+ meta_cursor_renderer_realize_cursor_sprite (renderer, sprite);
}
void
diff --git a/src/backends/native/meta-cursor-renderer-native.c
b/src/backends/native/meta-cursor-renderer-native.c
index a56cf4dfb..156d83d15 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -35,6 +35,7 @@
#include <meta/meta-backend.h>
#include "backends/meta-backend-private.h"
+#include "backends/meta-cursor-sprite-xcursor.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor.h"
#include "backends/meta-monitor-manager-private.h"
@@ -942,8 +943,8 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
}
static void
-meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
- MetaCursorSpriteWayland *sprite_wayland)
+realize_cursor_sprite_from_wl_buffer (MetaCursorRenderer *renderer,
+ MetaCursorSpriteWayland *sprite_wayland)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv =
@@ -1002,8 +1003,8 @@ realize_cursor_sprite_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
}
static void
-meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
- MetaCursorSpriteXcursor *sprite_xcursor)
+realize_cursor_sprite_from_xcursor (MetaCursorRenderer *renderer,
+ MetaCursorSpriteXcursor *sprite_xcursor)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv =
@@ -1025,6 +1026,28 @@ meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer
}
}
+static void
+meta_cursor_renderer_native_realize_cursor_sprite (MetaCursorRenderer *renderer,
+ MetaCursorSprite *cursor_sprite)
+{
+ if (META_IS_CURSOR_SPRITE_XCURSOR (cursor_sprite))
+ {
+ MetaCursorSpriteXcursor *sprite_xcursor =
+ META_CURSOR_SPRITE_XCURSOR (cursor_sprite);
+
+ realize_cursor_sprite_from_xcursor (renderer, sprite_xcursor);
+ }
+#ifdef HAVE_WAYLAND
+ else if (META_IS_CURSOR_SPRITE_WAYLAND (cursor_sprite))
+ {
+ MetaCursorSpriteWayland *sprite_wayland =
+ META_CURSOR_SPRITE_WAYLAND (cursor_sprite);
+
+ realize_cursor_sprite_from_wl_buffer (renderer, sprite_wayland);
+ }
+#endif
+}
+
static void
meta_cursor_renderer_native_class_init (MetaCursorRendererNativeClass *klass)
{
@@ -1033,12 +1056,8 @@ meta_cursor_renderer_native_class_init (MetaCursorRendererNativeClass *klass)
object_class->finalize = meta_cursor_renderer_native_finalize;
renderer_class->update_cursor = meta_cursor_renderer_native_update_cursor;
-#ifdef HAVE_WAYLAND
- renderer_class->realize_cursor_from_wl_buffer =
- meta_cursor_renderer_native_realize_cursor_from_wl_buffer;
-#endif
- renderer_class->realize_cursor_from_xcursor =
- meta_cursor_renderer_native_realize_cursor_from_xcursor;
+ renderer_class->realize_cursor_sprite =
+ meta_cursor_renderer_native_realize_cursor_sprite;
quark_cursor_sprite = g_quark_from_static_string ("-meta-cursor-native");
quark_cursor_renderer_native_gpu_data =
diff --git a/src/wayland/meta-wayland-cursor-surface.c b/src/wayland/meta-wayland-cursor-surface.c
index 9766e1e18..7b7d63c28 100644
--- a/src/wayland/meta-wayland-cursor-surface.c
+++ b/src/wayland/meta-wayland-cursor-surface.c
@@ -75,8 +75,8 @@ update_cursor_sprite_texture (MetaWaylandCursorSurface *cursor_surface)
if (priv->buffer)
{
g_assert (priv->buffer == buffer);
- meta_cursor_renderer_realize_cursor_from_wl_buffer (priv->cursor_renderer,
- priv->cursor_sprite);
+ meta_cursor_renderer_realize_cursor_sprite (priv->cursor_renderer,
+ cursor_sprite);
meta_wayland_surface_unref_buffer_use_count (surface);
g_clear_object (&priv->buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]