Initial Import
[profile/ivi/clutter.git] / clutter / clutter-paint-volume-private.h
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Copyright (C) 2010  Intel Corporation.
7  *
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.
12  *
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.
17  *
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/>.
20  */
21
22 #ifndef __CLUTTER_PAINT_VOLUME_PRIVATE_H__
23 #define __CLUTTER_PAINT_VOLUME_PRIVATE_H__
24
25 #include <clutter/clutter-types.h>
26 #include <clutter/clutter-private.h>
27
28 G_BEGIN_DECLS
29
30 struct _ClutterPaintVolume
31 {
32   /* A paint volume represents a volume in a given actors private
33    * coordinate system. */
34   ClutterActor *actor;
35
36   /* cuboid for the volume:
37    *
38    *       4━━━━━━━┓5
39    *    ┏━━━━━━━━┓╱┃
40    *    ┃0 ┊7   1┃ ┃
41    *    ┃   ┄┄┄┄┄┃┄┃6
42    *    ┃3      2┃╱
43    *    ┗━━━━━━━━┛
44    *
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
49    *
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
54    *
55    * Elements 0, 1, 3 and 4 are filled in by the PaintVolume setters
56    *
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.
60    */
61   ClutterVertex vertices[8];
62
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. */
66   guint is_static:1;
67
68   /* A newly initialized PaintVolume is considered empty as it is
69    * degenerate on all three axis.
70    *
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.
74    *
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. */
79   guint is_empty:1;
80
81   /* TRUE when we've updated the values we calculate lazily */
82   guint is_complete:1;
83
84   /* TRUE if vertices 4-7 can be ignored. (Only valid if complete is
85    * TRUE) */
86   guint is_2d:1;
87
88   /* Set to TRUE initialy but cleared if the paint volume is
89    * transfomed by a matrix. */
90   guint is_axis_aligned:1;
91
92
93   /* Note: There is a precedence to the above bitfields that should be
94    * considered whenever we implement code that manipulates
95    * PaintVolumes...
96    *
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.
100    *
101    * XXX: document other invariables...
102    */
103 };
104
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);
112
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);
125
126 ClutterCullResult   _clutter_paint_volume_cull                 (ClutterPaintVolume *pv,
127                                                                 const ClutterPlane       *planes);
128
129 void                _clutter_paint_volume_get_stage_paint_box  (ClutterPaintVolume *pv,
130                                                                 ClutterStage *stage,
131                                                                 ClutterActorBox *box);
132
133 void                _clutter_paint_volume_transform_relative   (ClutterPaintVolume *pv,
134                                                                 ClutterActor *relative_to_ancestor);
135
136 G_END_DECLS
137
138 #endif /* __CLUTTER_PAINT_VOLUME_PRIVATE_H__ */