2006-07-24 21:15:19 +00:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-feature
|
|
|
|
* @short_description: functions to query available GL features ay runtime
|
|
|
|
*
|
|
|
|
* Functions to query available GL features ay runtime
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
#include "clutter-feature.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
2006-11-15 21:19:01 +00:00
|
|
|
|
|
|
|
typedef void (*FuncPtr) (void);
|
|
|
|
typedef int (*GLXGetVideoSyncProc) (unsigned int *count);
|
|
|
|
typedef int (*GLXWaitVideoSyncProc) (int divisor,
|
|
|
|
int remainder,
|
|
|
|
unsigned int *count);
|
|
|
|
typedef FuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
|
|
|
|
|
|
|
typedef struct ClutterFeatureFuncs
|
|
|
|
{
|
|
|
|
GLXGetVideoSyncProc get_video_sync;
|
|
|
|
GLXWaitVideoSyncProc wait_video_sync;
|
|
|
|
|
|
|
|
} ClutterFeatureFuncs;
|
|
|
|
|
|
|
|
typedef enum ClutterVBlankType
|
|
|
|
{
|
|
|
|
CLUTTER_VBLANK_NONE = 0,
|
|
|
|
CLUTTER_VBLANK_GLX,
|
|
|
|
CLUTTER_VBLANK_DRI
|
|
|
|
|
|
|
|
} ClutterVBlankType;
|
|
|
|
|
|
|
|
typedef struct ClutterFeatures
|
|
|
|
{
|
|
|
|
ClutterFeatureFlags flags;
|
|
|
|
ClutterFeatureFuncs funcs;
|
|
|
|
gint dri_fd;
|
|
|
|
ClutterVBlankType vblank_type;
|
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
guint features_set : 1;
|
2006-11-15 21:19:01 +00:00
|
|
|
} ClutterFeatures;
|
|
|
|
|
|
|
|
static ClutterFeatures* __features = NULL;
|
2006-12-04 19:19:53 +00:00
|
|
|
G_LOCK_DEFINE_STATIC (__features);
|
2006-11-15 21:19:01 +00:00
|
|
|
|
|
|
|
/* #ifdef linux */
|
|
|
|
#define DRM_VBLANK_RELATIVE 0x1;
|
|
|
|
|
|
|
|
struct drm_wait_vblank_request {
|
|
|
|
int type;
|
|
|
|
unsigned int sequence;
|
|
|
|
unsigned long signal;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_wait_vblank_reply {
|
|
|
|
int type;
|
|
|
|
unsigned int sequence;
|
|
|
|
long tval_sec;
|
|
|
|
long tval_usec;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef union drm_wait_vblank {
|
|
|
|
struct drm_wait_vblank_request request;
|
|
|
|
struct drm_wait_vblank_reply reply;
|
|
|
|
} drm_wait_vblank_t;
|
|
|
|
|
|
|
|
#define DRM_IOCTL_BASE 'd'
|
|
|
|
#define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type)
|
|
|
|
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t)
|
|
|
|
|
|
|
|
static int drm_wait_vblank(int fd, drm_wait_vblank_t *vbl)
|
|
|
|
{
|
|
|
|
int ret, rc;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
|
|
|
|
vbl->request.type &= ~DRM_VBLANK_RELATIVE;
|
|
|
|
rc = errno;
|
|
|
|
}
|
|
|
|
while (ret && rc == EINTR);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* #endif */
|
|
|
|
|
2006-07-24 21:15:19 +00:00
|
|
|
|
|
|
|
/* Note must be called after context created */
|
|
|
|
static gboolean
|
2006-12-04 19:19:53 +00:00
|
|
|
check_gl_extension (const gchar *name,
|
|
|
|
const gchar *ext)
|
2006-07-24 21:15:19 +00:00
|
|
|
{
|
2006-12-04 19:19:53 +00:00
|
|
|
gchar *end;
|
|
|
|
gint name_len, n;
|
2006-07-24 21:15:19 +00:00
|
|
|
|
|
|
|
if (name == NULL || ext == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
end = (gchar*)(ext + strlen(ext));
|
|
|
|
|
|
|
|
name_len = strlen(name);
|
|
|
|
|
|
|
|
while (ext < end)
|
|
|
|
{
|
|
|
|
n = strcspn(ext, " ");
|
|
|
|
|
|
|
|
if ((name_len == n) && (!strncmp(name, ext, n)))
|
|
|
|
return TRUE;
|
|
|
|
ext += (n + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
static FuncPtr
|
|
|
|
get_proc_address (const gchar *name)
|
|
|
|
{
|
|
|
|
static GLXGetProcAddressProc get_proc_func = NULL;
|
|
|
|
static void *dlhand = NULL;
|
|
|
|
|
|
|
|
if (get_proc_func == NULL && dlhand == NULL)
|
|
|
|
{
|
|
|
|
dlhand = dlopen (NULL, RTLD_LAZY);
|
|
|
|
|
|
|
|
if (dlhand)
|
|
|
|
{
|
|
|
|
dlerror ();
|
2006-12-04 19:19:53 +00:00
|
|
|
|
|
|
|
get_proc_func =
|
|
|
|
(GLXGetProcAddressProc) dlsym (dlhand, "glXGetProcAddress");
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
if (dlerror () != NULL)
|
2006-12-04 19:19:53 +00:00
|
|
|
{
|
|
|
|
get_proc_func =
|
|
|
|
(GLXGetProcAddressProc) dlsym (dlhand, "glXGetProcAddressARB");
|
|
|
|
}
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
if (dlerror () != NULL)
|
|
|
|
{
|
|
|
|
get_proc_func = NULL;
|
2006-12-04 19:19:53 +00:00
|
|
|
g_warning ("failed to bind GLXGetProcAddress "
|
|
|
|
"or GLXGetProcAddressARB");
|
2006-11-15 21:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_proc_func)
|
2006-12-04 19:19:53 +00:00
|
|
|
return get_proc_func ((unsigned char*) name);
|
2006-11-15 21:19:01 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
check_vblank_env (const char *name)
|
|
|
|
{
|
|
|
|
const char *val;
|
|
|
|
|
|
|
|
val = getenv("CLUTTER_VBLANK");
|
|
|
|
|
|
|
|
if (val && !strcasecmp(val, name))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
/* clutter_feature_init:
|
|
|
|
* must be called with the static lock on __features held, to keep it
|
|
|
|
* mt-safe.
|
|
|
|
*
|
|
|
|
* XXX - here we need a bit of weird machinery in place. the features
|
|
|
|
* are checked at run time, each time we try to access them - unless
|
|
|
|
* we already checked them once. unfortunately, we need an open
|
|
|
|
* X display if we want to check them, so ideally we'd need to call
|
|
|
|
* clutter_init() before checking for any feature. the generator for
|
|
|
|
* the api documentation, and more in general every tool relying on the
|
|
|
|
* introspection API provided by GObject, may well not be able to call
|
|
|
|
* clutter_init() (and neither they should be, as we might be running
|
|
|
|
* them on a headless build box). so, we need a way to get the features
|
|
|
|
* without explicitely calling clutter_feature_init() inside clutter_init()
|
|
|
|
* and we also need to have an open X display when we test for the features.
|
|
|
|
* __features is dynamically allocated, and applications tend to badly
|
2006-12-05 05:42:47 +00:00
|
|
|
* crash when trying to access __features components if we did not allocate
|
|
|
|
* it; so when can't use a NULL check to know whether we already invoked
|
|
|
|
* clutter_feature_init() once; hence, we must allocate it anyway, and have
|
|
|
|
* a flag to let us know when the features have been set - that is when
|
|
|
|
* clutter_feature_init() has been successfully completed with an open
|
|
|
|
* X display.
|
2006-12-04 19:19:53 +00:00
|
|
|
*/
|
|
|
|
static void
|
2006-07-27 17:10:33 +00:00
|
|
|
clutter_feature_init (void)
|
2006-07-24 21:15:19 +00:00
|
|
|
{
|
2006-11-15 21:19:01 +00:00
|
|
|
const gchar *gl_extensions, *glx_extensions;
|
2006-12-04 19:19:53 +00:00
|
|
|
|
|
|
|
CLUTTER_NOTE (MISC, "checking features");
|
2006-11-15 21:19:01 +00:00
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
if (!__features)
|
2006-07-27 17:10:33 +00:00
|
|
|
{
|
2006-12-04 19:19:53 +00:00
|
|
|
CLUTTER_NOTE (MISC, "allocating features data");
|
|
|
|
|
|
|
|
__features = g_new0 (ClutterFeatures, 1);
|
|
|
|
memset(&__features->funcs, 0, sizeof(ClutterFeatureFuncs));
|
|
|
|
__features->features_set = FALSE; /* don't rely on zero-ing */
|
2006-07-27 17:10:33 +00:00
|
|
|
}
|
2006-07-24 21:15:19 +00:00
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
if (!clutter_xdisplay ())
|
|
|
|
return;
|
2006-11-15 21:19:01 +00:00
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
if (__features->features_set)
|
|
|
|
return;
|
2006-11-15 21:19:01 +00:00
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
|
|
|
|
glx_extensions = glXQueryExtensionsString (clutter_xdisplay (),
|
|
|
|
clutter_xscreen ());
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
if (check_gl_extension ("GL_ARB_texture_rectangle", gl_extensions))
|
|
|
|
__features->flags |= CLUTTER_FEATURE_TEXTURE_RECTANGLE;
|
|
|
|
|
|
|
|
/* vblank */
|
2006-07-24 21:15:19 +00:00
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
__features->vblank_type = CLUTTER_VBLANK_NONE;
|
|
|
|
|
|
|
|
if (getenv("__GL_SYNC_TO_VBLANK") || check_vblank_env("none"))
|
|
|
|
{
|
2006-11-22 20:52:27 +00:00
|
|
|
CLUTTER_NOTE (MISC, "vblank sync: disabled at user request");
|
2006-11-15 21:19:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-04 19:19:53 +00:00
|
|
|
if (!check_vblank_env("dri") &&
|
|
|
|
check_gl_extension ("GLX_SGI_video_sync", glx_extensions))
|
2006-11-15 21:19:01 +00:00
|
|
|
{
|
|
|
|
__features->funcs.get_video_sync =
|
|
|
|
(GLXGetVideoSyncProc) get_proc_address ("glXGetVideoSyncSGI");
|
|
|
|
|
|
|
|
__features->funcs.wait_video_sync =
|
|
|
|
(GLXWaitVideoSyncProc) get_proc_address ("glXWaitVideoSyncSGI");
|
|
|
|
|
2006-12-04 19:19:53 +00:00
|
|
|
if ((__features->funcs.get_video_sync != NULL) &&
|
|
|
|
(__features->funcs.wait_video_sync != NULL))
|
2006-11-15 21:19:01 +00:00
|
|
|
{
|
2006-11-22 20:52:27 +00:00
|
|
|
CLUTTER_NOTE (MISC, "vblank sync: using glx");
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
|
|
|
|
__features->vblank_type = CLUTTER_VBLANK_GLX;
|
2006-11-15 21:19:01 +00:00
|
|
|
__features->flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(__features->flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
|
|
|
|
{
|
|
|
|
__features->dri_fd = open("/dev/dri/card0", O_RDWR);
|
|
|
|
if (__features->dri_fd >= 0)
|
|
|
|
{
|
2006-11-22 20:52:27 +00:00
|
|
|
CLUTTER_NOTE (MISC, "vblank sync: using dri");
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
__features->vblank_type = CLUTTER_VBLANK_DRI;
|
|
|
|
__features->flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(__features->flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
{
|
|
|
|
CLUTTER_NOTE (MISC,
|
2006-11-22 20:52:27 +00:00
|
|
|
"vblank sync: no use-able mechanism found");
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
}
|
2006-11-15 21:19:01 +00:00
|
|
|
}
|
2006-12-04 19:19:53 +00:00
|
|
|
|
|
|
|
CLUTTER_NOTE (MISC, "features checked");
|
|
|
|
|
|
|
|
__features->features_set = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_feature_do_init (void)
|
|
|
|
{
|
|
|
|
G_LOCK (__features);
|
|
|
|
clutter_feature_init ();
|
|
|
|
G_UNLOCK (__features);
|
2006-07-27 16:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_feature_available:
|
|
|
|
* @feature: a #ClutterFeatureFlags
|
|
|
|
*
|
|
|
|
* Checks whether @feature is available. @feature can be a logical
|
|
|
|
* OR of #ClutterFeatureFlags.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if a feature is available
|
|
|
|
*
|
|
|
|
* Since: 0.1.1
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_feature_available (ClutterFeatureFlags feature)
|
|
|
|
{
|
2006-12-04 19:19:53 +00:00
|
|
|
clutter_feature_do_init ();
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
return (__features->flags & feature);
|
2006-07-27 16:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-11-15 23:37:53 +00:00
|
|
|
* clutter_feature_get_all:
|
2006-07-27 16:09:25 +00:00
|
|
|
*
|
2006-12-04 19:19:53 +00:00
|
|
|
* Returns all the supported features.
|
2006-07-27 16:09:25 +00:00
|
|
|
*
|
|
|
|
* Return value: a logical OR of all the supported features.
|
|
|
|
*
|
|
|
|
* Since: 0.1.1
|
|
|
|
*/
|
|
|
|
ClutterFeatureFlags
|
2006-11-15 23:37:53 +00:00
|
|
|
clutter_feature_get_all (void)
|
2006-07-27 16:09:25 +00:00
|
|
|
{
|
2006-12-04 19:19:53 +00:00
|
|
|
clutter_feature_do_init ();
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
return __features->flags;
|
|
|
|
}
|
|
|
|
|
2006-11-17 19:17:40 +00:00
|
|
|
/**
|
|
|
|
* clutter_feature_wait_for_vblank:
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
2006-11-15 21:19:01 +00:00
|
|
|
void
|
|
|
|
clutter_feature_wait_for_vblank (void)
|
|
|
|
{
|
2006-12-04 19:19:53 +00:00
|
|
|
clutter_feature_do_init ();
|
|
|
|
|
2006-11-15 21:19:01 +00:00
|
|
|
switch (__features->vblank_type)
|
|
|
|
{
|
|
|
|
case CLUTTER_VBLANK_GLX:
|
|
|
|
{
|
|
|
|
unsigned int retraceCount;
|
2006-12-04 19:19:53 +00:00
|
|
|
__features->funcs.get_video_sync (&retraceCount);
|
|
|
|
__features->funcs.wait_video_sync (2,
|
|
|
|
(retraceCount + 1) % 2,
|
|
|
|
&retraceCount);
|
2006-11-15 21:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CLUTTER_VBLANK_DRI:
|
|
|
|
{
|
|
|
|
drm_wait_vblank_t blank;
|
|
|
|
blank.request.type = DRM_VBLANK_RELATIVE;
|
|
|
|
blank.request.sequence = 1;
|
|
|
|
drm_wait_vblank (__features->dri_fd, &blank);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CLUTTER_VBLANK_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-07-24 21:15:19 +00:00
|
|
|
}
|