mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
renderer: Adds getters/setters for driver preference
This adds api for explicitly choosing what underlying driver cogl should use internally for rendering as well as api for querying back what driver is actually in use. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
5928cade0b
commit
be237cc2b7
@ -90,13 +90,6 @@ typedef enum { /*< prefix=COGL_DRIVER_ERROR >*/
|
||||
COGL_DRIVER_ERROR_FAILED_TO_LOAD_LIBRARY
|
||||
} CoglDriverError;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COGL_DRIVER_GL,
|
||||
COGL_DRIVER_GLES1,
|
||||
COGL_DRIVER_GLES2
|
||||
} CoglDriver;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE = 1L<<0,
|
||||
|
@ -42,6 +42,7 @@ struct _CoglRenderer
|
||||
{
|
||||
CoglObject _parent;
|
||||
gboolean connected;
|
||||
CoglDriver driver_override;
|
||||
const CoglWinsysVtable *winsys_vtable;
|
||||
CoglWinsysID winsys_id_override;
|
||||
GList *constraints;
|
||||
|
@ -245,7 +245,9 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
|
||||
driver_name = _cogl_config_driver;
|
||||
|
||||
#ifdef HAVE_COGL_GL
|
||||
if (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gl"))
|
||||
if (renderer->driver_override == COGL_DRIVER_GL ||
|
||||
(renderer->driver_override == COGL_DRIVER_ANY &&
|
||||
(driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gl"))))
|
||||
{
|
||||
renderer->driver = COGL_DRIVER_GL;
|
||||
libgl_name = COGL_GL_LIBNAME;
|
||||
@ -254,7 +256,9 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COGL_GLES2
|
||||
if (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles2"))
|
||||
if (renderer->driver_override == COGL_DRIVER_GLES2 ||
|
||||
(renderer->driver_override == COGL_DRIVER_ANY &&
|
||||
(driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles2"))))
|
||||
{
|
||||
renderer->driver = COGL_DRIVER_GLES2;
|
||||
libgl_name = COGL_GLES2_LIBNAME;
|
||||
@ -263,7 +267,9 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COGL_GLES
|
||||
if (driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles1"))
|
||||
if (renderer->driver_override == COGL_DRIVER_GLES1 ||
|
||||
(renderer->driver_override == COGL_DRIVER_ANY &&
|
||||
(driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles1"))))
|
||||
{
|
||||
renderer->driver = COGL_DRIVER_GLES1;
|
||||
libgl_name = COGL_GLES1_LIBNAME;
|
||||
@ -505,3 +511,18 @@ cogl_renderer_remove_constraint (CoglRenderer *renderer,
|
||||
GUINT_TO_POINTER (constraint));
|
||||
}
|
||||
|
||||
void
|
||||
cogl_renderer_set_driver (CoglRenderer *renderer,
|
||||
CoglDriver driver)
|
||||
{
|
||||
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
||||
renderer->driver_override = driver;
|
||||
}
|
||||
|
||||
CoglDriver
|
||||
cogl_renderer_get_driver (CoglRenderer *renderer)
|
||||
{
|
||||
_COGL_RETURN_VAL_IF_FAIL (renderer->connected, 0);
|
||||
|
||||
return renderer->driver;
|
||||
}
|
||||
|
@ -319,6 +319,62 @@ void
|
||||
cogl_renderer_remove_constraint (CoglRenderer *renderer,
|
||||
CoglRendererConstraint constraint);
|
||||
|
||||
/**
|
||||
* CoglDriver:
|
||||
* @COGL_DRIVER_ANY: Implies no preference for which driver is used
|
||||
* @COGL_DRIVER_GL: An OpenGL driver.
|
||||
* @COGL_DRIVER_GLES1: An OpenGL ES 1.1 driver.
|
||||
* @COGL_DRIVER_GLES2: An OpenGL ES 2.0 driver.
|
||||
*
|
||||
* Identifiers for underlying hardware drivers that may be used by
|
||||
* Cogl for rendering.
|
||||
*
|
||||
* Since: 1.10
|
||||
* Stability: unstable
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
COGL_DRIVER_ANY,
|
||||
COGL_DRIVER_GL,
|
||||
COGL_DRIVER_GLES1,
|
||||
COGL_DRIVER_GLES2
|
||||
} CoglDriver;
|
||||
|
||||
/**
|
||||
* cogl_renderer_set_driver:
|
||||
* @renderer: An unconnected #CoglRenderer
|
||||
*
|
||||
* Requests that Cogl should try to use a specific underlying driver
|
||||
* for rendering.
|
||||
*
|
||||
* If you select an unsupported driver then cogl_renderer_connect()
|
||||
* will fail and report an error. Most applications should not
|
||||
* explicitly select a driver and should rely on Cogl automatically
|
||||
* choosing the driver.
|
||||
*
|
||||
* This may only be called on an un-connected #CoglRenderer.
|
||||
*
|
||||
* Since: 1.10
|
||||
* Stability: unstable
|
||||
*/
|
||||
void
|
||||
cogl_renderer_set_driver (CoglRenderer *renderer,
|
||||
CoglDriver driver);
|
||||
|
||||
/**
|
||||
* cogl_renderer_get_driver:
|
||||
* @renderer: A connected #CoglRenderer
|
||||
*
|
||||
* Queries what underlying driver is being used by Cogl.
|
||||
*
|
||||
* This may only be called on a connected #CoglRenderer.
|
||||
*
|
||||
* Since: 1.10
|
||||
* Stability: unstable
|
||||
*/
|
||||
CoglDriver
|
||||
cogl_renderer_get_driver (CoglRenderer *renderer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_RENDERER_H__ */
|
||||
|
@ -178,6 +178,8 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display,
|
||||
surfaceless_feature = COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2;
|
||||
surfaceless_feature_name = "gles2";
|
||||
break;
|
||||
case COGL_DRIVER_ANY:
|
||||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
if (!(egl_renderer->private_features & surfaceless_feature))
|
||||
|
Loading…
Reference in New Issue
Block a user