actor: Add TransformInfo

ClutterTransformInfo is a (private) ancillary data structure that
contains all the decomposed transformation data, i.e. rotation angles
and centers, scale factors and centers, and anchor point. This data
structure is stored in the GData of the actor instance instead of the
actor's private data. This change gives us:

  • a smaller, cleaner private data structure;
  • no size penalty for untransformed actors;
  • static constant storage for the defaults, shared across all
    instances;
  • cache locality for all the decomposed transformation data,
    given that the structure size is smaller.

At the end of the day, the only authoritative piece of information for
actor transformation is the CoglMatrix that we initialize in
apply_transform() from all the decomposed parameters, and that can stay
inside the private data structure of ClutterActor.
This commit is contained in:
Emmanuele Bassi 2011-12-09 14:38:25 +00:00 committed by Emmanuele Bassi
parent 193af77866
commit 9eed2f58a6
2 changed files with 590 additions and 327 deletions

View File

@ -108,7 +108,41 @@ typedef ClutterActorTraverseVisitFlags (*ClutterTraverseCallback) (ClutterActor
typedef gboolean (*ClutterForeachCallback) (ClutterActor *actor, typedef gboolean (*ClutterForeachCallback) (ClutterActor *actor,
gpointer user_data); gpointer user_data);
typedef struct _AnchorCoord AnchorCoord;
typedef struct _SizeRequest SizeRequest;
typedef struct _ClutterLayoutInfo ClutterLayoutInfo; typedef struct _ClutterLayoutInfo ClutterLayoutInfo;
typedef struct _ClutterTransformInfo ClutterTransformInfo;
/* Internal helper struct to represent a point that can be stored in
either direct pixel coordinates or as a fraction of the actor's
size. It is used for the anchor point, scale center and rotation
centers. */
struct _AnchorCoord
{
gboolean is_fractional;
union
{
/* Used when is_fractional == TRUE */
struct
{
gdouble x;
gdouble y;
} fraction;
/* Use when is_fractional == FALSE */
ClutterVertex units;
} v;
};
struct _SizeRequest
{
guint age;
gfloat for_size;
gfloat min_size;
gfloat natural_size;
};
/*< private > /*< private >
* ClutterLayoutInfo: * ClutterLayoutInfo:
@ -149,6 +183,30 @@ struct _ClutterLayoutInfo
const ClutterLayoutInfo * _clutter_actor_get_layout_info_or_defaults (ClutterActor *self); const ClutterLayoutInfo * _clutter_actor_get_layout_info_or_defaults (ClutterActor *self);
ClutterLayoutInfo * _clutter_actor_get_layout_info (ClutterActor *self); ClutterLayoutInfo * _clutter_actor_get_layout_info (ClutterActor *self);
struct _ClutterTransformInfo
{
/* rotation (angle and center) */
gdouble rx_angle;
AnchorCoord rx_center;
gdouble ry_angle;
AnchorCoord ry_center;
gdouble rz_angle;
AnchorCoord rz_center;
/* scaling */
gdouble scale_x;
gdouble scale_y;
AnchorCoord scale_center;
/* anchor point */
AnchorCoord anchor;
};
const ClutterTransformInfo * _clutter_actor_get_transform_info_or_defaults (ClutterActor *self);
ClutterTransformInfo * _clutter_actor_get_transform_info (ClutterActor *self);
gboolean _clutter_actor_foreach_child (ClutterActor *self, gboolean _clutter_actor_foreach_child (ClutterActor *self,
ClutterForeachCallback callback, ClutterForeachCallback callback,
gpointer user_data); gpointer user_data);

File diff suppressed because it is too large Load Diff