From 0c83e6a59ae5287f54e82a9fdd0bbe289d46831c Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 28 Feb 2011 14:31:59 +0000 Subject: [PATCH] offscreen-effect: Add public accessor for target size The OffscreenEffect class needs to expose a way for sub-classes to track the size of FBO it creates, in case it has to do some geometry deformations like the DeformEffect sub-classes. Let's move the private symbol we used internally in 1.6 to fix DeformEffect to the list of public symbols of OffscreenEffect. http://bugzilla.clutter-project.org/show_bug.cgi?id=2570 --- clutter/clutter-deform-effect.c | 5 +++- clutter/clutter-offscreen-effect-private.h | 4 --- clutter/clutter-offscreen-effect.c | 30 +++++++++++++++++++--- clutter/clutter-offscreen-effect.h | 13 ++++++---- doc/reference/clutter/clutter-sections.txt | 1 + 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/clutter/clutter-deform-effect.c b/clutter/clutter-deform-effect.c index 9d6a7f3c5..b976d612d 100644 --- a/clutter/clutter-deform-effect.c +++ b/clutter/clutter-deform-effect.c @@ -184,7 +184,10 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect) actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect)); opacity = clutter_actor_get_paint_opacity (actor); - if (!_clutter_offscreen_effect_get_target_size (effect, &width, &height)) + /* if we don't have a target size, fall back to the actor's + * allocation, though wrong it might be + */ + if (!clutter_offscreen_effect_get_target_size (effect, &width, &height)) clutter_actor_get_size (actor, &width, &height); for (i = 0; i < priv->y_tiles + 1; i++) diff --git a/clutter/clutter-offscreen-effect-private.h b/clutter/clutter-offscreen-effect-private.h index 6a9137bff..a5249dad3 100644 --- a/clutter/clutter-offscreen-effect-private.h +++ b/clutter/clutter-offscreen-effect-private.h @@ -5,10 +5,6 @@ G_BEGIN_DECLS -gboolean _clutter_offscreen_effect_get_target_size (ClutterOffscreenEffect *effect, - gfloat *width, - gfloat *height); - G_END_DECLS #endif /* __CLUTTER_OFFSCREEN_EFFECT_PRIVATE_H__ */ diff --git a/clutter/clutter-offscreen-effect.c b/clutter/clutter-offscreen-effect.c index 269640847..804a36288 100644 --- a/clutter/clutter-offscreen-effect.c +++ b/clutter/clutter-offscreen-effect.c @@ -476,12 +476,34 @@ clutter_offscreen_effect_create_texture (ClutterOffscreenEffect *effect, height); } +/** + * clutter_offscreen_effect_get_target_size: + * @effect: a #ClutterOffscreenEffect + * @width: (out): return location for the target width, or %NULL + * @height: (out): return location for the target height, or %NULL + * + * Retrieves the size of the offscreen buffer used by @effect to + * paint the actor to which it has been applied. + * + * This function should only be called by #ClutterOffscreenEffect + * implementations, from within the paint_target() + * virtual function. + * + * Return value: %TRUE if the offscreen buffer has a valid size, + * and %FALSE otherwise + * + * Since: 1.8 + */ gboolean -_clutter_offscreen_effect_get_target_size (ClutterOffscreenEffect *effect, - gfloat *width, - gfloat *height) +clutter_offscreen_effect_get_target_size (ClutterOffscreenEffect *effect, + gfloat *width, + gfloat *height) { - ClutterOffscreenEffectPrivate *priv = effect->priv; + ClutterOffscreenEffectPrivate *priv; + + g_return_val_if_fail (CLUTTER_IS_OFFSCREEN_EFFECT (effect), FALSE); + + priv = effect->priv; if (priv->target == NULL) return FALSE; diff --git a/clutter/clutter-offscreen-effect.h b/clutter/clutter-offscreen-effect.h index 0f16c9f31..72636ed5c 100644 --- a/clutter/clutter-offscreen-effect.h +++ b/clutter/clutter-offscreen-effect.h @@ -93,12 +93,15 @@ struct _ClutterOffscreenEffectClass GType clutter_offscreen_effect_get_type (void) G_GNUC_CONST; -CoglMaterial *clutter_offscreen_effect_get_target (ClutterOffscreenEffect *effect); +CoglMaterial * clutter_offscreen_effect_get_target (ClutterOffscreenEffect *effect); -void clutter_offscreen_effect_paint_target (ClutterOffscreenEffect *effect); -CoglHandle clutter_offscreen_effect_create_texture (ClutterOffscreenEffect *effect, - gfloat width, - gfloat height); +void clutter_offscreen_effect_paint_target (ClutterOffscreenEffect *effect); +CoglHandle clutter_offscreen_effect_create_texture (ClutterOffscreenEffect *effect, + gfloat width, + gfloat height); +gboolean clutter_offscreen_effect_get_target_size (ClutterOffscreenEffect *effect, + gfloat *width, + gfloat *height); G_END_DECLS diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index ba95702eb..3bad5941e 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -2486,6 +2486,7 @@ ClutterOffscreenEffectClass clutter_offscreen_effect_get_target clutter_offscreen_effect_create_texture clutter_offscreen_effect_paint_target +clutter_offscreen_effect_get_target_size CLUTTER_TYPE_OFFSCREEN_EFFECT CLUTTER_OFFSCREEN_EFFECT