summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-11-17 16:08:59 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-11-17 16:08:59 +0100
commit1b9380ef3c89623907c1d6a4437957c5f4df4179 (patch)
treefaf50ad485947a3d76fadc66f191d5ae2d3ba7c7
parenta3ae538c4593ff7878f99a9169e27f1c5ff9a3ee (diff)
mir: add support for foreign surfaces
-rw-r--r--cogl/cogl-onscreen-private.h4
-rw-r--r--cogl/cogl-onscreen.h18
-rw-r--r--cogl/winsys/cogl-winsys-egl-mir.c39
3 files changed, 51 insertions, 10 deletions
diff --git a/cogl/cogl-onscreen-private.h b/cogl/cogl-onscreen-private.h
index b30aeb93..b2d7dcb4 100644
--- a/cogl/cogl-onscreen-private.h
+++ b/cogl/cogl-onscreen-private.h
@@ -77,6 +77,10 @@ struct _CoglOnscreen
struct wl_surface *foreign_surface;
#endif
+#ifdef COGL_HAS_EGL_PLATFORM_MIR_SUPPORT
+ struct MirSurface *foreign_surface;
+#endif
+
CoglBool swap_throttled;
CoglList frame_closures;
diff --git a/cogl/cogl-onscreen.h b/cogl/cogl-onscreen.h
index d9f36f72..990a7161 100644
--- a/cogl/cogl-onscreen.h
+++ b/cogl/cogl-onscreen.h
@@ -270,6 +270,24 @@ cogl_wayland_onscreen_resize (CoglOnscreen *onscreen,
#if defined (COGL_HAS_EGL_PLATFORM_MIR_SUPPORT)
struct MirSurface *
cogl_mir_onscreen_get_surface (CoglOnscreen *onscreen);
+
+/**
+ * cogl_mir_onscreen_set_foreign_surface:
+ * @onscreen: An unallocated framebuffer.
+ * @surface A Mir surface to associate with the @onscreen.
+ *
+ * Allows you to explicitly notify Cogl of an existing Mir surface to use,
+ * which prevents Cogl from allocating a surface for the @onscreen.
+ * An allocated surface will not be destroyed when the @onscreen is freed.
+ *
+ * This function must be called before @onscreen is allocated.
+ *
+ * Since: 1.18
+ * Stability: unstable
+ */
+void
+cogl_mir_onscreen_set_foreign_surface (CoglOnscreen *onscreen,
+ struct MirSurface *surface);
#endif /* COGL_HAS_EGL_PLATFORM_MIR_SUPPORT */
/**
diff --git a/cogl/winsys/cogl-winsys-egl-mir.c b/cogl/winsys/cogl-winsys-egl-mir.c
index 7ae05d9c..c48e1027 100644
--- a/cogl/winsys/cogl-winsys-egl-mir.c
+++ b/cogl/winsys/cogl-winsys-egl-mir.c
@@ -317,15 +317,21 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
mir_onscreen = g_slice_new0 (CoglOnscreenMir);
egl_onscreen->platform = mir_onscreen;
- surfaceparm.name = "CoglSurface";
- surfaceparm.width = cogl_framebuffer_get_width (framebuffer);
- surfaceparm.height = cogl_framebuffer_get_height (framebuffer);
- surfaceparm.pixel_format = _mir_connection_get_valid_format (mir_renderer->mir_connection);
- surfaceparm.buffer_usage = mir_buffer_usage_hardware;
- surfaceparm.output_id = mir_display_output_id_invalid;
-
- mir_onscreen->mir_surface =
- mir_connection_create_surface_sync (mir_renderer->mir_connection, &surfaceparm);
+ if (mir_surface_is_valid (onscreen->foreign_surface))
+ {
+ mir_onscreen->mir_surface = onscreen->foreign_surface;
+ }
+ else
+ {
+ surfaceparm.name = "CoglSurface";
+ surfaceparm.width = cogl_framebuffer_get_width (framebuffer);
+ surfaceparm.height = cogl_framebuffer_get_height (framebuffer);
+ surfaceparm.pixel_format = _mir_connection_get_valid_format (mir_renderer->mir_connection);
+ surfaceparm.buffer_usage = mir_buffer_usage_hardware;
+ surfaceparm.output_id = mir_display_output_id_invalid;
+ mir_onscreen->mir_surface =
+ mir_connection_create_surface_sync (mir_renderer->mir_connection, &surfaceparm);
+ }
mir_onscreen->last_state = mir_surface_get_state (mir_onscreen->mir_surface);
@@ -362,7 +368,7 @@ _cogl_winsys_egl_onscreen_deinit (CoglOnscreen *onscreen)
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
CoglOnscreenMir *mir_onscreen = egl_onscreen->platform;
- if (mir_onscreen->mir_surface)
+ if (mir_onscreen->mir_surface && !onscreen->foreign_surface)
{
mir_surface_release (mir_onscreen->mir_surface, NULL, NULL);
mir_onscreen->mir_surface = NULL;
@@ -433,6 +439,19 @@ cogl_mir_renderer_get_connection (CoglRenderer *renderer)
return NULL;
}
+void
+cogl_mir_onscreen_set_foreign_surface (CoglOnscreen *onscreen,
+ MirSurface *surface)
+{
+ CoglFramebuffer *fb;
+ _COGL_RETURN_IF_FAIL (mir_surface_is_valid (surface));
+
+ fb = COGL_FRAMEBUFFER (onscreen);
+ _COGL_RETURN_IF_FAIL (!fb->allocated);
+
+ onscreen->foreign_surface = surface;
+}
+
MirSurface *
cogl_mir_onscreen_get_surface (CoglOnscreen *onscreen)
{