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.
This commit is contained in:
Robert Bragg 2011-05-11 14:07:02 +01:00
parent 653d59af04
commit 2282455f27
3 changed files with 93 additions and 8 deletions

View File

@ -34,6 +34,10 @@
#include <windows.h> #include <windows.h>
#endif /* COGL_HAS_WIN32_SUPPORT */ #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 G_BEGIN_DECLS
#ifdef COGL_ENABLE_EXPERIMENTAL_API #ifdef COGL_ENABLE_EXPERIMENTAL_API
@ -172,6 +176,11 @@ HWND
cogl_onscreen_win32_get_window (CoglOnscreen *onscreen); cogl_onscreen_win32_get_window (CoglOnscreen *onscreen);
#endif /* COGL_HAS_WIN32_SUPPORT */ #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 #define cogl_onscreen_set_swap_throttled cogl_onscreen_set_swap_throttled_EXP
void void
cogl_onscreen_set_swap_throttled (CoglOnscreen *onscreen, cogl_onscreen_set_swap_throttled (CoglOnscreen *onscreen,

View File

@ -156,21 +156,21 @@ void
cogl_renderer_wayland_set_foreign_display (CoglRenderer *renderer, cogl_renderer_wayland_set_foreign_display (CoglRenderer *renderer,
struct wl_display *display); 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 \ #define cogl_renderer_wayland_set_foreign_compositor \
cogl_renderer_wayland_set_foreign_compositor_EXP cogl_renderer_wayland_set_foreign_compositor_EXP
void void
cogl_renderer_wayland_set_foreign_compositor (CoglRenderer *renderer, cogl_renderer_wayland_set_foreign_compositor (CoglRenderer *renderer,
struct wl_compositor *compositor); struct wl_compositor *compositor);
#define cogl_renderer_wayland_get_foreign_display \ #define cogl_renderer_wayland_get_compositor \
cogl_renderer_wayland_get_foreign_display_EXP cogl_renderer_wayland_get_compositor_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
struct wl_compositor * 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 */ #endif /* COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT */
#define cogl_renderer_check_onscreen_template \ #define cogl_renderer_check_onscreen_template \

View File

@ -1512,3 +1512,79 @@ _cogl_winsys_egl_get_vtable (void)
{ {
return &_cogl_winsys_vtable; 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 */