offscreen-effect: Use macros for subclassing boilerplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
parent
0760e90b0d
commit
99501482df
@ -43,7 +43,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFlowLayout, g_object_unref)
|
|||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref)
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref)
|
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 (ClutterOffscreenEffect, 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 (ClutterShaderEffect, g_object_unref)
|
||||||
|
@ -103,7 +103,7 @@
|
|||||||
#include "clutter/clutter-paint-volume-private.h"
|
#include "clutter/clutter-paint-volume-private.h"
|
||||||
#include "clutter/clutter-actor-box-private.h"
|
#include "clutter/clutter-actor-box-private.h"
|
||||||
|
|
||||||
struct _ClutterOffscreenEffectPrivate
|
typedef struct _ClutterOffscreenEffectPrivate
|
||||||
{
|
{
|
||||||
CoglOffscreen *offscreen;
|
CoglOffscreen *offscreen;
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
@ -123,7 +123,7 @@ struct _ClutterOffscreenEffectPrivate
|
|||||||
int target_height;
|
int target_height;
|
||||||
|
|
||||||
gulong purge_handler_id;
|
gulong purge_handler_id;
|
||||||
};
|
} ClutterOffscreenEffectPrivate;
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterOffscreenEffect,
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterOffscreenEffect,
|
||||||
clutter_offscreen_effect,
|
clutter_offscreen_effect,
|
||||||
@ -134,7 +134,8 @@ clutter_offscreen_effect_set_actor (ClutterActorMeta *meta,
|
|||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (meta);
|
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (meta);
|
||||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
ClutterActorMetaClass *meta_class;
|
ClutterActorMetaClass *meta_class;
|
||||||
|
|
||||||
meta_class = CLUTTER_ACTOR_META_CLASS (clutter_offscreen_effect_parent_class);
|
meta_class = CLUTTER_ACTOR_META_CLASS (clutter_offscreen_effect_parent_class);
|
||||||
@ -162,9 +163,11 @@ static void
|
|||||||
ensure_pipeline_filter_for_scale (ClutterOffscreenEffect *self,
|
ensure_pipeline_filter_for_scale (ClutterOffscreenEffect *self,
|
||||||
float resource_scale)
|
float resource_scale)
|
||||||
{
|
{
|
||||||
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
CoglPipelineFilter filter;
|
CoglPipelineFilter filter;
|
||||||
|
|
||||||
if (!self->priv->pipeline)
|
if (!priv->pipeline)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If no fractional scaling is set, we're always going to render the texture
|
/* If no fractional scaling is set, we're always going to render the texture
|
||||||
@ -178,7 +181,7 @@ ensure_pipeline_filter_for_scale (ClutterOffscreenEffect *self,
|
|||||||
else
|
else
|
||||||
filter = COGL_PIPELINE_FILTER_LINEAR;
|
filter = COGL_PIPELINE_FILTER_LINEAR;
|
||||||
|
|
||||||
cogl_pipeline_set_layer_filters (self->priv->pipeline, 0 /* layer_index */,
|
cogl_pipeline_set_layer_filters (priv->pipeline, 0 /* layer_index */,
|
||||||
filter, filter);
|
filter, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +189,8 @@ static CoglPipeline *
|
|||||||
clutter_offscreen_effect_real_create_pipeline (ClutterOffscreenEffect *effect,
|
clutter_offscreen_effect_real_create_pipeline (ClutterOffscreenEffect *effect,
|
||||||
CoglTexture *texture)
|
CoglTexture *texture)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffectPrivate *priv = effect->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (effect);
|
||||||
CoglContext *ctx =
|
CoglContext *ctx =
|
||||||
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
@ -204,7 +208,10 @@ clutter_offscreen_effect_real_create_pipeline (ClutterOffscreenEffect *effect,
|
|||||||
static void
|
static void
|
||||||
video_memory_purged (ClutterOffscreenEffect *self)
|
video_memory_purged (ClutterOffscreenEffect *self)
|
||||||
{
|
{
|
||||||
g_clear_object (&self->priv->offscreen);
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
|
|
||||||
|
g_clear_object (&priv->offscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -216,7 +223,8 @@ update_fbo (ClutterEffect *effect,
|
|||||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||||
ClutterOffscreenEffectClass *offscreen_class =
|
ClutterOffscreenEffectClass *offscreen_class =
|
||||||
CLUTTER_OFFSCREEN_EFFECT_GET_CLASS (self);
|
CLUTTER_OFFSCREEN_EFFECT_GET_CLASS (self);
|
||||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
ClutterActor *stage_actor;
|
ClutterActor *stage_actor;
|
||||||
CoglOffscreen *offscreen;
|
CoglOffscreen *offscreen;
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
@ -251,10 +259,10 @@ update_fbo (ClutterEffect *effect,
|
|||||||
if (priv->target_width == target_width &&
|
if (priv->target_width == target_width &&
|
||||||
priv->target_height == target_height &&
|
priv->target_height == target_height &&
|
||||||
priv->offscreen != NULL)
|
priv->offscreen != NULL)
|
||||||
{
|
{
|
||||||
ensure_pipeline_filter_for_scale (self, resource_scale);
|
ensure_pipeline_filter_for_scale (self, resource_scale);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_object (&priv->texture);
|
g_clear_object (&priv->texture);
|
||||||
g_clear_object (&priv->offscreen);
|
g_clear_object (&priv->offscreen);
|
||||||
@ -296,7 +304,8 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
|
|||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
CoglFramebuffer *offscreen;
|
CoglFramebuffer *offscreen;
|
||||||
ClutterActorBox raw_box, box;
|
ClutterActorBox raw_box, box;
|
||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
@ -412,7 +421,8 @@ clutter_offscreen_effect_real_paint_target (ClutterOffscreenEffect *effect,
|
|||||||
ClutterPaintNode *node,
|
ClutterPaintNode *node,
|
||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffectPrivate *priv = effect->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (effect);
|
||||||
ClutterPaintNode *pipeline_node;
|
ClutterPaintNode *pipeline_node;
|
||||||
guint8 paint_opacity;
|
guint8 paint_opacity;
|
||||||
|
|
||||||
@ -449,7 +459,8 @@ clutter_offscreen_effect_paint_texture (ClutterOffscreenEffect *effect,
|
|||||||
ClutterPaintNode *node,
|
ClutterPaintNode *node,
|
||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffectPrivate *priv = effect->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (effect);
|
||||||
graphene_matrix_t transform;
|
graphene_matrix_t transform;
|
||||||
float unscale;
|
float unscale;
|
||||||
|
|
||||||
@ -485,7 +496,8 @@ clutter_offscreen_effect_post_paint (ClutterEffect *effect,
|
|||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
|
|
||||||
g_warn_if_fail (priv->offscreen);
|
g_warn_if_fail (priv->offscreen);
|
||||||
g_warn_if_fail (priv->pipeline);
|
g_warn_if_fail (priv->pipeline);
|
||||||
@ -499,7 +511,8 @@ add_actor_node (ClutterOffscreenEffect *offscreen_effect,
|
|||||||
ClutterPaintNode *node,
|
ClutterPaintNode *node,
|
||||||
int paint_opacity)
|
int paint_opacity)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffectPrivate *priv = offscreen_effect->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (offscreen_effect);
|
||||||
ClutterPaintNode *actor_node;
|
ClutterPaintNode *actor_node;
|
||||||
|
|
||||||
actor_node = clutter_actor_node_new (priv->actor, paint_opacity);
|
actor_node = clutter_actor_node_new (priv->actor, paint_opacity);
|
||||||
@ -514,7 +527,8 @@ clutter_offscreen_effect_paint_node (ClutterEffect *effect,
|
|||||||
ClutterEffectPaintFlags flags)
|
ClutterEffectPaintFlags flags)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (effect);
|
ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||||
ClutterOffscreenEffectPrivate *priv = offscreen_effect->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (offscreen_effect);
|
||||||
ClutterPaintNode *layer_node;
|
ClutterPaintNode *layer_node;
|
||||||
CoglFramebuffer *fb;
|
CoglFramebuffer *fb;
|
||||||
|
|
||||||
@ -535,7 +549,8 @@ clutter_offscreen_effect_paint (ClutterEffect *effect,
|
|||||||
ClutterEffectPaintFlags flags)
|
ClutterEffectPaintFlags flags)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
ClutterEffectClass *parent_class =
|
ClutterEffectClass *parent_class =
|
||||||
CLUTTER_EFFECT_CLASS (clutter_offscreen_effect_parent_class);
|
CLUTTER_EFFECT_CLASS (clutter_offscreen_effect_parent_class);
|
||||||
|
|
||||||
@ -562,7 +577,8 @@ clutter_offscreen_effect_set_enabled (ClutterActorMeta *meta,
|
|||||||
ClutterActorMetaClass *parent_class =
|
ClutterActorMetaClass *parent_class =
|
||||||
CLUTTER_ACTOR_META_CLASS (clutter_offscreen_effect_parent_class);
|
CLUTTER_ACTOR_META_CLASS (clutter_offscreen_effect_parent_class);
|
||||||
ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (meta);
|
ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (meta);
|
||||||
ClutterOffscreenEffectPrivate *priv = offscreen_effect->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (offscreen_effect);
|
||||||
|
|
||||||
g_clear_object (&priv->offscreen);
|
g_clear_object (&priv->offscreen);
|
||||||
|
|
||||||
@ -573,7 +589,8 @@ static void
|
|||||||
clutter_offscreen_effect_finalize (GObject *gobject)
|
clutter_offscreen_effect_finalize (GObject *gobject)
|
||||||
{
|
{
|
||||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (gobject);
|
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (gobject);
|
||||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
ClutterOffscreenEffectPrivate *priv =
|
||||||
|
clutter_offscreen_effect_get_instance_private (self);
|
||||||
|
|
||||||
g_clear_object (&priv->offscreen);
|
g_clear_object (&priv->offscreen);
|
||||||
g_clear_object (&priv->texture);
|
g_clear_object (&priv->texture);
|
||||||
@ -607,7 +624,6 @@ clutter_offscreen_effect_class_init (ClutterOffscreenEffectClass *klass)
|
|||||||
static void
|
static void
|
||||||
clutter_offscreen_effect_init (ClutterOffscreenEffect *self)
|
clutter_offscreen_effect_init (ClutterOffscreenEffect *self)
|
||||||
{
|
{
|
||||||
self->priv = clutter_offscreen_effect_get_instance_private (self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -631,10 +647,13 @@ clutter_offscreen_effect_init (ClutterOffscreenEffect *self)
|
|||||||
CoglTexture*
|
CoglTexture*
|
||||||
clutter_offscreen_effect_get_texture (ClutterOffscreenEffect *effect)
|
clutter_offscreen_effect_get_texture (ClutterOffscreenEffect *effect)
|
||||||
{
|
{
|
||||||
|
ClutterOffscreenEffectPrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect),
|
g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return effect->priv->texture;
|
priv = clutter_offscreen_effect_get_instance_private (effect);
|
||||||
|
return priv->texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -654,10 +673,13 @@ clutter_offscreen_effect_get_texture (ClutterOffscreenEffect *effect)
|
|||||||
CoglPipeline *
|
CoglPipeline *
|
||||||
clutter_offscreen_effect_get_pipeline (ClutterOffscreenEffect *effect)
|
clutter_offscreen_effect_get_pipeline (ClutterOffscreenEffect *effect)
|
||||||
{
|
{
|
||||||
|
ClutterOffscreenEffectPrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect),
|
g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return effect->priv->pipeline;
|
priv = clutter_offscreen_effect_get_instance_private (effect);
|
||||||
|
return priv->pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -730,7 +752,7 @@ clutter_offscreen_effect_get_target_size (ClutterOffscreenEffect *effect,
|
|||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect), FALSE);
|
||||||
|
|
||||||
priv = effect->priv;
|
priv = clutter_offscreen_effect_get_instance_private (effect);
|
||||||
|
|
||||||
if (priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -34,23 +34,13 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define CLUTTER_TYPE_OFFSCREEN_EFFECT (clutter_offscreen_effect_get_type ())
|
#define CLUTTER_TYPE_OFFSCREEN_EFFECT (clutter_offscreen_effect_get_type ())
|
||||||
#define CLUTTER_OFFSCREEN_EFFECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CLUTTER_TYPE_OFFSCREEN_EFFECT, ClutterOffscreenEffect))
|
|
||||||
#define CLUTTER_IS_OFFSCREEN_EFFECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CLUTTER_TYPE_OFFSCREEN_EFFECT))
|
|
||||||
#define CLUTTER_OFFSCREEN_EFFECT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CLUTTER_TYPE_OFFSCREEN_EFFECT, ClutterOffscreenEffectClass))
|
|
||||||
#define CLUTTER_IS_OFFSCREEN_EFFECT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CLUTTER_TYPE_OFFSCREEN_EFFECT))
|
|
||||||
#define CLUTTER_OFFSCREEN_EFFECT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CLUTTER_TYPE_OFFSCREEN_EFFECT, ClutterOffscreenEffectClass))
|
|
||||||
|
|
||||||
typedef struct _ClutterOffscreenEffect ClutterOffscreenEffect;
|
CLUTTER_EXPORT
|
||||||
typedef struct _ClutterOffscreenEffectPrivate ClutterOffscreenEffectPrivate;
|
G_DECLARE_DERIVABLE_TYPE (ClutterOffscreenEffect,
|
||||||
typedef struct _ClutterOffscreenEffectClass ClutterOffscreenEffectClass;
|
clutter_offscreen_effect,
|
||||||
|
CLUTTER,
|
||||||
struct _ClutterOffscreenEffect
|
OFFSCREEN_EFFECT,
|
||||||
{
|
ClutterEffect)
|
||||||
/*< private >*/
|
|
||||||
ClutterEffect parent_instance;
|
|
||||||
|
|
||||||
ClutterOffscreenEffectPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterOffscreenEffectClass:
|
* ClutterOffscreenEffectClass:
|
||||||
@ -75,9 +65,6 @@ struct _ClutterOffscreenEffectClass
|
|||||||
ClutterPaintContext *paint_context);
|
ClutterPaintContext *paint_context);
|
||||||
};
|
};
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
|
||||||
GType clutter_offscreen_effect_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
CoglPipeline * clutter_offscreen_effect_get_pipeline (ClutterOffscreenEffect *effect);
|
CoglPipeline * clutter_offscreen_effect_get_pipeline (ClutterOffscreenEffect *effect);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user