4 * An OpenGL based 'interactive canvas' library.
6 * Authored By Matthew Allum <mallum@openedhand.com>
8 * Copyright (C) 2006 OpenedHand
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
26 #ifndef __CLUTTER_PRIVATE_H__
27 #define __CLUTTER_PRIVATE_H__
31 #include <glib/gi18n-lib.h>
33 #include <cogl-pango/cogl-pango.h>
35 #include "clutter-backend.h"
36 #include "clutter-effect.h"
37 #include "clutter-event.h"
38 #include "clutter-feature.h"
39 #include "clutter-id-pool.h"
40 #include "clutter-layout-manager.h"
41 #include "clutter-master-clock.h"
42 #include "clutter-settings.h"
43 #include "clutter-stage-manager.h"
44 #include "clutter-stage.h"
48 typedef struct _ClutterMainContext ClutterMainContext;
50 #define CLUTTER_REGISTER_VALUE_TRANSFORM_TO(TYPE_TO,func) { \
51 g_value_register_transform_func (g_define_type_id, TYPE_TO, func); \
54 #define CLUTTER_REGISTER_VALUE_TRANSFORM_FROM(TYPE_FROM,func) { \
55 g_value_register_transform_func (TYPE_FROM, g_define_type_id, func); \
58 #define CLUTTER_REGISTER_INTERVAL_PROGRESS(func) { \
59 clutter_interval_register_progress_func (g_define_type_id, func); \
62 #define CLUTTER_PRIVATE_FLAGS(a) (((ClutterActor *) (a))->private_flags)
63 #define CLUTTER_SET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) |= (f))
64 #define CLUTTER_UNSET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) &= ~(f))
66 #define CLUTTER_ACTOR_IS_TOPLEVEL(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IS_TOPLEVEL) != FALSE)
67 #define CLUTTER_ACTOR_IS_INTERNAL_CHILD(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_INTERNAL_CHILD) != FALSE)
68 #define CLUTTER_ACTOR_IN_DESTRUCTION(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_DESTRUCTION) != FALSE)
69 #define CLUTTER_ACTOR_IN_REPARENT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_REPARENT) != FALSE)
70 #define CLUTTER_ACTOR_IN_PAINT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_PAINT) != FALSE)
71 #define CLUTTER_ACTOR_IN_RELAYOUT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_RELAYOUT) != FALSE)
72 #define CLUTTER_STAGE_IN_RESIZE(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_RESIZE) != FALSE)
74 #define CLUTTER_PARAM_READABLE (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)
75 #define CLUTTER_PARAM_WRITABLE (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)
76 #define CLUTTER_PARAM_READWRITE (G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)
78 #define CLUTTER_PARAM_ANIMATABLE (1 << G_PARAM_USER_SHIFT)
80 /* automagic interning of a static string */
81 #define I_(str) (g_intern_static_string ((str)))
83 /* mark all properties under the "Property" context */
85 #define P_(String) (_clutter_gettext ((String)))
87 #define P_(String) (String)
90 /* This is a replacement for the nearbyint function which always rounds to the
91 * nearest integer. nearbyint is apparently a C99 function so it might not
92 * always be available but also it seems in glibc it is defined as a function
93 * call so this macro could end up faster anyway. We can't just add 0.5f
94 * because it will break for negative numbers. */
95 #define CLUTTER_NEARBYINT(x) ((int) ((x) < 0.0f ? (x) - 0.5f : (x) + 0.5f))
98 CLUTTER_ACTOR_UNUSED_FLAG = 0,
100 CLUTTER_IN_DESTRUCTION = 1 << 0,
101 CLUTTER_IS_TOPLEVEL = 1 << 1,
102 CLUTTER_IN_REPARENT = 1 << 2,
104 /* Used to avoid recursion */
105 CLUTTER_IN_PAINT = 1 << 3,
107 /* Used to avoid recursion */
108 CLUTTER_IN_RELAYOUT = 1 << 4,
110 /* Used by the stage if resizing is an asynchronous operation (like on
111 * X11) to delay queueing relayouts until we got a notification from the
114 CLUTTER_IN_RESIZE = 1 << 5,
116 /* a flag for internal children of Containers */
117 CLUTTER_INTERNAL_CHILD = 1 << 6
118 } ClutterPrivateFlags;
121 * ClutterMainContext:
123 * The shared state of Clutter
125 struct _ClutterMainContext
127 /* the main windowing system backend */
128 ClutterBackend *backend;
130 /* the object holding all the stage instances */
131 ClutterStageManager *stage_manager;
133 /* the clock driving all the frame operations */
134 ClutterMasterClock *master_clock;
136 /* the main event queue */
137 GQueue *events_queue;
139 ClutterPickMode pick_mode;
141 /* mapping between reused integer ids and actors */
142 ClutterIDPool *id_pool;
144 /* default FPS; this is only used if we cannot sync to vblank */
147 /* actors with a grab on all devices */
148 ClutterActor *pointer_grab_actor;
149 ClutterActor *keyboard_grab_actor;
151 /* stack of actors with shaders during paint */
154 /* fb bit masks for col<->id mapping in picking */
162 PangoContext *pango_context; /* Global Pango context */
163 CoglPangoFontMap *font_map; /* Global font map */
165 ClutterEvent *current_event;
166 guint32 last_event_time;
168 /* list of repaint functions installed through
169 * clutter_threads_add_repaint_func()
171 GList *repaint_funcs;
172 guint last_repaint_id;
174 /* main settings singleton */
175 ClutterSettings *settings;
178 guint is_initialized : 1;
179 guint motion_events_per_actor : 1;
180 guint defer_display_setup : 1;
181 guint options_parsed : 1;
185 /* shared between clutter-main.c and clutter-frame-source.c */
190 GDestroyNotify notify;
191 } ClutterThreadsDispatch;
193 gboolean _clutter_threads_dispatch (gpointer data);
194 void _clutter_threads_dispatch_free (gpointer data);
196 ClutterMainContext * _clutter_context_get_default (void);
197 void _clutter_context_lock (void);
198 void _clutter_context_unlock (void);
199 gboolean _clutter_context_is_initialized (void);
200 PangoContext * _clutter_context_create_pango_context (void);
201 PangoContext * _clutter_context_get_pango_context (void);
202 ClutterPickMode _clutter_context_get_pick_mode (void);
203 void _clutter_context_push_shader_stack (ClutterActor *actor);
204 ClutterActor * _clutter_context_pop_shader_stack (ClutterActor *actor);
205 ClutterActor * _clutter_context_peek_shader_stack (void);
206 guint32 _clutter_context_acquire_id (gpointer key);
207 void _clutter_context_release_id (guint32 id_);
208 gboolean _clutter_context_get_motion_events_enabled (void);
209 gboolean _clutter_context_get_show_fps (void);
211 const gchar *_clutter_gettext (const gchar *str);
213 gboolean _clutter_feature_init (GError **error);
215 /* Diagnostic mode */
216 gboolean _clutter_diagnostic_enabled (void);
217 void _clutter_diagnostic_message (const char *fmt, ...);
220 guint _clutter_pixel_to_id (guchar pixel[4]);
221 void _clutter_id_to_color (guint id,
223 ClutterActor * _clutter_get_actor_by_id (ClutterStage *stage,
226 gboolean _clutter_get_sync_to_vblank (void);
228 /* use this function as the accumulator if you have a signal with
229 * a G_TYPE_BOOLEAN return value; this will stop the emission as
230 * soon as one handler returns TRUE
232 gboolean _clutter_boolean_handled_accumulator (GSignalInvocationHint *ihint,
234 const GValue *handler_return,
237 void _clutter_run_repaint_functions (ClutterRepaintFlags flags);
239 void _clutter_constraint_update_allocation (ClutterConstraint *constraint,
241 ClutterActorBox *allocation);
243 GType _clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager);
245 void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
246 const CoglMatrix *projection,
247 const float *viewport,
248 const ClutterVertex *vertices_in,
249 ClutterVertex *vertices_out,
252 void _clutter_util_rectangle_union (const cairo_rectangle_int_t *src1,
253 const cairo_rectangle_int_t *src2,
254 cairo_rectangle_int_t *dest);
256 typedef struct _ClutterPlane
262 typedef enum _ClutterCullResult
264 CLUTTER_CULL_RESULT_UNKNOWN,
265 CLUTTER_CULL_RESULT_IN,
266 CLUTTER_CULL_RESULT_OUT,
267 CLUTTER_CULL_RESULT_PARTIAL
270 gboolean _clutter_has_progress_function (GType gtype);
271 gboolean _clutter_run_progress_function (GType gtype,
272 const GValue *initial,
279 #endif /* __CLUTTER_PRIVATE_H__ */