shaped-texture: Take a ClutterContext when constructing
This will be used to fetch the corresponding pipeline cache. This also means some minor reshuffling in MetaSurfaceActor to create it after constructing the object. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
This commit is contained in:
parent
6c34055cae
commit
b538f4b999
@ -27,7 +27,7 @@
|
||||
#include "backends/meta-monitor-manager-private.h"
|
||||
#include "meta/meta-shaped-texture.h"
|
||||
|
||||
MetaShapedTexture * meta_shaped_texture_new (void);
|
||||
MetaShapedTexture * meta_shaped_texture_new (ClutterContext *clutter_context);
|
||||
void meta_shaped_texture_set_texture (MetaShapedTexture *stex,
|
||||
MetaMultiTexture *multi_texture);
|
||||
void meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex,
|
||||
|
@ -51,6 +51,17 @@ static void meta_shaped_texture_dispose (GObject *object);
|
||||
|
||||
static void clutter_content_iface_init (ClutterContentInterface *iface);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_CLUTTER_CONTEXT,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *obj_props[N_PROPS];
|
||||
|
||||
enum
|
||||
{
|
||||
SIZE_CHANGED,
|
||||
@ -69,6 +80,8 @@ struct _MetaShapedTexture
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
ClutterContext *clutter_context;
|
||||
|
||||
MetaMultiTexture *texture;
|
||||
CoglTexture *mask_texture;
|
||||
CoglSnippet *snippet;
|
||||
@ -114,12 +127,50 @@ G_DEFINE_TYPE_WITH_CODE (MetaShapedTexture, meta_shaped_texture, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTENT,
|
||||
clutter_content_iface_init));
|
||||
|
||||
static void
|
||||
meta_shaped_texture_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaShapedTexture *stex = META_SHAPED_TEXTURE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CLUTTER_CONTEXT:
|
||||
stex->clutter_context = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_shaped_texture_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaShapedTexture *stex = META_SHAPED_TEXTURE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CLUTTER_CONTEXT:
|
||||
g_value_set_object (value, stex->clutter_context);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_shaped_texture_class_init (MetaShapedTextureClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = (GObjectClass *) klass;
|
||||
|
||||
object_class->dispose = meta_shaped_texture_dispose;
|
||||
object_class->set_property = meta_shaped_texture_set_property;
|
||||
object_class->get_property = meta_shaped_texture_get_property;
|
||||
|
||||
signals[SIZE_CHANGED] = g_signal_new ("size-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
@ -127,6 +178,14 @@ meta_shaped_texture_class_init (MetaShapedTextureClass *klass)
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
obj_props[PROP_CLUTTER_CONTEXT] =
|
||||
g_param_spec_object ("clutter-context", NULL, NULL,
|
||||
CLUTTER_TYPE_CONTEXT,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1512,9 +1571,11 @@ meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex,
|
||||
}
|
||||
|
||||
MetaShapedTexture *
|
||||
meta_shaped_texture_new (void)
|
||||
meta_shaped_texture_new (ClutterContext *clutter_context)
|
||||
{
|
||||
return g_object_new (META_TYPE_SHAPED_TEXTURE, NULL);
|
||||
return g_object_new (META_TYPE_SHAPED_TEXTURE,
|
||||
"clutter-context", clutter_context,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,6 +250,35 @@ meta_surface_actor_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
texture_size_changed (MetaShapedTexture *texture,
|
||||
MetaSurfaceActor *surface_actor)
|
||||
{
|
||||
g_signal_emit (surface_actor, signals[SIZE_CHANGED], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_surface_actor_constructed (GObject *object)
|
||||
{
|
||||
MetaSurfaceActor *surface_actor = META_SURFACE_ACTOR (object);
|
||||
MetaSurfaceActorPrivate *priv =
|
||||
meta_surface_actor_get_instance_private (surface_actor);
|
||||
ClutterContext *clutter_context =
|
||||
clutter_actor_get_context (CLUTTER_ACTOR (surface_actor));
|
||||
|
||||
priv->is_obscured = TRUE;
|
||||
priv->texture = meta_shaped_texture_new (clutter_context);
|
||||
g_signal_connect_object (priv->texture, "size-changed",
|
||||
G_CALLBACK (texture_size_changed), surface_actor,
|
||||
G_CONNECT_DEFAULT);
|
||||
clutter_actor_set_content (CLUTTER_ACTOR (surface_actor),
|
||||
CLUTTER_CONTENT (priv->texture));
|
||||
clutter_actor_set_request_mode (CLUTTER_ACTOR (surface_actor),
|
||||
CLUTTER_REQUEST_CONTENT_SIZE);
|
||||
|
||||
G_OBJECT_CLASS (meta_surface_actor_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_surface_actor_dispose (GObject *object)
|
||||
{
|
||||
@ -271,6 +300,7 @@ meta_surface_actor_class_init (MetaSurfaceActorClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
|
||||
object_class->constructed = meta_surface_actor_constructed;
|
||||
object_class->dispose = meta_surface_actor_dispose;
|
||||
object_class->get_property = meta_surface_actor_get_property;
|
||||
|
||||
@ -369,28 +399,9 @@ cullable_iface_init (MetaCullableInterface *iface)
|
||||
iface->cull_unobscured = meta_surface_actor_cull_unobscured;
|
||||
}
|
||||
|
||||
static void
|
||||
texture_size_changed (MetaShapedTexture *texture,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaSurfaceActor *actor = META_SURFACE_ACTOR (user_data);
|
||||
g_signal_emit (actor, signals[SIZE_CHANGED], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_surface_actor_init (MetaSurfaceActor *self)
|
||||
{
|
||||
MetaSurfaceActorPrivate *priv =
|
||||
meta_surface_actor_get_instance_private (self);
|
||||
|
||||
priv->is_obscured = TRUE;
|
||||
priv->texture = meta_shaped_texture_new ();
|
||||
g_signal_connect_object (priv->texture, "size-changed",
|
||||
G_CALLBACK (texture_size_changed), self, 0);
|
||||
clutter_actor_set_content (CLUTTER_ACTOR (self),
|
||||
CLUTTER_CONTENT (priv->texture));
|
||||
clutter_actor_set_request_mode (CLUTTER_ACTOR (self),
|
||||
CLUTTER_REQUEST_CONTENT_SIZE);
|
||||
}
|
||||
|
||||
MetaShapedTexture *
|
||||
|
Loading…
x
Reference in New Issue
Block a user