Commit a09bbffd authored by Emmanuele Bassi's avatar Emmanuele Bassi

Implement multi-backend support

The Clutter backend split is opaque enough that should allow us to just
build all possible backends inside the same shared object, and select
the wanted backend at initialization time.

This requires some work in the build system, as well as the
initialization code, to remove duplicate functions that might cause
conflicts at build and link time. We also need to defer all the checks
of the internal state of the platform-specific API to run-time type
checks.
parent 9c102b7c
......@@ -14,8 +14,6 @@ lib_LTLIBRARIES =
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter \
-I$(top_srcdir)/clutter/$(CLUTTER_WINSYS) \
-I$(top_srcdir)/clutter/$(CLUTTER_WINSYS_BASE) \
-I$(top_srcdir)/clutter/deprecated \
-I$(top_srcdir)/clutter/cally \
-I$(top_builddir) \
......@@ -301,6 +299,13 @@ EXTRA_DIST += clutter-keysyms-update.pl
pc_files += clutter-$(CLUTTER_API_VERSION).pc
# in order to be compatible with Clutter < 1.10, when we shipped a single
# shared library whose name was determined by the single backend it
# supported, we need to install symbolic links so that existing applications
# using Clutter won't break in the Brave New World of multi-backend support
# in the same shared object.
compat_libs =
# backends source listings
#
# backend_source_c := source code
......@@ -370,6 +375,11 @@ x11_introspection = $(x11_source_c) $(x11_source_h)
clutterx11_includedir = $(clutter_includedir)/x11
clutterx11_include_HEADERS = $(x11_source_h)
clutter-x11-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-x11-$(CLUTTER_API_VERSION).pc
endif # SUPPORT_X11
# Shared cogl backend files
......@@ -387,20 +397,31 @@ cogl_source_h_priv = \
cogl_source_c_priv =
if USE_COGL
backend_source_h += $(cogl_source_h)
backend_source_c += $(cogl_source_c)
backend_source_h_priv += $(cogl_source_h_priv)
backend_source_c_priv += $(cogl_source_c_priv)
# pkg-config file for the cogl meta-backend
clutter-cogl-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-cogl-$(CLUTTER_API_VERSION).pc
endif
if SUPPORT_X11
# For compatability with the old GLX backend
# For compatibility with the old GLX backend
#
# Note: there wasn't actually anything GLX specific so we can add
# the compatability if clutter supports x11
backend_source_c += $(srcdir)/x11/clutter-glx-texture-pixmap.c
# the compatibility if clutter supports x11
glx_source_c = $(srcdir)/x11/clutter-glx-texture-pixmap.c
glx_source_h = $(srcdir)/x11/clutter-glx-texture-pixmap.h \
$(srcdir)/x11/clutter-glx.h
if SUPPORT_X11
backend_source_h += $(glx_source_h)
backend_source_c += $(glx_source_c)
clutterglx_includedir = $(clutter_includedir)/glx
clutterglx_include_HEADERS = $(glx_source_h)
......@@ -408,13 +429,9 @@ clutter-glx-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-glx-$(CLUTTER_API_VERSION).pc
endif
if SUPPORT_GLX
backend_source_h += $(cogl_source_h) $(glx_source_h)
backend_source_c += $(cogl_source_c) $(glx_source_c)
backend_source_h_priv += $(cogl_source_h_priv)
endif # SUPPORT_GLX
compat_libs += libclutter-glx-$(CLUTTER_API_VERSION).so.0
endif
# GDK backend rules
gdk_source_c = \
......@@ -439,12 +456,19 @@ gdk_source_h_priv = \
$(NULL)
if SUPPORT_GDK
backend_source_h += $(cogl_source_h) $(gdk_source_h)
backend_source_c += $(cogl_source_c) $(gdk_source_c)
backend_source_h_priv += $(cogl_source_h_priv) $(gdk_source_h_priv)
backend_source_h += $(gdk_source_h)
backend_source_c += $(gdk_source_c)
backend_source_h_priv += $(gdk_source_h_priv)
cluttergdk_includedir = $(clutter_includedir)/gdk
cluttergdk_include_HEADERS = $(gdk_source_h)
clutter-gdk-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-gdk-$(CLUTTER_API_VERSION).pc
gdk_introspection = $(gdk_source_c) $(gdk_source_h)
endif # SUPPORT_GDK
# Windows backend rules
......@@ -486,6 +510,11 @@ backend_source_h_priv += $(win32_source_h_priv)
clutterwin_includedir = $(clutter_includedir)/win32
clutterwin_include_HEADERS = $(win32_source_h)
clutter-win32-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-win32-$(CLUTTER_API_VERSION).pc
endif # SUPPORT_WIN32
EXTRA_DIST += \
......@@ -520,23 +549,32 @@ if USE_TSLIB
backend_source_c_priv += $(egl_tslib_c)
endif # SUPPORT_TSLIB
if SUPPORT_EVDEV
if USE_EVDEV
backend_source_c_priv += $(evdev_c_priv)
backend_source_h_priv += $(evdev_h_priv)
endif # SUPPORT_EVDEV
if SUPPORT_CEX100
backend_source_h += $(cex_h)
clutter-cex100-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-cex100-$(CLUTTER_API_VERSION).pc
compat_libs += libclutter-cex100-$(CLUTTER_API_VERSION).so.0
endif # SUPPORT_CEX100
if SUPPORT_EGL
backend_source_h += $(cogl_source_h) $(egl_source_h)
backend_source_c += $(cogl_source_c)
backend_source_h_priv += $(cogl_source_h_priv)
backend_source_c_priv += $(cogl_source_c_priv)
backend_source_h += $(egl_source_h)
clutteregl_includedir = $(clutter_includedir)/egl
clutteregl_include_HEADERS = $(egl_source_h)
clutter-egl-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-egl-$(CLUTTER_API_VERSION).pc
endif # SUPPORT_EGL
# OSX backend rules
......@@ -572,6 +610,11 @@ backend_source_c_priv += $(osx_source_c_priv)
clutterosx_includedir = $(clutter_includedir)/osx
clutterosx_include_HEADERS = $(osx_source_h)
clutter-osx-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-osx-$(CLUTTER_API_VERSION).pc
endif # SUPPORT_OSX
# Wayland backend rules
......@@ -593,6 +636,13 @@ backend_source_c += \
clutterwayland_includedir = $(clutter_includedir)/wayland
clutterwayland_include_HEADERS = $(wayland_source_h)
clutter-wayland-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-wayland-$(CLUTTER_API_VERSION).pc
compat_libs += libclutter-wayland-$(CLUTTER_API_VERSION).so.0
endif # SUPPORT_WAYLAND
# cally
......@@ -648,12 +698,6 @@ glib_enum_c = clutter-enum-types.c
glib_enum_headers = $(source_h) $(backend_source_h)
include $(top_srcdir)/build/autotools/Makefile.am.enums
# backend-specific pkg-config file
clutter-$(CLUTTER_WINSYS)-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
$(QUIET_GEN)cp -f $< $(@F)
pc_files += clutter-$(CLUTTER_WINSYS)-$(CLUTTER_API_VERSION).pc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pc_files)
DISTCLEANFILES += $(pc_files)
......@@ -666,17 +710,17 @@ nodist_clutter_include_HEADERS = \
clutter_deprecated_HEADERS = $(deprecated_h)
lib_LTLIBRARIES += libclutter-@CLUTTER_SONAME_INFIX@-@CLUTTER_API_VERSION@.la
lib_LTLIBRARIES += libclutter-@CLUTTER_API_VERSION@.la
libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_LIBADD = \
libclutter_@CLUTTER_API_VERSION@_la_LIBADD = \
-lm \
$(CLUTTER_LIBS) \
$(CLUTTER_PROFILE_LIBS)
libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_DEPENDENCIES = \
libclutter_@CLUTTER_API_VERSION@_la_DEPENDENCIES = \
$(win32_resources)
libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_SOURCES = \
libclutter_@CLUTTER_API_VERSION@_la_SOURCES = \
$(backend_source_c) \
$(backend_source_h) \
$(backend_source_c_priv) \
......@@ -694,12 +738,12 @@ libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_SOURCES = \
$(cally_sources_private) \
$(NULL)
nodist_libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_SOURCES = \
nodist_libclutter_@CLUTTER_API_VERSION@_la_SOURCES = \
$(backend_source_built) \
$(built_source_c) \
$(built_source_h)
libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_LDFLAGS = \
libclutter_@CLUTTER_API_VERSION@_la_LDFLAGS = \
$(CLUTTER_LINK_FLAGS) \
$(CLUTTER_LT_LDFLAGS) \
$(GCOV_LDFLAGS) \
......@@ -709,15 +753,21 @@ libclutter_@CLUTTER_SONAME_INFIX@_@CLUTTER_API_VERSION@_la_LDFLAGS = \
$(win32_resources_ldflag) \
$(NULL)
install-exec-local:
for lib in "$(compat_libs)"; do \
rm -f $(DESTDIR)$(libdir)/$$lib ; \
ln -s libclutter-$(CLUTTER_API_VERSION).so.0.$(CLUTTER_LT_CURRENT).$(CLUTTER_LT_REVISION) $(DESTDIR)$(libdir)/$$lib ; \
done
# gobject-introspection rules
-include $(INTROSPECTION_MAKEFILE)
if HAVE_INTROSPECTION
Clutter-@CLUTTER_API_VERSION@.gir: libclutter-@CLUTTER_SONAME_INFIX@-@CLUTTER_API_VERSION@.la Makefile
Clutter-@CLUTTER_API_VERSION@.gir: libclutter-@CLUTTER_API_VERSION@.la Makefile
Clutter_@CLUTTER_API_VERSION_AM@_gir_NAMESPACE = Clutter
Clutter_@CLUTTER_API_VERSION_AM@_gir_VERSION = @CLUTTER_API_VERSION@
Clutter_@CLUTTER_API_VERSION_AM@_gir_LIBS = libclutter-@CLUTTER_SONAME_INFIX@-@CLUTTER_API_VERSION@.la
Clutter_@CLUTTER_API_VERSION_AM@_gir_LIBS = libclutter-@CLUTTER_API_VERSION@.la
Clutter_@CLUTTER_API_VERSION_AM@_gir_FILES = \
$(clutter_include_HEADERS) \
$(clutter_deprecated_HEADERS) \
......@@ -738,7 +788,7 @@ Cally-@CLUTTER_API_VERSION@.gir: Makefile Clutter-@CLUTTER_API_VERSION@.gir
Cally_@CLUTTER_API_VERSION_AM@_gir_NAMESPACE = Cally
Cally_@CLUTTER_API_VERSION_AM@_gir_VERSION = @CLUTTER_API_VERSION@
Cally_@CLUTTER_API_VERSION_AM@_gir_LIBS = libclutter-@CLUTTER_SONAME_INFIX@-@CLUTTER_API_VERSION@.la
Cally_@CLUTTER_API_VERSION_AM@_gir_LIBS = libclutter-@CLUTTER_API_VERSION@.la
Cally_@CLUTTER_API_VERSION_AM@_gir_FILES = $(cally_sources_h) $(cally_sources_c)
Cally_@CLUTTER_API_VERSION_AM@_gir_CFLAGS = $(INCLUDES) $(CLUTTER_CFLAGS) $(AM_CPPFLAGS) -UCLUTTER_DISABLE_DEPRECATED
Cally_@CLUTTER_API_VERSION_AM@_gir_SCANNERFLAGS = \
......@@ -760,13 +810,30 @@ ClutterX11_@CLUTTER_API_VERSION_AM@_gir_SCANNERFLAGS = \
--pkg-export=clutter-x11-@CLUTTER_API_VERSION@ \
--include-uninstalled=$(top_builddir)/clutter/Clutter-@CLUTTER_API_VERSION@.gir
ClutterX11_@CLUTTER_API_VERSION_AM@_gir_INCLUDES = xlib-2.0
ClutterX11_@CLUTTER_API_VERSION_AM@_gir_LIBS = libclutter-@CLUTTER_SONAME_INFIX@-@CLUTTER_API_VERSION@.la
ClutterX11_@CLUTTER_API_VERSION_AM@_gir_LIBS = libclutter-@CLUTTER_API_VERSION@.la
ClutterX11_@CLUTTER_API_VERSION_AM@_gir_FILES = $(x11_introspection)
ClutterX11_@CLUTTER_API_VERSION_AM@_gir_CFLAGS = $(INCLUDES) $(CLUTTER_CFLAGS) $(AM_CPPFLAGS) -UCLUTTER_DISABLE_DEPRECATED
INTROSPECTION_GIRS += ClutterX11-@CLUTTER_API_VERSION@.gir
endif # SUPPORT_X11
if SUPPORT_GDK
ClutterGdk-@CLUTTER_API_VERSION@.gir: Makefile Clutter-@CLUTTER_API_VERSION@.gir
ClutterGdk_@CLUTTER_API_VERSION_AM@_gir_SCANNERFLAGS = \
--identifier-prefix=ClutterGdk \
--symbol-prefix=clutter_gdk \
--c-include='clutter/gdk/clutter-gdk.h' \
--pkg-export=clutter-gdk-@CLUTTER_API_VERSION@ \
--include-uninstalled=$(top_builddir)/clutter/Clutter-@CLUTTER_API_VERSION@.gir
ClutterGdk_@CLUTTER_API_VERSION_AM@_gir_INCLUDES = Gdk-3.0
ClutterGdk_@CLUTTER_API_VERSION_AM@_gir_LIBS = libclutter-@CLUTTER_API_VERSION@.la
ClutterGdk_@CLUTTER_API_VERSION_AM@_gir_FILES = $(gdk_introspection)
ClutterGdk_@CLUTTER_API_VERSION_AM@_gir_CFLAGS = $(INCLUDES) $(CLUTTER_CFLAGS) $(AM_CPPFLAGS) -UCLUTTER_DISABLE_DEPRECATED
INTROSPECTION_GIRS += ClutterGdk-@CLUTTER_API_VERSION@.gir
endif # SUPPORT_GDK
# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
# install anything - we need to install inside our prefix.
girdir = $(datadir)/gir-1.0
......
......@@ -87,9 +87,6 @@ struct _ClutterBackendClass
void (* settings_changed) (ClutterBackend *backend);
};
/* vfuncs implemented by backend */
GType _clutter_backend_impl_get_type (void);
void _clutter_backend_redraw (ClutterBackend *backend,
ClutterStage *stage);
ClutterStageWindow *_clutter_backend_create_stage (ClutterBackend *backend,
......
......@@ -100,6 +100,7 @@
#include "clutter-actor.h"
#include "clutter-backend-private.h"
#include "clutter-config.h"
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-event.h"
......@@ -114,6 +115,25 @@
#include "clutter-stage-private.h"
#include "clutter-version.h" /* For flavour define */
#ifdef CLUTTER_WINDOWING_OSX
#include "osx/clutter-backend-osx.h"
#endif
#ifdef CLUTTER_WINDOWING_WIN32
#include "win32/clutter-backend-win32.h"
#endif
#ifdef CLUTTER_WINDOWING_GDK
#include "gdk/clutter-backend-gdk.h"
#endif
#ifdef CLUTTER_WINDOWING_X11
#include "x11/clutter-backend-x11.h"
#endif
#ifdef CLUTTER_WINDOWING_EGL
#include "egl/clutter-backend-eglnative.h"
#endif
#ifdef CLUTTER_WINDOWING_WAYLAND
#include "wayland/clutter-backend-wayland.h"
#endif
#include <cogl/cogl.h>
#include <cogl-pango/cogl-pango.h>
......@@ -1299,11 +1319,46 @@ clutter_context_get_default_unlocked (void)
if (G_UNLIKELY (ClutterCntx == NULL))
{
ClutterMainContext *ctx;
const char *backend;
ClutterCntx = ctx = g_new0 (ClutterMainContext, 1);
/* create the default backend */
ctx->backend = g_object_new (_clutter_backend_impl_get_type (), NULL);
backend = g_getenv ("CLUTTER_BACKEND");
#ifdef CLUTTER_WINDOWING_OSX
if (backend == NULL || strcmp (backend, "osx") == 0)
ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_OSX, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_WIN32
if (backend == NULL || strcmp (backend, "win32") == 0)
ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_WIN32, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_WAYLAND
if (backend == NULL || strcmp (backend, "wayland") == 0)
ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_WAYLAND, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_EGL
if (backend == NULL || strcmp (backend, "eglnative") == 0)
ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_EGLNATIVE, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_X11
if (backend == NULL || strcmp (backend, "x11") == 0)
ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_X11, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_GDK
if (backend == NULL || strcmp (backend, "gdk") == 0)
ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_GDK, NULL);
else
#endif
if (backend != NULL)
g_error ("Unsupported Clutter backend: '%s'", backend);
else
g_error ("No default Clutter backend found.");
ctx->is_initialized = FALSE;
ctx->motion_events_per_actor = TRUE;
......@@ -1320,6 +1375,10 @@ clutter_context_get_default_unlocked (void)
#endif
ctx->last_repaint_id = 1;
CLUTTER_NOTE (BACKEND, "Backend type: '%s' (requested: '%s')",
G_OBJECT_TYPE_NAME (ctx->backend),
backend != NULL ? backend : "<default>");
}
return ClutterCntx;
......
......@@ -103,6 +103,12 @@ G_BEGIN_DECLS
* GL Windowing system used
*
* Since: 0.4
*
* Deprecated: 1.10: The macro evaluates to "deprecated" as Clutter can be
* compiled with multiple windowing system backends. Use the various
* CLUTTER_WINDOWING_* macros to detect the windowing system that Clutter
* is being compiled against, and the type check macros for the
* #ClutterBackend for a run-time check.
*/
#define CLUTTER_FLAVOUR "@CLUTTER_FLAVOUR@"
......@@ -113,6 +119,9 @@ G_BEGIN_DECLS
* "gles" currently
*
* Since: 0.4
*
* Deprecated: 1.10: The macro evaluates to "deprecated" as Cogl can be
* compiled against multiple GL implementations.
*/
#define CLUTTER_COGL "@CLUTTER_COGL@"
......@@ -122,6 +131,11 @@ G_BEGIN_DECLS
* The default GObject type for the Clutter stage.
*
* Since: 0.8
*
* Deprecated: 1.10: The macro evaluates to "deprecated" as Clutter can
* be compiled against multiple windowing systems. You can use the
* CLUTTER_WINDOWING_* macros for compile-time checks, and the type
* check macros for run-time checks.
*/
#define CLUTTER_STAGE_TYPE @CLUTTER_STAGE_TYPE@
......
......@@ -4,18 +4,19 @@ libdir=@libdir@
includedir=@includedir@
apiversion=@CLUTTER_API_VERSION@
winsys=@CLUTTER_WINSYS@
soname_infix=@CLUTTER_SONAME_INFIX@
cogl_driver=@COGL_DRIVER@
requires=@CLUTTER_REQUIRES@
backends=@CLUTTER_BACKENDS@
# only kept for backward compatibility
soname_infix=@CLUTTER_SONAME_INFIX@
winsys=@CLUTTER_WINSYS@
cogl=@COGL_DRIVER@
cogl_driver=@COGL_DRIVER@
backend=@CLUTTER_WINSYS@
Name: Clutter
Description: Clutter Core Library (${winsys}/${cogl_driver} backend)
Description: Clutter Core Library
Version: @VERSION@
Libs: -L${libdir} -lclutter-${soname_infix}-${apiversion}
Libs: -L${libdir} -lclutter-${apiversion}
Cflags: -I${includedir}/clutter-${apiversion}
Requires: ${requires}
......@@ -46,7 +46,7 @@
#include "clutter-util.h"
#ifdef CLUTTER_WINDOWING_X11
/* needed for a small check in redraw() */
/* FIXME: needed for a small check in redraw(), needs to be moved */
#include "x11/clutter-stage-x11.h"
#endif
......@@ -353,24 +353,27 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
CLUTTER_TIMER_START (_clutter_uprof_context, painting_timer);
may_use_clipped_redraw = FALSE;
if (G_LIKELY (backend_cogl->can_blit_sub_buffer) &&
/* NB: a zero width redraw clip == full stage redraw */
stage_cogl->bounding_redraw_clip.width != 0 &&
/* some drivers struggle to get going and produce some junk
* frames when starting up... */
G_LIKELY (stage_cogl->frame_count > 3)
G_LIKELY (stage_cogl->frame_count > 3))
{
#if defined(CLUTTER_WINDOWING_X11)
/* FIXME - move this to a StageWindow vfunc */
/* While resizing a window clipped redraws are disabled to avoid
* artefacts. See clutter-event-x11.c:event_translate for a
* detailed explanation */
&& G_LIKELY (CLUTTER_STAGE_X11 (stage_cogl)->clipped_redraws_cool_off == 0)
if (CLUTTER_IS_STAGE_X11 (stage_cogl) &&
(CLUTTER_STAGE_X11 (stage_cogl)->clipped_redraws_cool_off == 0))
{
may_use_clipped_redraw = TRUE;
}
#endif
)
{
may_use_clipped_redraw = TRUE;
}
else
may_use_clipped_redraw = FALSE;
if (may_use_clipped_redraw &&
G_LIKELY (!(clutter_paint_debug_flags &
......
......@@ -38,6 +38,7 @@
#include <errno.h>
#include "clutter-backend-eglnative.h"
/* This is a Cogl based backend */
#include "cogl/clutter-stage-cogl.h"
......@@ -53,18 +54,18 @@
#ifdef COGL_HAS_EGL_SUPPORT
#include "clutter-egl.h"
#endif
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
#ifdef CLUTTER_EGL_BACKEND_CEX100
#include "clutter-cex100.h"
#endif
static gchar *clutter_vblank = NULL;
/* FIXME: We should have CLUTTER_ define for this... */
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
#ifdef CLUTTER_EGL_BACKEND_CEX100
static gdl_plane_id_t gdl_plane = GDL_PLANE_ID_UPP_C;
static guint gdl_n_buffers = CLUTTER_CEX100_TRIPLE_BUFFERING;
#endif
static gboolean gdl_plane_set = FALSE;
static gboolean gdl_n_buffers_set = FALSE;
G_DEFINE_TYPE (ClutterBackendEglNative, _clutter_backend_egl_native, CLUTTER_TYPE_BACKEND_COGL);
static ClutterDeviceManager *
......@@ -91,6 +92,7 @@ clutter_backend_egl_native_init_events (ClutterBackend *backend)
#ifdef HAVE_TSLIB
_clutter_events_tslib_init (CLUTTER_BACKEND_EGL (backend));
#endif
#ifdef HAVE_EVDEV
_clutter_events_evdev_init (CLUTTER_BACKEND (backend));
#endif
......@@ -157,9 +159,8 @@ clutter_backend_egl_native_create_context (ClutterBackend *backend,
swap_chain = cogl_swap_chain_new ();
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
cogl_swap_chain_set_length (swap_chain, gdl_n_buffers);
#endif
if (gdl_n_buffers_set)
cogl_swap_chain_set_length (swap_chain, gdl_n_buffers);
onscreen_template = cogl_onscreen_template_new (swap_chain);
cogl_object_unref (swap_chain);
......@@ -176,9 +177,10 @@ clutter_backend_egl_native_create_context (ClutterBackend *backend,
backend->cogl_display = cogl_display_new (backend->cogl_renderer,
onscreen_template);
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
cogl_gdl_display_set_plane (backend->cogl_display, gdl_plane);
#endif
#ifdef CLUTTER_EGL_BACKEND_CEX100
if (gdl_plane_set)
cogl_gdl_display_set_plane (backend->cogl_display, gdl_plane);
#endif /* CLUTTER_EGL_BACKEND_CEX100 */
cogl_object_unref (backend->cogl_renderer);
cogl_object_unref (onscreen_template);
......@@ -235,28 +237,41 @@ _clutter_backend_egl_native_init (ClutterBackendEglNative *backend_egl_native)
#endif
}
GType
_clutter_backend_impl_get_type (void)
{
return _clutter_backend_egl_native_get_type ();
}
/* FIXME we should have a CLUTTER_ define for this */
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
/**
* clutter_cex100_set_plane:
* @plane: FIXME
*
* FIXME
*
* Since:
*/
void
clutter_cex100_set_plane (gdl_plane_id_t plane)
{
#ifdef CLUTTER_EGL_BACKEND_CEX100
g_return_if_fail (plane >= GDL_PLANE_ID_UPP_A && plane <= GDL_PLANE_ID_UPP_E);
gdl_plane = plane;
gdl_plane_set = TRUE;
#endif
}
/**
* clutter_cex100_set_plane:
* @mode: FIXME
*
* FIXME
*
* Since:
*/
void
clutter_cex100_set_buffering_mode (ClutterCex100BufferingMode mode)
{
#ifdef CLUTTER_EGL_BACKEND_CEX100
g_return_if_fail (mode == CLUTTER_CEX100_DOUBLE_BUFFERING ||
mode == CLUTTER_CEX100_TRIPLE_BUFFERING);
gdl_n_buffers = mode;
}
gdl_n_buffers_set = TRUE;
#endif
}
......@@ -410,9 +410,15 @@ clutter_gdk_get_default_display (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
if (!backend || !CLUTTER_IS_BACKEND_GDK (backend))
if (backend == NULL)
{
g_critical ("GDK backend has not been initialised");
g_critical ("The Clutter backend has not been initialised");
return NULL;
}
if (!CLUTTER_IS_BACKEND_GDK (backend))
{
g_critical ("The Clutter backend is not a GDK backend");
return NULL;
}
......@@ -446,9 +452,3 @@ clutter_gdk_set_display (GdkDisplay *display)
_foreign_dpy = g_object_ref (display);
}
GType
_clutter_backend_impl_get_type (void)
{
return _clutter_backend_gdk_get_type ();
}
......@@ -41,14 +41,15 @@
G_BEGIN_DECLS
void clutter_gdk_set_display (GdkDisplay *display);
GdkWindow *clutter_gdk_get_stage_window (ClutterStage *stage);
gboolean clutter_gdk_set_stage_foreign (ClutterStage *stage,
GdkWindow *window);
void clutter_gdk_set_display (GdkDisplay *display);
GdkFilterReturn clutter_gdk_handle_event (GdkEvent *event);
GdkWindow * clutter_gdk_get_stage_window (ClutterStage *stage);
gboolean clutter_gdk_set_stage_foreign (ClutterStage *stage,
GdkWindow *window);
ClutterStage *clutter_gdk_get_stage_from_window (GdkWindow *window);
GdkFilterReturn clutter_gdk_handle_event (GdkEvent *event);
ClutterStage * clutter_gdk_get_stage_from_window (GdkWindow *window);
G_END_DECLS
......
......@@ -468,7 +468,7 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
*
* Since: 0.4
*/
GdkWindow*
GdkWindow *
clutter_gdk_get_stage_window (ClutterStage *stage)
{
ClutterStageWindow *impl;
......@@ -476,7 +476,11 @@ clutter_gdk_get_stage_window (ClutterStage *stage)
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), None);
impl = _clutter_stage_get_window (stage);
g_assert (CLUTTER_IS_STAGE_GDK (impl));
if (!CLUTTER_IS_STAGE_GDK (impl))
{
g_critical ("The Clutter backend is not a GDK backend");
return NULL;
}
return CLUTTER_STAGE_GDK (impl)->window;
}
......@@ -552,6 +556,12 @@ clutter_gdk_set_stage_foreign (ClutterStage *stage,
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
impl = _clutter_stage_get_window (stage);
if (!CLUTTER_IS_STAGE_GDK (impl))
{
g_critical ("The Clutter backend is not a GDK backend");
return FALSE;
}
stage_gdk = CLUTTER_STAGE_GDK (impl);
if (g_object_get_data (G_OBJECT (window), "clutter-stage-window") != NULL)
......
......@@ -253,9 +253,3 @@ clutter_backend_osx_class_init (ClutterBackendOSXClass *klass)
backend_class->init_events = clutter_backend_osx_init_events;
backend_class->get_device_manager = clutter_backend_osx_get_device_manager;
}
GType
_clutter_backend_impl_get_type (void)
{
return clutter_backend_osx_get_type ();
}
......@@ -650,12 +650,6 @@ _clutter_backend_wayland_init (ClutterBackendWayland *backend_wayland)
backend_wayland->drm_fd = -1;
}
GType
_clutter_backend_impl_get_type (void)
{
return _clutter_backend_wayland_get_type ();
}
EGLDisplay
clutter_wayland_get_egl_display (void)
{
......
......@@ -376,12 +376,6 @@ clutter_backend_win32_init (ClutterBackendWin32 *backend_win32)
timeBeginPeriod (1);
}
GType
_clutter_backend_impl_get_type (void)
{
return clutter_backend_win32_get_type ();
}
BOOL WINAPI
DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
{
......
......@@ -733,9 +733,13 @@ clutter_win32_set_stage_foreign (ClutterStage *stage,
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
g_return_val_if_fail (hwnd != NULL, FALSE);
actor = CLUTTER_ACTOR (stage);
impl = _clutter_stage_get_window (stage);
if (!CLUTTER_IS_STAGE_WIN32 (impl))
{
g_critical ("The Clutter backend is not a Windows backend");
return FALSE;
}