[mutter] cursor-renderer/native: Fetch instead of pass wl_buffer when realizing
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cursor-renderer/native: Fetch instead of pass wl_buffer when realizing
- Date: Fri, 15 Jun 2018 19:12:46 +0000 (UTC)
commit 42c78bd41f98220d99b703fde862fcc5f9e57eff
Author: Jonas Ådahl <jadahl gmail com>
Date: Wed May 2 12:27:02 2018 +0200
cursor-renderer/native: Fetch instead of pass wl_buffer when realizing
This is the next step in centralizing the cursor sprite hw sprite
realization paths.
https://gitlab.gnome.org/GNOME/mutter/issues/77
src/backends/meta-cursor-renderer.c | 7 +++--
src/backends/meta-cursor-renderer.h | 17 ++++++------
src/backends/native/meta-cursor-renderer-native.c | 33 ++++++++++++++++-------
src/wayland/meta-cursor-sprite-wayland.c | 17 ++++++++++--
src/wayland/meta-cursor-sprite-wayland.h | 5 +++-
src/wayland/meta-wayland-buffer.c | 6 +++++
src/wayland/meta-wayland-buffer.h | 1 +
src/wayland/meta-wayland-cursor-surface.c | 19 ++++++-------
8 files changed, 69 insertions(+), 36 deletions(-)
---
diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c
index 51470f3ac..6b6d35dba 100644
--- a/src/backends/meta-cursor-renderer.c
+++ b/src/backends/meta-cursor-renderer.c
@@ -286,15 +286,14 @@ meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
#ifdef HAVE_WAYLAND
void
-meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
- MetaCursorSprite *cursor_sprite,
- struct wl_resource *buffer)
+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, cursor_sprite, buffer);
+ renderer_class->realize_cursor_from_wl_buffer (renderer, sprite_wayland);
}
#endif
diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h
index da4b31783..699b20aae 100644
--- a/src/backends/meta-cursor-renderer.h
+++ b/src/backends/meta-cursor-renderer.h
@@ -26,14 +26,15 @@
#define META_CURSOR_RENDERER_H
#include <glib-object.h>
-#ifdef HAVE_WAYLAND
-#include <wayland-server.h>
-#endif
#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,
META, CURSOR_RENDERER, GObject);
@@ -45,9 +46,8 @@ struct _MetaCursorRendererClass
gboolean (* update_cursor) (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
#ifdef HAVE_WAYLAND
- void (* realize_cursor_from_wl_buffer) (MetaCursorRenderer *renderer,
- MetaCursorSprite *cursor_sprite,
- struct wl_resource *buffer);
+ void (* realize_cursor_from_wl_buffer) (MetaCursorRenderer *renderer,
+ MetaCursorSpriteWayland *sprite_wayland);
#endif
void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
MetaCursorSpriteXcursor *sprite_xcursor);
@@ -70,9 +70,8 @@ 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,
- MetaCursorSprite *cursor_sprite,
- struct wl_resource *buffer);
+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,
diff --git a/src/backends/native/meta-cursor-renderer-native.c
b/src/backends/native/meta-cursor-renderer-native.c
index 756ad1a0d..4036e694b 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -43,6 +43,11 @@
#include "core/boxes-private.h"
#include "meta/boxes.h"
+#ifdef HAVE_WAYLAND
+#include "wayland/meta-cursor-sprite-wayland.h"
+#include "wayland/meta-wayland-buffer.h"
+#endif
+
#ifndef DRM_CAP_CURSOR_WIDTH
#define DRM_CAP_CURSOR_WIDTH 0x8
#endif
@@ -827,12 +832,13 @@ invalidate_pending_cursor_sprite_gbm_bo (MetaCursorSprite *cursor_sprite,
#ifdef HAVE_WAYLAND
static void
-realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
- MetaGpuKms *gpu_kms,
- MetaCursorSprite *cursor_sprite,
- struct wl_resource *buffer)
+realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
+ MetaGpuKms *gpu_kms,
+ MetaCursorSpriteWayland *sprite_wayland,
+ struct wl_resource *buffer)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
+ MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_wayland);
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
uint32_t gbm_format;
uint64_t cursor_width, cursor_height;
@@ -929,16 +935,25 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
}
static void
-meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
- MetaCursorSprite *cursor_sprite,
- struct wl_resource *buffer)
+meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
+ MetaCursorSpriteWayland *sprite_wayland)
{
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (native);
+ MetaWaylandBuffer *buffer;
+ struct wl_resource *buffer_resource;
GList *gpus;
GList *l;
+ buffer = meta_cursor_sprite_wayland_get_buffer (sprite_wayland);
+ if (!buffer)
+ return;
+
+ buffer_resource = meta_wayland_buffer_get_resource (buffer);
+ if (!buffer_resource)
+ return;
+
gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
for (l = gpus; l; l = l->next)
{
@@ -946,8 +961,8 @@ meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *r
realize_cursor_sprite_from_wl_buffer_for_gpu (renderer,
gpu_kms,
- cursor_sprite,
- buffer);
+ sprite_wayland,
+ buffer_resource);
}
}
#endif
diff --git a/src/wayland/meta-cursor-sprite-wayland.c b/src/wayland/meta-cursor-sprite-wayland.c
index 20532f13c..7c14960ff 100644
--- a/src/wayland/meta-cursor-sprite-wayland.c
+++ b/src/wayland/meta-cursor-sprite-wayland.c
@@ -23,6 +23,8 @@
struct _MetaCursorSpriteWayland
{
MetaCursorSprite parent;
+
+ MetaWaylandSurface *surface;
};
G_DEFINE_TYPE (MetaCursorSpriteWayland,
@@ -41,9 +43,20 @@ meta_cursor_sprite_wayland_is_animated (MetaCursorSprite *sprite)
}
MetaCursorSpriteWayland *
-meta_cursor_sprite_wayland_new (void)
+meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface)
+{
+ MetaCursorSpriteWayland *sprite_wayland;
+
+ sprite_wayland = g_object_new (META_TYPE_CURSOR_SPRITE_WAYLAND, NULL);
+ sprite_wayland->surface = surface;
+
+ return sprite_wayland;
+}
+
+MetaWaylandBuffer *
+meta_cursor_sprite_wayland_get_buffer (MetaCursorSpriteWayland *sprite_wayland)
{
- return g_object_new (META_TYPE_CURSOR_SPRITE_WAYLAND, NULL);
+ return meta_wayland_surface_get_buffer (sprite_wayland->surface);
}
static void
diff --git a/src/wayland/meta-cursor-sprite-wayland.h b/src/wayland/meta-cursor-sprite-wayland.h
index f0b9a0769..107698f3f 100644
--- a/src/wayland/meta-cursor-sprite-wayland.h
+++ b/src/wayland/meta-cursor-sprite-wayland.h
@@ -22,11 +22,14 @@
#include <glib-object.h>
#include "backends/meta-cursor.h"
+#include "wayland/meta-wayland-surface.h"
#define META_TYPE_CURSOR_SPRITE_WAYLAND meta_cursor_sprite_wayland_get_type ()
G_DECLARE_FINAL_TYPE (MetaCursorSpriteWayland, meta_cursor_sprite_wayland,
META, CURSOR_SPRITE_WAYLAND, MetaCursorSprite)
-MetaCursorSpriteWayland * meta_cursor_sprite_wayland_new (void);
+MetaCursorSpriteWayland * meta_cursor_sprite_wayland_new (MetaWaylandSurface *surface);
+
+MetaWaylandBuffer * meta_cursor_sprite_wayland_get_buffer (MetaCursorSpriteWayland *sprite_wayland);
#endif /* META_CURSOR_SPRITE_WAYLAND_H */
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index 55564492a..c759eefc1 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -88,6 +88,12 @@ meta_wayland_buffer_from_resource (struct wl_resource *resource)
return buffer;
}
+struct wl_resource *
+meta_wayland_buffer_get_resource (MetaWaylandBuffer *buffer)
+{
+ return buffer->resource;
+}
+
static gboolean
meta_wayland_buffer_is_realized (MetaWaylandBuffer *buffer)
{
diff --git a/src/wayland/meta-wayland-buffer.h b/src/wayland/meta-wayland-buffer.h
index 5345033c2..e00a41e09 100644
--- a/src/wayland/meta-wayland-buffer.h
+++ b/src/wayland/meta-wayland-buffer.h
@@ -68,6 +68,7 @@ G_DECLARE_FINAL_TYPE (MetaWaylandBuffer, meta_wayland_buffer,
META, WAYLAND_BUFFER, GObject);
MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource);
+struct wl_resource * meta_wayland_buffer_get_resource (MetaWaylandBuffer *buffer);
gboolean meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
GError **error);
CoglTexture * meta_wayland_buffer_get_texture (MetaWaylandBuffer *buffer);
diff --git a/src/wayland/meta-wayland-cursor-surface.c b/src/wayland/meta-wayland-cursor-surface.c
index 77931ab65..9766e1e18 100644
--- a/src/wayland/meta-wayland-cursor-surface.c
+++ b/src/wayland/meta-wayland-cursor-surface.c
@@ -74,13 +74,9 @@ update_cursor_sprite_texture (MetaWaylandCursorSurface *cursor_surface)
if (priv->buffer)
{
- struct wl_resource *buffer_resource;
-
g_assert (priv->buffer == buffer);
- buffer_resource = buffer->resource;
meta_cursor_renderer_realize_cursor_from_wl_buffer (priv->cursor_renderer,
- cursor_sprite,
- buffer_resource);
+ priv->cursor_sprite);
meta_wayland_surface_unref_buffer_use_count (surface);
g_clear_object (&priv->buffer);
@@ -260,6 +256,13 @@ meta_wayland_cursor_surface_constructed (GObject *object)
g_set_object (&priv->buffer, buffer);
meta_wayland_surface_ref_buffer_use_count (surface);
}
+
+ priv->cursor_sprite = meta_cursor_sprite_wayland_new (surface);
+ g_signal_connect_object (priv->cursor_sprite,
+ "prepare-at",
+ G_CALLBACK (cursor_sprite_prepare_at),
+ cursor_surface,
+ 0);
}
static void
@@ -268,12 +271,6 @@ meta_wayland_cursor_surface_init (MetaWaylandCursorSurface *role)
MetaWaylandCursorSurfacePrivate *priv =
meta_wayland_cursor_surface_get_instance_private (role);
- priv->cursor_sprite = meta_cursor_sprite_wayland_new ();
- g_signal_connect_object (priv->cursor_sprite,
- "prepare-at",
- G_CALLBACK (cursor_sprite_prepare_at),
- role,
- 0);
wl_list_init (&priv->frame_callbacks);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]