egl: Add a way to set the KMS FD

This is needed for the logind integration work, where logind will
send us an already-opened FD to KMS.

https://bugzilla.gnome.org/show_bug.cgi?id=726198
This commit is contained in:
Jasper St. Pierre 2014-02-28 09:48:10 -05:00
parent 06387c3fd7
commit a96daf82c2
2 changed files with 41 additions and 0 deletions

View File

@ -59,6 +59,8 @@
G_DEFINE_TYPE (ClutterBackendEglNative, clutter_backend_egl_native, CLUTTER_TYPE_BACKEND);
static int _kms_fd = -1;
static void
clutter_backend_egl_native_dispose (GObject *gobject)
{
@ -73,6 +75,23 @@ clutter_backend_egl_native_dispose (GObject *gobject)
G_OBJECT_CLASS (clutter_backend_egl_native_parent_class)->dispose (gobject);
}
static CoglRenderer *
clutter_backend_egl_native_get_renderer (ClutterBackend *backend,
GError **error)
{
CoglRenderer *renderer;
renderer = cogl_renderer_new ();
if (_kms_fd > -1)
{
cogl_renderer_set_winsys_id (renderer, COGL_WINSYS_ID_EGL_KMS);
cogl_kms_renderer_set_kms_fd (renderer, _kms_fd);
}
return renderer;
}
static void
clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
{
@ -82,6 +101,8 @@ clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
gobject_class->dispose = clutter_backend_egl_native_dispose;
backend_class->stage_window_type = CLUTTER_TYPE_STAGE_EGL_NATIVE;
backend_class->get_renderer = clutter_backend_egl_native_get_renderer;
}
static void
@ -159,3 +180,21 @@ clutter_egl_get_egl_display (void)
return 0;
#endif
}
/**
* clutter_egl_set_kms_fd:
* @fd: The fd to talk to the kms driver with
*
* Sets the fd that Cogl should use to talk to the kms driver.
* Setting this to a negative value effectively reverts this
* call, making Cogl open the device itself.
*
* This can only be called before clutter_init() is called.
*
* Since: 1.18
*/
void
clutter_egl_set_kms_fd (int fd)
{
_kms_fd = fd;
}

View File

@ -87,6 +87,8 @@ EGLDisplay clutter_egl_display (void);
*/
EGLDisplay clutter_egl_get_egl_display (void);
void clutter_egl_set_kms_fd (int fd);
G_END_DECLS
#endif /* __CLUTTER_EGL_H__ */