* clutter/clutter-actor.[ch]: added clutter_actor_get_shader and

renamed clutter_actor_apply_shader to be clutter_actor_set_shader.
Reindented/aligned header.
* clutter/clutter-texture.c: (clutter_texture_paint): temporarily
disable the shader on top of the clutter context's shader stack while
rendering into the FBO.
* tests/test-fbo.c: (main): s/apply_shader/set_shader/
* tests/test-shader.c: (button_release_cb), (main):
s/apply_shader/set_shader/
This commit is contained in:
Øyvind Kolås 2008-02-04 11:45:12 +00:00
parent 680cd23b43
commit 1fe08217b7
6 changed files with 304 additions and 230 deletions

View File

@ -1,3 +1,15 @@
2008-02-04 Øyvind Kolås <pippin@o-hand.com>
* clutter/clutter-actor.[ch]: added clutter_actor_get_shader and
renamed clutter_actor_apply_shader to be clutter_actor_set_shader.
Reindented/aligned header.
* clutter/clutter-texture.c: (clutter_texture_paint): temporarily
disable the shader on top of the clutter context's shader stack while
rendering into the FBO.
* tests/test-fbo.c: (main): s/apply_shader/set_shader/
* tests/test-shader.c: (button_release_cb), (main):
s/apply_shader/set_shader/
2008-02-03 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-actor.c: (clutter_actor_set_rotationx):

View File

@ -5027,27 +5027,64 @@ destroy_shader_data (ClutterActor *self)
actor_priv->shader_data = NULL;
}
/**
* clutter_actor_apply_shader:
* clutter_actor_get_shader:
* @self: a #ClutterActor
* @shader: a #ClutterShader or %NULL
*
* Sets the #ClutterShader to be applied on @self.
* Queries the currently set #ClutterShader on @self.
*
* Return value: The currently set #ClutterShader or NULL if no shader is set.
*
* Since: 0.6
*/
ClutterShader *
clutter_actor_get_shader (ClutterActor *self)
{
ClutterActorPrivate *actor_priv;
ShaderData *shader_data;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
actor_priv = self->priv;
shader_data = actor_priv->shader_data;
if (!shader_data)
{
return NULL;
}
return shader_data->shader;
}
/**
* clutter_actor_set_shader:
* @self: a #ClutterActor
* @shader: a #ClutterShader or %NULL to unset the shader.
*
* Sets the #ClutterShader to be used when rendering @self, pass in NULL
* to unset a currently set shader for an actor.
*
* Return value: %TRUE if the shader was successfully applied
*
* Since: 0.6
*/
gboolean
clutter_actor_apply_shader (ClutterActor *self,
ClutterShader *shader)
clutter_actor_set_shader (ClutterActor *self,
ClutterShader *shader)
{
ClutterActorPrivate *actor_priv;
ShaderData *shader_data;
ShaderData *shader_data;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
g_return_val_if_fail (shader == NULL || CLUTTER_IS_SHADER (shader), FALSE);
/* if shader passed in is NULL we destroy the shader */
if (shader == NULL)
{
destroy_shader_data (self);
}
actor_priv = self->priv;
shader_data = actor_priv->shader_data;
@ -5066,13 +5103,17 @@ clutter_actor_apply_shader (ClutterActor *self,
}
if (shader)
shader_data->shader = g_object_ref (shader);
{
shader_data->shader = g_object_ref (shader);
}
clutter_actor_queue_redraw (self);
return TRUE;
}
static void
set_each_param (gpointer key,
gpointer value,

View File

@ -72,7 +72,7 @@ typedef struct _ClutterActorPrivate ClutterActorPrivate;
* Generic callback
*/
typedef void (*ClutterCallback) (ClutterActor *actor, gpointer data);
#define CLUTTER_CALLBACK(f) ((ClutterCallback) (f))
#define CLUTTER_CALLBACK(f) ((ClutterCallback) (f))
/**
* ClutterActorFlags:
@ -192,9 +192,9 @@ struct _ClutterActorClass
void (* unrealize) (ClutterActor *actor);
void (* paint) (ClutterActor *actor);
void (* request_coords) (ClutterActor *actor,
ClutterActorBox *box);
ClutterActorBox *box);
void (* query_coords) (ClutterActor *actor,
ClutterActorBox *box);
ClutterActorBox *box);
void (* parent_set) (ClutterActor *actor,
ClutterActor *old_parent);
@ -204,25 +204,25 @@ struct _ClutterActorClass
/* event signals */
gboolean (* event) (ClutterActor *actor,
ClutterEvent *event);
ClutterEvent *event);
gboolean (* button_press_event) (ClutterActor *actor,
ClutterButtonEvent *event);
ClutterButtonEvent *event);
gboolean (* button_release_event) (ClutterActor *actor,
ClutterButtonEvent *event);
ClutterButtonEvent *event);
gboolean (* scroll_event) (ClutterActor *actor,
ClutterScrollEvent *event);
ClutterScrollEvent *event);
gboolean (* key_press_event) (ClutterActor *actor,
ClutterKeyEvent *event);
ClutterKeyEvent *event);
gboolean (* key_release_event) (ClutterActor *actor,
ClutterKeyEvent *event);
ClutterKeyEvent *event);
gboolean (* motion_event) (ClutterActor *actor,
ClutterMotionEvent *event);
ClutterMotionEvent *event);
gboolean (* enter_event) (ClutterActor *actor,
ClutterCrossingEvent *event);
ClutterCrossingEvent *event);
gboolean (* leave_event) (ClutterActor *actor,
ClutterCrossingEvent *event);
ClutterCrossingEvent *event);
gboolean (* captured_event) (ClutterActor *actor,
ClutterEvent *event);
ClutterEvent *event);
void (* focus_in) (ClutterActor *actor);
void (* focus_out) (ClutterActor *actor);
@ -231,172 +231,172 @@ struct _ClutterActorClass
gpointer _padding_dummy[32];
};
GType clutter_actor_get_type (void) G_GNUC_CONST;
GType clutter_actor_get_type (void) G_GNUC_CONST;
void clutter_actor_show (ClutterActor *self);
void clutter_actor_show_all (ClutterActor *self);
void clutter_actor_hide (ClutterActor *self);
void clutter_actor_hide_all (ClutterActor *self);
void clutter_actor_realize (ClutterActor *self);
void clutter_actor_unrealize (ClutterActor *self);
void clutter_actor_paint (ClutterActor *self);
void clutter_actor_pick (ClutterActor *self,
const ClutterColor *color);
void clutter_actor_queue_redraw (ClutterActor *self);
void clutter_actor_destroy (ClutterActor *self);
void clutter_actor_show (ClutterActor *self);
void clutter_actor_show_all (ClutterActor *self);
void clutter_actor_hide (ClutterActor *self);
void clutter_actor_hide_all (ClutterActor *self);
void clutter_actor_realize (ClutterActor *self);
void clutter_actor_unrealize (ClutterActor *self);
void clutter_actor_paint (ClutterActor *self);
void clutter_actor_pick (ClutterActor *self,
const ClutterColor *color);
void clutter_actor_queue_redraw (ClutterActor *self);
void clutter_actor_destroy (ClutterActor *self);
void clutter_actor_request_coords (ClutterActor *self,
ClutterActorBox *box);
void clutter_actor_query_coords (ClutterActor *self,
ClutterActorBox *box);
void clutter_actor_set_geometry (ClutterActor *self,
const ClutterGeometry *geometry);
void clutter_actor_get_geometry (ClutterActor *self,
ClutterGeometry *geometry);
void clutter_actor_get_coords (ClutterActor *self,
gint *x_1,
gint *y_1,
gint *x_2,
gint *y_2);
void clutter_actor_set_size (ClutterActor *self,
gint width,
gint height);
void clutter_actor_set_sizeu (ClutterActor *self,
ClutterUnit width,
ClutterUnit height);
void clutter_actor_get_size (ClutterActor *self,
guint *width,
guint *height);
void clutter_actor_get_sizeu (ClutterActor *self,
ClutterUnit *width,
ClutterUnit *height);
void clutter_actor_get_abs_size (ClutterActor *self,
guint *width,
guint *height);
void clutter_actor_set_position (ClutterActor *self,
gint x,
gint y);
void clutter_actor_set_positionu (ClutterActor *self,
ClutterUnit x,
ClutterUnit y);
void clutter_actor_get_position (ClutterActor *self,
gint *x,
gint *y);
void clutter_actor_get_positionu (ClutterActor *self,
ClutterUnit *x,
ClutterUnit *y);
void clutter_actor_get_abs_position (ClutterActor *self,
gint *x,
gint *y);
guint clutter_actor_get_width (ClutterActor *self);
ClutterUnit clutter_actor_get_widthu (ClutterActor *self);
guint clutter_actor_get_height (ClutterActor *self);
ClutterUnit clutter_actor_get_heightu (ClutterActor *self);
void clutter_actor_set_width (ClutterActor *self,
guint width);
void clutter_actor_set_widthu (ClutterActor *self,
ClutterUnit width);
void clutter_actor_set_height (ClutterActor *self,
guint height);
void clutter_actor_set_heightu (ClutterActor *self,
ClutterUnit height);
gint clutter_actor_get_x (ClutterActor *self);
ClutterUnit clutter_actor_get_xu (ClutterActor *self);
gint clutter_actor_get_y (ClutterActor *self);
ClutterUnit clutter_actor_get_yu (ClutterActor *self);
void clutter_actor_set_x (ClutterActor *self,
gint x);
void clutter_actor_set_xu (ClutterActor *self,
ClutterUnit x);
void clutter_actor_set_y (ClutterActor *self,
gint y);
void clutter_actor_set_yu (ClutterActor *self,
ClutterUnit y);
void clutter_actor_set_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gdouble angle,
gint x,
gint y,
gint z);
void clutter_actor_set_rotationx (ClutterActor *self,
ClutterRotateAxis axis,
ClutterFixed angle,
gint x,
gint y,
gint z);
gdouble clutter_actor_get_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gint *x,
gint *y,
gint *z);
ClutterFixed clutter_actor_get_rotationx (ClutterActor *self,
ClutterRotateAxis axis,
gint *x,
gint *y,
gint *z);
void clutter_actor_request_coords (ClutterActor *self,
ClutterActorBox *box);
void clutter_actor_query_coords (ClutterActor *self,
ClutterActorBox *box);
void clutter_actor_set_geometry (ClutterActor *self,
const ClutterGeometry *geometry);
void clutter_actor_get_geometry (ClutterActor *self,
ClutterGeometry *geometry);
void clutter_actor_get_coords (ClutterActor *self,
gint *x_1,
gint *y_1,
gint *x_2,
gint *y_2);
void clutter_actor_set_size (ClutterActor *self,
gint width,
gint height);
void clutter_actor_set_sizeu (ClutterActor *self,
ClutterUnit width,
ClutterUnit height);
void clutter_actor_get_size (ClutterActor *self,
guint *width,
guint *height);
void clutter_actor_get_sizeu (ClutterActor *self,
ClutterUnit *width,
ClutterUnit *height);
void clutter_actor_get_abs_size (ClutterActor *self,
guint *width,
guint *height);
void clutter_actor_set_position (ClutterActor *self,
gint x,
gint y);
void clutter_actor_set_positionu (ClutterActor *self,
ClutterUnit x,
ClutterUnit y);
void clutter_actor_get_position (ClutterActor *self,
gint *x,
gint *y);
void clutter_actor_get_positionu (ClutterActor *self,
ClutterUnit *x,
ClutterUnit *y);
void clutter_actor_get_abs_position (ClutterActor *self,
gint *x,
gint *y);
guint clutter_actor_get_width (ClutterActor *self);
ClutterUnit clutter_actor_get_widthu (ClutterActor *self);
guint clutter_actor_get_height (ClutterActor *self);
ClutterUnit clutter_actor_get_heightu (ClutterActor *self);
void clutter_actor_set_width (ClutterActor *self,
guint width);
void clutter_actor_set_widthu (ClutterActor *self,
ClutterUnit width);
void clutter_actor_set_height (ClutterActor *self,
guint height);
void clutter_actor_set_heightu (ClutterActor *self,
ClutterUnit height);
gint clutter_actor_get_x (ClutterActor *self);
ClutterUnit clutter_actor_get_xu (ClutterActor *self);
gint clutter_actor_get_y (ClutterActor *self);
ClutterUnit clutter_actor_get_yu (ClutterActor *self);
void clutter_actor_set_x (ClutterActor *self,
gint x);
void clutter_actor_set_xu (ClutterActor *self,
ClutterUnit x);
void clutter_actor_set_y (ClutterActor *self,
gint y);
void clutter_actor_set_yu (ClutterActor *self,
ClutterUnit y);
void clutter_actor_set_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gdouble angle,
gint x,
gint y,
gint z);
void clutter_actor_set_rotationx (ClutterActor *self,
ClutterRotateAxis axis,
ClutterFixed angle,
gint x,
gint y,
gint z);
gdouble clutter_actor_get_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gint *x,
gint *y,
gint *z);
ClutterFixed clutter_actor_get_rotationx (ClutterActor *self,
ClutterRotateAxis axis,
gint *x,
gint *y,
gint *z);
void clutter_actor_set_opacity (ClutterActor *self,
guint8 opacity);
guint8 clutter_actor_get_opacity (ClutterActor *self);
void clutter_actor_set_name (ClutterActor *self,
const gchar *name);
G_CONST_RETURN gchar *clutter_actor_get_name (ClutterActor *self);
guint32 clutter_actor_get_gid (ClutterActor *self);
void clutter_actor_set_clip (ClutterActor *self,
gint xoff,
gint yoff,
gint width,
gint height);
void clutter_actor_set_clipu (ClutterActor *self,
ClutterUnit xoff,
ClutterUnit yoff,
ClutterUnit width,
ClutterUnit height);
void clutter_actor_remove_clip (ClutterActor *self);
gboolean clutter_actor_has_clip (ClutterActor *self);
void clutter_actor_get_clip (ClutterActor *self,
gint *xoff,
gint *yoff,
gint *width,
gint *height);
void clutter_actor_get_clipu (ClutterActor *self,
ClutterUnit *xoff,
ClutterUnit *yoff,
ClutterUnit *width,
ClutterUnit *height);
void clutter_actor_set_parent (ClutterActor *self,
ClutterActor *parent);
ClutterActor * clutter_actor_get_parent (ClutterActor *self);
void clutter_actor_reparent (ClutterActor *self,
ClutterActor *new_parent);
void clutter_actor_unparent (ClutterActor *self);
void clutter_actor_raise (ClutterActor *self,
ClutterActor *below);
void clutter_actor_lower (ClutterActor *self,
ClutterActor *above);
void clutter_actor_raise_top (ClutterActor *self);
void clutter_actor_lower_bottom (ClutterActor *self);
void clutter_actor_set_depth (ClutterActor *self,
gint depth);
gint clutter_actor_get_depth (ClutterActor *self);
void clutter_actor_set_depthu (ClutterActor *self,
ClutterUnit depth);
ClutterUnit clutter_actor_get_depthu (ClutterActor *self);
void clutter_actor_set_reactive (ClutterActor *actor,
gboolean reactive);
gboolean clutter_actor_get_reactive (ClutterActor *actor);
void clutter_actor_set_scalex (ClutterActor *self,
ClutterFixed scale_x,
ClutterFixed scale_y);
void clutter_actor_set_scale (ClutterActor *self,
gdouble scale_x,
gdouble scale_y);
void clutter_actor_get_scalex (ClutterActor *self,
ClutterFixed *scale_x,
ClutterFixed *scale_y);
void clutter_actor_get_scale (ClutterActor *self,
gdouble *scale_x,
gdouble *scale_y);
void clutter_actor_set_opacity (ClutterActor *self,
guint8 opacity);
guint8 clutter_actor_get_opacity (ClutterActor *self);
void clutter_actor_set_name (ClutterActor *self,
const gchar *name);
G_CONST_RETURN gchar *clutter_actor_get_name (ClutterActor *self);
guint32 clutter_actor_get_gid (ClutterActor *self);
void clutter_actor_set_clip (ClutterActor *self,
gint xoff,
gint yoff,
gint width,
gint height);
void clutter_actor_set_clipu (ClutterActor *self,
ClutterUnit xoff,
ClutterUnit yoff,
ClutterUnit width,
ClutterUnit height);
void clutter_actor_remove_clip (ClutterActor *self);
gboolean clutter_actor_has_clip (ClutterActor *self);
void clutter_actor_get_clip (ClutterActor *self,
gint *xoff,
gint *yoff,
gint *width,
gint *height);
void clutter_actor_get_clipu (ClutterActor *self,
ClutterUnit *xoff,
ClutterUnit *yoff,
ClutterUnit *width,
ClutterUnit *height);
void clutter_actor_set_parent (ClutterActor *self,
ClutterActor *parent);
ClutterActor * clutter_actor_get_parent (ClutterActor *self);
void clutter_actor_reparent (ClutterActor *self,
ClutterActor *new_parent);
void clutter_actor_unparent (ClutterActor *self);
void clutter_actor_raise (ClutterActor *self,
ClutterActor *below);
void clutter_actor_lower (ClutterActor *self,
ClutterActor *above);
void clutter_actor_raise_top (ClutterActor *self);
void clutter_actor_lower_bottom (ClutterActor *self);
void clutter_actor_set_depth (ClutterActor *self,
gint depth);
gint clutter_actor_get_depth (ClutterActor *self);
void clutter_actor_set_depthu (ClutterActor *self,
ClutterUnit depth);
ClutterUnit clutter_actor_get_depthu (ClutterActor *self);
void clutter_actor_set_reactive (ClutterActor *actor,
gboolean reactive);
gboolean clutter_actor_get_reactive (ClutterActor *actor);
void clutter_actor_set_scalex (ClutterActor *self,
ClutterFixed scale_x,
ClutterFixed scale_y);
void clutter_actor_set_scale (ClutterActor *self,
gdouble scale_x,
gdouble scale_y);
void clutter_actor_get_scalex (ClutterActor *self,
ClutterFixed *scale_x,
ClutterFixed *scale_y);
void clutter_actor_get_scale (ClutterActor *self,
gdouble *scale_x,
gdouble *scale_y);
void clutter_actor_move_by (ClutterActor *self,
gint dx,
@ -406,54 +406,54 @@ void clutter_actor_move_byu (ClutterActor
ClutterUnit dy);
void clutter_actor_get_vertices (ClutterActor *self,
ClutterVertex verts[4]);
ClutterVertex verts[4]);
void clutter_actor_apply_transform_to_point (ClutterActor *self,
ClutterVertex *point,
ClutterVertex *vertex);
ClutterVertex *point,
ClutterVertex *vertex);
gboolean clutter_actor_event (ClutterActor *actor,
ClutterEvent *event,
gboolean capture);
ClutterActor * clutter_get_actor_by_gid (guint32 id);
gboolean clutter_actor_event (ClutterActor *actor,
ClutterEvent *event,
gboolean capture);
ClutterActor * clutter_get_actor_by_gid (guint32 id);
gboolean clutter_actor_should_pick_paint (ClutterActor *self);
gboolean clutter_actor_should_pick_paint (ClutterActor *self);
gboolean clutter_actor_apply_shader (ClutterActor *self,
ClutterShader *shader);
void clutter_actor_set_shader_param (ClutterActor *self,
const gchar *param,
gfloat value);
gboolean clutter_actor_set_shader (ClutterActor *self,
ClutterShader *shader);
ClutterShader * clutter_actor_get_shader (ClutterActor *self);
void clutter_actor_set_shader_param (ClutterActor *self,
const gchar *param,
gfloat value);
void clutter_actor_set_anchor_point (ClutterActor *self,
gint anchor_x,
gint anchor_y);
void clutter_actor_move_anchor_point (ClutterActor *self,
gint anchor_x,
gint anchor_y);
void clutter_actor_get_anchor_point (ClutterActor *self,
gint *anchor_x,
gint *anchor_y);
void clutter_actor_set_anchor_pointu (ClutterActor *self,
ClutterUnit anchor_x,
ClutterUnit anchor_y);
void clutter_actor_move_anchor_pointu (ClutterActor *self,
ClutterUnit anchor_x,
ClutterUnit anchor_y);
void clutter_actor_get_anchor_pointu (ClutterActor *self,
ClutterUnit *anchor_x,
ClutterUnit *anchor_y);
void clutter_actor_set_anchor_point_from_gravity (ClutterActor *self,
ClutterGravity gravity);
void clutter_actor_set_anchor_point (ClutterActor *self,
gint anchor_x,
gint anchor_y);
void clutter_actor_move_anchor_point (ClutterActor *self,
gint anchor_x,
gint anchor_y);
void clutter_actor_get_anchor_point (ClutterActor *self,
gint *anchor_x,
gint *anchor_y);
void clutter_actor_set_anchor_pointu (ClutterActor *self,
ClutterUnit anchor_x,
ClutterUnit anchor_y);
void clutter_actor_move_anchor_pointu (ClutterActor *self,
ClutterUnit anchor_x,
ClutterUnit anchor_y);
void clutter_actor_get_anchor_pointu (ClutterActor *self,
ClutterUnit *anchor_x,
ClutterUnit *anchor_y);
void clutter_actor_set_anchor_point_from_gravity (ClutterActor *self,
ClutterGravity gravity);
void clutter_actor_move_anchor_point_from_gravity (ClutterActor *self,
ClutterGravity gravity);
gboolean clutter_actor_transform_stage_point (ClutterActor *self,
ClutterUnit x,
ClutterUnit y,
ClutterUnit *x_out,
ClutterUnit *y_out);
void clutter_actor_move_anchor_point_from_gravity (ClutterActor *self,
ClutterGravity gravity);
gboolean clutter_actor_transform_stage_point (ClutterActor *self,
ClutterUnit x,
ClutterUnit y,
ClutterUnit *x_out,
ClutterUnit *y_out);
G_END_DECLS

View File

@ -762,14 +762,34 @@ clutter_texture_paint (ClutterActor *self)
if (priv->fbo_handle)
{
ClutterMainContext *context;
context = clutter_context_get_default ();
/* Temporarily turn of the shader on the top of the context's
* shader stack, to restore the GL pipeline to it's natural state.
*/
if (context->shaders)
{
clutter_shader_set_is_enabled (
clutter_actor_get_shader (context->shaders->data), FALSE);
}
cogl_offscreen_redirect_start (priv->fbo_handle,
priv->width, priv->height);
priv->width, priv->height);
clutter_actor_paint (priv->fbo_source);
cogl_offscreen_redirect_end (priv->fbo_handle,
CLUTTER_STAGE_WIDTH(),
CLUTTER_STAGE_HEIGHT());
CLUTTER_STAGE_WIDTH(),
CLUTTER_STAGE_HEIGHT());
glBindTexture(CGL_TEXTURE_RECTANGLE_ARB, priv->tiles[0]);
/* If there is a shader on top of the shader stack, turn it back on. */
if (context->shaders)
{
clutter_shader_set_is_enabled (
clutter_actor_get_shader (context->shaders->data), TRUE);
}
}

View File

@ -107,7 +107,7 @@ main (gint argc,
/* apply a shader to it */
shader = make_shader();
clutter_actor_apply_shader (fbo, shader);
clutter_actor_set_shader (fbo, shader);
clutter_actor_set_shader_param (fbo, "radius", 2.0);

View File

@ -173,11 +173,12 @@ button_release_cb (ClutterActor *actor,
shader_no, shaders[shader_no].name,
error->message);
g_error_free (error);
clutter_actor_apply_shader (actor, NULL);
clutter_actor_set_shader (actor, NULL);
}
else
{
clutter_actor_apply_shader (actor, shader);
clutter_actor_set_shader (actor, NULL);
clutter_actor_set_shader (actor, shader);
clutter_actor_set_shader_param (actor, "radius", 3.0);
}
}
@ -262,7 +263,7 @@ main (gint argc,
}
#endif
clutter_actor_apply_shader (actor, shader);
clutter_actor_set_shader (actor, shader);
clutter_actor_set_position (actor, 100, 100);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);