mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
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
This commit is contained in:
parent
b702c0fa5c
commit
42c78bd41f
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
return g_object_new (META_TYPE_CURSOR_SPRITE_WAYLAND, NULL);
|
||||
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 meta_wayland_surface_get_buffer (sprite_wayland->surface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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 */
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user