[cogl] wayland: Allow setting foreign display/compositor



commit 2282455f27341fb4074144e5ff830d7aa02f0cb6
Author: Robert Bragg <robert linux intel com>
Date:   Wed May 11 14:07:02 2011 +0100

    wayland: Allow setting foreign display/compositor
    
    To support toolkits targeting wayland and using Cogl we allow toolkits
    to be responsible for connecting to a wayland display and asking Cogl to
    use the toolkit owned display and compositor object. Note: eventually
    the plan is that wayland will allow retrospective querying of objects so
    we won't need the foreign compositor API when Cogl can simply query it
    from the foreign display.

 cogl/cogl-framebuffer.h       |    9 +++++
 cogl/cogl-renderer.h          |   16 ++++----
 cogl/winsys/cogl-winsys-egl.c |   76 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 8 deletions(-)
---
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index 50ac7cb..ae2419a 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -34,6 +34,10 @@
 #include <windows.h>
 #endif /* COGL_HAS_WIN32_SUPPORT */
 
+#if COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+#include <wayland-client.h>
+#endif /* COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT */
+
 G_BEGIN_DECLS
 
 #ifdef COGL_ENABLE_EXPERIMENTAL_API
@@ -172,6 +176,11 @@ HWND
 cogl_onscreen_win32_get_window (CoglOnscreen *onscreen);
 #endif /* COGL_HAS_WIN32_SUPPORT */
 
+#if COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+struct wl_surface *
+cogl_wayland_onscreen_get_surface (CoglOnscreen *onscreen);
+#endif /* COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT */
+
 #define cogl_onscreen_set_swap_throttled cogl_onscreen_set_swap_throttled_EXP
 void
 cogl_onscreen_set_swap_throttled (CoglOnscreen *onscreen,
diff --git a/cogl/cogl-renderer.h b/cogl/cogl-renderer.h
index 6dbac51..53285ec 100644
--- a/cogl/cogl-renderer.h
+++ b/cogl/cogl-renderer.h
@@ -156,21 +156,21 @@ void
 cogl_renderer_wayland_set_foreign_display (CoglRenderer *renderer,
                                            struct wl_display *display);
 
+#define cogl_renderer_wayland_get_display \
+  cogl_renderer_wayland_get_display_EXP
+struct wl_display *
+cogl_renderer_wayland_get_display (CoglRenderer *renderer);
+
 #define cogl_renderer_wayland_set_foreign_compositor \
   cogl_renderer_wayland_set_foreign_compositor_EXP
 void
 cogl_renderer_wayland_set_foreign_compositor (CoglRenderer *renderer,
                                               struct wl_compositor *compositor);
 
-#define cogl_renderer_wayland_get_foreign_display \
-  cogl_renderer_wayland_get_foreign_display_EXP
-struct wl_display *
-cogl_renderer_wayland_get_foreign_display (CoglRenderer *renderer);
-
-#define cogl_renderer_wayland_get_foreign_compositor \
-  cogl_renderer_wayland_get_foreign_compositor_EXP
+#define cogl_renderer_wayland_get_compositor \
+  cogl_renderer_wayland_get_compositor_EXP
 struct wl_compositor *
-cogl_renderer_wayland_get_foreign_compositor (CoglRenderer *renderer);
+cogl_renderer_wayland_get_compositor (CoglRenderer *renderer);
 #endif /* COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT */
 
 #define cogl_renderer_check_onscreen_template \
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index aeae982..f503cd1 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -1512,3 +1512,79 @@ _cogl_winsys_egl_get_vtable (void)
 {
   return &_cogl_winsys_vtable;
 }
+
+/* FIXME: we should have a separate wayland file for these entry
+ * points... */
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+void
+cogl_renderer_wayland_set_foreign_display (CoglRenderer *renderer,
+                                           struct wl_display *display)
+{
+  g_return_if_fail (cogl_is_renderer (renderer));
+
+  /* NB: Renderers are considered immutable once connected */
+  g_return_if_fail (!renderer->connected);
+
+  renderer->foreign_wayland_display = display;
+}
+
+struct wl_display *
+cogl_renderer_wayland_get_display (CoglRenderer *renderer)
+{
+  g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
+
+  if (renderer->foreign_wayland_display)
+    return renderer->foreign_wayland_display;
+  else if (renderer->connected)
+    {
+      CoglRendererEGL *egl_renderer = renderer->winsys;
+      return egl_renderer->wayland_display;
+    }
+  else
+    return NULL;
+}
+
+void
+cogl_renderer_wayland_set_foreign_compositor (CoglRenderer *renderer,
+                                              struct wl_compositor *compositor)
+{
+  g_return_if_fail (cogl_is_renderer (renderer));
+
+  /* NB: Renderers are considered immutable once connected */
+  g_return_if_fail (!renderer->connected);
+
+  renderer->foreign_wayland_compositor = compositor;
+}
+
+struct wl_compositor *
+cogl_renderer_wayland_get_compositor (CoglRenderer *renderer)
+{
+  g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
+
+  if (renderer->foreign_wayland_compositor)
+    return renderer->foreign_wayland_compositor;
+  else if (renderer->connected)
+    {
+      CoglRendererEGL *egl_renderer = renderer->winsys;
+      return egl_renderer->wayland_compositor;
+    }
+  else
+    return NULL;
+}
+
+struct wl_surface *
+cogl_wayland_onscreen_get_surface (CoglOnscreen *onscreen)
+{
+  CoglFramebuffer *fb;
+
+  fb = COGL_FRAMEBUFFER (onscreen);
+  if (fb->allocated)
+    {
+      CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
+      return egl_onscreen->wayland_surface;
+    }
+  else
+    return NULL;
+}
+
+#endif /* COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT */



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