[clutter] unify egl and glx backends as "cogl" backend
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] unify egl and glx backends as "cogl" backend
- Date: Tue, 14 Jun 2011 19:44:11 +0000 (UTC)
commit 2d8083bab8b9ec0b353d08d66265bd0ae38d6822
Author: Robert Bragg <robert linux intel com>
Date: Mon May 9 00:27:10 2011 +0100
unify egl and glx backends as "cogl" backend
Since GLX and EGL are abstracted by Cogl the two backends are both
implementing everything using the Cogl API and they are almost
identical.
This updates the egl backend to support everything that the glx backend
supports. Now that EGL and GLX are abstracted by Cogl, the plan is that
we will squash the clutter-egl/glx backends into one. Since the EGL
backend in clutter can conditionally not depend on X11 we will use the
EGL backend as the starting point of our common backend.
https://bugzilla.gnome.org/show_bug.cgi?id=649826
clutter/Makefile.am | 82 ++--
.../clutter-backend-cogl.c} | 170 ++++---
.../clutter-backend-cogl.h} | 36 +-
clutter/{egl => cogl}/clutter-cex100.h.in | 0
clutter/{egl => cogl}/clutter-egl.h | 0
clutter/{egl => cogl}/clutter-event-tslib.c | 2 +-
clutter/{glx => cogl}/clutter-glx-texture-pixmap.c | 0
clutter/{glx => cogl}/clutter-glx-texture-pixmap.h | 0
.../clutter-stage-cogl.c} | 328 ++++++++-----
clutter/cogl/clutter-stage-cogl.h | 78 +++
clutter/egl/clutter-egl-headers.h | 46 --
clutter/egl/clutter-stage-egl.h | 75 ---
clutter/glx/clutter-backend-glx.c | 380 --------------
clutter/glx/clutter-backend-glx.h | 75 ---
clutter/glx/clutter-glx.h | 46 --
clutter/glx/clutter-stage-glx.c | 541 --------------------
clutter/glx/clutter-stage-glx.h | 77 ---
configure.ac | 12 +-
18 files changed, 443 insertions(+), 1505 deletions(-)
---
diff --git a/clutter/Makefile.am b/clutter/Makefile.am
index 1ab56f2..071b786 100644
--- a/clutter/Makefile.am
+++ b/clutter/Makefile.am
@@ -353,32 +353,37 @@ clutterx11_includedir = $(clutter_includedir)/x11
clutterx11_include_HEADERS = $(x11_source_h)
endif # SUPPORT_X11
-# GLX backend rules
-glx_source_c = \
- $(srcdir)/glx/clutter-backend-glx.c \
- $(srcdir)/glx/clutter-glx-texture-pixmap.c \
- $(srcdir)/glx/clutter-stage-glx.c \
- $(NULL)
+# Shared cogl backend files
+cogl_source_h =
-glx_source_h = \
- $(srcdir)/glx/clutter-glx-texture-pixmap.h \
- $(srcdir)/glx/clutter-glx.h \
+cogl_source_c = \
+ $(srcdir)/cogl/clutter-backend-cogl.c \
+ $(srcdir)/cogl/clutter-stage-cogl.c \
$(NULL)
-glx_source_h_priv = \
- $(srcdir)/glx/clutter-backend-glx.h \
- $(srcdir)/glx/clutter-stage-glx.h \
+cogl_source_h_priv = \
+ $(srcdir)/cogl/clutter-backend-cogl.h \
+ $(srcdir)/cogl/clutter-stage-cogl.h \
$(NULL)
-if SUPPORT_GLX
-backend_source_h += $(glx_source_h)
-backend_source_c += $(glx_source_c)
-backend_source_h_priv += $(glx_source_h_priv)
+cogl_source_c_priv =
-# XXX - this is another hack; we installed glx headers under includedir/glx
-# instead of using the same directory.
+if SUPPORT_X11
+# For compatability with the old GLX backend
+#
+# Note: there wasn't actually anything GLX specific so we can add
+# the compatability if clutter supports x11
+glx_source_c = $(srcdir)/cogl/clutter-glx-texture-pixmap.c
+glx_source_h = $(srcdir)/cogl/clutter-glx-texture-pixmap.h \
+ $(srcdir)/cogl/clutter-glx.h
clutterglx_includedir = $(clutter_includedir)/glx
clutterglx_include_HEADERS = $(glx_source_h)
+endif
+
+if SUPPORT_GLX
+backend_source_h += $(cogl_source_h)
+backend_source_c += $(cogl_source_c)
+backend_source_h_priv += $(cogl_source_h_priv)
endif # SUPPORT_GLX
# Windows backend rules
@@ -429,22 +434,10 @@ EXTRA_DIST += \
# EGL backend rules
egl_source_h = \
- $(srcdir)/egl/clutter-egl-headers.h \
- $(srcdir)/egl/clutter-egl.h \
- $(NULL)
-
-egl_source_c = \
- $(srcdir)/egl/clutter-backend-egl.c \
- $(srcdir)/egl/clutter-stage-egl.c \
- $(NULL)
-
-egl_source_h_priv = \
- $(srcdir)/egl/clutter-backend-egl.h \
- $(srcdir)/egl/clutter-stage-egl.h \
+ $(srcdir)/cogl/clutter-egl-headers.h \
+ $(srcdir)/cogl/clutter-egl.h \
$(NULL)
-egl_source_c_priv =
-
egl_tslib_c = $(srcdir)/egl/clutter-event-tslib.c
evdev_c_priv = \
@@ -458,29 +451,28 @@ evdev_h_priv = \
$(srcdir)/evdev/clutter-input-device-evdev.h \
$(NULL)
-egl_cex_h = egl/clutter-cex100.h
-BUILT_SOURCES += egl/clutter-cex100.h
-EXTRA_DIST += $(srcdir)/egl/clutter-cex100.h.in
-
-if SUPPORT_EGL
+cex_h = cogl/clutter-cex100.h
+BUILT_SOURCES += $(cex_h)
+EXTRA_DIST += $(srcdir)/$(cex_h).in
if USE_TSLIB
-egl_source_c_priv += $(egl_tslib_c)
+backend_source_c_priv += $(egl_tslib_c)
endif # SUPPORT_TSLIB
if SUPPORT_EVDEV
-egl_source_c_priv += $(evdev_c_priv)
-egl_source_h_priv += $(evdev_h_priv)
+backend_source_c_priv += $(evdev_c_priv)
+backend_source_h_priv += $(evdev_h_priv)
endif # SUPPORT_EVDEV
if SUPPORT_CEX100
-egl_source_h += $(egl_cex_h)
+backend_source_h += $(cex_h)
endif # SUPPORT_CEX100
-backend_source_h += $(egl_source_h)
-backend_source_c += $(egl_source_c)
-backend_source_h_priv += $(egl_source_h_priv)
-backend_source_c_priv += $(egl_source_c_priv)
+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)
clutteregl_includedir = $(clutter_includedir)/egl
clutteregl_include_HEADERS = $(egl_source_h)
diff --git a/clutter/egl/clutter-backend-egl.c b/clutter/cogl/clutter-backend-cogl.c
similarity index 68%
rename from clutter/egl/clutter-backend-egl.c
rename to clutter/cogl/clutter-backend-cogl.c
index 601b4bf..0b2d21e 100644
--- a/clutter/egl/clutter-backend-egl.c
+++ b/clutter/cogl/clutter-backend-cogl.c
@@ -3,7 +3,7 @@
*
* An OpenGL based 'interactive canvas' library.
*
- * Copyright (C) 2010 Intel Corporation.
+ * Copyright (C) 2010,2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -36,9 +36,8 @@
#include <errno.h>
-#include "clutter-backend-egl.h"
-#include "clutter-stage-egl.h"
-#include "clutter-egl.h"
+#include "clutter-backend-cogl.h"
+#include "clutter-stage-cogl.h"
#ifdef HAVE_EVDEV
#include "clutter-device-manager-evdev.h"
@@ -48,12 +47,15 @@
#include "clutter-private.h"
#include "clutter-main.h"
#include "clutter-stage-private.h"
-/* FIXME: We should have CLUTTER_ define for this... */
+
+#ifdef COGL_HAS_EGL_SUPPORT
+#include "clutter-egl.h"
+#endif
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
#include "clutter-cex100.h"
#endif
-static ClutterBackendEGL *backend_singleton = NULL;
+static ClutterBackendCogl *backend_singleton = NULL;
static gchar *clutter_vblank = NULL;
@@ -64,9 +66,9 @@ static guint gdl_n_buffers = CLUTTER_CEX100_TRIPLE_BUFFERING;
#endif
#ifdef COGL_HAS_X11_SUPPORT
-G_DEFINE_TYPE (ClutterBackendEGL, _clutter_backend_egl, CLUTTER_TYPE_BACKEND_X11);
+G_DEFINE_TYPE (ClutterBackendCogl, _clutter_backend_cogl, CLUTTER_TYPE_BACKEND_X11);
#else
-G_DEFINE_TYPE (ClutterBackendEGL, _clutter_backend_egl, CLUTTER_TYPE_BACKEND);
+G_DEFINE_TYPE (ClutterBackendCogl, _clutter_backend_cogl, CLUTTER_TYPE_BACKEND);
#endif
static void
@@ -77,7 +79,7 @@ clutter_backend_at_exit (void)
}
const gchar*
-_clutter_backend_egl_get_vblank (void)
+_clutter_backend_cogl_get_vblank (void)
{
if (clutter_vblank && strcmp (clutter_vblank, "0") == 0)
return "none";
@@ -86,13 +88,13 @@ _clutter_backend_egl_get_vblank (void)
}
static gboolean
-clutter_backend_egl_pre_parse (ClutterBackend *backend,
- GError **error)
+clutter_backend_cogl_pre_parse (ClutterBackend *backend,
+ GError **error)
{
const gchar *env_string;
#ifdef COGL_HAS_X11_SUPPORT
ClutterBackendClass *parent_class =
- CLUTTER_BACKEND_CLASS (_clutter_backend_egl_parent_class);
+ CLUTTER_BACKEND_CLASS (_clutter_backend_cogl_parent_class);
if (!parent_class->pre_parse (backend, error))
return FALSE;
@@ -109,12 +111,12 @@ clutter_backend_egl_pre_parse (ClutterBackend *backend,
}
static gboolean
-clutter_backend_egl_post_parse (ClutterBackend *backend,
- GError **error)
+clutter_backend_cogl_post_parse (ClutterBackend *backend,
+ GError **error)
{
#ifdef COGL_HAS_X11_SUPPORT
ClutterBackendClass *parent_class =
- CLUTTER_BACKEND_CLASS (_clutter_backend_egl_parent_class);
+ CLUTTER_BACKEND_CLASS (_clutter_backend_cogl_parent_class);
if (!parent_class->post_parse (backend, error))
return FALSE;
@@ -129,62 +131,62 @@ clutter_backend_egl_post_parse (ClutterBackend *backend,
#ifndef COGL_HAS_XLIB_SUPPORT
static ClutterDeviceManager *
-clutter_backend_egl_get_device_manager (ClutterBackend *backend)
+clutter_backend_cogl_get_device_manager (ClutterBackend *backend)
{
- ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
+ ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (backend);
- if (G_UNLIKELY (backend_egl->device_manager == NULL))
+ if (G_UNLIKELY (backend_cogl->device_manager == NULL))
{
#ifdef HAVE_EVDEV
- backend_egl->device_manager =
+ backend_cogl->device_manager =
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_EVDEV,
- "backend", backend_egl,
+ "backend", backend_cogl,
NULL);
#endif
}
- return backend_egl->device_manager;
+ return backend_cogl->device_manager;
}
#endif
static void
-clutter_backend_egl_init_events (ClutterBackend *backend)
+clutter_backend_cogl_init_events (ClutterBackend *backend)
{
#ifdef HAVE_TSLIB
/* XXX: This should be renamed to _clutter_events_tslib_init */
- _clutter_events_egl_init (CLUTTER_BACKEND_EGL (backend));
+ _clutter_events_tslib_init (CLUTTER_BACKEND_COGL (backend));
#endif
#ifdef HAVE_EVDEV
_clutter_events_evdev_init (CLUTTER_BACKEND (backend));
#endif
#ifdef COGL_HAS_X11_SUPPORT
/* Chain up to the X11 backend */
- CLUTTER_BACKEND_CLASS (_clutter_backend_egl_parent_class)->
+ CLUTTER_BACKEND_CLASS (_clutter_backend_cogl_parent_class)->
init_events (backend);
#endif
}
static void
-clutter_backend_egl_finalize (GObject *gobject)
+clutter_backend_cogl_finalize (GObject *gobject)
{
if (backend_singleton)
backend_singleton = NULL;
- G_OBJECT_CLASS (_clutter_backend_egl_parent_class)->finalize (gobject);
+ G_OBJECT_CLASS (_clutter_backend_cogl_parent_class)->finalize (gobject);
}
static void
-clutter_backend_egl_dispose (GObject *gobject)
+clutter_backend_cogl_dispose (GObject *gobject)
{
ClutterBackend *backend = CLUTTER_BACKEND (gobject);
#ifdef HAVE_TSLIB
- ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (gobject);
+ ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (gobject);
#endif
/* We chain up before disposing our CoglContext so that we will
* destroy all of the stages first. Otherwise the actors may try to
* make Cogl calls during destruction which would cause a crash */
- G_OBJECT_CLASS (_clutter_backend_egl_parent_class)->dispose (gobject);
+ G_OBJECT_CLASS (_clutter_backend_cogl_parent_class)->dispose (gobject);
if (backend->cogl_context)
{
@@ -194,30 +196,30 @@ clutter_backend_egl_dispose (GObject *gobject)
#ifdef HAVE_TSLIB
/* XXX: This should be renamed to _clutter_events_tslib_uninit */
- _clutter_events_egl_uninit (backend_egl);
+ _clutter_events_egl_uninit (backend_cogl);
- if (backend_egl->event_timer != NULL)
+ if (backend_cogl->event_timer != NULL)
{
- g_timer_destroy (backend_egl->event_timer);
- backend_egl->event_timer = NULL;
+ g_timer_destroy (backend_cogl->event_timer);
+ backend_cogl->event_timer = NULL;
}
#endif
}
static GObject *
-clutter_backend_egl_constructor (GType gtype,
- guint n_params,
- GObjectConstructParam *params)
+clutter_backend_cogl_constructor (GType gtype,
+ guint n_params,
+ GObjectConstructParam *params)
{
GObjectClass *parent_class;
GObject *retval;
if (!backend_singleton)
{
- parent_class = G_OBJECT_CLASS (_clutter_backend_egl_parent_class);
+ parent_class = G_OBJECT_CLASS (_clutter_backend_cogl_parent_class);
retval = parent_class->constructor (gtype, n_params, params);
- backend_singleton = CLUTTER_BACKEND_EGL (retval);
+ backend_singleton = CLUTTER_BACKEND_COGL (retval);
return retval;
}
@@ -229,16 +231,16 @@ clutter_backend_egl_constructor (GType gtype,
}
static ClutterFeatureFlags
-clutter_backend_egl_get_features (ClutterBackend *backend)
+clutter_backend_cogl_get_features (ClutterBackend *backend)
{
- ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
+ ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (backend);
#ifdef COGL_HAS_XLIB_SUPPORT
ClutterBackendClass *parent_class;
#endif
ClutterFeatureFlags flags = 0;
#ifdef COGL_HAS_XLIB_SUPPORT
- parent_class = CLUTTER_BACKEND_CLASS (_clutter_backend_egl_parent_class);
+ parent_class = CLUTTER_BACKEND_CLASS (_clutter_backend_cogl_parent_class);
flags = parent_class->get_features (backend);
#endif
@@ -271,7 +273,7 @@ clutter_backend_egl_get_features (ClutterBackend *backend)
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION))
{
CLUTTER_NOTE (BACKEND, "Cogl supports swapping buffer regions");
- backend_egl->can_blit_sub_buffer = TRUE;
+ backend_cogl->can_blit_sub_buffer = TRUE;
}
return flags;
@@ -279,15 +281,15 @@ clutter_backend_egl_get_features (ClutterBackend *backend)
#ifdef COGL_HAS_XLIB_SUPPORT
static XVisualInfo *
-clutter_backend_egl_get_visual_info (ClutterBackendX11 *backend_x11)
+clutter_backend_cogl_get_visual_info (ClutterBackendX11 *backend_x11)
{
return cogl_clutter_winsys_xlib_get_visual_info ();
}
#endif
static gboolean
-clutter_backend_egl_create_context (ClutterBackend *backend,
- GError **error)
+clutter_backend_cogl_create_context (ClutterBackend *backend,
+ GError **error)
{
#ifdef COGL_HAS_XLIB_SUPPORT
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
@@ -372,9 +374,9 @@ error:
}
static ClutterStageWindow *
-clutter_backend_egl_create_stage (ClutterBackend *backend,
- ClutterStage *wrapper,
- GError **error)
+clutter_backend_cogl_create_stage (ClutterBackend *backend,
+ ClutterStage *wrapper,
+ GError **error)
{
#ifdef COGL_HAS_XLIB_SUPPORT
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
@@ -382,7 +384,7 @@ clutter_backend_egl_create_stage (ClutterBackend *backend,
ClutterStageWindow *stage;
ClutterStageX11 *stage_x11;
- stage = g_object_new (CLUTTER_TYPE_STAGE_EGL, NULL);
+ stage = g_object_new (CLUTTER_TYPE_STAGE_COGL, NULL);
/* copy backend data into the stage */
stage_x11 = CLUTTER_STAGE_X11 (stage);
@@ -392,33 +394,33 @@ clutter_backend_egl_create_stage (ClutterBackend *backend,
translator = CLUTTER_EVENT_TRANSLATOR (stage_x11);
_clutter_backend_add_event_translator (backend, translator);
- CLUTTER_NOTE (MISC, "EGLX stage created (display:%p, screen:%d, root:%u)",
+ CLUTTER_NOTE (MISC, "Cogl stage created (display:%p, screen:%d, root:%u)",
backend_x11->xdpy,
backend_x11->xscreen_num,
(unsigned int) backend_x11->xwin_root);
#else /* COGL_HAS_XLIB_SUPPORT */
- ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
+ ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (backend);
ClutterStageWindow *stage;
- ClutterStageEGL *stage_egl;
+ ClutterStageCogl *stage_cogl;
- if (G_UNLIKELY (backend_egl->stage != NULL))
+ if (G_UNLIKELY (backend_cogl->stage != NULL))
{
g_set_error (error, CLUTTER_INIT_ERROR,
CLUTTER_INIT_ERROR_BACKEND,
"The Cogl backend does not support multiple "
"onscreen windows");
- return backend_egl->stage;
+ return backend_cogl->stage;
}
- stage = g_object_new (CLUTTER_TYPE_STAGE_EGL, NULL);
+ stage = g_object_new (CLUTTER_TYPE_STAGE_COGL, NULL);
- stage_egl = CLUTTER_STAGE_EGL (stage);
- stage_egl->backend = backend_egl;
- stage_egl->wrapper = wrapper;
+ stage_cogl = CLUTTER_STAGE_COGL (stage);
+ stage_cogl->backend = backend_cogl;
+ stage_cogl->wrapper = wrapper;
- backend_egl->stage = stage;
+ backend_cogl->stage = stage;
#endif /* COGL_HAS_XLIB_SUPPORT */
@@ -426,17 +428,23 @@ clutter_backend_egl_create_stage (ClutterBackend *backend,
}
static void
-clutter_backend_egl_ensure_context (ClutterBackend *backend,
- ClutterStage *stage)
+clutter_backend_cogl_ensure_context (ClutterBackend *backend,
+ ClutterStage *stage)
{
- ClutterStageEGL *stage_egl =
- CLUTTER_STAGE_EGL (_clutter_stage_get_window (stage));
+ ClutterStageCogl *stage_cogl;
+
+ /* ignore ensuring the context on an empty stage */
+ if (stage == NULL)
+ return;
- cogl_set_framebuffer (COGL_FRAMEBUFFER (stage_egl->onscreen));
+ stage_cogl =
+ CLUTTER_STAGE_COGL (_clutter_stage_get_window (stage));
+
+ cogl_set_framebuffer (COGL_FRAMEBUFFER (stage_cogl->onscreen));
}
static void
-_clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
+_clutter_backend_cogl_class_init (ClutterBackendCoglClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
@@ -444,40 +452,41 @@ _clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
ClutterBackendX11Class *backendx11_class = CLUTTER_BACKEND_X11_CLASS (klass);
#endif
- gobject_class->constructor = clutter_backend_egl_constructor;
- gobject_class->dispose = clutter_backend_egl_dispose;
- gobject_class->finalize = clutter_backend_egl_finalize;
+ gobject_class->constructor = clutter_backend_cogl_constructor;
+ gobject_class->dispose = clutter_backend_cogl_dispose;
+ gobject_class->finalize = clutter_backend_cogl_finalize;
- backend_class->pre_parse = clutter_backend_egl_pre_parse;
- backend_class->post_parse = clutter_backend_egl_post_parse;
- backend_class->get_features = clutter_backend_egl_get_features;
+ backend_class->pre_parse = clutter_backend_cogl_pre_parse;
+ backend_class->post_parse = clutter_backend_cogl_post_parse;
+ backend_class->get_features = clutter_backend_cogl_get_features;
#ifndef COGL_HAS_XLIB_SUPPORT
- backend_class->get_device_manager = clutter_backend_egl_get_device_manager;
+ backend_class->get_device_manager = clutter_backend_cogl_get_device_manager;
#endif
- backend_class->init_events = clutter_backend_egl_init_events;
- backend_class->create_stage = clutter_backend_egl_create_stage;
- backend_class->create_context = clutter_backend_egl_create_context;
- backend_class->ensure_context = clutter_backend_egl_ensure_context;
+ backend_class->init_events = clutter_backend_cogl_init_events;
+ backend_class->create_stage = clutter_backend_cogl_create_stage;
+ backend_class->create_context = clutter_backend_cogl_create_context;
+ backend_class->ensure_context = clutter_backend_cogl_ensure_context;
#ifdef COGL_HAS_XLIB_SUPPORT
- backendx11_class->get_visual_info = clutter_backend_egl_get_visual_info;
+ backendx11_class->get_visual_info = clutter_backend_cogl_get_visual_info;
#endif
}
static void
-_clutter_backend_egl_init (ClutterBackendEGL *backend_egl)
+_clutter_backend_cogl_init (ClutterBackendCogl *backend_cogl)
{
#ifdef HAVE_TSLIB
- backend_egl->event_timer = g_timer_new ();
+ backend_cogl->event_timer = g_timer_new ();
#endif
}
GType
_clutter_backend_impl_get_type (void)
{
- return _clutter_backend_egl_get_type ();
+ return _clutter_backend_cogl_get_type ();
}
+#ifdef COGL_HAS_EGL_SUPPORT
EGLDisplay
clutter_eglx_display (void)
{
@@ -501,6 +510,7 @@ clutter_egl_get_egl_display (void)
return cogl_context_egl_get_egl_display (backend_singleton->cogl_context);
}
+#endif
/* FIXME we should have a CLUTTER_ define for this */
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
diff --git a/clutter/egl/clutter-backend-egl.h b/clutter/cogl/clutter-backend-cogl.h
similarity index 60%
rename from clutter/egl/clutter-backend-egl.h
rename to clutter/cogl/clutter-backend-cogl.h
index c2a72d6..8f96d56 100644
--- a/clutter/egl/clutter-backend-egl.h
+++ b/clutter/cogl/clutter-backend-cogl.h
@@ -22,8 +22,8 @@
* Robert Bragg
*/
-#ifndef __CLUTTER_BACKEND_EGL_H__
-#define __CLUTTER_BACKEND_EGL_H__
+#ifndef __CLUTTER_BACKEND_COGL_H__
+#define __CLUTTER_BACKEND_COGL_H__
#include <glib-object.h>
#include <clutter/clutter-event.h>
@@ -37,8 +37,6 @@
#include "clutter-backend-private.h"
-#include "clutter-egl-headers.h"
-
#ifdef COGL_HAS_X11_SUPPORT
#include "../x11/clutter-backend-x11.h"
#endif
@@ -47,17 +45,17 @@
G_BEGIN_DECLS
-#define CLUTTER_TYPE_BACKEND_EGL (_clutter_backend_egl_get_type ())
-#define CLUTTER_BACKEND_EGL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_EGL, ClutterBackendEGL))
-#define CLUTTER_IS_BACKEND_EGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_EGL))
-#define CLUTTER_BACKEND_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_EGL, ClutterBackendEGLClass))
-#define CLUTTER_IS_BACKEND_EGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND_EGL))
-#define CLUTTER_BACKEND_EGL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND_EGL, ClutterBackendEGLClass))
+#define CLUTTER_TYPE_BACKEND_COGL (_clutter_backend_cogl_get_type ())
+#define CLUTTER_BACKEND_COGL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_COGL, ClutterBackendCogl))
+#define CLUTTER_IS_BACKEND_COGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_COGL))
+#define CLUTTER_BACKEND_COGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_COGL, ClutterBackendCoglClass))
+#define CLUTTER_IS_BACKEND_COGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND_COGL))
+#define CLUTTER_BACKEND_COGL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND_COGL, ClutterBackendCoglClass))
-typedef struct _ClutterBackendEGL ClutterBackendEGL;
-typedef struct _ClutterBackendEGLClass ClutterBackendEGLClass;
+typedef struct _ClutterBackendCogl ClutterBackendCogl;
+typedef struct _ClutterBackendCoglClass ClutterBackendCoglClass;
-struct _ClutterBackendEGL
+struct _ClutterBackendCogl
{
#ifdef COGL_HAS_XLIB_SUPPORT
ClutterBackendX11 parent_instance;
@@ -84,7 +82,7 @@ struct _ClutterBackendEGL
gboolean can_blit_sub_buffer;
};
-struct _ClutterBackendEGLClass
+struct _ClutterBackendCoglClass
{
#ifdef COGL_HAS_XLIB_SUPPORT
ClutterBackendX11Class parent_class;
@@ -93,13 +91,15 @@ struct _ClutterBackendEGLClass
#endif
};
-GType _clutter_backend_egl_get_type (void) G_GNUC_CONST;
+GType _clutter_backend_cogl_get_type (void) G_GNUC_CONST;
-void _clutter_events_egl_init (ClutterBackendEGL *backend);
-void _clutter_events_egl_uninit (ClutterBackendEGL *backend);
+#ifdef HAVE_TSLIB
+void _clutter_events_tslib_init (ClutterBackendCogl *backend);
+void _clutter_events_tslib_uninit (ClutterBackendCogl *backend);
+#endif
const gchar *_clutter_backend_egl_get_vblank (void);
G_END_DECLS
-#endif /* __CLUTTER_BACKEND_EGL_H__ */
+#endif /* __CLUTTER_BACKEND_COGL_H__ */
diff --git a/clutter/egl/clutter-cex100.h.in b/clutter/cogl/clutter-cex100.h.in
similarity index 100%
rename from clutter/egl/clutter-cex100.h.in
rename to clutter/cogl/clutter-cex100.h.in
diff --git a/clutter/egl/clutter-egl.h b/clutter/cogl/clutter-egl.h
similarity index 100%
rename from clutter/egl/clutter-egl.h
rename to clutter/cogl/clutter-egl.h
diff --git a/clutter/egl/clutter-event-tslib.c b/clutter/cogl/clutter-event-tslib.c
similarity index 99%
rename from clutter/egl/clutter-event-tslib.c
rename to clutter/cogl/clutter-event-tslib.c
index b346c9b..de04fd8 100644
--- a/clutter/egl/clutter-event-tslib.c
+++ b/clutter/cogl/clutter-event-tslib.c
@@ -96,7 +96,7 @@ get_backend_time (void)
#endif
void
-_clutter_events_egl_init (ClutterBackendEGL *backend_egl)
+_clutter_events_tslib_init (ClutterBackendEGL *backend_egl)
{
#ifdef HAVE_TSLIB
ClutterEventSource *event_source;
diff --git a/clutter/glx/clutter-glx-texture-pixmap.c b/clutter/cogl/clutter-glx-texture-pixmap.c
similarity index 100%
rename from clutter/glx/clutter-glx-texture-pixmap.c
rename to clutter/cogl/clutter-glx-texture-pixmap.c
diff --git a/clutter/glx/clutter-glx-texture-pixmap.h b/clutter/cogl/clutter-glx-texture-pixmap.h
similarity index 100%
rename from clutter/glx/clutter-glx-texture-pixmap.h
rename to clutter/cogl/clutter-glx-texture-pixmap.h
diff --git a/clutter/egl/clutter-stage-egl.c b/clutter/cogl/clutter-stage-cogl.c
similarity index 52%
rename from clutter/egl/clutter-stage-egl.c
rename to clutter/cogl/clutter-stage-cogl.c
index 1de7d4a..494909c 100644
--- a/clutter/egl/clutter-stage-egl.c
+++ b/clutter/cogl/clutter-stage-cogl.c
@@ -1,10 +1,37 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+ * Authors:
+ * Matthew Allum
+ * Robert Bragg
+ * Neil Roberts
+ * Emmanuele Bassi
+ */
+
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "clutter-stage-egl.h"
-#include "clutter-egl.h"
-#include "clutter-backend-egl.h"
+#include "clutter-stage-cogl.h"
+#include "clutter-backend-cogl.h"
#include "clutter-debug.h"
#include "clutter-event.h"
@@ -17,13 +44,13 @@
#include "clutter-util.h"
#ifdef COGL_HAS_X11_SUPPORT
-static ClutterStageWindowIface *clutter_stage_egl_parent_iface = NULL;
+static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL;
#endif
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
-G_DEFINE_TYPE_WITH_CODE (ClutterStageEGL,
- _clutter_stage_egl,
+G_DEFINE_TYPE_WITH_CODE (ClutterStageCogl,
+ _clutter_stage_cogl,
#ifdef COGL_HAS_X11_SUPPORT
CLUTTER_TYPE_STAGE_X11,
#else
@@ -33,30 +60,49 @@ G_DEFINE_TYPE_WITH_CODE (ClutterStageEGL,
clutter_stage_window_iface_init));
static void
-clutter_stage_egl_unrealize (ClutterStageWindow *stage_window)
+clutter_stage_cogl_unrealize (ClutterStageWindow *stage_window)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
- CLUTTER_NOTE (BACKEND, "Unrealizing EGL stage [%p]", stage_egl);
+ CLUTTER_NOTE (BACKEND, "Unrealizing Cogl stage [%p]", stage_cogl);
#ifdef COGL_HAS_XLIB_SUPPORT
/* chain up to the StageX11 implementation */
clutter_stage_window_parent_iface->unrealize (stage_window);
#endif
- cogl_object_unref (stage_egl->onscreen);
- stage_egl->onscreen = NULL;
+ cogl_object_unref (stage_cogl->onscreen);
+ stage_cogl->onscreen = NULL;
+}
+
+static void
+handle_swap_complete_cb (CoglFramebuffer *framebuffer,
+ void *user_data)
+{
+ ClutterStageCogl *stage_cogl = user_data;
+
+ /* Early versions of the swap_event implementation in Mesa
+ * deliver BufferSwapComplete event when not selected for,
+ * so if we get a swap event we aren't expecting, just ignore it.
+ *
+ * https://bugs.freedesktop.org/show_bug.cgi?id=27962
+ *
+ * FIXME: This issue can be hidden inside Cogl so we shouldn't
+ * need to care about this bug here.
+ */
+ if (stage_cogl->pending_swaps > 0)
+ stage_cogl->pending_swaps--;
}
static gboolean
-clutter_stage_egl_realize (ClutterStageWindow *stage_window)
+clutter_stage_cogl_realize (ClutterStageWindow *stage_window)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
#ifdef COGL_HAS_XLIB_SUPPORT
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
#endif
ClutterBackend *backend;
- ClutterBackendEGL *backend_egl;
+ ClutterBackendCogl *backend_cogl;
CoglFramebuffer *framebuffer;
GError *error = NULL;
gfloat width = 800;
@@ -64,23 +110,23 @@ clutter_stage_egl_realize (ClutterStageWindow *stage_window)
const char *clutter_vblank;
CLUTTER_NOTE (BACKEND, "Realizing stage '%s' [%p]",
- G_OBJECT_TYPE_NAME (stage_egl),
- stage_egl);
+ G_OBJECT_TYPE_NAME (stage_cogl),
+ stage_cogl);
backend = clutter_get_default_backend ();
- backend_egl = CLUTTER_BACKEND_EGL (backend);
+ backend_cogl = CLUTTER_BACKEND_COGL (backend);
#ifdef COGL_HAS_XLIB_SUPPORT
clutter_actor_get_size (CLUTTER_ACTOR (stage_x11->wrapper), &width, &height);
#endif
- stage_egl->onscreen = cogl_onscreen_new (backend->cogl_context,
+ stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
width, height);
#ifdef COGL_HAS_XLIB_SUPPORT
if (stage_x11->xwin != None)
{
cogl_onscreen_x11_set_foreign_window_xid (
- stage_egl->onscreen,
+ stage_cogl->onscreen,
stage_x11->xwin,
_clutter_stage_x11_update_foreign_event_mask,
stage_x11);
@@ -88,39 +134,55 @@ clutter_stage_egl_realize (ClutterStageWindow *stage_window)
}
#endif
- clutter_vblank = _clutter_backend_egl_get_vblank ();
+ clutter_vblank = _clutter_backend_cogl_get_vblank ();
if (clutter_vblank && strcmp (clutter_vblank, "none") == 0)
- cogl_onscreen_set_swap_throttled (stage_egl->onscreen, FALSE);
+ cogl_onscreen_set_swap_throttled (stage_cogl->onscreen, FALSE);
- framebuffer = COGL_FRAMEBUFFER (stage_egl->onscreen);
+ framebuffer = COGL_FRAMEBUFFER (stage_cogl->onscreen);
if (!cogl_framebuffer_allocate (framebuffer, &error))
{
g_warning ("Failed to allocate stage: %s", error->message);
g_error_free (error);
- cogl_object_unref (stage_egl->onscreen);
- stage_egl->onscreen = NULL;
+ cogl_object_unref (stage_cogl->onscreen);
+ stage_cogl->onscreen = NULL;
return FALSE;
}
- /* FIXME: for fullscreen EGL platforms then the size we gave above
+ /* FIXME: for fullscreen Cogl platforms then the size we gave above
* will be ignored, so we need to make sure the stage size is
* updated to this size. */
+ if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT))
+ {
+ stage_cogl->swap_callback_id =
+ cogl_framebuffer_add_swap_buffers_callback (framebuffer,
+ handle_swap_complete_cb,
+ stage_cogl);
+ }
+
#ifdef COGL_HAS_XLIB_SUPPORT
if (stage_x11->xwin == None)
- stage_x11->xwin = cogl_onscreen_x11_get_window_xid (stage_egl->onscreen);
+ stage_x11->xwin = cogl_onscreen_x11_get_window_xid (stage_cogl->onscreen);
- return clutter_stage_egl_parent_iface->realize (stage_window);
+ return clutter_stage_window_parent_iface->realize (stage_window);
#else
return TRUE;
#endif
}
+static int
+clutter_stage_cogl_get_pending_swaps (ClutterStageWindow *stage_window)
+{
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
+
+ return stage_cogl->pending_swaps;
+}
+
#ifndef COGL_HAS_XLIB_SUPPORT
/* FIXME: Move this warnings up into clutter-stage.c */
static void
-clutter_stage_egl_set_fullscreen (ClutterStageWindow *stage_window,
+clutter_stage_cogl_set_fullscreen (ClutterStageWindow *stage_window,
gboolean fullscreen)
{
g_warning ("Stage of type '%s' do not support ClutterStage::set_fullscreen",
@@ -128,7 +190,7 @@ clutter_stage_egl_set_fullscreen (ClutterStageWindow *stage_window,
}
static void
-clutter_stage_egl_set_title (ClutterStageWindow *stage_window,
+clutter_stage_cogl_set_title (ClutterStageWindow *stage_window,
const gchar *title)
{
g_warning ("Stage of type '%s' do not support ClutterStage::set_title",
@@ -136,7 +198,7 @@ clutter_stage_egl_set_title (ClutterStageWindow *stage_window,
}
static void
-clutter_stage_egl_set_cursor_visible (ClutterStageWindow *stage_window,
+clutter_stage_cogl_set_cursor_visible (ClutterStageWindow *stage_window,
gboolean cursor_visible)
{
g_warning ("Stage of type '%s' do not support ClutterStage::set_cursor_visible",
@@ -144,40 +206,40 @@ clutter_stage_egl_set_cursor_visible (ClutterStageWindow *stage_window,
}
static ClutterActor *
-clutter_stage_egl_get_wrapper (ClutterStageWindow *stage_window)
+clutter_stage_cogl_get_wrapper (ClutterStageWindow *stage_window)
{
- return CLUTTER_ACTOR (CLUTTER_STAGE_EGL (stage_window)->wrapper);
+ return CLUTTER_ACTOR (CLUTTER_STAGE_COGL (stage_window)->wrapper);
}
static void
-clutter_stage_egl_show (ClutterStageWindow *stage_window,
+clutter_stage_cogl_show (ClutterStageWindow *stage_window,
gboolean do_raise)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
- clutter_actor_map (CLUTTER_ACTOR (stage_egl->wrapper));
+ clutter_actor_map (CLUTTER_ACTOR (stage_cogl->wrapper));
}
static void
-clutter_stage_egl_hide (ClutterStageWindow *stage_window)
+clutter_stage_cogl_hide (ClutterStageWindow *stage_window)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
- clutter_actor_unmap (CLUTTER_ACTOR (stage_egl->wrapper));
+ clutter_actor_unmap (CLUTTER_ACTOR (stage_cogl->wrapper));
}
static void
-clutter_stage_egl_get_geometry (ClutterStageWindow *stage_window,
+clutter_stage_cogl_get_geometry (ClutterStageWindow *stage_window,
ClutterGeometry *geometry)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
if (geometry)
{
- if (stage_egl->onscreen)
+ if (stage_cogl->onscreen)
{
CoglFramebuffer *framebuffer =
- COGL_FRAMEBUFFER (stage_egl->onscreen);
+ COGL_FRAMEBUFFER (stage_cogl->onscreen);
geometry->x = geometry->y = 0;
@@ -194,7 +256,7 @@ clutter_stage_egl_get_geometry (ClutterStageWindow *stage_window,
}
static void
-clutter_stage_egl_resize (ClutterStageWindow *stage_window,
+clutter_stage_cogl_resize (ClutterStageWindow *stage_window,
gint width,
gint height)
{
@@ -203,9 +265,9 @@ clutter_stage_egl_resize (ClutterStageWindow *stage_window,
#endif /* COGL_HAS_XLIB_SUPPORT */
static gboolean
-clutter_stage_egl_has_redraw_clips (ClutterStageWindow *stage_window)
+clutter_stage_cogl_has_redraw_clips (ClutterStageWindow *stage_window)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
/* NB: at the start of each new frame there is an implied clip that
* clips everything (i.e. nothing would be drawn) so we need to make
@@ -214,22 +276,22 @@ clutter_stage_egl_has_redraw_clips (ClutterStageWindow *stage_window)
* NB: a clip width of 0 means a full stage redraw has been queued
* so we effectively don't have any redraw clips in that case.
*/
- if (!stage_egl->initialized_redraw_clip ||
- (stage_egl->initialized_redraw_clip &&
- stage_egl->bounding_redraw_clip.width != 0))
+ if (!stage_cogl->initialized_redraw_clip ||
+ (stage_cogl->initialized_redraw_clip &&
+ stage_cogl->bounding_redraw_clip.width != 0))
return TRUE;
else
return FALSE;
}
static gboolean
-clutter_stage_egl_ignoring_redraw_clips (ClutterStageWindow *stage_window)
+clutter_stage_cogl_ignoring_redraw_clips (ClutterStageWindow *stage_window)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
/* NB: a clip width of 0 means a full stage redraw is required */
- if (stage_egl->initialized_redraw_clip &&
- stage_egl->bounding_redraw_clip.width == 0)
+ if (stage_cogl->initialized_redraw_clip &&
+ stage_cogl->bounding_redraw_clip.width == 0)
return TRUE;
else
return FALSE;
@@ -238,7 +300,7 @@ clutter_stage_egl_ignoring_redraw_clips (ClutterStageWindow *stage_window)
/* A redraw clip represents (in stage coordinates) the bounding box of
* something that needs to be redraw. Typically they are added to the
* StageWindow as a result of clutter_actor_queue_clipped_redraw() by
- * actors such as ClutterEGLTexturePixmap. All redraw clips are
+ * actors such as ClutterGLXTexturePixmap. All redraw clips are
* discarded after the next paint.
*
* A NULL stage_clip means the whole stage needs to be redrawn.
@@ -250,22 +312,22 @@ clutter_stage_egl_ignoring_redraw_clips (ClutterStageWindow *stage_window)
* buffer.
*/
static void
-clutter_stage_egl_add_redraw_clip (ClutterStageWindow *stage_window,
+clutter_stage_cogl_add_redraw_clip (ClutterStageWindow *stage_window,
ClutterGeometry *stage_clip)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
/* If we are already forced to do a full stage redraw then bail early */
- if (clutter_stage_egl_ignoring_redraw_clips (stage_window))
+ if (clutter_stage_cogl_ignoring_redraw_clips (stage_window))
return;
/* A NULL stage clip means a full stage redraw has been queued and
* we keep track of this by setting a zero width
- * stage_egl->bounding_redraw_clip */
+ * stage_cogl->bounding_redraw_clip */
if (stage_clip == NULL)
{
- stage_egl->bounding_redraw_clip.width = 0;
- stage_egl->initialized_redraw_clip = TRUE;
+ stage_cogl->bounding_redraw_clip.width = 0;
+ stage_cogl->initialized_redraw_clip = TRUE;
return;
}
@@ -273,30 +335,30 @@ clutter_stage_egl_add_redraw_clip (ClutterStageWindow *stage_window,
if (stage_clip->width == 0 || stage_clip->height == 0)
return;
- if (!stage_egl->initialized_redraw_clip)
+ if (!stage_cogl->initialized_redraw_clip)
{
- stage_egl->bounding_redraw_clip.x = stage_clip->x;
- stage_egl->bounding_redraw_clip.y = stage_clip->y;
- stage_egl->bounding_redraw_clip.width = stage_clip->width;
- stage_egl->bounding_redraw_clip.height = stage_clip->height;
+ stage_cogl->bounding_redraw_clip.x = stage_clip->x;
+ stage_cogl->bounding_redraw_clip.y = stage_clip->y;
+ stage_cogl->bounding_redraw_clip.width = stage_clip->width;
+ stage_cogl->bounding_redraw_clip.height = stage_clip->height;
}
- else if (stage_egl->bounding_redraw_clip.width > 0)
+ else if (stage_cogl->bounding_redraw_clip.width > 0)
{
- clutter_geometry_union (&stage_egl->bounding_redraw_clip, stage_clip,
- &stage_egl->bounding_redraw_clip);
+ clutter_geometry_union (&stage_cogl->bounding_redraw_clip, stage_clip,
+ &stage_cogl->bounding_redraw_clip);
}
- stage_egl->initialized_redraw_clip = TRUE;
+ stage_cogl->initialized_redraw_clip = TRUE;
}
/* XXX: This is basically identical to clutter_stage_glx_redraw */
static void
-clutter_stage_egl_redraw (ClutterStageWindow *stage_window)
+clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
{
- ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
ClutterActor *wrapper;
ClutterBackend *backend;
- ClutterBackendEGL *backend_egl;
+ ClutterBackendCogl *backend_cogl;
gboolean may_use_clipped_redraw;
gboolean use_clipped_redraw;
@@ -317,27 +379,27 @@ clutter_stage_egl_redraw (ClutterStageWindow *stage_window)
0 /* no application private data */);
#ifdef COGL_HAS_X11_SUPPORT
- ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_egl);
+ ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_cogl);
wrapper = CLUTTER_ACTOR (stage_x11->wrapper);
#else
- wrapper = CLUTTER_ACTOR (stage_egl->wrapper);
+ wrapper = CLUTTER_ACTOR (stage_cogl->wrapper);
#endif
- if (!stage_egl->onscreen)
+ if (!stage_cogl->onscreen)
return;
backend = clutter_get_default_backend ();
- backend_egl = CLUTTER_BACKEND_EGL (backend);
+ backend_cogl = CLUTTER_BACKEND_COGL (backend);
CLUTTER_TIMER_START (_clutter_uprof_context, painting_timer);
- if (G_LIKELY (backend_egl->can_blit_sub_buffer) &&
+ if (G_LIKELY (backend_cogl->can_blit_sub_buffer) &&
/* NB: a zero width redraw clip == full stage redraw */
- stage_egl->bounding_redraw_clip.width != 0 &&
+ stage_cogl->bounding_redraw_clip.width != 0 &&
/* some drivers struggle to get going and produce some junk
* frames when starting up... */
- G_LIKELY (stage_egl->frame_count > 3)
+ G_LIKELY (stage_cogl->frame_count > 3)
#ifdef COGL_HAS_X11_SUPPORT
/* While resizing a window clipped redraws are disabled to avoid
* artefacts. See clutter-event-x11.c:event_translate for a
@@ -360,22 +422,42 @@ clutter_stage_egl_redraw (ClutterStageWindow *stage_window)
if (use_clipped_redraw)
{
- cogl_clip_push_window_rectangle (stage_egl->bounding_redraw_clip.x,
- stage_egl->bounding_redraw_clip.y,
- stage_egl->bounding_redraw_clip.width,
- stage_egl->bounding_redraw_clip.height);
+ CLUTTER_NOTE (CLIPPING,
+ "Stage clip pushed: x=%d, y=%d, width=%d, height=%d\n",
+ stage_cogl->bounding_redraw_clip.x,
+ stage_cogl->bounding_redraw_clip.y,
+ stage_cogl->bounding_redraw_clip.width,
+ stage_cogl->bounding_redraw_clip.height);
+ cogl_clip_push_window_rectangle (stage_cogl->bounding_redraw_clip.x,
+ stage_cogl->bounding_redraw_clip.y,
+ stage_cogl->bounding_redraw_clip.width,
+ stage_cogl->bounding_redraw_clip.height);
_clutter_stage_do_paint (CLUTTER_STAGE (wrapper),
- &stage_egl->bounding_redraw_clip);
+ &stage_cogl->bounding_redraw_clip);
cogl_clip_pop ();
}
else
- _clutter_stage_do_paint (CLUTTER_STAGE (wrapper), NULL);
+ {
+ CLUTTER_NOTE (CLIPPING, "Unclipped stage paint\n");
+
+ /* If we are trying to debug redraw issues then we want to pass
+ * the bounding_redraw_clip so it can be visualized */
+ if (G_UNLIKELY (clutter_paint_debug_flags &
+ CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS) &&
+ may_use_clipped_redraw)
+ {
+ _clutter_stage_do_paint (CLUTTER_STAGE (wrapper),
+ &stage_cogl->bounding_redraw_clip);
+ }
+ else
+ _clutter_stage_do_paint (CLUTTER_STAGE (wrapper), NULL);
+ }
if (may_use_clipped_redraw &&
G_UNLIKELY ((clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS)))
{
static CoglMaterial *outline = NULL;
- ClutterGeometry *clip = &stage_egl->bounding_redraw_clip;
+ ClutterGeometry *clip = &stage_cogl->bounding_redraw_clip;
ClutterActor *actor = CLUTTER_ACTOR (wrapper);
CoglHandle vbo;
float x_1 = clip->x;
@@ -422,7 +504,7 @@ clutter_stage_egl_redraw (ClutterStageWindow *stage_window)
/* push on the screen */
if (use_clipped_redraw)
{
- ClutterGeometry *clip = &stage_egl->bounding_redraw_clip;
+ ClutterGeometry *clip = &stage_cogl->bounding_redraw_clip;
int copy_area[4];
ClutterActor *actor;
@@ -445,13 +527,13 @@ clutter_stage_egl_redraw (ClutterStageWindow *stage_window)
"cogl_framebuffer_swap_region (onscreen: %p, "
"x: %d, y: %d, "
"width: %d, height: %d)",
- stage_egl->onscreen,
+ stage_cogl->onscreen,
copy_area[0], copy_area[1], copy_area[2], copy_area[3]);
CLUTTER_TIMER_START (_clutter_uprof_context, blit_sub_buffer_timer);
- cogl_framebuffer_swap_region (COGL_FRAMEBUFFER (stage_egl->onscreen),
+ cogl_framebuffer_swap_region (COGL_FRAMEBUFFER (stage_cogl->onscreen),
copy_area, 1);
CLUTTER_TIMER_STOP (_clutter_uprof_context, blit_sub_buffer_timer);
@@ -459,73 +541,89 @@ clutter_stage_egl_redraw (ClutterStageWindow *stage_window)
else
{
CLUTTER_NOTE (BACKEND, "cogl_framebuffer_swap_buffers (onscreen: %p)",
- stage_egl->onscreen);
+ stage_cogl->onscreen);
+
+ /* If we have swap buffer events then
+ * cogl_framebuffer_swap_buffers will return immediately and we
+ * need to track that there is a swap in progress... */
+ if (clutter_feature_available (CLUTTER_FEATURE_SWAP_EVENTS))
+ stage_cogl->pending_swaps++;
CLUTTER_TIMER_START (_clutter_uprof_context, swapbuffers_timer);
- cogl_framebuffer_swap_buffers (COGL_FRAMEBUFFER (stage_egl->onscreen));
+ cogl_framebuffer_swap_buffers (COGL_FRAMEBUFFER (stage_cogl->onscreen));
CLUTTER_TIMER_STOP (_clutter_uprof_context, swapbuffers_timer);
}
/* reset the redraw clipping for the next paint... */
- stage_egl->initialized_redraw_clip = FALSE;
+ stage_cogl->initialized_redraw_clip = FALSE;
+
+ stage_cogl->frame_count++;
+}
+
+static CoglFramebuffer *
+clutter_stage_cogl_get_active_framebuffer (ClutterStageWindow *stage_window)
+{
+ ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
- stage_egl->frame_count++;
+ return COGL_FRAMEBUFFER (stage_cogl->onscreen);
}
static void
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
{
#ifdef COGL_HAS_X11_SUPPORT
- clutter_stage_egl_parent_iface = g_type_interface_peek_parent (iface);
+ clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);
- iface->realize = clutter_stage_egl_realize;
- iface->unrealize = clutter_stage_egl_unrealize;
+ iface->realize = clutter_stage_cogl_realize;
+ iface->unrealize = clutter_stage_cogl_unrealize;
/* the rest is inherited from ClutterStageX11 */
#else /* COGL_HAS_X11_SUPPORT */
- iface->realize = clutter_stage_egl_realize;
- iface->unrealize = clutter_stage_egl_unrealize;
- iface->set_fullscreen = clutter_stage_egl_set_fullscreen;
- iface->set_title = clutter_stage_egl_set_title;
- iface->set_cursor_visible = clutter_stage_egl_set_cursor_visible;
- iface->get_wrapper = clutter_stage_egl_get_wrapper;
- iface->get_geometry = clutter_stage_egl_get_geometry;
- iface->resize = clutter_stage_egl_resize;
- iface->show = clutter_stage_egl_show;
- iface->hide = clutter_stage_egl_hide;
+ iface->realize = clutter_stage_cogl_realize;
+ iface->unrealize = clutter_stage_cogl_unrealize;
+ iface->set_fullscreen = clutter_stage_cogl_set_fullscreen;
+ iface->set_title = clutter_stage_cogl_set_title;
+ iface->set_cursor_visible = clutter_stage_cogl_set_cursor_visible;
+ iface->get_wrapper = clutter_stage_cogl_get_wrapper;
+ iface->get_geometry = clutter_stage_cogl_get_geometry;
+ iface->resize = clutter_stage_cogl_resize;
+ iface->show = clutter_stage_cogl_show;
+ iface->hide = clutter_stage_cogl_hide;
#endif /* COGL_HAS_X11_SUPPORT */
- iface->add_redraw_clip = clutter_stage_egl_add_redraw_clip;
- iface->has_redraw_clips = clutter_stage_egl_has_redraw_clips;
- iface->ignoring_redraw_clips = clutter_stage_egl_ignoring_redraw_clips;
- iface->redraw = clutter_stage_egl_redraw;
+ iface->get_pending_swaps = clutter_stage_cogl_get_pending_swaps;
+ iface->add_redraw_clip = clutter_stage_cogl_add_redraw_clip;
+ iface->has_redraw_clips = clutter_stage_cogl_has_redraw_clips;
+ iface->ignoring_redraw_clips = clutter_stage_cogl_ignoring_redraw_clips;
+ iface->redraw = clutter_stage_cogl_redraw;
+ iface->get_active_framebuffer = clutter_stage_cogl_get_active_framebuffer;
}
#ifdef COGL_HAS_X11_SUPPORT
static void
-clutter_stage_egl_dispose (GObject *gobject)
+clutter_stage_cogl_dispose (GObject *gobject)
{
- G_OBJECT_CLASS (_clutter_stage_egl_parent_class)->dispose (gobject);
+ G_OBJECT_CLASS (_clutter_stage_cogl_parent_class)->dispose (gobject);
}
static void
-_clutter_stage_egl_class_init (ClutterStageEGLClass *klass)
+_clutter_stage_cogl_class_init (ClutterStageCoglClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->dispose = clutter_stage_egl_dispose;
+ gobject_class->dispose = clutter_stage_cogl_dispose;
}
#else
static void
-_clutter_stage_egl_class_init (ClutterStageEGLClass *klass)
+_clutter_stage_cogl_class_init (ClutterStageCoglClass *klass)
{
}
#endif /* COGL_HAS_X11_SUPPORT */
static void
-_clutter_stage_egl_init (ClutterStageEGL *stage)
+_clutter_stage_cogl_init (ClutterStageCogl *stage)
{
}
diff --git a/clutter/cogl/clutter-stage-cogl.h b/clutter/cogl/clutter-stage-cogl.h
new file mode 100644
index 0000000..e718d27
--- /dev/null
+++ b/clutter/cogl/clutter-stage-cogl.h
@@ -0,0 +1,78 @@
+#ifndef __CLUTTER_STAGE_COGL_H__
+#define __CLUTTER_STAGE_COGL_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib-object.h>
+#include <clutter/clutter-stage.h>
+
+#ifdef COGL_HAS_X11_SUPPORT
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include "../x11/clutter-stage-x11.h"
+#endif
+
+#include "clutter-backend-cogl.h"
+
+G_BEGIN_DECLS
+
+#define CLUTTER_TYPE_STAGE_COGL (_clutter_stage_cogl_get_type ())
+#define CLUTTER_STAGE_COGL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STAGE_COGL, ClutterStageCogl))
+#define CLUTTER_IS_STAGE_COGL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_STAGE_COGL))
+#define CLUTTER_STAGE_COGL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_STAGE_COGL, ClutterStageCoglClass))
+#define CLUTTER_IS_STAGE_COGL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_STAGE_COGL))
+#define CLUTTER_STAGE_COGL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_STAGE_COGL, ClutterStageCoglClass))
+
+typedef struct _ClutterStageCogl ClutterStageCogl;
+typedef struct _ClutterStageCoglClass ClutterStageCoglClass;
+
+struct _ClutterStageCogl
+{
+#ifdef COGL_HAS_X11_SUPPORT
+
+ ClutterStageX11 parent_instance;
+
+#else
+
+ GObject parent_instance;
+
+ /* the stage wrapper */
+ ClutterStage *wrapper;
+
+ /* back pointer to the backend */
+ ClutterBackendCogl *backend;
+
+#endif
+
+ CoglOnscreen *onscreen;
+
+ gint pending_swaps;
+ unsigned int swap_callback_id;
+
+ /* We only enable clipped redraws after 2 frames, since we've seen
+ * a lot of drivers can struggle to get going and may output some
+ * junk frames to start with. */
+ unsigned long frame_count;
+
+ ClutterGeometry bounding_redraw_clip;
+
+ guint initialized_redraw_clip : 1;
+};
+
+struct _ClutterStageCoglClass
+{
+#ifdef COGL_HAS_X11_SUPPORT
+ ClutterStageX11Class parent_class;
+#else
+ GObjectClass parent_class;
+#endif
+};
+
+GType _clutter_stage_cogl_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __CLUTTER_STAGE_COGL_H__ */
diff --git a/configure.ac b/configure.ac
index cdba2a7..b6bc378 100644
--- a/configure.ac
+++ b/configure.ac
@@ -207,7 +207,7 @@ AS_CASE([$CLUTTER_FLAVOUR],
SUPPORT_XLIB=1
SUPPORT_GLX=1
- CLUTTER_WINSYS=glx
+ CLUTTER_WINSYS=cogl
CLUTTER_WINSYS_BASE=x11
CLUTTER_WINSYS_BASE_LIB="x11/libclutter-x11.la"
CLUTTER_SONAME_INFIX=glx
@@ -238,7 +238,7 @@ AS_CASE([$CLUTTER_FLAVOUR],
SUPPORT_EGL=1
SUPPORT_EGL_PLATFORM_POWERVR_X11=1
- CLUTTER_WINSYS=egl
+ CLUTTER_WINSYS=cogl
CLUTTER_WINSYS_BASE=x11
CLUTTER_WINSYS_BASE_LIB="x11/libclutter-x11.la"
# I think this winsys can be API and ABI compatible with the
@@ -275,7 +275,7 @@ AS_CASE([$CLUTTER_FLAVOUR],
SUPPORT_EGL=1
SUPPORT_EGL_PLATFORM_POWERVR_X11=1
- CLUTTER_WINSYS=egl
+ CLUTTER_WINSYS=cogl
CLUTTER_WINSYS_BASE=x11
CLUTTER_WINSYS_BASE_LIB="x11/libclutter-x11.la"
CLUTTER_SONAME_INFIX=eglx
@@ -310,7 +310,7 @@ AS_CASE([$CLUTTER_FLAVOUR],
FLAVOUR_LIBS="$FLAVOUR_LIBS $TSLIB_LIBS $EVDEV_LIBS"
FLAVOUR_CFLAGS="$FLAVOUR_CFLAGS $TSLIB_CFLAGS $EVDEV_CFLAGS"
- CLUTTER_WINSYS=egl
+ CLUTTER_WINSYS=cogl
CLUTTER_SONAME_INFIX=eglnative
],
@@ -323,7 +323,7 @@ AS_CASE([$CLUTTER_FLAVOUR],
SUPPORT_EGL_PLATFORM_GDL=1
# The cex100 is a small specialization of the EGL backend
- CLUTTER_WINSYS=egl
+ CLUTTER_WINSYS=cogl
CLUTTER_SONAME_INFIX=cex100
found_gdl=no
@@ -939,7 +939,7 @@ AC_CONFIG_FILES([
clutter/cally/cally-$CLUTTER_API_VERSION.pc:clutter/cally/cally.pc.in
- clutter/egl/clutter-cex100.h
+ clutter/cogl/clutter-cex100.h
tests/Makefile
tests/accessibility/Makefile
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]