cogl-context: Store winsys features in an array of unsigned ints

Previously the mask of available winsys features was stored in a
CoglBitmask. That isn't the ideal type to use for this because it is
intended for a growable array of bits so it can allocate extra memory
if there are more than 31 flags set. For the winsys feature flags the
highest used bit is known at compile time so it makes sense to
allocate a fixed array instead. This is conceptually similar to the
CoglDebugFlags which are stored in an array of integers with macros to
test a bit in the array. This moves the macros used for CoglDebugFlags
to cogl-flags.h and makes them more generic so they can be shared with
CoglContext.
This commit is contained in:
Neil Roberts
2011-04-15 15:39:14 +01:00
parent f6ae9decaa
commit 4a7762d6d7
9 changed files with 126 additions and 45 deletions

View File

@@ -332,7 +332,7 @@ update_winsys_features (CoglContext *context)
_cogl_gl_update_features (context);
_cogl_bitmask_init (&context->winsys_features);
memset (context->winsys_features, 0, sizeof (context->winsys_features));
glx_extensions =
glXQueryExtensionsString (xlib_renderer->xdpy,
@@ -341,9 +341,9 @@ update_winsys_features (CoglContext *context)
COGL_NOTE (WINSYS, " GLX Extensions: %s", glx_extensions);
context->feature_flags |= COGL_FEATURE_ONSCREEN_MULTIPLE;
_cogl_bitmask_set (&context->winsys_features,
COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN,
TRUE);
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN,
TRUE);
initialize_function_table (context->display->renderer);
@@ -354,9 +354,9 @@ update_winsys_features (CoglContext *context)
{
context->feature_flags |= winsys_feature_data[i].feature_flags;
if (winsys_feature_data[i].winsys_feature)
_cogl_bitmask_set (&context->winsys_features,
winsys_feature_data[i].winsys_feature,
TRUE);
COGL_FLAGS_SET (context->winsys_features,
winsys_feature_data[i].winsys_feature,
TRUE);
}
/* Note: the GLX_SGI_video_sync spec explicitly states this extension
@@ -368,9 +368,9 @@ update_winsys_features (CoglContext *context)
}
if (glx_renderer->pf_glXWaitVideoSync)
_cogl_bitmask_set (&context->winsys_features,
COGL_WINSYS_FEATURE_VBLANK_WAIT,
TRUE);
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_VBLANK_WAIT,
TRUE);
#ifdef HAVE_DRM
/* drm is really an extreme fallback -rumoured to work with Via
@@ -380,23 +380,23 @@ update_winsys_features (CoglContext *context)
if (glx_renderer->dri_fd < 0)
glx_renderer->dri_fd = open("/dev/dri/card0", O_RDWR);
if (glx_renderer->dri_fd >= 0)
_cogl_bitmask_set (&context->winsys_features,
COGL_WINSYS_FEATURE_VBLANK_WAIT,
TRUE);
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_VBLANK_WAIT,
TRUE);
}
#endif
if (glx_renderer->pf_glXCopySubBuffer || context->drv.pf_glBlitFramebuffer)
_cogl_bitmask_set (&context->winsys_features,
COGL_WINSYS_FEATURE_SWAP_REGION, TRUE);
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_SWAP_REGION, TRUE);
/* Note: glXCopySubBuffer and glBlitFramebuffer won't be throttled
* by the SwapInterval so we have to throttle swap_region requests
* manually... */
if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION) &&
_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_VBLANK_WAIT))
_cogl_bitmask_set (&context->winsys_features,
COGL_WINSYS_FEATURE_SWAP_REGION_THROTTLE, TRUE);
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_SWAP_REGION_THROTTLE, TRUE);
}
/* It seems the GLX spec never defined an invalid GLXFBConfig that
@@ -1314,7 +1314,7 @@ _cogl_winsys_has_feature (CoglWinsysFeature feature)
{
_COGL_GET_CONTEXT (ctx, FALSE);
return _cogl_bitmask_get (&ctx->winsys_features, feature);
return COGL_FLAGS_GET (ctx->winsys_features, feature);
}
/* XXX: This is a particularly hacky _cogl_winsys interface... */