diff options
author | Robert Bragg <robert@linux.intel.com> | 2011-10-12 22:31:12 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2011-11-01 12:03:01 +0000 |
commit | 426c8b8f41626527bcf764bc275d46ffe8c2e84b (patch) | |
tree | 1516ef2cacb1d7f4379154694b5dcf5ac50f4b1a /cogl/cogl.c | |
parent | c86f698eb9088db0d3dd32497d29a56a9e144143 (diff) | |
download | cogl-426c8b8f41626527bcf764bc275d46ffe8c2e84b.tar.gz |
features: Support more than 32 features!
Currently features are represented as bits in a 32bit mask so we
obviously can't have more than 32 features with that approach. The new
approach is to use the COGL_FLAGS_ macros which lets us handle bitmasks
without a size limit and we change the public api to accept individual
feature enums instead of a mask. This way there is no limit on the
number of features we can add to Cogl.
Instead of using cogl_features_available() there is a new
cogl_has_feature() function and for checking multiple features there is
cogl_has_features() which takes a zero terminated vararg list of
features.
In addition to being able to check for individual features this also
adds a way to query all the features currently available via
cogl_foreach_feature() which will call a callback for each feature.
Since the new functions take an explicit context pointer there is also
no longer any ambiguity over when users can first start to query
features.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'cogl/cogl.c')
-rw-r--r-- | cogl/cogl.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cogl/cogl.c b/cogl/cogl.c index e81caa7e..bee8170d 100644 --- a/cogl/cogl.c +++ b/cogl/cogl.c @@ -319,6 +319,38 @@ cogl_features_available (CoglFeatureFlags features) return (ctx->feature_flags & features) == features; } +gboolean +cogl_has_feature (CoglContext *ctx, CoglFeatureID feature) +{ + return COGL_FLAGS_GET (ctx->features, feature); +} + +gboolean +cogl_has_features (CoglContext *ctx, ...) +{ + va_list args; + CoglFeatureID feature; + + va_start (args, ctx); + while ((feature = va_arg (args, CoglFeatureID))) + if (!cogl_has_feature (ctx, feature)) + return FALSE; + va_end (args); + + return TRUE; +} + +void +cogl_foreach_feature (CoglContext *ctx, + CoglFeatureCallback callback, + void *user_data) +{ + int i; + for (i = 0; i < _COGL_N_FEATURE_IDS; i++) + if (COGL_FLAGS_GET (ctx->features, i)) + callback (i, user_data); +} + /* XXX: This function should either be replaced with one returning * integers, or removed/deprecated and make the * _cogl_framebuffer_get_viewport* functions public. |