mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 03:50:47 -05:00
shader-effect: Use macros for subclassing boilerplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
parent
7b32f06f44
commit
accff6b937
@ -44,7 +44,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref)
|
|||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInterval, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInterval, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPageTurnEffect, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPageTurnEffect, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterScrollActor, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterScrollActor, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterShaderEffect, g_object_unref)
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterStage, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterStage, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterText, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterText, g_object_unref)
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ typedef struct _ShaderUniform
|
|||||||
int location;
|
int location;
|
||||||
} ShaderUniform;
|
} ShaderUniform;
|
||||||
|
|
||||||
struct _ClutterShaderEffectPrivate
|
typedef struct _ClutterShaderEffectPrivate
|
||||||
{
|
{
|
||||||
ClutterActor *actor;
|
ClutterActor *actor;
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ struct _ClutterShaderEffectPrivate
|
|||||||
CoglShader *shader;
|
CoglShader *shader;
|
||||||
|
|
||||||
GHashTable *uniforms;
|
GHashTable *uniforms;
|
||||||
};
|
} ClutterShaderEffectPrivate;
|
||||||
|
|
||||||
typedef struct _ClutterShaderEffectClassPrivate
|
typedef struct _ClutterShaderEffectClassPrivate
|
||||||
{
|
{
|
||||||
@ -175,7 +175,8 @@ static inline void
|
|||||||
clutter_shader_effect_clear (ClutterShaderEffect *self,
|
clutter_shader_effect_clear (ClutterShaderEffect *self,
|
||||||
gboolean reset_uniforms)
|
gboolean reset_uniforms)
|
||||||
{
|
{
|
||||||
ClutterShaderEffectPrivate *priv = self->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (self);
|
||||||
|
|
||||||
g_clear_object (&priv->shader);
|
g_clear_object (&priv->shader);
|
||||||
g_clear_object (&priv->program);
|
g_clear_object (&priv->program);
|
||||||
@ -192,7 +193,8 @@ clutter_shader_effect_clear (ClutterShaderEffect *self,
|
|||||||
static void
|
static void
|
||||||
clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
clutter_shader_effect_update_uniforms (ClutterShaderEffect *effect)
|
||||||
{
|
{
|
||||||
ClutterShaderEffectPrivate *priv = effect->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (effect);
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
gsize size;
|
gsize size;
|
||||||
@ -278,7 +280,8 @@ clutter_shader_effect_set_actor (ClutterActorMeta *meta,
|
|||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
ClutterShaderEffect *self = CLUTTER_SHADER_EFFECT (meta);
|
ClutterShaderEffect *self = CLUTTER_SHADER_EFFECT (meta);
|
||||||
ClutterShaderEffectPrivate *priv = self->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (self);
|
||||||
ClutterActorMetaClass *parent;
|
ClutterActorMetaClass *parent;
|
||||||
|
|
||||||
parent = CLUTTER_ACTOR_META_CLASS (clutter_shader_effect_parent_class);
|
parent = CLUTTER_ACTOR_META_CLASS (clutter_shader_effect_parent_class);
|
||||||
@ -296,7 +299,8 @@ clutter_shader_effect_set_actor (ClutterActorMeta *meta,
|
|||||||
static CoglShader*
|
static CoglShader*
|
||||||
clutter_shader_effect_create_shader (ClutterShaderEffect *self)
|
clutter_shader_effect_create_shader (ClutterShaderEffect *self)
|
||||||
{
|
{
|
||||||
ClutterShaderEffectPrivate *priv = self->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (self);
|
||||||
|
|
||||||
switch (priv->shader_type)
|
switch (priv->shader_type)
|
||||||
{
|
{
|
||||||
@ -317,7 +321,8 @@ clutter_shader_effect_create_shader (ClutterShaderEffect *self)
|
|||||||
static void
|
static void
|
||||||
clutter_shader_effect_try_static_source (ClutterShaderEffect *self)
|
clutter_shader_effect_try_static_source (ClutterShaderEffect *self)
|
||||||
{
|
{
|
||||||
ClutterShaderEffectPrivate *priv = self->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (self);
|
||||||
ClutterShaderEffectClass *shader_effect_class =
|
ClutterShaderEffectClass *shader_effect_class =
|
||||||
CLUTTER_SHADER_EFFECT_GET_CLASS (self);
|
CLUTTER_SHADER_EFFECT_GET_CLASS (self);
|
||||||
|
|
||||||
@ -365,7 +370,8 @@ clutter_shader_effect_paint_target (ClutterOffscreenEffect *effect,
|
|||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
ClutterShaderEffect *self = CLUTTER_SHADER_EFFECT (effect);
|
ClutterShaderEffect *self = CLUTTER_SHADER_EFFECT (effect);
|
||||||
ClutterShaderEffectPrivate *priv = self->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (self);
|
||||||
ClutterOffscreenEffectClass *parent;
|
ClutterOffscreenEffectClass *parent;
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
|
|
||||||
@ -402,7 +408,8 @@ clutter_shader_effect_set_property (GObject *gobject,
|
|||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
ClutterShaderEffectPrivate *priv = CLUTTER_SHADER_EFFECT (gobject)->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (CLUTTER_SHADER_EFFECT (gobject));
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
@ -464,8 +471,10 @@ clutter_shader_effect_class_init (ClutterShaderEffectClass *klass)
|
|||||||
static void
|
static void
|
||||||
clutter_shader_effect_init (ClutterShaderEffect *effect)
|
clutter_shader_effect_init (ClutterShaderEffect *effect)
|
||||||
{
|
{
|
||||||
effect->priv = clutter_shader_effect_get_instance_private (effect);
|
ClutterShaderEffectPrivate *priv =
|
||||||
effect->priv->shader_type = CLUTTER_FRAGMENT_SHADER;
|
clutter_shader_effect_get_instance_private (effect);
|
||||||
|
|
||||||
|
priv->shader_type = CLUTTER_FRAGMENT_SHADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -502,10 +511,13 @@ clutter_shader_effect_new (ClutterShaderType shader_type)
|
|||||||
CoglShader*
|
CoglShader*
|
||||||
clutter_shader_effect_get_shader (ClutterShaderEffect *effect)
|
clutter_shader_effect_get_shader (ClutterShaderEffect *effect)
|
||||||
{
|
{
|
||||||
|
ClutterShaderEffectPrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect),
|
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return effect->priv->shader;
|
priv = clutter_shader_effect_get_instance_private (effect);
|
||||||
|
return priv->shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -520,10 +532,13 @@ clutter_shader_effect_get_shader (ClutterShaderEffect *effect)
|
|||||||
CoglProgram*
|
CoglProgram*
|
||||||
clutter_shader_effect_get_program (ClutterShaderEffect *effect)
|
clutter_shader_effect_get_program (ClutterShaderEffect *effect)
|
||||||
{
|
{
|
||||||
|
ClutterShaderEffectPrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect),
|
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return effect->priv->program;
|
priv = clutter_shader_effect_get_instance_private (effect);
|
||||||
|
return priv->program;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -572,7 +587,8 @@ clutter_shader_effect_add_uniform (ClutterShaderEffect *effect,
|
|||||||
const gchar *name,
|
const gchar *name,
|
||||||
const GValue *value)
|
const GValue *value)
|
||||||
{
|
{
|
||||||
ClutterShaderEffectPrivate *priv = effect->priv;
|
ClutterShaderEffectPrivate *priv =
|
||||||
|
clutter_shader_effect_get_instance_private (effect);
|
||||||
ShaderUniform *uniform;
|
ShaderUniform *uniform;
|
||||||
|
|
||||||
if (priv->uniforms == NULL)
|
if (priv->uniforms == NULL)
|
||||||
@ -846,7 +862,7 @@ clutter_shader_effect_set_shader_source (ClutterShaderEffect *effect,
|
|||||||
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_SHADER_EFFECT (effect), FALSE);
|
||||||
g_return_val_if_fail (source != NULL && *source != '\0', FALSE);
|
g_return_val_if_fail (source != NULL && *source != '\0', FALSE);
|
||||||
|
|
||||||
priv = effect->priv;
|
priv = clutter_shader_effect_get_instance_private (effect);
|
||||||
|
|
||||||
if (priv->shader != NULL)
|
if (priv->shader != NULL)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -33,23 +33,13 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CLUTTER_TYPE_SHADER_EFFECT (clutter_shader_effect_get_type ())
|
#define CLUTTER_TYPE_SHADER_EFFECT (clutter_shader_effect_get_type ())
|
||||||
#define CLUTTER_SHADER_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_SHADER_EFFECT, ClutterShaderEffect))
|
|
||||||
#define CLUTTER_IS_SHADER_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_SHADER_EFFECT))
|
|
||||||
#define CLUTTER_SHADER_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_SHADER_EFFECT, ClutterShaderEffectClass))
|
|
||||||
#define CLUTTER_IS_SHADER_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_SHADER_EFFECT))
|
|
||||||
#define CLUTTER_SHADER_EFFECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_SHADER_EFFECT, ClutterShaderEffectClass))
|
|
||||||
|
|
||||||
typedef struct _ClutterShaderEffect ClutterShaderEffect;
|
CLUTTER_EXPORT
|
||||||
typedef struct _ClutterShaderEffectPrivate ClutterShaderEffectPrivate;
|
G_DECLARE_DERIVABLE_TYPE (ClutterShaderEffect,
|
||||||
typedef struct _ClutterShaderEffectClass ClutterShaderEffectClass;
|
clutter_shader_effect,
|
||||||
|
CLUTTER,
|
||||||
struct _ClutterShaderEffect
|
SHADER_EFFECT,
|
||||||
{
|
ClutterOffscreenEffect)
|
||||||
/*< private >*/
|
|
||||||
ClutterOffscreenEffect parent_instance;
|
|
||||||
|
|
||||||
ClutterShaderEffectPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterShaderEffectClass:
|
* ClutterShaderEffectClass:
|
||||||
@ -71,9 +61,6 @@ struct _ClutterShaderEffectClass
|
|||||||
gchar * (* get_static_shader_source) (ClutterShaderEffect *effect);
|
gchar * (* get_static_shader_source) (ClutterShaderEffect *effect);
|
||||||
};
|
};
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
GType clutter_shader_effect_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
ClutterEffect * clutter_shader_effect_new (ClutterShaderType shader_type);
|
ClutterEffect * clutter_shader_effect_new (ClutterShaderType shader_type);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user