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   CoglFramebuffer *(* get_framebuffer) (ClutterPaintNode *node);
73 };
74 
75 #define PAINT_OP_INIT   { PAINT_OP_INVALID }
76 
77 typedef enum {
78   PAINT_OP_INVALID = 0,
79   PAINT_OP_TEX_RECT,
80   PAINT_OP_PATH,
81   PAINT_OP_PRIMITIVE
82 } PaintOpCode;
83 
84 struct _ClutterPaintOperation
85 {
86   PaintOpCode opcode;
87 
88   union {
89     float texrect[8];
90 
91     CoglPath *path;
92 
93     CoglPrimitive *primitive;
94   } op;
95 };
96 
97 GType _clutter_root_node_get_type (void) G_GNUC_CONST;
98 GType _clutter_transform_node_get_type (void) G_GNUC_CONST;
99 GType _clutter_dummy_node_get_type (void) G_GNUC_CONST;
100 
101 void                    _clutter_paint_operation_paint_rectangle        (const ClutterPaintOperation *op);
102 void                    _clutter_paint_operation_clip_rectangle         (const ClutterPaintOperation *op);
103 void                    _clutter_paint_operation_paint_path             (const ClutterPaintOperation *op);
104 void                    _clutter_paint_operation_clip_path              (const ClutterPaintOperation *op);
105 void                    _clutter_paint_operation_paint_primitive        (const ClutterPaintOperation *op);
106 
107 void                    _clutter_paint_node_init_types                  (void);
108 gpointer                _clutter_paint_node_create                      (GType gtype);
109 
110 ClutterPaintNode *      _clutter_root_node_new                          (CoglFramebuffer             *framebuffer,
111                                                                          const ClutterColor          *clear_color,
112                                                                          CoglBufferBit                clear_flags);
113 ClutterPaintNode *      _clutter_transform_node_new                     (const CoglMatrix            *matrix);
114 ClutterPaintNode *      _clutter_dummy_node_new                         (ClutterActor                *actor);
115 
116 void                    _clutter_paint_node_paint                       (ClutterPaintNode            *root);
117 void                    _clutter_paint_node_dump_tree                   (ClutterPaintNode            *root);
118 
119 G_GNUC_INTERNAL
120 void                    clutter_paint_node_remove_child                 (ClutterPaintNode      *node,
121                                                                          ClutterPaintNode      *child);
122 G_GNUC_INTERNAL
123 void                    clutter_paint_node_replace_child                (ClutterPaintNode      *node,
124                                                                          ClutterPaintNode      *old_child,
125                                                                          ClutterPaintNode      *new_child);
126 G_GNUC_INTERNAL
127 void                    clutter_paint_node_remove_all                   (ClutterPaintNode      *node);
128 
129 G_GNUC_INTERNAL
130 guint                   clutter_paint_node_get_n_children               (ClutterPaintNode      *node);
131 
132 G_GNUC_INTERNAL
133 ClutterPaintNode *      clutter_paint_node_get_first_child              (ClutterPaintNode      *node);
134 G_GNUC_INTERNAL
135 ClutterPaintNode *      clutter_paint_node_get_previous_sibling         (ClutterPaintNode      *node);
136 G_GNUC_INTERNAL
137 ClutterPaintNode *      clutter_paint_node_get_next_sibling             (ClutterPaintNode      *node);
138 G_GNUC_INTERNAL
139 ClutterPaintNode *      clutter_paint_node_get_last_child               (ClutterPaintNode      *node);
140 G_GNUC_INTERNAL
141 ClutterPaintNode *      clutter_paint_node_get_parent                   (ClutterPaintNode      *node);
142 G_GNUC_INTERNAL
143 CoglFramebuffer *       clutter_paint_node_get_framebuffer              (ClutterPaintNode      *node);
144 
145 #define CLUTTER_TYPE_LAYER_NODE                 (_clutter_layer_node_get_type ())
146 #define CLUTTER_LAYER_NODE(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_LAYER_NODE, ClutterLayerNode))
147 #define CLUTTER_IS_LAYER_NODE(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_LAYER_NODE))
148 
149 /*
150  * ClutterLayerNode:
151  *
152  * The #ClutterLayerNode structure is an opaque
153  * type whose members cannot be directly accessed.
154  *
155  * Since: 1.10
156  */
157 typedef struct _ClutterLayerNode                ClutterLayerNode;
158 typedef struct _ClutterLayerNodeClass           ClutterLayerNodeClass;
159 
160 GType _clutter_layer_node_get_type (void) G_GNUC_CONST;
161 
162 ClutterPaintNode *      _clutter_layer_node_new         (const CoglMatrix        *projection,
163                                                          const cairo_rectangle_t *viewport,
164                                                          float                    width,
165                                                          float                    height,
166                                                          guint8                   opacity);
167 
168 
169 G_END_DECLS
170 
171 #endif /* __CLUTTER_PAINT_NODE_PRIVATE_H__ */
172