mir: add support for foreign display
This commit is contained in:
parent
672eff0c6c
commit
a3ae538c45
@ -504,6 +504,8 @@ cogl_sources_c += \
|
||||
$(srcdir)/winsys/cogl-winsys-egl-android-private.h
|
||||
endif
|
||||
if SUPPORT_EGL_PLATFORM_MIR
|
||||
cogl_experimental_h += \
|
||||
$(srcdir)/cogl-mir-renderer.h
|
||||
cogl_sources_c += \
|
||||
$(srcdir)/winsys/cogl-winsys-egl-mir.c \
|
||||
$(srcdir)/winsys/cogl-winsys-egl-mir-private.h
|
||||
|
83
cogl/cogl-mir-renderer.h
Normal file
83
cogl/cogl-mir-renderer.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A Low Level GPU Graphics and Utilities API
|
||||
*
|
||||
* Copyright (C) 2014 Canonical Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __COGL_MIR_RENDERER_H__
|
||||
#define __COGL_MIR_RENDERER_H__
|
||||
|
||||
#include <cogl/cogl-types.h>
|
||||
#include <cogl/cogl-renderer.h>
|
||||
|
||||
#include <mir_toolkit/mir_client_library.h>
|
||||
|
||||
COGL_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* cogl_mir_renderer_set_foreign_connection:
|
||||
* @renderer: A #CoglRenderer
|
||||
* @connection: A Mir connection
|
||||
*
|
||||
* Allows you to explicitly control what Mir connection you want Cogl
|
||||
* to work with instead of leaving Cogl to automatically connect to a
|
||||
* mir server.
|
||||
*
|
||||
* Since: 1.8
|
||||
* Stability: unstable
|
||||
*/
|
||||
void
|
||||
cogl_mir_renderer_set_foreign_connection (CoglRenderer *renderer,
|
||||
MirConnection *connection);
|
||||
|
||||
/**
|
||||
* cogl_mir_renderer_get_connection:
|
||||
* @renderer: A #CoglRenderer
|
||||
*
|
||||
* Retrieves the Mir Connection that Cogl is using. If a foreign
|
||||
* connection has been specified using
|
||||
* cogl_mir_renderer_set_foreign_connection() then that connection will
|
||||
* be returned. If no foreign connection has been specified then the
|
||||
* display that Cogl creates internally will be returned unless the
|
||||
* renderer has not yet been connected (either implicitly or explicitly by
|
||||
* calling cogl_renderer_connect()) in which case %NULL is returned.
|
||||
*
|
||||
* Returns: The mir connection currently associated with @renderer,
|
||||
* or %NULL if the renderer hasn't yet been connected and no
|
||||
* foreign connection has been specified.
|
||||
*
|
||||
* Since: 1.8
|
||||
* Stability: unstable
|
||||
*/
|
||||
MirConnection *
|
||||
cogl_mir_renderer_get_connection (CoglRenderer *renderer);
|
||||
|
||||
COGL_END_DECLS
|
||||
|
||||
#endif /* __COGL_MIR_RENDERER_H__ */
|
@ -48,6 +48,10 @@
|
||||
#include <wayland-client.h>
|
||||
#endif
|
||||
|
||||
#if defined (COGL_HAS_EGL_PLATFORM_MIR_SUPPORT)
|
||||
#include <mir_toolkit/mir_client_library.h>
|
||||
#endif
|
||||
|
||||
struct _CoglRenderer
|
||||
{
|
||||
CoglObject _parent;
|
||||
@ -88,6 +92,10 @@ struct _CoglRenderer
|
||||
CoglBool wayland_enable_event_dispatch;
|
||||
#endif
|
||||
|
||||
#if defined (COGL_HAS_EGL_PLATFORM_MIR_SUPPORT)
|
||||
MirConnection *foreign_mir_connection;
|
||||
#endif
|
||||
|
||||
#if defined (COGL_HAS_EGL_PLATFORM_KMS_SUPPORT)
|
||||
int kms_fd;
|
||||
#endif
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "cogl-winsys-egl-private.h"
|
||||
#include "cogl-renderer-private.h"
|
||||
#include "cogl-onscreen-private.h"
|
||||
#include "cogl-mir-renderer.h"
|
||||
#include "cogl-error-private.h"
|
||||
|
||||
static const CoglWinsysEGLVtable _cogl_winsys_egl_vtable;
|
||||
@ -103,7 +104,10 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
|
||||
eglTerminate (egl_renderer->edpy);
|
||||
|
||||
if (mir_connection_is_valid (mir_renderer->mir_connection))
|
||||
mir_connection_release (mir_renderer->mir_connection);
|
||||
{
|
||||
if (!mir_connection_is_valid (renderer->foreign_mir_connection))
|
||||
mir_connection_release (mir_renderer->mir_connection);
|
||||
}
|
||||
|
||||
g_slice_free (CoglRendererMir, egl_renderer->platform);
|
||||
g_slice_free (CoglRendererEGL, egl_renderer);
|
||||
@ -124,13 +128,20 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
|
||||
|
||||
egl_renderer->platform_vtable = &_cogl_winsys_egl_vtable;
|
||||
|
||||
mir_renderer->mir_connection = mir_connect_sync (NULL, __PRETTY_FUNCTION__);
|
||||
if (!mir_connection_is_valid (mir_renderer->mir_connection))
|
||||
if (mir_connection_is_valid (renderer->foreign_mir_connection))
|
||||
{
|
||||
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_INIT,
|
||||
"Failed to connect mir display");
|
||||
goto error;
|
||||
mir_renderer->mir_connection = renderer->foreign_mir_connection;
|
||||
}
|
||||
else
|
||||
{
|
||||
mir_renderer->mir_connection = mir_connect_sync (NULL, __PRETTY_FUNCTION__);
|
||||
if (!mir_connection_is_valid (mir_renderer->mir_connection))
|
||||
{
|
||||
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_INIT,
|
||||
"Failed to connect mir display");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
mir_native_dpy =
|
||||
@ -391,6 +402,37 @@ _cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
|
||||
mir_surface_set_state (mir_onscreen->mir_surface, new_state);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_mir_renderer_set_foreign_connection (CoglRenderer *renderer,
|
||||
MirConnection *connection)
|
||||
{
|
||||
_COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
|
||||
_COGL_RETURN_IF_FAIL (mir_connection_is_valid (connection));
|
||||
|
||||
/* NB: Renderers are considered immutable once connected */
|
||||
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
||||
|
||||
renderer->foreign_mir_connection = connection;
|
||||
}
|
||||
|
||||
MirConnection *
|
||||
cogl_mir_renderer_get_connection (CoglRenderer *renderer)
|
||||
{
|
||||
_COGL_RETURN_VAL_IF_FAIL (cogl_is_renderer (renderer), NULL);
|
||||
|
||||
if (mir_connection_is_valid (renderer->foreign_mir_connection))
|
||||
return renderer->foreign_mir_connection;
|
||||
|
||||
if (renderer->connected)
|
||||
{
|
||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||
CoglRendererMir *mir_renderer = egl_renderer->platform;
|
||||
return mir_renderer->mir_connection;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MirSurface *
|
||||
cogl_mir_onscreen_get_surface (CoglOnscreen *onscreen)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user