[clutter/clutter-1.18] egl: Add a way to set the KMS FD



commit a96daf82c255c0d8c45361b5b2059008d660029d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Feb 28 09:48:10 2014 -0500

    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

 clutter/egl/clutter-backend-eglnative.c |   39 +++++++++++++++++++++++++++++++
 clutter/egl/clutter-egl.h               |    2 +
 2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/clutter/egl/clutter-backend-eglnative.c b/clutter/egl/clutter-backend-eglnative.c
index 1c0aee8..0541c56 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 c15cd15..a06cf8c 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__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]