Create cogl renderer in MetaRenderer
Instead of passing around the KMS file descriptor via clutter to cogl, just make our own clutter backend create the cogl renderer and set the KSM fd. https://bugzilla.gnome.org/show_bug.cgi?id=768976
This commit is contained in:
parent
b2a62e6d5a
commit
2ceff4ee9b
@ -242,14 +242,6 @@ clutter_backend_do_real_create_context (ClutterBackend *backend,
|
||||
if (backend->cogl_renderer == NULL)
|
||||
goto error;
|
||||
|
||||
#ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT
|
||||
/* If the application is trying to act as a Wayland compositor then
|
||||
it needs to have an EGL-based renderer backend */
|
||||
if (_wayland_compositor_display)
|
||||
cogl_renderer_add_constraint (backend->cogl_renderer,
|
||||
COGL_RENDERER_CONSTRAINT_USES_EGL);
|
||||
#endif
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Connecting the renderer");
|
||||
cogl_renderer_set_driver (backend->cogl_renderer, driver_id);
|
||||
if (!cogl_renderer_connect (backend->cogl_renderer, &internal_error))
|
||||
|
@ -57,10 +57,6 @@
|
||||
|
||||
G_DEFINE_TYPE (ClutterBackendEglNative, clutter_backend_egl_native, CLUTTER_TYPE_BACKEND);
|
||||
|
||||
#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
|
||||
static int _kms_fd = -1;
|
||||
#endif
|
||||
|
||||
static void
|
||||
clutter_backend_egl_native_dispose (GObject *gobject)
|
||||
{
|
||||
@ -75,25 +71,6 @@ clutter_backend_egl_native_dispose (GObject *gobject)
|
||||
G_OBJECT_CLASS (clutter_backend_egl_native_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static CoglRenderer *
|
||||
clutter_backend_egl_native_get_renderer (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
CoglRenderer *renderer;
|
||||
|
||||
renderer = cogl_renderer_new ();
|
||||
|
||||
#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
|
||||
if (_kms_fd > -1)
|
||||
{
|
||||
cogl_renderer_set_winsys_id (renderer, COGL_WINSYS_ID_EGL_KMS);
|
||||
cogl_kms_renderer_set_kms_fd (renderer, _kms_fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
|
||||
{
|
||||
@ -103,8 +80,6 @@ clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
|
||||
gobject_class->dispose = clutter_backend_egl_native_dispose;
|
||||
|
||||
backend_class->stage_window_type = CLUTTER_TYPE_STAGE_EGL_NATIVE;
|
||||
|
||||
backend_class->get_renderer = clutter_backend_egl_native_get_renderer;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -189,26 +164,6 @@ clutter_egl_get_egl_display (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
|
||||
/**
|
||||
* clutter_egl_set_kms_fd:
|
||||
* @fd: The fd to talk to the kms driver with
|
||||
*
|
||||
* Sets the fd that Cogl should use to talk to the kms driver.
|
||||
* Setting this to a negative value effectively reverts this
|
||||
* call, making Cogl open the device itself.
|
||||
*
|
||||
* This can only be called before clutter_init() is called.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
void
|
||||
clutter_egl_set_kms_fd (int fd)
|
||||
{
|
||||
_kms_fd = fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* clutter_egl_freeze_master_clock:
|
||||
*
|
||||
|
@ -13,6 +13,7 @@ AM_CPPFLAGS = \
|
||||
-DCLUTTER_ENABLE_EXPERIMENTAL_API \
|
||||
-DCOGL_ENABLE_EXPERIMENTAL_API \
|
||||
-DCOGL_ENABLE_EXPERIMENTAL_2_0_API \
|
||||
-DCOGL_ENABLE_MUTTER_API \
|
||||
-DCLUTTER_DISABLE_DEPRECATION_WARNINGS \
|
||||
-DCOGL_DISABLE_DEPRECATION_WARNINGS \
|
||||
$(MUTTER_CFLAGS) \
|
||||
|
@ -30,6 +30,12 @@
|
||||
|
||||
G_DEFINE_TYPE (MetaRenderer, meta_renderer, G_TYPE_OBJECT)
|
||||
|
||||
CoglRenderer *
|
||||
meta_renderer_create_cogl_renderer (MetaRenderer *renderer)
|
||||
{
|
||||
return META_RENDERER_GET_CLASS (renderer)->create_cogl_renderer (renderer);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_renderer_init (MetaRenderer *renderer)
|
||||
{
|
||||
|
@ -27,12 +27,18 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "cogl/cogl.h"
|
||||
|
||||
#define META_TYPE_RENDERER (meta_renderer_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaRenderer, meta_renderer, META, RENDERER, GObject)
|
||||
|
||||
struct _MetaRendererClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
CoglRenderer * (* create_cogl_renderer) (MetaRenderer *renderer);
|
||||
};
|
||||
|
||||
CoglRenderer * meta_renderer_create_cogl_renderer (MetaRenderer *renderer);
|
||||
|
||||
#endif /* META_RENDERER_H */
|
||||
|
@ -26,9 +26,11 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "clutter/clutter.h"
|
||||
#include "clutter/egl/clutter-backend-eglnative.h"
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/meta-renderer.h"
|
||||
#include "backends/native/meta-clutter-backend-native.h"
|
||||
#include "clutter/clutter.h"
|
||||
#include "meta/meta-backend.h"
|
||||
|
||||
struct _MetaClutterBackendNative
|
||||
{
|
||||
@ -38,6 +40,16 @@ struct _MetaClutterBackendNative
|
||||
G_DEFINE_TYPE (MetaClutterBackendNative, meta_clutter_backend_native,
|
||||
CLUTTER_TYPE_BACKEND_EGL_NATIVE)
|
||||
|
||||
static CoglRenderer *
|
||||
meta_clutter_backend_native_get_renderer (ClutterBackend *clutter_backend,
|
||||
GError **error)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
|
||||
return meta_renderer_create_cogl_renderer (renderer);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_clutter_backend_native_init (MetaClutterBackendNative *clutter_backend_nativen)
|
||||
{
|
||||
@ -46,4 +58,7 @@ meta_clutter_backend_native_init (MetaClutterBackendNative *clutter_backend_nati
|
||||
static void
|
||||
meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass)
|
||||
{
|
||||
ClutterBackendClass *clutter_backend_class = CLUTTER_BACKEND_CLASS (klass);
|
||||
|
||||
clutter_backend_class->get_renderer = meta_clutter_backend_native_get_renderer;
|
||||
}
|
||||
|
@ -465,7 +465,6 @@ meta_launcher_new (GError **error)
|
||||
self->session_active = TRUE;
|
||||
self->kms_fd = kms_fd;
|
||||
|
||||
clutter_egl_set_kms_fd (kms_fd);
|
||||
clutter_evdev_set_device_callbacks (on_evdev_device_open,
|
||||
on_evdev_device_close,
|
||||
self);
|
||||
|
@ -52,6 +52,20 @@ struct _MetaRendererNative
|
||||
|
||||
G_DEFINE_TYPE (MetaRendererNative, meta_renderer_native, META_TYPE_RENDERER)
|
||||
|
||||
static CoglRenderer *
|
||||
meta_renderer_native_create_cogl_renderer (MetaRenderer *renderer)
|
||||
{
|
||||
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
||||
CoglRenderer *cogl_renderer;
|
||||
|
||||
cogl_renderer = cogl_renderer_new ();
|
||||
cogl_renderer_set_custom_winsys (cogl_renderer,
|
||||
_cogl_winsys_egl_kms_get_vtable);
|
||||
cogl_kms_renderer_set_kms_fd (cogl_renderer, renderer_native->kms_fd);
|
||||
|
||||
return cogl_renderer;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_renderer_native_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -99,10 +113,13 @@ static void
|
||||
meta_renderer_native_class_init (MetaRendererNativeClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
MetaRendererClass *renderer_class = META_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->get_property = meta_renderer_native_get_property;
|
||||
object_class->set_property = meta_renderer_native_set_property;
|
||||
|
||||
renderer_class->create_cogl_renderer = meta_renderer_native_create_cogl_renderer;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_KMS_FD,
|
||||
g_param_spec_int ("kms-fd",
|
||||
|
@ -26,8 +26,11 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/meta-renderer.h"
|
||||
#include "backends/x11/meta-clutter-backend-x11.h"
|
||||
#include "clutter/clutter.h"
|
||||
#include "meta/meta-backend.h"
|
||||
|
||||
struct _MetaClutterBackendX11
|
||||
{
|
||||
@ -37,6 +40,16 @@ struct _MetaClutterBackendX11
|
||||
G_DEFINE_TYPE (MetaClutterBackendX11, meta_clutter_backend_x11,
|
||||
CLUTTER_TYPE_BACKEND_X11)
|
||||
|
||||
static CoglRenderer *
|
||||
meta_clutter_backend_x11_get_renderer (ClutterBackend *clutter_backend,
|
||||
GError **error)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
|
||||
return meta_renderer_create_cogl_renderer (renderer);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_clutter_backend_x11_init (MetaClutterBackendX11 *clutter_backend_x11)
|
||||
{
|
||||
@ -45,4 +58,7 @@ meta_clutter_backend_x11_init (MetaClutterBackendX11 *clutter_backend_x11)
|
||||
static void
|
||||
meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
|
||||
{
|
||||
ClutterBackendClass *clutter_backend_class = CLUTTER_BACKEND_CLASS (klass);
|
||||
|
||||
clutter_backend_class->get_renderer = meta_clutter_backend_x11_get_renderer;
|
||||
}
|
||||
|
@ -26,7 +26,14 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "clutter/x11/clutter-x11.h"
|
||||
#include "cogl/cogl.h"
|
||||
#include "cogl/cogl-xlib.h"
|
||||
#include "cogl/winsys/cogl-winsys-glx-private.h"
|
||||
#include "cogl/winsys/cogl-winsys-egl-x11-private.h"
|
||||
#include "backends/meta-renderer.h"
|
||||
#include "backends/x11/meta-renderer-x11.h"
|
||||
#include "meta/util.h"
|
||||
|
||||
struct _MetaRendererX11
|
||||
{
|
||||
@ -35,6 +42,28 @@ struct _MetaRendererX11
|
||||
|
||||
G_DEFINE_TYPE (MetaRendererX11, meta_renderer_x11, META_TYPE_RENDERER)
|
||||
|
||||
static const CoglWinsysVtable *
|
||||
get_x11_cogl_winsys_vtable (void)
|
||||
{
|
||||
if (meta_is_wayland_compositor ())
|
||||
return _cogl_winsys_egl_xlib_get_vtable ();
|
||||
else
|
||||
return _cogl_winsys_glx_get_vtable ();
|
||||
}
|
||||
|
||||
static CoglRenderer *
|
||||
meta_renderer_x11_create_cogl_renderer (MetaRenderer *renderer)
|
||||
{
|
||||
CoglRenderer *cogl_renderer;
|
||||
Display *xdisplay = clutter_x11_get_default_display ();
|
||||
|
||||
cogl_renderer = cogl_renderer_new ();
|
||||
cogl_renderer_set_custom_winsys (cogl_renderer, get_x11_cogl_winsys_vtable);
|
||||
cogl_xlib_renderer_set_foreign_display (cogl_renderer, xdisplay);
|
||||
|
||||
return cogl_renderer;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_renderer_x11_init (MetaRendererX11 *renderer_x11)
|
||||
{
|
||||
@ -43,4 +72,7 @@ meta_renderer_x11_init (MetaRendererX11 *renderer_x11)
|
||||
static void
|
||||
meta_renderer_x11_class_init (MetaRendererX11Class *klass)
|
||||
{
|
||||
MetaRendererClass *renderer_class = META_RENDERER_CLASS (klass);
|
||||
|
||||
renderer_class->create_cogl_renderer = meta_renderer_x11_create_cogl_renderer;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user