mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
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
This commit is contained in:
parent
0f519ffb05
commit
9dcf9782b6
@ -284,25 +284,12 @@ meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
|
|||||||
return priv->displayed_cursor;
|
return priv->displayed_cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_WAYLAND
|
|
||||||
void
|
void
|
||||||
meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
|
meta_cursor_renderer_realize_cursor_sprite (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSpriteWayland *sprite_wayland)
|
MetaCursorSprite *cursor_sprite)
|
||||||
{
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
|
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
|
||||||
|
|
||||||
if (renderer_class->realize_cursor_from_xcursor)
|
if (renderer_class->realize_cursor_sprite)
|
||||||
renderer_class->realize_cursor_from_xcursor (renderer, sprite_xcursor);
|
renderer_class->realize_cursor_sprite (renderer, cursor_sprite);
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,6 @@
|
|||||||
|
|
||||||
#include <meta/screen.h>
|
#include <meta/screen.h>
|
||||||
#include "meta-cursor.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 ())
|
#define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ())
|
||||||
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
|
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
|
||||||
@ -45,12 +40,8 @@ struct _MetaCursorRendererClass
|
|||||||
|
|
||||||
gboolean (* update_cursor) (MetaCursorRenderer *renderer,
|
gboolean (* update_cursor) (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite);
|
MetaCursorSprite *cursor_sprite);
|
||||||
#ifdef HAVE_WAYLAND
|
void (* realize_cursor_sprite) (MetaCursorRenderer *renderer,
|
||||||
void (* realize_cursor_from_wl_buffer) (MetaCursorRenderer *renderer,
|
MetaCursorSprite *cursor_sprite);
|
||||||
MetaCursorSpriteWayland *sprite_wayland);
|
|
||||||
#endif
|
|
||||||
void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
|
|
||||||
MetaCursorSpriteXcursor *sprite_xcursor);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaCursorRenderer * meta_cursor_renderer_new (void);
|
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,
|
ClutterRect meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite);
|
MetaCursorSprite *cursor_sprite);
|
||||||
|
|
||||||
#ifdef HAVE_WAYLAND
|
void meta_cursor_renderer_realize_cursor_sprite (MetaCursorRenderer *renderer,
|
||||||
void meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
|
MetaCursorSprite *cursor_sprite);
|
||||||
MetaCursorSpriteWayland *sprite_wayland);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
|
||||||
MetaCursorSpriteXcursor *sprite_xcursor);
|
|
||||||
|
|
||||||
void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
|
void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite);
|
MetaCursorSprite *cursor_sprite);
|
||||||
|
@ -117,6 +117,7 @@ load_cursor_on_client (MetaCursor cursor, int scale)
|
|||||||
static void
|
static void
|
||||||
load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
||||||
{
|
{
|
||||||
|
MetaCursorSprite *sprite = META_CURSOR_SPRITE (sprite_xcursor);
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (backend);
|
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (backend);
|
||||||
XcursorImage *xc_image;
|
XcursorImage *xc_image;
|
||||||
@ -127,7 +128,7 @@ load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
|||||||
CoglTexture2D *texture;
|
CoglTexture2D *texture;
|
||||||
CoglError *error = NULL;
|
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);
|
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
|
||||||
width = (int) xc_image->width;
|
width = (int) xc_image->width;
|
||||||
@ -155,13 +156,13 @@ load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
|||||||
cogl_error_free (error);
|
cogl_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_cursor_sprite_set_texture (META_CURSOR_SPRITE (sprite_xcursor),
|
meta_cursor_sprite_set_texture (sprite,
|
||||||
COGL_TEXTURE (texture),
|
COGL_TEXTURE (texture),
|
||||||
xc_image->xhot, xc_image->yhot);
|
xc_image->xhot, xc_image->yhot);
|
||||||
|
|
||||||
g_clear_pointer (&texture, cogl_object_unref);
|
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
|
void
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <meta/meta-backend.h>
|
#include <meta/meta-backend.h>
|
||||||
|
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
|
#include "backends/meta-cursor-sprite-xcursor.h"
|
||||||
#include "backends/meta-logical-monitor.h"
|
#include "backends/meta-logical-monitor.h"
|
||||||
#include "backends/meta-monitor.h"
|
#include "backends/meta-monitor.h"
|
||||||
#include "backends/meta-monitor-manager-private.h"
|
#include "backends/meta-monitor-manager-private.h"
|
||||||
@ -942,7 +943,7 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer,
|
realize_cursor_sprite_from_wl_buffer (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSpriteWayland *sprite_wayland)
|
MetaCursorSpriteWayland *sprite_wayland)
|
||||||
{
|
{
|
||||||
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
||||||
@ -1002,7 +1003,7 @@ realize_cursor_sprite_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
realize_cursor_sprite_from_xcursor (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSpriteXcursor *sprite_xcursor)
|
MetaCursorSpriteXcursor *sprite_xcursor)
|
||||||
{
|
{
|
||||||
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
||||||
@ -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
|
static void
|
||||||
meta_cursor_renderer_native_class_init (MetaCursorRendererNativeClass *klass)
|
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;
|
object_class->finalize = meta_cursor_renderer_native_finalize;
|
||||||
renderer_class->update_cursor = meta_cursor_renderer_native_update_cursor;
|
renderer_class->update_cursor = meta_cursor_renderer_native_update_cursor;
|
||||||
#ifdef HAVE_WAYLAND
|
renderer_class->realize_cursor_sprite =
|
||||||
renderer_class->realize_cursor_from_wl_buffer =
|
meta_cursor_renderer_native_realize_cursor_sprite;
|
||||||
meta_cursor_renderer_native_realize_cursor_from_wl_buffer;
|
|
||||||
#endif
|
|
||||||
renderer_class->realize_cursor_from_xcursor =
|
|
||||||
meta_cursor_renderer_native_realize_cursor_from_xcursor;
|
|
||||||
|
|
||||||
quark_cursor_sprite = g_quark_from_static_string ("-meta-cursor-native");
|
quark_cursor_sprite = g_quark_from_static_string ("-meta-cursor-native");
|
||||||
quark_cursor_renderer_native_gpu_data =
|
quark_cursor_renderer_native_gpu_data =
|
||||||
|
@ -75,8 +75,8 @@ update_cursor_sprite_texture (MetaWaylandCursorSurface *cursor_surface)
|
|||||||
if (priv->buffer)
|
if (priv->buffer)
|
||||||
{
|
{
|
||||||
g_assert (priv->buffer == buffer);
|
g_assert (priv->buffer == buffer);
|
||||||
meta_cursor_renderer_realize_cursor_from_wl_buffer (priv->cursor_renderer,
|
meta_cursor_renderer_realize_cursor_sprite (priv->cursor_renderer,
|
||||||
priv->cursor_sprite);
|
cursor_sprite);
|
||||||
|
|
||||||
meta_wayland_surface_unref_buffer_use_count (surface);
|
meta_wayland_surface_unref_buffer_use_count (surface);
|
||||||
g_clear_object (&priv->buffer);
|
g_clear_object (&priv->buffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user