diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h index 50ac7cb33..ae2419aaa 100644 --- a/cogl/cogl-framebuffer.h +++ b/cogl/cogl-framebuffer.h @@ -34,6 +34,10 @@ #include #endif /* COGL_HAS_WIN32_SUPPORT */ +#if COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT +#include +#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 6dbac519e..53285eccf 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 aeae9822d..f503cd18c 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 */