From cf3a29f224644b718458576191a6246883ba6485 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 21 Oct 2010 11:59:50 +0100 Subject: [PATCH] Clean up clutter-private.h/5 Move PaintVolume private API to a separate header. --- clutter/Makefile.am | 1 + clutter/clutter-actor.c | 1 + clutter/clutter-clone.c | 2 +- clutter/clutter-paint-volume-private.h | 104 +++++++++++++++++++++++ clutter/clutter-paint-volume.c | 3 + clutter/clutter-private.h | 93 -------------------- clutter/clutter-stage.c | 19 +++-- clutter/x11/clutter-event-x11.c | 1 + clutter/x11/clutter-x11-texture-pixmap.c | 4 +- 9 files changed, 124 insertions(+), 104 deletions(-) create mode 100644 clutter/clutter-paint-volume-private.h diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 3d26ff497..0bff379d2 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -228,6 +228,7 @@ source_h_priv = \ $(srcdir)/clutter-keysyms-table.h \ $(srcdir)/clutter-master-clock.h \ $(srcdir)/clutter-model-private.h \ + $(srcdir)/clutter-paint-volume-private.h \ $(srcdir)/clutter-private.h \ $(srcdir)/clutter-profile.h \ $(srcdir)/clutter-script-private.h \ diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 2435e250c..e78295654 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -299,6 +299,7 @@ #include "clutter-enum-types.h" #include "clutter-main.h" #include "clutter-marshal.h" +#include "clutter-paint-volume-private.h" #include "clutter-private.h" #include "clutter-profile.h" #include "clutter-scriptable.h" diff --git a/clutter/clutter-clone.c b/clutter/clutter-clone.c index bb63905b3..5e7d585be 100644 --- a/clutter/clutter-clone.c +++ b/clutter/clutter-clone.c @@ -41,10 +41,10 @@ #include "config.h" #endif -#include "clutter-color.h" #include "clutter-clone.h" #include "clutter-debug.h" #include "clutter-main.h" +#include "clutter-paint-volume-private.h" #include "clutter-private.h" #include "cogl/cogl.h" diff --git a/clutter/clutter-paint-volume-private.h b/clutter/clutter-paint-volume-private.h new file mode 100644 index 000000000..e186e65b3 --- /dev/null +++ b/clutter/clutter-paint-volume-private.h @@ -0,0 +1,104 @@ +#ifndef __CLUTTER_PAINT_VOLUME_PRIVATE_H__ +#define __CLUTTER_PAINT_VOLUME_PRIVATE_H__ + +#include + +G_BEGIN_DECLS + +struct _ClutterPaintVolume +{ + ClutterActor *actor; + + /* cuboid for the volume: + * + * 4━━━━━━━┓5 + * ┏━━━━━━━━┓╱┃ + * ┃0 ┊7 1┃ ┃ + * ┃ ┄┄┄┄┄┃┄┃6 + * ┃3 2┃╱ + * ┗━━━━━━━━┛ + * + * 0: top, left (origin) : always valid + * 1: top, right : always valid + * 2: bottom, right : updated lazily + * 3: bottom, left : always valid + * + * 4: top, left, back : always valid + * 5: top, right, back : updated lazily + * 6: bottom, right, back : updated lazily + * 7: bottom, left, back : updated lazily + * + * Elements 0, 1, 3 and 4 are filled in by the PaintVolume setters + * + * Note: the reason for this ordering is that we can simply ignore + * elements 4, 5, 6 and 7 most of the time for 2D actors when + * calculating the projected paint box. + */ + ClutterVertex vertices[8]; + + /* As an optimization for internally managed PaintVolumes we allow + * initializing ClutterPaintVolume variables allocated on the stack + * so we can avoid hammering the slice allocator. */ + guint is_static:1; + + /* A newly initialized PaintVolume is considered empty as it is + * degenerate on all three axis. + * + * We consider this carefully when we union an empty volume with + * another so that the union simply results in a copy of the other + * volume instead of also bounding the origin of the empty volume. + * + * For example this is a convenient property when calculating the + * volume of a container as the union of the volume of its children + * where the initial volume passed to the containers + * ->get_paint_volume method will be empty. */ + guint is_empty:1; + + /* TRUE when we've updated the values we calculate lazily */ + guint is_complete:1; + + /* TRUE if vertices 4-7 can be ignored. (Only valid if complete is + * TRUE) */ + guint is_2d:1; + + /* Set to TRUE initialy but cleared if the paint volume is + * transfomed by a matrix. */ + guint is_axis_aligned:1; + + + /* Note: There is a precedence to the above bitfields that should be + * considered whenever we implement code that manipulates + * PaintVolumes... + * + * Firstly if ->is_empty == TRUE then the values for ->is_complete + * and ->is_2d are undefined, so you should typically check + * ->is_empty as the first priority. + * + * XXX: document other invariables... + */ +}; + +void _clutter_paint_volume_init_static (ClutterActor *actor, + ClutterPaintVolume *pv); +ClutterPaintVolume *_clutter_paint_volume_new (ClutterActor *actor); +void _clutter_paint_volume_copy_static (const ClutterPaintVolume *src_pv, + ClutterPaintVolume *dst_pv); +void _clutter_paint_volume_set_from_volume (ClutterPaintVolume *pv, + const ClutterPaintVolume *src); + +void _clutter_paint_volume_complete (ClutterPaintVolume *pv); +void _clutter_paint_volume_transform (ClutterPaintVolume *pv, + const CoglMatrix *matrix); +void _clutter_paint_volume_project (ClutterPaintVolume *pv, + const CoglMatrix *modelview, + const CoglMatrix *projection, + const int *viewport); +void _clutter_paint_volume_get_bounding_box (ClutterPaintVolume *pv, + ClutterActorBox *box); +void _clutter_paint_volume_axis_align (ClutterPaintVolume *pv); +void _clutter_paint_volume_set_reference_actor (ClutterPaintVolume *pv, + ClutterActor *actor); + +G_END_DECLS + +#endif /* __CLUTTER_PAINT_VOLUME_PRIVATE_H__ */ diff --git a/clutter/clutter-paint-volume.c b/clutter/clutter-paint-volume.c index 07deaba75..61d441c71 100644 --- a/clutter/clutter-paint-volume.c +++ b/clutter/clutter-paint-volume.c @@ -28,8 +28,11 @@ #include "config.h" #endif +#include + #include +#include "clutter-paint-volume-private.h" #include "clutter-private.h" G_DEFINE_BOXED_TYPE (ClutterPaintVolume, clutter_paint_volume, diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 892fc639a..e0d49ae6c 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -176,79 +176,6 @@ struct _ClutterMainContext ClutterSettings *settings; }; -struct _ClutterPaintVolume -{ - ClutterActor *actor; - - /* cuboid for the volume: - * - * 4━━━━━━━┓5 - * ┏━━━━━━━━┓╱┃ - * ┃0 ┊7 1┃ ┃ - * ┃ ┄┄┄┄┄┃┄┃6 - * ┃3 2┃╱ - * ┗━━━━━━━━┛ - * - * 0: top, left (origin) : always valid - * 1: top, right : always valid - * 2: bottom, right : updated lazily - * 3: bottom, left : always valid - * - * 4: top, left, back : always valid - * 5: top, right, back : updated lazily - * 6: bottom, right, back : updated lazily - * 7: bottom, left, back : updated lazily - * - * Elements 0, 1, 3 and 4 are filled in by the PaintVolume setters - * - * Note: the reason for this ordering is that we can simply ignore - * elements 4, 5, 6 and 7 most of the time for 2D actors when - * calculating the projected paint box. - */ - ClutterVertex vertices[8]; - - /* As an optimization for internally managed PaintVolumes we allow - * initializing ClutterPaintVolume variables allocated on the stack - * so we can avoid hammering the slice allocator. */ - guint is_static:1; - - /* A newly initialized PaintVolume is considered empty as it is - * degenerate on all three axis. - * - * We consider this carefully when we union an empty volume with - * another so that the union simply results in a copy of the other - * volume instead of also bounding the origin of the empty volume. - * - * For example this is a convenient property when calculating the - * volume of a container as the union of the volume of its children - * where the initial volume passed to the containers - * ->get_paint_volume method will be empty. */ - guint is_empty:1; - - /* TRUE when we've updated the values we calculate lazily */ - guint is_complete:1; - - /* TRUE if vertices 4-7 can be ignored. (Only valid if complete is - * TRUE) */ - guint is_2d:1; - - /* Set to TRUE initialy but cleared if the paint volume is - * transfomed by a matrix. */ - guint is_axis_aligned:1; - - - /* Note: There is a precedence to the above bitfields that should be - * considered whenever we implement code that manipulates - * PaintVolumes... - * - * Firstly if ->is_empty == TRUE then the values for ->is_complete - * and ->is_2d are undefined, so you should typically check - * ->is_empty as the first priority. - * - * XXX: document other invariables... - */ -}; - /* ClutterActorTraverseFlags: * * Controls some options for how clutter_actor_traverse() iterates @@ -383,26 +310,6 @@ void _clutter_event_set_platform_data (ClutterEvent *event, gpointer data); gpointer _clutter_event_get_platform_data (const ClutterEvent *event); -void _clutter_paint_volume_init_static (ClutterActor *actor, - ClutterPaintVolume *pv); -ClutterPaintVolume *_clutter_paint_volume_new (ClutterActor *actor); -void _clutter_paint_volume_copy_static (const ClutterPaintVolume *src_pv, - ClutterPaintVolume *dst_pv); -void _clutter_paint_volume_set_from_volume (ClutterPaintVolume *pv, - const ClutterPaintVolume *src); - -void _clutter_paint_volume_complete (ClutterPaintVolume *pv); -void _clutter_paint_volume_transform (ClutterPaintVolume *pv, - const CoglMatrix *matrix); -void _clutter_paint_volume_project (ClutterPaintVolume *pv, - const CoglMatrix *modelview, - const CoglMatrix *projection, - const int *viewport); -void _clutter_paint_volume_get_bounding_box (ClutterPaintVolume *pv, - ClutterActorBox *box); -void _clutter_paint_volume_axis_align (ClutterPaintVolume *pv); -void _clutter_paint_volume_set_reference_actor (ClutterPaintVolume *pv, - ClutterActor *actor); diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 14b3ae793..011bedc66 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -56,21 +56,22 @@ #include "clutter-stage.h" #include "clutter-backend-private.h" -#include "clutter-main.h" #include "clutter-color.h" -#include "clutter-util.h" +#include "clutter-container.h" +#include "clutter-debug.h" +#include "clutter-device-manager-private.h" +#include "clutter-enum-types.h" +#include "clutter-id-pool.h" +#include "clutter-main.h" #include "clutter-marshal.h" #include "clutter-master-clock.h" -#include "clutter-enum-types.h" +#include "clutter-paint-volume-private.h" #include "clutter-private.h" -#include "clutter-debug.h" -#include "clutter-stage-manager-private.h" -#include "clutter-version.h" /* For flavour */ -#include "clutter-id-pool.h" -#include "clutter-container.h" #include "clutter-profile.h" -#include "clutter-device-manager-private.h" +#include "clutter-stage-manager-private.h" #include "clutter-stage-private.h" +#include "clutter-util.h" +#include "clutter-version.h" /* For flavour */ #include "cogl/cogl.h" diff --git a/clutter/x11/clutter-event-x11.c b/clutter/x11/clutter-event-x11.c index 8dc3a2719..b3a4768ef 100644 --- a/clutter/x11/clutter-event-x11.c +++ b/clutter/x11/clutter-event-x11.c @@ -38,6 +38,7 @@ #include "clutter-device-manager-private.h" #include "clutter-event.h" #include "clutter-main.h" +#include "clutter-paint-volume-private.h" #include "clutter-private.h" #include "clutter-stage-private.h" diff --git a/clutter/x11/clutter-x11-texture-pixmap.c b/clutter/x11/clutter-x11-texture-pixmap.c index 47a34ce3e..d03690816 100644 --- a/clutter/x11/clutter-x11-texture-pixmap.c +++ b/clutter/x11/clutter-x11-texture-pixmap.c @@ -42,10 +42,12 @@ #include "config.h" #endif -#include "../clutter-marshal.h" #include "clutter-x11-texture-pixmap.h" #include "clutter-x11.h" #include "clutter-backend-x11.h" + +#include "clutter-marshal.h" +#include "clutter-paint-volume-private.h" #include "clutter-private.h" #include "cogl/cogl.h"