update to 1.10.4
[profile/ivi/clutter.git] / clutter / clutter-paint-node-private.h
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Copyright (C) 2011  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  * Author:
22  *   Emmanuele Bassi <ebassi@linux.intel.com>
23  */
24
25 #ifndef __CLUTTER_PAINT_NODE_PRIVATE_H__
26 #define __CLUTTER_PAINT_NODE_PRIVATE_H__
27
28 #include <glib-object.h>
29 #include <json-glib/json-glib.h>
30 #include <clutter/clutter-paint-node.h>
31
32 G_BEGIN_DECLS
33
34 #define CLUTTER_PAINT_NODE_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_PAINT_NODE, ClutterPaintNodeClass))
35 #define CLUTTER_IS_PAINT_NODE_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_PAINT_NODE))
36 #define CLUTTER_PAINT_NODE_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_PAINT_NODE, ClutterPaintNodeClass))
37
38 typedef struct _ClutterPaintOperation   ClutterPaintOperation;
39
40 struct _ClutterPaintNode
41 {
42   GTypeInstance parent_instance;
43
44   ClutterPaintNode *parent;
45
46   ClutterPaintNode *first_child;
47   ClutterPaintNode *prev_sibling;
48   ClutterPaintNode *next_sibling;
49   ClutterPaintNode *last_child;
50
51   guint n_children;
52
53   GArray *operations;
54
55   gchar *name;
56
57   volatile int ref_count;
58 };
59
60 struct _ClutterPaintNodeClass
61 {
62   GTypeClass base_class;
63
64   void     (* finalize)  (ClutterPaintNode *node);
65
66   gboolean (* pre_draw)  (ClutterPaintNode *node);
67   void     (* draw)      (ClutterPaintNode *node);
68   void     (* post_draw) (ClutterPaintNode *node);
69
70   JsonNode*(* serialize) (ClutterPaintNode *node);
71 };
72
73 #define PAINT_OP_INIT   { PAINT_OP_INVALID }
74
75 typedef enum {
76   PAINT_OP_INVALID = 0,
77   PAINT_OP_TEX_RECT,
78   PAINT_OP_PATH,
79   PAINT_OP_PRIMITIVE
80 } PaintOpCode;
81
82 struct _ClutterPaintOperation
83 {
84   PaintOpCode opcode;
85
86   union {
87     float texrect[8];
88
89     CoglPath *path;
90
91     CoglPrimitive *primitive;
92   } op;
93 };
94
95 GType _clutter_root_node_get_type (void) G_GNUC_CONST;
96 GType _clutter_transform_node_get_type (void) G_GNUC_CONST;
97 GType _clutter_dummy_node_get_type (void) G_GNUC_CONST;
98
99 void                    _clutter_paint_operation_paint_rectangle        (const ClutterPaintOperation *op);
100 void                    _clutter_paint_operation_clip_rectangle         (const ClutterPaintOperation *op);
101 void                    _clutter_paint_operation_paint_path             (const ClutterPaintOperation *op);
102 void                    _clutter_paint_operation_clip_path              (const ClutterPaintOperation *op);
103 void                    _clutter_paint_operation_paint_primitive        (const ClutterPaintOperation *op);
104
105 void                    _clutter_paint_node_init_types                  (void);
106 gpointer                _clutter_paint_node_create                      (GType gtype);
107
108 ClutterPaintNode *      _clutter_root_node_new                          (CoglFramebuffer             *framebuffer,
109                                                                          const ClutterColor          *clear_color,
110                                                                          CoglBufferBit                clear_flags,
111                                                                          const CoglMatrix            *matrix);
112 ClutterPaintNode *      _clutter_transform_node_new                     (const CoglMatrix            *matrix);
113 ClutterPaintNode *      _clutter_dummy_node_new                         (ClutterActor                *actor);
114
115 void                    _clutter_paint_node_paint                       (ClutterPaintNode            *root);
116 void                    _clutter_paint_node_dump_tree                   (ClutterPaintNode            *root);
117
118 G_GNUC_INTERNAL
119 void                    clutter_paint_node_remove_child                 (ClutterPaintNode      *node,
120                                                                          ClutterPaintNode      *child);
121 G_GNUC_INTERNAL
122 void                    clutter_paint_node_replace_child                (ClutterPaintNode      *node,
123                                                                          ClutterPaintNode      *old_child,
124                                                                          ClutterPaintNode      *new_child);
125 G_GNUC_INTERNAL
126 void                    clutter_paint_node_remove_all                   (ClutterPaintNode      *node);
127
128 G_GNUC_INTERNAL
129 guint                   clutter_paint_node_get_n_children               (ClutterPaintNode      *node);
130
131 G_GNUC_INTERNAL
132 ClutterPaintNode *      clutter_paint_node_get_first_child              (ClutterPaintNode      *node);
133 G_GNUC_INTERNAL
134 ClutterPaintNode *      clutter_paint_node_get_previous_sibling         (ClutterPaintNode      *node);
135 G_GNUC_INTERNAL
136 ClutterPaintNode *      clutter_paint_node_get_next_sibling             (ClutterPaintNode      *node);
137 G_GNUC_INTERNAL
138 ClutterPaintNode *      clutter_paint_node_get_last_child               (ClutterPaintNode      *node);
139 G_GNUC_INTERNAL
140 ClutterPaintNode *      clutter_paint_node_get_parent                   (ClutterPaintNode      *node);
141
142 #define CLUTTER_TYPE_LAYER_NODE                 (_clutter_layer_node_get_type ())
143 #define CLUTTER_LAYER_NODE(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_LAYER_NODE, ClutterLayerNode))
144 #define CLUTTER_IS_LAYER_NODE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_LAYER_NODE))
145
146 /*
147  * ClutterLayerNode:
148  *
149  * The <structname>ClutterLayerNode</structname> structure is an opaque
150  * type whose members cannot be directly accessed.
151  *
152  * Since: 1.10
153  */
154 typedef struct _ClutterLayerNode                ClutterLayerNode;
155 typedef struct _ClutterLayerNodeClass           ClutterLayerNodeClass;
156
157 GType _clutter_layer_node_get_type (void) G_GNUC_CONST;
158
159 ClutterPaintNode *      _clutter_layer_node_new         (const CoglMatrix        *projection,
160                                                          const cairo_rectangle_t *viewport,
161                                                          float                    width,
162                                                          float                    height,
163                                                          guint8                   opacity);
164
165
166 G_END_DECLS
167
168 #endif /* __CLUTTER_PAINT_NODE_PRIVATE_H__ */