4 * An OpenGL based 'interactive canvas' library.
6 * Copyright (C) 2010 Intel Corporation.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __CLUTTER_PAINT_VOLUME_PRIVATE_H__
23 #define __CLUTTER_PAINT_VOLUME_PRIVATE_H__
25 #include <clutter/clutter-types.h>
26 #include <clutter/clutter-private.h>
30 struct _ClutterPaintVolume
32 /* A paint volume represents a volume in a given actors private
33 * coordinate system. */
36 /* cuboid for the volume:
45 * 0: top, left (origin) : always valid
46 * 1: top, right : always valid
47 * 2: bottom, right : updated lazily
48 * 3: bottom, left : always valid
50 * 4: top, left, back : always valid
51 * 5: top, right, back : updated lazily
52 * 6: bottom, right, back : updated lazily
53 * 7: bottom, left, back : updated lazily
55 * Elements 0, 1, 3 and 4 are filled in by the PaintVolume setters
57 * Note: the reason for this ordering is that we can simply ignore
58 * elements 4, 5, 6 and 7 most of the time for 2D actors when
59 * calculating the projected paint box.
61 ClutterVertex vertices[8];
63 /* As an optimization for internally managed PaintVolumes we allow
64 * initializing ClutterPaintVolume variables allocated on the stack
65 * so we can avoid hammering the slice allocator. */
68 /* A newly initialized PaintVolume is considered empty as it is
69 * degenerate on all three axis.
71 * We consider this carefully when we union an empty volume with
72 * another so that the union simply results in a copy of the other
73 * volume instead of also bounding the origin of the empty volume.
75 * For example this is a convenient property when calculating the
76 * volume of a container as the union of the volume of its children
77 * where the initial volume passed to the containers
78 * ->get_paint_volume method will be empty. */
81 /* TRUE when we've updated the values we calculate lazily */
84 /* TRUE if vertices 4-7 can be ignored. (Only valid if complete is
88 /* Set to TRUE initialy but cleared if the paint volume is
89 * transfomed by a matrix. */
90 guint is_axis_aligned:1;
93 /* Note: There is a precedence to the above bitfields that should be
94 * considered whenever we implement code that manipulates
97 * Firstly if ->is_empty == TRUE then the values for ->is_complete
98 * and ->is_2d are undefined, so you should typically check
99 * ->is_empty as the first priority.
101 * XXX: document other invariables...
105 void _clutter_paint_volume_init_static (ClutterPaintVolume *pv,
106 ClutterActor *actor);
107 ClutterPaintVolume *_clutter_paint_volume_new (ClutterActor *actor);
108 void _clutter_paint_volume_copy_static (const ClutterPaintVolume *src_pv,
109 ClutterPaintVolume *dst_pv);
110 void _clutter_paint_volume_set_from_volume (ClutterPaintVolume *pv,
111 const ClutterPaintVolume *src);
113 void _clutter_paint_volume_complete (ClutterPaintVolume *pv);
114 void _clutter_paint_volume_transform (ClutterPaintVolume *pv,
115 const CoglMatrix *matrix);
116 void _clutter_paint_volume_project (ClutterPaintVolume *pv,
117 const CoglMatrix *modelview,
118 const CoglMatrix *projection,
119 const float *viewport);
120 void _clutter_paint_volume_get_bounding_box (ClutterPaintVolume *pv,
121 ClutterActorBox *box);
122 void _clutter_paint_volume_axis_align (ClutterPaintVolume *pv);
123 void _clutter_paint_volume_set_reference_actor (ClutterPaintVolume *pv,
124 ClutterActor *actor);
126 ClutterCullResult _clutter_paint_volume_cull (ClutterPaintVolume *pv,
127 const ClutterPlane *planes);
129 void _clutter_paint_volume_get_stage_paint_box (ClutterPaintVolume *pv,
131 ClutterActorBox *box);
133 void _clutter_paint_volume_transform_relative (ClutterPaintVolume *pv,
134 ClutterActor *relative_to_ancestor);
138 #endif /* __CLUTTER_PAINT_VOLUME_PRIVATE_H__ */