mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
renderer: Adds api to add/remove selection constraints
This allows applications to specify certain constraints that feed into the process of selecting a CoglRenderer backend. For example applications might depend on x11 for handling input and so they require a backend that's also based on x11.
This commit is contained in:
parent
7d38d9bdf2
commit
a8513c1d77
@ -44,6 +44,8 @@ struct _CoglRenderer
|
|||||||
gboolean connected;
|
gboolean connected;
|
||||||
const CoglWinsysVtable *winsys_vtable;
|
const CoglWinsysVtable *winsys_vtable;
|
||||||
CoglWinsysID winsys_id_override;
|
CoglWinsysID winsys_id_override;
|
||||||
|
GList *constraints;
|
||||||
|
|
||||||
#ifdef COGL_HAS_XLIB_SUPPORT
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
||||||
Display *foreign_xdpy;
|
Display *foreign_xdpy;
|
||||||
gboolean xlib_enable_event_retrieval;
|
gboolean xlib_enable_event_retrieval;
|
||||||
|
@ -321,6 +321,8 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
|
|||||||
{
|
{
|
||||||
const CoglWinsysVtable *winsys = _cogl_winsys_vtable_getters[i]();
|
const CoglWinsysVtable *winsys = _cogl_winsys_vtable_getters[i]();
|
||||||
GError *tmp_error = NULL;
|
GError *tmp_error = NULL;
|
||||||
|
GList *l;
|
||||||
|
gboolean constraints_failed = FALSE;
|
||||||
|
|
||||||
if (renderer->winsys_id_override != COGL_WINSYS_ID_ANY)
|
if (renderer->winsys_id_override != COGL_WINSYS_ID_ANY)
|
||||||
{
|
{
|
||||||
@ -337,6 +339,18 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (l = renderer->constraints; l; l = l->next)
|
||||||
|
{
|
||||||
|
CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
|
||||||
|
if (!(winsys->constraints & constraint))
|
||||||
|
{
|
||||||
|
constraints_failed = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (constraints_failed)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* At least temporarily we will associate this winsys with
|
/* At least temporarily we will associate this winsys with
|
||||||
* the renderer in-case ->renderer_connect calls API that
|
* the renderer in-case ->renderer_connect calls API that
|
||||||
* wants to query the current winsys... */
|
* wants to query the current winsys... */
|
||||||
@ -473,3 +487,22 @@ cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer)
|
|||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_renderer_add_contraint (CoglRenderer *renderer,
|
||||||
|
CoglRendererConstraint constraint)
|
||||||
|
{
|
||||||
|
g_return_if_fail (!renderer->connected);
|
||||||
|
renderer->constraints = g_list_prepend (renderer->constraints,
|
||||||
|
GUINT_TO_POINTER (constraint));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_renderer_remove_constraint (CoglRenderer *renderer,
|
||||||
|
CoglRendererConstraint constraint)
|
||||||
|
{
|
||||||
|
g_return_if_fail (!renderer->connected);
|
||||||
|
renderer->constraints = g_list_remove (renderer->constraints,
|
||||||
|
GUINT_TO_POINTER (constraint));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -155,6 +155,70 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
|
|||||||
gboolean
|
gboolean
|
||||||
cogl_renderer_connect (CoglRenderer *renderer, GError **error);
|
cogl_renderer_connect (CoglRenderer *renderer, GError **error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CoglRendererConstraint:
|
||||||
|
* @COGL_RENDERER_CONSTRAINT_USES_X11: Require the renderer to be X11 based
|
||||||
|
* @COGL_RENDERER_CONSTRAINT_USES_XLIB: Require the renderer to be X11
|
||||||
|
* based and use Xlib
|
||||||
|
* @COGL_RENDERER_CONSTRAINT_USES_EGL: Require the renderer to be EGL based
|
||||||
|
*
|
||||||
|
* These constraint flags are hard-coded features of the different renderer
|
||||||
|
* backends. Sometimes a platform may support multiple rendering options which
|
||||||
|
* Cogl will usually choose from automatically. Some of these features are
|
||||||
|
* important to higher level applications and frameworks though, such as
|
||||||
|
* whether a renderer is X11 based because an application might only support
|
||||||
|
* X11 based input handling. An application might also need to ensure EGL is
|
||||||
|
* used internally too if they depend on access to an EGLDisplay for some
|
||||||
|
* purpose.
|
||||||
|
*
|
||||||
|
* Applications should ideally minimize how many of these constraints
|
||||||
|
* they depend on to ensure maximum portability.
|
||||||
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COGL_RENDERER_CONSTRAINT_USES_X11 = (1 << 0),
|
||||||
|
COGL_RENDERER_CONSTRAINT_USES_XLIB = (1 << 1),
|
||||||
|
COGL_RENDERER_CONSTRAINT_USES_EGL = (1 << 2)
|
||||||
|
} CoglRendererConstraint;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_renderer_add_contraint:
|
||||||
|
* @renderer: An unconnected #CoglRenderer
|
||||||
|
* @constraint: A #CoglRendererConstraint to add
|
||||||
|
*
|
||||||
|
* This adds a renderer selection @constraint.
|
||||||
|
*
|
||||||
|
* Applications should ideally minimize how many of these constraints they
|
||||||
|
* depend on to ensure maximum portability.
|
||||||
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_renderer_add_contraint (CoglRenderer *renderer,
|
||||||
|
CoglRendererConstraint constraint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_renderer_remove_constraint:
|
||||||
|
* @renderer: An unconnected #CoglRenderer
|
||||||
|
* @constraint: A #CoglRendererConstraint to remove
|
||||||
|
*
|
||||||
|
* This removes a renderer selection @constraint.
|
||||||
|
*
|
||||||
|
* Applications should ideally minimize how many of these constraints they
|
||||||
|
* depend on to ensure maximum portability.
|
||||||
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_renderer_remove_constraint (CoglRenderer *renderer,
|
||||||
|
CoglRendererConstraint constraint);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_RENDERER_H__ */
|
#endif /* __COGL_RENDERER_H__ */
|
||||||
|
@ -460,8 +460,8 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
|
|||||||
CoglTexture2D *tex_2d;
|
CoglTexture2D *tex_2d;
|
||||||
GLenum gl_error;
|
GLenum gl_error;
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->criteria &
|
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->constraints &
|
||||||
COGL_WINSYS_CRITERIA_USES_EGL,
|
COGL_RENDERER_CONSTRAINT_USES_EGL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (ctx->private_feature_flags &
|
_COGL_RETURN_VAL_IF_FAIL (ctx->private_feature_flags &
|
||||||
@ -541,8 +541,8 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
|
|||||||
{
|
{
|
||||||
EGLImageKHR image;
|
EGLImageKHR image;
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->criteria &
|
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->constraints &
|
||||||
COGL_WINSYS_CRITERIA_USES_EGL,
|
COGL_RENDERER_CONSTRAINT_USES_EGL,
|
||||||
NULL);
|
NULL);
|
||||||
image = _cogl_egl_create_image (ctx,
|
image = _cogl_egl_create_image (ctx,
|
||||||
EGL_WAYLAND_BUFFER_WL,
|
EGL_WAYLAND_BUFFER_WL,
|
||||||
|
@ -718,8 +718,8 @@ _cogl_winsys_egl_xlib_get_vtable (void)
|
|||||||
|
|
||||||
vtable.id = COGL_WINSYS_ID_EGL_XLIB;
|
vtable.id = COGL_WINSYS_ID_EGL_XLIB;
|
||||||
vtable.name = "EGL_XLIB";
|
vtable.name = "EGL_XLIB";
|
||||||
vtable.criteria |= (COGL_WINSYS_CRITERIA_USES_X11 |
|
vtable.constraints |= (COGL_RENDERER_CONSTRAINT_USES_X11 |
|
||||||
COGL_WINSYS_CRITERIA_USES_XLIB);
|
COGL_RENDERER_CONSTRAINT_USES_XLIB);
|
||||||
|
|
||||||
vtable.renderer_connect = _cogl_winsys_renderer_connect;
|
vtable.renderer_connect = _cogl_winsys_renderer_connect;
|
||||||
vtable.renderer_disconnect = _cogl_winsys_renderer_disconnect;
|
vtable.renderer_disconnect = _cogl_winsys_renderer_disconnect;
|
||||||
|
@ -640,7 +640,7 @@ _cogl_winsys_context_egl_get_egl_display (CoglContext *context)
|
|||||||
|
|
||||||
static CoglWinsysVtable _cogl_winsys_vtable =
|
static CoglWinsysVtable _cogl_winsys_vtable =
|
||||||
{
|
{
|
||||||
.criteria = COGL_WINSYS_CRITERIA_USES_EGL,
|
.constraints = COGL_RENDERER_CONSTRAINT_USES_EGL,
|
||||||
|
|
||||||
/* This winsys is only used as a base for the EGL-platform
|
/* This winsys is only used as a base for the EGL-platform
|
||||||
winsys's so it does not have an ID or a name */
|
winsys's so it does not have an ID or a name */
|
||||||
|
@ -2032,8 +2032,8 @@ static CoglWinsysVtable _cogl_winsys_vtable =
|
|||||||
{
|
{
|
||||||
.id = COGL_WINSYS_ID_GLX,
|
.id = COGL_WINSYS_ID_GLX,
|
||||||
.name = "GLX",
|
.name = "GLX",
|
||||||
.criteria = (COGL_WINSYS_CRITERIA_USES_X11 |
|
.constraints = (COGL_RENDERER_CONSTRAINT_USES_X11 |
|
||||||
COGL_WINSYS_CRITERIA_USES_XLIB),
|
COGL_RENDERER_CONSTRAINT_USES_XLIB),
|
||||||
|
|
||||||
.renderer_get_proc_address = _cogl_winsys_renderer_get_proc_address,
|
.renderer_get_proc_address = _cogl_winsys_renderer_get_proc_address,
|
||||||
.renderer_connect = _cogl_winsys_renderer_connect,
|
.renderer_connect = _cogl_winsys_renderer_connect,
|
||||||
|
@ -54,23 +54,10 @@ typedef enum
|
|||||||
COGL_WINSYS_RECTANGLE_STATE_ENABLE
|
COGL_WINSYS_RECTANGLE_STATE_ENABLE
|
||||||
} CoglWinsysRectangleState;
|
} CoglWinsysRectangleState;
|
||||||
|
|
||||||
/* These criteria flags are hard-coded features of the winsys
|
|
||||||
regardless of the underlying driver or GPU. We might eventually
|
|
||||||
want to use these in a mechanism for the application to specify
|
|
||||||
criteria for the winsys instead of a specific winsys but for now
|
|
||||||
they are only used internally to assert that an EGL winsys is
|
|
||||||
selected */
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
COGL_WINSYS_CRITERIA_USES_X11 = (1 << 0),
|
|
||||||
COGL_WINSYS_CRITERIA_USES_XLIB = (1 << 1),
|
|
||||||
COGL_WINSYS_CRITERIA_USES_EGL = (1 << 2)
|
|
||||||
} CoglWinsysCriteria;
|
|
||||||
|
|
||||||
typedef struct _CoglWinsysVtable
|
typedef struct _CoglWinsysVtable
|
||||||
{
|
{
|
||||||
CoglWinsysID id;
|
CoglWinsysID id;
|
||||||
CoglWinsysCriteria criteria;
|
CoglRendererConstraint constraints;
|
||||||
|
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user