diff --git a/clutter/egl/clutter-backend-eglnative.c b/clutter/egl/clutter-backend-eglnative.c index 1c0aee8b1..0541c5623 100644 --- a/clutter/egl/clutter-backend-eglnative.c +++ b/clutter/egl/clutter-backend-eglnative.c @@ -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; +} diff --git a/clutter/egl/clutter-egl.h b/clutter/egl/clutter-egl.h index c15cd1556..a06cf8cb1 100644 --- a/clutter/egl/clutter-egl.h +++ b/clutter/egl/clutter-egl.h @@ -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__ */