diff --git a/ChangeLog b/ChangeLog index 0f32ba47a..e47af3521 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2007-05-25 Tomas Frydrych + + * clutter/clutter-actor.c: + * clutter/clutter-actor.h: + Renamed clutter_actor_scalex() to clutter_actor_set_scale_with_gravityx + Added floating point version clutter_actor_set_scale_with_gravity. + + * clutter/clutter-units.h: + * clutter/clutter-actor.h: + typedef ClutterUnit + + * clutter/clutter-fixed.h: + * clutter/clutter-stage.c: + CLUTTER_ANGLE_FROM_DEG(), CLUTTER_ANGLE_FROM_DEGX() + renamed CLUTTER_DEGF_TO_CLUTTER_ANGLE to CLUTTER_ANGLE_FROM_DEGF + + * clutter/clutter-behaviour-ellipse.h: + * clutter/clutter-behaviour-ellipse.c: + * examples/behave.c: + (clutter_behaviour_ellipse_new): + Changed signature to take angles in degrees, and x,y offsets. + (clutter_behaviour_ellipse_newx): + Fixed version clutter_behaviour_ellipse_new. + (clutter_behaviour_ellipse_set_center): + (clutter_behaviour_ellipse_get_center): + Changed signature to take x,y coords instead of ClutterKnot. + + clutter/cogl/gl/cogl.c: + clutter/cogl/gles/cogl.c: + (cogl_setup_viewport): + Added z_camera calculation. + 2007-05-25 Matthew Allum * Makefile.am: @@ -55,7 +87,7 @@ * tests/test-offscreen.c: * tests/test-scale.c: More tests. - + 2007-05-23 Tomas Frydrych * clutter/clutter-actor.c: diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 3216ca04f..5405d5be9 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -1428,7 +1428,31 @@ clutter_actor_get_scale (ClutterActor *self, } /** - * clutter_actor_scalex: + * clutter_actor_set_scale_with_gravity: + * @self: A #ClutterActor + * @scale_x: scaling factor for x axis + * @scale_y: scaling factor for y axis + * @gravity: #ClutterGravity to apply to scaling. + * + * Scales the actor by scale_x, scale_y taking into consideration the + * required gravity. + * + * Since: 0.4 + */ +void +clutter_actor_set_scale_with_gravity (ClutterActor *self, + gfloat scale_x, + gfloat scale_y, + ClutterGravity gravity) +{ + clutter_actor_set_scale_with_gravityx (self, + CLUTTER_FLOAT_TO_FIXED (scale_x), + CLUTTER_FLOAT_TO_FIXED (scale_y), + gravity); +} + +/** + * clutter_actor_set_scale_with_gravityx: * @self: A #ClutterActor * @scale_x: #ClutterFixed scaling factor for x axis * @scale_y: #ClutterFixed scaling factor for y axis @@ -1440,10 +1464,10 @@ clutter_actor_get_scale (ClutterActor *self, * Since: 0.4 */ void -clutter_actor_scalex (ClutterActor *self, - ClutterFixed scale_x, - ClutterFixed scale_y, - ClutterGravity gravity) +clutter_actor_set_scale_with_gravityx (ClutterActor *self, + ClutterFixed scale_x, + ClutterFixed scale_y, + ClutterGravity gravity) { ClutterActorBox box; gint32 sw, sh, w, h; diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 3fbd3f1c8..ff8427c3b 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -30,6 +30,7 @@ #include #include +#include G_BEGIN_DECLS @@ -101,7 +102,7 @@ typedef enum CLUTTER_ACTOR_REALIZED = 1 << 2 } ClutterActorFlags; -struct _ClutterActorBox { gint32 x1, y1, x2, y2; }; +struct _ClutterActorBox { ClutterUnit x1, y1, x2, y2; }; GType clutter_actor_box_get_type (void) G_GNUC_CONST; @@ -250,10 +251,15 @@ void clutter_actor_get_scale (ClutterActor *sel gdouble *scale_x, gdouble *scale_y); -void clutter_actor_scalex (ClutterActor *self, - ClutterFixed scale_x, - ClutterFixed scale_y, - ClutterGravity gravity); +void clutter_actor_set_scale_with_gravityx (ClutterActor *self, + ClutterFixed scale_x, + ClutterFixed scale_y, + ClutterGravity gravity); + +void clutter_actor_set_scale_with_gravity (ClutterActor *self, + gfloat scale_x, + gfloat scale_y, + ClutterGravity gravity); void clutter_actor_get_abs_size (ClutterActor *self, guint *width, diff --git a/clutter/clutter-behaviour-ellipse.c b/clutter/clutter-behaviour-ellipse.c index df6d08176..bb1bef93c 100644 --- a/clutter/clutter-behaviour-ellipse.c +++ b/clutter/clutter-behaviour-ellipse.c @@ -217,7 +217,12 @@ clutter_behaviour_ellipse_set_property (GObject *gobject, priv->b = g_value_get_int (value) >> 1; break; case PROP_CENTER: - clutter_behaviour_ellipse_set_center (el, g_value_get_boxed (value)); + { + ClutterKnot * k = g_value_get_boxed (value); + if (k) + clutter_behaviour_ellipse_set_center (el, k->x, k->y); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); @@ -393,12 +398,13 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self) /** * clutter_behaviour_ellipse_new: * @alpha: a #ClutterAlpha, or %NULL - * @center: center of the ellipse as #ClutterKnot + * @x: x coordinace of the center + * @y: y coordiance of the center * @width: width of the ellipse * @height: height of the ellipse - * @begin: #ClutterAngle at which movement begins - * @end: #ClutterAngle at which movement ends - * @tilt: #ClutterAngle with which the ellipse should be tilted around its + * @begin: angle in degrees at which movement begins + * @end: angle in degrees at which movement ends + * @tilt: angle in degrees with which the ellipse should be tilted around its * center * * Creates a behaviour that drives actors along an elliptical path with @@ -412,34 +418,93 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self) */ ClutterBehaviour * clutter_behaviour_ellipse_new (ClutterAlpha * alpha, - ClutterKnot * center, + gint x, + gint y, gint width, gint height, - ClutterAngle begin, - ClutterAngle end, - ClutterAngle tilt) + gdouble begin, + gdouble end, + gdouble tilt) { ClutterBehaviourEllipse *bc; g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL); - + + ClutterKnot center; + center.x = x; + center.y = y; + bc = g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE, "alpha", alpha, - "center", center, + "center", ¢er, "width", width, "height", height, - "angle-begin", begin, - "angle-end", end, - "angle-tilt", tilt, + "angle-begin", CLUTTER_ANGLE_FROM_DEG (begin), + "angle-end", CLUTTER_ANGLE_FROM_DEG (end), + "angle-tilt", CLUTTER_ANGLE_FROM_DEG (tilt), NULL); return CLUTTER_BEHAVIOUR (bc); } +/** + * clutter_behaviour_ellipse_newx: + * @alpha: a #ClutterAlpha, or %NULL + * @x: x coordinace of the center + * @y: y coordiance of the center + * @width: width of the ellipse + * @height: height of the ellipse + * @begin: #ClutterFixed angle in degrees at which movement begins + * @end: #ClutterFixed angle in degrees at which movement ends + * @tilt: #ClutterFixed angle in degrees with which the ellipse should be tilted around its + * center + * + * Creates a behaviour that drives actors along an elliptical path with + * given center, width and height; the movement begins at angle_begin and + * ends at angle_end; if angle_end > angle_begin, the movement is in + * counter-clockwise direction, clockwise other wise. + * + * Return value: a #ClutterBehaviour + * + * Since: 0.4 + */ +ClutterBehaviour * +clutter_behaviour_ellipse_newx (ClutterAlpha * alpha, + gint x, + gint y, + gint width, + gint height, + ClutterFixed begin, + ClutterFixed end, + ClutterFixed tilt) +{ + ClutterBehaviourEllipse *bc; + + g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL); + + ClutterKnot center; + center.x = x; + center.y = y; + + bc = g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE, + "alpha", alpha, + "center", ¢er, + "width", width, + "height", height, + "angle-begin", CLUTTER_ANGLE_FROM_DEGX (begin), + "angle-end", CLUTTER_ANGLE_FROM_DEGX (end), + "angle-tilt", CLUTTER_ANGLE_FROM_DEGX (tilt), + NULL); + + return CLUTTER_BEHAVIOUR (bc); +} + + /** * clutter_behaviour_ellipse_set_center * @self: a #ClutterBehaviourEllipse - * @knot: a #ClutterKnot center for the ellipse + * @x: x coordinace of centre + * @y: y coordinace of centre * * Sets the center of the elliptical path to the point represented by knot. * @@ -447,12 +512,14 @@ clutter_behaviour_ellipse_new (ClutterAlpha * alpha, */ void clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self, - ClutterKnot * knot) + gint x, + gint y) { - if (self->priv->center.x != knot->x || self->priv->center.y != knot->y) + if (self->priv->center.x != x || self->priv->center.y != y) { g_object_ref (self); - self->priv->center = *knot; + self->priv->center.x = x; + self->priv->center.y = y; g_object_notify (G_OBJECT (self), "center"); g_object_unref (self); } @@ -461,7 +528,8 @@ clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self, /** * clutter_behaviour_ellipse_get_center * @self: a #ClutterBehaviourEllipse - * @knot: a #ClutterKnot where to store the center of the ellipse + * @x: location to store the x coordinace of the center, or NULL + * @y: location to store the y coordinace of the center, or NULL * * Gets the center of the elliptical path path. * @@ -469,9 +537,14 @@ clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self, */ void clutter_behaviour_ellipse_get_center (ClutterBehaviourEllipse * self, - ClutterKnot * knot) + gint * x, + gint * y) { - *knot = self->priv->center; + if (x) + *x = self->priv->center.x; + + if (y) + *y = self->priv->center.y; } diff --git a/clutter/clutter-behaviour-ellipse.h b/clutter/clutter-behaviour-ellipse.h index a673d7ea6..11e07dca5 100644 --- a/clutter/clutter-behaviour-ellipse.h +++ b/clutter/clutter-behaviour-ellipse.h @@ -82,17 +82,30 @@ struct _ClutterBehaviourEllipseClass GType clutter_behaviour_ellipse_get_type (void) G_GNUC_CONST; ClutterBehaviour *clutter_behaviour_ellipse_new (ClutterAlpha * alpha, - ClutterKnot * center, - gint width, - gint height, - ClutterAngle start, - ClutterAngle end, - ClutterAngle tilt); + gint x, + gint y, + gint width, + gint height, + gdouble start, + gdouble end, + gdouble tilt); + +ClutterBehaviour *clutter_behaviour_ellipse_newx (ClutterAlpha * alpha, + gint x, + gint y, + gint width, + gint height, + ClutterFixed start, + ClutterFixed end, + ClutterFixed tilt); void clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self, - ClutterKnot * knot); + gint x, + gint y); + void clutter_behaviour_ellipse_get_center (ClutterBehaviourEllipse * bs, - ClutterKnot * knot); + gint * x, + gint * y); void clutter_behaviour_ellipse_set_width (ClutterBehaviourEllipse * self, gint width); diff --git a/clutter/clutter-behaviour-scale.c b/clutter/clutter-behaviour-scale.c index 8999f97b3..b94d386c6 100644 --- a/clutter/clutter-behaviour-scale.c +++ b/clutter/clutter-behaviour-scale.c @@ -83,7 +83,7 @@ scale_frame_foreach (ClutterBehaviour *behaviour, ClutterFixed scale = GPOINTER_TO_UINT (data); ClutterGravity gravity = priv->gravity; - clutter_actor_scalex (actor, scale, scale, gravity); + clutter_actor_set_scale_with_gravityx (actor, scale, scale, gravity); } static void diff --git a/clutter/clutter-fixed.h b/clutter/clutter-fixed.h index ea555aca2..10bdfd659 100644 --- a/clutter/clutter-fixed.h +++ b/clutter/clutter-fixed.h @@ -46,6 +46,13 @@ typedef gint32 ClutterFixed; */ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */ +#define CLUTTER_ANGLE_FROM_DEG(x) CLUTTER_FLOAT_TO_INT((x*1024.0)/360.0) + +#define CLUTTER_ANGLE_FROM_DEGF(x) CLUTTER_FLOAT_TO_INT(((float)x*1024.0f)/360.0f) +#define CLUTTER_ANGLE_TO_DEGF(x) (((float)x * 360.0)/ 1024.0) + +#define CLUTTER_ANGLE_FROM_DEGX(x) CFX_INT(((x*1024)/360) + CFX_HALF) + #define CFX_Q 16 /* Decimal part size in bits */ #define CFX_ONE (1 << CFX_Q) /* 1 */ #define CFX_HALF 32768 @@ -135,10 +142,6 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */ #define CLUTTER_FIXED_MUL(x,y) ((x) >> 8) * ((y) >> 8) #define CLUTTER_FIXED_DIV(x,y) ((((x) << 8)/(y)) << 8) -#define CLUTTER_DEGF_TO_CLUTTER_ANGLE(x) CLUTTER_FLOAT_TO_INT ((x / 360.0) * 1024) - -#define CLUTTER_ANGLE_TO_DEGF(x) (((float)x * 360.0)/ 1024.0) - /* some handy short aliases to avoid exessively long lines */ #define CFX_INT CLUTTER_FIXED_INT diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 9804e0248..918bfa12f 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -557,7 +557,7 @@ clutter_stage_set_perspective (ClutterStage *stage, g_return_if_fail (CLUTTER_IS_STAGE (stage)); priv = stage->priv; - priv->perspective.fovy = CLUTTER_DEGF_TO_CLUTTER_ANGLE(fovy); + priv->perspective.fovy = CLUTTER_ANGLE_FROM_DEGF(fovy); priv->perspective.aspect = CLUTTER_FLOAT_TO_FIXED(aspect); priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED(z_near); priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED(z_far); diff --git a/clutter/clutter-units.h b/clutter/clutter-units.h index 799271ede..6d9a4d983 100644 --- a/clutter/clutter-units.h +++ b/clutter/clutter-units.h @@ -49,6 +49,10 @@ #include +G_BEGIN_DECLS + +typedef gint32 ClutterUnit; + /* * Currently CLUTTER_UNIT maps directly onto ClutterFixed. Nevertheless, the * _FROM_FIXED and _TO_FIXED macros should always be used in case that we @@ -71,4 +75,6 @@ #define CLUTTER_UNITS_FROM_PANGO_UNIT(x) (x << 6) +G_END_DECLS + #endif /* _HAVE_CLUTTER_UNITS_H */ diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c index bb6853b76..91af4be31 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -549,6 +549,8 @@ cogl_setup_viewport (guint width, ClutterFixed z_near, ClutterFixed z_far) { + GLfloat z_camera; + GE( glViewport (0, 0, width, height) ); GE( glMatrixMode (GL_PROJECTION) ); @@ -562,7 +564,9 @@ cogl_setup_viewport (guint width, /* camera distance from screen, 0.5 * tan (FOV) */ #define DEFAULT_Z_CAMERA 0.866025404f - GE( glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA) ); + z_camera = CLUTTER_FIXED_TO_FLOAT (clutter_tani (fovy) >> 1); + + GE( glTranslatef (-0.5f, -0.5f, -z_camera) ); GE( glScalef ( 1.0f / width, -1.0f / height, 1.0f / width) ); diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c index 0739a7b57..133572438 100644 --- a/clutter/cogl/gles/cogl.c +++ b/clutter/cogl/gles/cogl.c @@ -489,7 +489,8 @@ cogl_setup_viewport (guint w, { gint width = (gint) w; gint height = (gint) h; - + ClutterFixed z_camera; + GE( glViewport (0, 0, width, height) ); GE( glMatrixMode (GL_PROJECTION) ); GE( glLoadIdentity () ); @@ -505,10 +506,9 @@ cogl_setup_viewport (guint w, /* camera distance from screen, 0.5 * tan (FOV) */ #define DEFAULT_Z_CAMERA 0.866025404f - - GE( glTranslatex (-1 << 15, - -1 << 15, - -CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA)) ); + z_camera = clutter_tani (fovy) << 1; + + GE( glTranslatex (-1 << 15, -1 << 15, -z_camera ); GE( glScalex ( CFX_ONE / width, -CFX_ONE / height, diff --git a/doc/reference/tmpl/clutter-behaviour-ellipse.sgml b/doc/reference/tmpl/clutter-behaviour-ellipse.sgml index 95cb2d7bf..d7b55331b 100644 --- a/doc/reference/tmpl/clutter-behaviour-ellipse.sgml +++ b/doc/reference/tmpl/clutter-behaviour-ellipse.sgml @@ -79,7 +79,8 @@ ClutterBehaviourEllipse @alpha: -@center: +@x: +@y: @width: @height: @start: @@ -94,7 +95,8 @@ ClutterBehaviourEllipse @self: -@knot: +@x: +@y: @@ -103,7 +105,8 @@ ClutterBehaviourEllipse @bs: -@knot: +@x: +@y: diff --git a/doc/reference/tmpl/clutter-feature.sgml b/doc/reference/tmpl/clutter-feature.sgml index 6d5585cac..3f2ee9cd7 100644 --- a/doc/reference/tmpl/clutter-feature.sgml +++ b/doc/reference/tmpl/clutter-feature.sgml @@ -24,6 +24,7 @@ clutter-feature @CLUTTER_FEATURE_TEXTURE_RECTANGLE: @CLUTTER_FEATURE_SYNC_TO_VBLANK: +@CLUTTER_FEATURE_TEXTURE_YUV: @CLUTTER_FEATURE_TEXTURE_READ_PIXELS: diff --git a/doc/reference/tmpl/clutter-stage.sgml b/doc/reference/tmpl/clutter-stage.sgml index 03abded50..92e12302a 100644 --- a/doc/reference/tmpl/clutter-stage.sgml +++ b/doc/reference/tmpl/clutter-stage.sgml @@ -38,8 +38,8 @@ Macro evaluating to the height of the #ClutterStage @fovy: @aspect: -@zNear: -@zFar: +@z_near: +@z_far: diff --git a/doc/reference/tmpl/clutter-texture.sgml b/doc/reference/tmpl/clutter-texture.sgml index c7423bf68..1d39ea901 100644 --- a/doc/reference/tmpl/clutter-texture.sgml +++ b/doc/reference/tmpl/clutter-texture.sgml @@ -116,20 +116,6 @@ ClutterTexture @Returns: - - - - - -@texture: -@data: -@has_alpha: -@width: -@height: -@rowstride: -@bpp: - - @@ -137,6 +123,8 @@ ClutterTexture @texture: @pixbuf: +@error: +@Returns: diff --git a/examples/behave.c b/examples/behave.c index 8956a028c..31a74bd6b 100644 --- a/examples/behave.c +++ b/examples/behave.c @@ -165,8 +165,8 @@ main (int argc, char *argv[]) break; case PATH_ELLIPSE: p_behave = - clutter_behaviour_ellipse_new (alpha, &origin, 400, 300, - 0, 1024, 0); + clutter_behaviour_ellipse_new (alpha, 200, 200, 400, 300, + 0.0, 360.0, 0.0); break; case PATH_BSPLINE: