2006-07-27 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-private.h: Move clutter_feature_init()
	declaration here: you shouldn't even need to initialise
	features yourself.

	* clutter/clutter-feature.c: call clutter_feature_init()
	each time you try to access the feature list; add a static
	lock around the feature flags container; add api documentation.

	* clutter/clutter-feature.h: Add a type for the feature flags
	to make bindings happy.
This commit is contained in:
Emmanuele Bassi 2006-07-27 16:09:25 +00:00
parent ecccec75cb
commit ad29f37780
4 changed files with 66 additions and 26 deletions

View File

@ -1,3 +1,16 @@
2006-07-27 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-private.h: Move clutter_feature_init()
declaration here: you shouldn't even need to initialise
features yourself.
* clutter/clutter-feature.c: call clutter_feature_init()
each time you try to access the feature list; add a static
lock around the feature flags container; add api documentation.
* clutter/clutter-feature.h: Add a type for the feature flags
to make bindings happy.
2006-07-24 Matthew Allum <mallum@openedhand.com>
* clutter/Makefile.am:

View File

@ -34,7 +34,8 @@
#include "clutter-feature.h"
#include "string.h"
static gulong __features;
G_LOCK_DEFINE_STATIC (__features);
static ClutterFeatureFlags __features;
/* Note must be called after context created */
static gboolean
@ -65,20 +66,9 @@ check_gl_extension (const gchar *name)
return FALSE;
}
gboolean
clutter_feature_available (gulong query)
{
return (__features & query);
}
gulong
clutter_feature_all (void)
{
return __features;
}
void
clutter_feature_init (void)
/* HOLDS: __features lock */
static void
clutter_feature_init_do (void)
{
if (__features)
return;
@ -87,5 +77,46 @@ clutter_feature_init (void)
if (check_gl_extension ("GL_ARB_texture_rectangle"))
__features |= CLUTTER_FEATURE_TEXTURE_RECTANGLE;
}
void
clutter_feature_init (void)
{
G_LOCK (__features);
clutter_feature_init_do ();
G_UNLOCK (__features);
}
/**
* 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)
{
clutter_feature_init ();
return (__features & feature);
}
/**
* clutter_feature_all:
*
* Returns all the suppoerted features.
*
* Return value: a logical OR of all the supported features.
*
* Since: 0.1.1
*/
ClutterFeatureFlags
clutter_feature_all (void)
{
clutter_feature_init ();
return __features;
}

View File

@ -39,19 +39,13 @@
G_END_DECLS
enum
typedef enum
{
CLUTTER_FEATURE_TEXTURE_RECTANGLE = (1 << 1)
};
} ClutterFeatureFlags;
gboolean
clutter_feature_available (gulong query);
gulong
clutter_feature_get_all (void);
void
clutter_feature_init (void);
gboolean clutter_feature_available (ClutterFeatureFlags flags);
ClutterFeatureFlags clutter_feature_get_all (void);
G_END_DECLS

View File

@ -82,6 +82,8 @@ typedef enum {
#define CLUTTER_SET_PRIVATE_FLAGS(a,f) G_STMT_START{ (CLUTTER_PRIVATE_FLAGS (a) |= (f)); }G_STMT_END
#define CLUTTER_UNSET_PRIVATE_FLAGS(a,f) G_STMT_START{ (CLUTTER_PRIVATE_FLAGS (a) &= ~(f)); }G_STMT_END
void clutter_feature_init (void);
G_END_DECLS
#endif