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-context.h> 31 #include <clutter/clutter-paint-node.h> 32 33 G_BEGIN_DECLS 34 35 #define CLUTTER_PAINT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_PAINT_NODE, ClutterPaintNodeClass)) 36 #define CLUTTER_IS_PAINT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_PAINT_NODE)) 37 #define CLUTTER_PAINT_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_PAINT_NODE, ClutterPaintNodeClass)) 38 39 typedef struct _ClutterPaintOperation ClutterPaintOperation; 40 41 struct _ClutterPaintNode 42 { 43 GTypeInstance parent_instance; 44 45 ClutterPaintNode *parent; 46 47 ClutterPaintNode *first_child; 48 ClutterPaintNode *prev_sibling; 49 ClutterPaintNode *next_sibling; 50 ClutterPaintNode *last_child; 51 52 GArray *operations; 53 54 const gchar *name; 55 56 guint n_children; 57 58 volatile int ref_count; 59 }; 60 61 struct _ClutterPaintNodeClass 62 { 63 GTypeClass base_class; 64 65 void (* finalize) (ClutterPaintNode *node); 66 67 gboolean (* pre_draw) (ClutterPaintNode *node, 68 ClutterPaintContext *paint_context); 69 void (* draw) (ClutterPaintNode *node, 70 ClutterPaintContext *paint_context); 71 void (* post_draw) (ClutterPaintNode *node, 72 ClutterPaintContext *paint_context); 73 74 JsonNode*(* serialize) (ClutterPaintNode *node); 75 76 CoglFramebuffer *(* get_framebuffer) (ClutterPaintNode *node); 77 }; 78 79 #define PAINT_OP_INIT { PAINT_OP_INVALID } 80 81 typedef enum 82 { 83 PAINT_OP_INVALID = 0, 84 PAINT_OP_TEX_RECT, 85 PAINT_OP_TEX_RECTS, 86 PAINT_OP_MULTITEX_RECT, 87 PAINT_OP_PRIMITIVE 88 } PaintOpCode; 89 90 struct _ClutterPaintOperation 91 { 92 PaintOpCode opcode; 93 94 GArray *coords; 95 96 union { 97 float texrect[8]; 98 99 CoglPrimitive *primitive; 100 } op; 101 }; 102 103 GType _clutter_transform_node_get_type (void) G_GNUC_CONST; 104 GType _clutter_dummy_node_get_type (void) G_GNUC_CONST; 105 106 void _clutter_paint_operation_paint_rectangle (const ClutterPaintOperation *op); 107 void _clutter_paint_operation_clip_rectangle (const ClutterPaintOperation *op); 108 void _clutter_paint_operation_paint_path (const ClutterPaintOperation *op); 109 void _clutter_paint_operation_clip_path (const ClutterPaintOperation *op); 110 void _clutter_paint_operation_paint_primitive (const ClutterPaintOperation *op); 111 112 void _clutter_paint_node_init_types (void); 113 gpointer _clutter_paint_node_create (GType gtype); 114 115 ClutterPaintNode * _clutter_transform_node_new (const graphene_matrix_t *matrix); 116 ClutterPaintNode * _clutter_dummy_node_new (ClutterActor *actor, 117 CoglFramebuffer *framebuffer); 118 119 void _clutter_paint_node_dump_tree (ClutterPaintNode *root); 120 121 G_GNUC_INTERNAL 122 void clutter_paint_node_remove_child (ClutterPaintNode *node, 123 ClutterPaintNode *child); 124 G_GNUC_INTERNAL 125 void clutter_paint_node_replace_child (ClutterPaintNode *node, 126 ClutterPaintNode *old_child, 127 ClutterPaintNode *new_child); 128 G_GNUC_INTERNAL 129 void clutter_paint_node_remove_all (ClutterPaintNode *node); 130 131 G_GNUC_INTERNAL 132 guint clutter_paint_node_get_n_children (ClutterPaintNode *node); 133 134 G_GNUC_INTERNAL 135 ClutterPaintNode * clutter_paint_node_get_first_child (ClutterPaintNode *node); 136 G_GNUC_INTERNAL 137 ClutterPaintNode * clutter_paint_node_get_previous_sibling (ClutterPaintNode *node); 138 G_GNUC_INTERNAL 139 ClutterPaintNode * clutter_paint_node_get_next_sibling (ClutterPaintNode *node); 140 G_GNUC_INTERNAL 141 ClutterPaintNode * clutter_paint_node_get_last_child (ClutterPaintNode *node); 142 G_GNUC_INTERNAL 143 ClutterPaintNode * clutter_paint_node_get_parent (ClutterPaintNode *node); 144 145 146 #define CLUTTER_TYPE_EFFECT_NODE (clutter_effect_node_get_type ()) 147 #define CLUTTER_EFFECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_EFFECT_NODE, ClutterEffectNode)) 148 #define CLUTTER_IS_EFFECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_EFFECT_NODE)) 149 150 /** 151 * ClutterEffectNode: 152 * 153 * The #ClutterEffectNode structure is an opaque 154 * type whose members cannot be directly accessed. 155 */ 156 typedef struct _ClutterEffectNode ClutterEffectNode; 157 typedef struct _ClutterEffectNode ClutterEffectNodeClass; 158 159 CLUTTER_EXPORT 160 GType clutter_effect_node_get_type (void) G_GNUC_CONST; 161 162 CLUTTER_EXPORT 163 ClutterPaintNode * clutter_effect_node_new (ClutterEffect *effect); 164 165 G_END_DECLS 166 167 #endif /* __CLUTTER_PAINT_NODE_PRIVATE_H__ */ 168