2007-03-22 14:21:59 -04:00
|
|
|
/* Clutter.
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Copyright (C) 2006-2007 OpenedHand
|
|
|
|
*
|
|
|
|
* 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, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2009-01-06 07:11:07 -05:00
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
#include "clutter-backend-glx.h"
|
|
|
|
#include "clutter-stage-glx.h"
|
2007-05-16 05:08:30 -04:00
|
|
|
#include "clutter-glx.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
#include "../clutter-event.h"
|
|
|
|
#include "../clutter-main.h"
|
|
|
|
#include "../clutter-debug.h"
|
|
|
|
#include "../clutter-private.h"
|
2008-03-31 13:15:02 -04:00
|
|
|
#include "../clutter-version.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
#include "cogl/cogl.h"
|
2007-05-16 05:08:30 -04:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
G_DEFINE_TYPE (ClutterBackendGLX, clutter_backend_glx, CLUTTER_TYPE_BACKEND_X11);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
/* singleton object */
|
2007-05-31 07:13:43 -04:00
|
|
|
static ClutterBackendGLX *backend_singleton = NULL;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
static gchar *clutter_vblank_name = NULL;
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
#define DRM_VBLANK_RELATIVE 0x1;
|
|
|
|
|
|
|
|
struct drm_wait_vblank_request {
|
|
|
|
int type;
|
|
|
|
unsigned int sequence;
|
|
|
|
unsigned long signal;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_wait_vblank_reply {
|
|
|
|
int type;
|
|
|
|
unsigned int sequence;
|
|
|
|
long tval_sec;
|
|
|
|
long tval_usec;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef union drm_wait_vblank {
|
|
|
|
struct drm_wait_vblank_request request;
|
|
|
|
struct drm_wait_vblank_reply reply;
|
|
|
|
} drm_wait_vblank_t;
|
|
|
|
|
|
|
|
#define DRM_IOCTL_BASE 'd'
|
|
|
|
#define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type)
|
|
|
|
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t)
|
|
|
|
|
|
|
|
static int drm_wait_vblank(int fd, drm_wait_vblank_t *vbl)
|
|
|
|
{
|
|
|
|
int ret, rc;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2008-01-31 18:10:30 -05:00
|
|
|
ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
|
|
|
|
vbl->request.type &= ~DRM_VBLANK_RELATIVE;
|
|
|
|
rc = errno;
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
while (ret && rc == EINTR);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
G_CONST_RETURN gchar*
|
|
|
|
clutter_backend_glx_get_vblank_method (void)
|
|
|
|
{
|
|
|
|
return clutter_vblank_name;
|
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_pre_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
const gchar *env_string;
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
env_string = g_getenv ("CLUTTER_VBLANK");
|
|
|
|
if (env_string)
|
|
|
|
{
|
|
|
|
clutter_vblank_name = g_strdup (env_string);
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
return clutter_backend_x11_pre_parse (backend, error);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_post_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
2007-11-15 09:45:27 -05:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
int glx_major, glx_minor;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
if (clutter_backend_x11_post_parse (backend, error))
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
2007-11-15 09:45:27 -05:00
|
|
|
if (!glXQueryVersion (backend_x11->xdpy, &glx_major, &glx_minor)
|
2008-01-31 18:10:30 -05:00
|
|
|
|| !(glx_major > 1 || glx_minor > 1))
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
"XServer appears to lack required GLX support");
|
2008-10-31 08:48:26 -04:00
|
|
|
|
|
|
|
return FALSE;
|
2008-01-31 18:10:30 -05:00
|
|
|
}
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
2008-10-31 08:48:26 -04:00
|
|
|
else
|
|
|
|
return FALSE;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GOptionEntry entries[] =
|
|
|
|
{
|
2007-05-16 05:08:30 -04:00
|
|
|
{ "vblank", 0,
|
2007-07-05 07:05:46 -04:00
|
|
|
0,
|
2007-05-16 05:08:30 -04:00
|
|
|
G_OPTION_ARG_STRING, &clutter_vblank_name,
|
2009-01-06 07:11:07 -05:00
|
|
|
N_("VBlank method to be used (none, dri or glx)"), "METHOD"
|
2007-05-16 05:08:30 -04:00
|
|
|
},
|
2007-03-22 14:21:59 -04:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_add_options (ClutterBackend *backend,
|
|
|
|
GOptionGroup *group)
|
|
|
|
{
|
|
|
|
g_option_group_add_entries (group, entries);
|
2007-11-15 09:45:27 -05:00
|
|
|
clutter_backend_x11_add_options (backend, group);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
if (backend_singleton)
|
|
|
|
backend_singleton = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_backend_glx_parent_class)->finalize (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_glx_dispose (GObject *gobject)
|
|
|
|
{
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (gobject);
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (gobject);
|
|
|
|
|
2008-05-13 06:42:36 -04:00
|
|
|
/* Unrealize all shaders, since the GL context is going away */
|
|
|
|
_clutter_shader_release_all ();
|
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
if (backend_glx->gl_context)
|
|
|
|
{
|
|
|
|
glXDestroyContext (backend_x11->xdpy, backend_glx->gl_context);
|
|
|
|
backend_glx->gl_context = None;
|
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
G_OBJECT_CLASS (clutter_backend_glx_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
clutter_backend_glx_constructor (GType gtype,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObjectClass *parent_class;
|
|
|
|
GObject *retval;
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
parent_class = G_OBJECT_CLASS (clutter_backend_glx_parent_class);
|
|
|
|
retval = parent_class->constructor (gtype, n_params, params);
|
|
|
|
|
|
|
|
backend_singleton = CLUTTER_BACKEND_GLX (retval);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warning ("Attempting to create a new backend object. This should "
|
|
|
|
"never happen, so we return the singleton instance.");
|
|
|
|
|
|
|
|
return g_object_ref (backend_singleton);
|
|
|
|
}
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
static gboolean
|
|
|
|
check_vblank_env (const char *name)
|
|
|
|
{
|
2009-05-25 07:42:17 -04:00
|
|
|
if (clutter_vblank_name && !g_ascii_strcasecmp (clutter_vblank_name, name))
|
2007-05-16 05:08:30 -04:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ClutterFeatureFlags
|
|
|
|
clutter_backend_glx_get_features (ClutterBackend *backend)
|
|
|
|
{
|
2007-05-31 07:13:43 -04:00
|
|
|
ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend);
|
2007-05-16 05:08:30 -04:00
|
|
|
const gchar *glx_extensions = NULL;
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterFeatureFlags flags;
|
|
|
|
|
|
|
|
flags = clutter_backend_x11_get_features (backend);
|
|
|
|
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
|
2007-05-16 05:08:30 -04:00
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
/* this will make sure that the GL context exists and
|
|
|
|
* it's bound to a drawable
|
2008-04-02 23:04:41 -04:00
|
|
|
*/
|
|
|
|
g_assert (backend_glx->gl_context != None);
|
|
|
|
g_assert (glXGetCurrentDrawable () != None);
|
2007-05-16 05:08:30 -04:00
|
|
|
|
2007-06-14 08:54:47 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Checking features\n"
|
2008-01-31 18:10:30 -05:00
|
|
|
"GL_VENDOR: %s\n"
|
|
|
|
"GL_RENDERER: %s\n"
|
|
|
|
"GL_VERSION: %s\n"
|
|
|
|
"GL_EXTENSIONS: %s\n",
|
|
|
|
glGetString (GL_VENDOR),
|
|
|
|
glGetString (GL_RENDERER),
|
|
|
|
glGetString (GL_VERSION),
|
|
|
|
glGetString (GL_EXTENSIONS));
|
2007-06-14 08:54:47 -04:00
|
|
|
|
2007-07-05 07:05:46 -04:00
|
|
|
glx_extensions =
|
2007-11-15 09:45:27 -05:00
|
|
|
glXQueryExtensionsString (clutter_x11_get_default_display (),
|
|
|
|
clutter_x11_get_default_screen ());
|
2007-05-16 05:08:30 -04:00
|
|
|
|
2007-06-14 08:54:47 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "GLX Extensions: %s", glx_extensions);
|
|
|
|
|
|
|
|
/* First check for explicit disabling or it set elsewhere (eg NVIDIA) */
|
2007-05-16 05:08:30 -04:00
|
|
|
if (getenv("__GL_SYNC_TO_VBLANK") || check_vblank_env ("none"))
|
|
|
|
{
|
2007-06-14 08:54:47 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "vblank sync: disabled at user request");
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-14 08:54:47 -04:00
|
|
|
/* We try two GL vblank syncing mechanisms.
|
|
|
|
* glXSwapIntervalSGI is tried first, then glXGetVideoSyncSGI.
|
|
|
|
*
|
|
|
|
* glXSwapIntervalSGI is known to work with Mesa and in particular
|
|
|
|
* the Intel drivers. glXGetVideoSyncSGI has serious problems with
|
|
|
|
* Intel drivers causing terrible frame rate so it only tried as a
|
|
|
|
* fallback.
|
|
|
|
*
|
|
|
|
* How well glXGetVideoSyncSGI works with other driver (ATI etc) needs
|
|
|
|
* to be investigated. glXGetVideoSyncSGI on ATI at least seems to have
|
|
|
|
* no effect.
|
|
|
|
*/
|
|
|
|
if (!check_vblank_env ("dri") &&
|
2008-01-31 18:10:30 -05:00
|
|
|
cogl_check_extension ("GLX_SGI_swap_control", glx_extensions))
|
|
|
|
{
|
|
|
|
backend_glx->swap_interval =
|
|
|
|
(SwapIntervalProc) cogl_get_proc_address ("glXSwapIntervalSGI");
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "attempting glXSwapIntervalSGI vblank setup");
|
|
|
|
|
|
|
|
if (backend_glx->swap_interval != NULL)
|
|
|
|
{
|
|
|
|
if (backend_glx->swap_interval (1) == 0)
|
|
|
|
{
|
|
|
|
backend_glx->vblank_type = CLUTTER_VBLANK_GLX_SWAP;
|
|
|
|
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
CLUTTER_NOTE (BACKEND, "glXSwapIntervalSGI setup success");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
|
|
|
|
CLUTTER_NOTE (BACKEND, "glXSwapIntervalSGI vblank setup failed");
|
|
|
|
}
|
2007-06-14 08:54:47 -04:00
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
if (!check_vblank_env ("dri") &&
|
2008-01-31 18:10:30 -05:00
|
|
|
!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK) &&
|
|
|
|
cogl_check_extension ("GLX_SGI_video_sync", glx_extensions))
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "attempting glXGetVideoSyncSGI vblank setup");
|
|
|
|
|
|
|
|
backend_glx->get_video_sync =
|
|
|
|
(GetVideoSyncProc) cogl_get_proc_address ("glXGetVideoSyncSGI");
|
|
|
|
|
|
|
|
backend_glx->wait_video_sync =
|
|
|
|
(WaitVideoSyncProc) cogl_get_proc_address ("glXWaitVideoSyncSGI");
|
|
|
|
|
|
|
|
if ((backend_glx->get_video_sync != NULL) &&
|
|
|
|
(backend_glx->wait_video_sync != NULL))
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"glXGetVideoSyncSGI vblank setup success");
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
backend_glx->vblank_type = CLUTTER_VBLANK_GLX;
|
2008-01-31 18:10:30 -05:00
|
|
|
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
}
|
2007-06-14 08:54:47 -04:00
|
|
|
|
2008-01-31 18:10:30 -05:00
|
|
|
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
|
|
|
|
CLUTTER_NOTE (BACKEND, "glXGetVideoSyncSGI vblank setup failed");
|
|
|
|
}
|
2007-05-16 05:08:30 -04:00
|
|
|
#ifdef __linux__
|
2007-06-14 08:54:47 -04:00
|
|
|
/*
|
|
|
|
* DRI is really an extreme fallback -rumoured to work with Via chipsets
|
|
|
|
*/
|
2007-05-16 05:08:30 -04:00
|
|
|
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
|
2008-01-31 18:10:30 -05:00
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "attempting DRI vblank setup");
|
|
|
|
backend_glx->dri_fd = open("/dev/dri/card0", O_RDWR);
|
|
|
|
if (backend_glx->dri_fd >= 0)
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "DRI vblank setup success");
|
|
|
|
backend_glx->vblank_type = CLUTTER_VBLANK_DRI;
|
|
|
|
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
|
|
|
|
CLUTTER_NOTE (BACKEND, "DRI vblank setup failed");
|
|
|
|
}
|
2007-05-16 05:08:30 -04:00
|
|
|
#endif
|
|
|
|
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
|
|
|
|
{
|
2007-06-14 08:54:47 -04:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"no use-able vblank mechanism found");
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CLUTTER_NOTE (MISC, "backend features checked");
|
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
return flags;
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
|
2009-05-13 17:21:48 -04:00
|
|
|
static gboolean
|
|
|
|
clutter_backend_glx_create_context (ClutterBackend *backend,
|
|
|
|
gboolean is_offscreen,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend);
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
|
|
|
|
if (backend_glx->gl_context == None)
|
|
|
|
{
|
|
|
|
XVisualInfo *xvisinfo;
|
|
|
|
|
|
|
|
xvisinfo =
|
|
|
|
clutter_backend_x11_get_visual_info (backend_x11, is_offscreen);
|
|
|
|
|
|
|
|
CLUTTER_NOTE (GL, "Creating GL Context (display: %p, %s)",
|
|
|
|
backend_x11->xdpy,
|
|
|
|
is_offscreen ? "offscreen" : "onscreen");
|
|
|
|
|
|
|
|
backend_glx->gl_context = glXCreateContext (backend_x11->xdpy,
|
|
|
|
xvisinfo,
|
|
|
|
0,
|
|
|
|
is_offscreen ? False : True);
|
|
|
|
|
|
|
|
XFree (xvisinfo);
|
|
|
|
|
|
|
|
if (backend_glx->gl_context == None)
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
"Unable to create suitable %s GL context",
|
|
|
|
is_offscreen ? "offscreen" : "onscreen");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_offscreen)
|
|
|
|
{
|
|
|
|
gboolean is_direct;
|
|
|
|
|
|
|
|
is_direct = glXIsDirect (backend_x11->xdpy,
|
|
|
|
backend_glx->gl_context);
|
|
|
|
|
|
|
|
CLUTTER_NOTE (GL, "Setting %s context",
|
|
|
|
is_direct ? "direct" : "indirect");
|
|
|
|
_cogl_set_indirect_context (!is_direct);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-05-28 14:49:34 -04:00
|
|
|
static void
|
2008-03-28 18:50:55 -04:00
|
|
|
clutter_backend_glx_ensure_context (ClutterBackend *backend,
|
|
|
|
ClutterStage *stage)
|
2007-05-28 14:49:34 -04:00
|
|
|
{
|
2008-04-01 10:04:46 -04:00
|
|
|
if (stage == NULL)
|
|
|
|
{
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterBackendX11 *backend_x11;
|
|
|
|
|
|
|
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2008-04-01 10:04:46 -04:00
|
|
|
CLUTTER_NOTE (MULTISTAGE, "Clearing all context");
|
2008-03-28 18:50:55 -04:00
|
|
|
|
2008-04-01 10:04:46 -04:00
|
|
|
glXMakeCurrent (backend_x11->xdpy, None, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterBackendGLX *backend_glx;
|
|
|
|
ClutterStageGLX *stage_glx;
|
|
|
|
ClutterStageX11 *stage_x11;
|
|
|
|
ClutterStageWindow *impl;
|
|
|
|
|
|
|
|
impl = _clutter_stage_get_window (stage);
|
|
|
|
g_assert (impl != NULL);
|
|
|
|
|
|
|
|
CLUTTER_NOTE (MULTISTAGE, "Setting context for stage of type %s [%p]",
|
|
|
|
g_type_name (G_OBJECT_TYPE (impl)),
|
|
|
|
impl);
|
|
|
|
|
|
|
|
stage_glx = CLUTTER_STAGE_GLX (impl);
|
|
|
|
stage_x11 = CLUTTER_STAGE_X11 (impl);
|
|
|
|
backend_glx = CLUTTER_BACKEND_GLX (backend);
|
2008-04-01 10:04:46 -04:00
|
|
|
|
2008-04-04 13:26:26 -04:00
|
|
|
/* no GL context to set */
|
|
|
|
if (backend_glx->gl_context == None)
|
|
|
|
return;
|
2008-03-28 18:50:55 -04:00
|
|
|
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 11:26:37 -04:00
|
|
|
clutter_x11_trap_x_errors ();
|
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
/* we might get here inside the final dispose cycle, so we
|
|
|
|
* need to handle this gracefully
|
|
|
|
*/
|
|
|
|
if (stage_x11->xwin == None)
|
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11;
|
|
|
|
|
|
|
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
CLUTTER_NOTE (MULTISTAGE,
|
|
|
|
"Received a stale stage, clearing all context");
|
2008-04-01 10:04:46 -04:00
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
glXMakeCurrent (backend_x11->xdpy, None, NULL);
|
|
|
|
}
|
|
|
|
else
|
2008-04-04 13:26:26 -04:00
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"MakeCurrent dpy: %p, window: 0x%x (%s), context: %p",
|
|
|
|
stage_x11->xdpy,
|
|
|
|
(int) stage_x11->xwin,
|
|
|
|
stage_x11->is_foreign_xwin ? "foreign" : "native",
|
2008-04-04 11:02:11 -04:00
|
|
|
backend_glx->gl_context);
|
2008-04-04 13:26:26 -04:00
|
|
|
|
|
|
|
glXMakeCurrent (stage_x11->xdpy,
|
|
|
|
stage_x11->xwin,
|
|
|
|
backend_glx->gl_context);
|
|
|
|
}
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 11:26:37 -04:00
|
|
|
|
|
|
|
if (clutter_x11_untrap_x_errors ())
|
|
|
|
g_critical ("Unable to make the stage window 0x%x the current "
|
|
|
|
"GLX drawable",
|
|
|
|
(int) stage_x11->xwin);
|
2008-04-01 10:04:46 -04:00
|
|
|
}
|
2008-03-28 18:50:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-04 11:02:11 -04:00
|
|
|
clutter_backend_glx_redraw (ClutterBackend *backend,
|
|
|
|
ClutterStage *stage)
|
2008-03-28 18:50:55 -04:00
|
|
|
{
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterStageGLX *stage_glx;
|
|
|
|
ClutterStageX11 *stage_x11;
|
|
|
|
ClutterStageWindow *impl;
|
|
|
|
|
|
|
|
impl = _clutter_stage_get_window (stage);
|
2009-05-13 16:49:45 -04:00
|
|
|
if (G_UNLIKELY (impl == NULL))
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Stage [%p] has no implementation", stage);
|
|
|
|
return;
|
|
|
|
}
|
2008-04-04 11:02:11 -04:00
|
|
|
|
|
|
|
g_assert (CLUTTER_IS_STAGE_GLX (impl));
|
2008-03-28 18:50:55 -04:00
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
stage_x11 = CLUTTER_STAGE_X11 (impl);
|
|
|
|
stage_glx = CLUTTER_STAGE_GLX (impl);
|
2007-05-28 14:49:34 -04:00
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
/* this will cause the stage implementation to be painted */
|
|
|
|
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
[cogl] Improving Cogl journal to minimize driver overheads + GPU state changes
Previously the journal was always flushed at the end of
_cogl_rectangles_with_multitexture_coords, (i.e. the end of any
cogl_rectangle* calls) but now we have broadened the potential for batching
geometry. In ideal circumstances we will only flush once per scene.
In summary the journal works like this:
When you use any of the cogl_rectangle* APIs then nothing is emitted to the
GPU at this point, we just log one or more quads into the journal. A
journal entry consists of the quad coordinates, an associated material
reference, and a modelview matrix. Ideally the journal only gets flushed
once at the end of a scene, but in fact there are things to consider that
may cause unwanted flushing, including:
- modifying materials mid-scene
This is because each quad in the journal has an associated material
reference (i.e. not copy), so if you try and modify a material that is
already referenced in the journal we force a flush first)
NOTE: For now this means you should avoid using cogl_set_source_color()
since that currently uses a single shared material. Later we
should change it to use a pool of materials that is recycled
when the journal is flushed.
- modifying any state that isn't currently logged, such as depth, fog and
backface culling enables.
The first thing that happens when flushing, is to upload all the vertex data
associated with the journal into a single VBO.
We then go through a process of splitting up the journal into batches that
have compatible state so they can be emitted to the GPU together. This is
currently broken up into 3 levels so we can stagger the state changes:
1) we break the journal up according to changes in the number of material layers
associated with logged quads. The number of layers in a material determines
the stride of the associated vertices, so we have to update our vertex
array offsets at this level. (i.e. calling gl{Vertex,Color},Pointer etc)
2) we further split batches up according to material compatability. (e.g.
materials with different textures) We flush material state at this level.
3) Finally we split batches up according to modelview changes. At this level
we update the modelview matrix and actually emit the actual draw command.
This commit is largely about putting the initial design in-place; this will be
followed by other changes that take advantage of the extended batching.
2009-06-17 13:46:42 -04:00
|
|
|
_cogl_flush ();
|
2007-05-28 14:49:34 -04:00
|
|
|
|
2009-05-13 16:49:45 -04:00
|
|
|
if (stage_x11->xwin != None)
|
2007-05-28 14:49:34 -04:00
|
|
|
{
|
2009-05-13 16:49:45 -04:00
|
|
|
/* wait for the next vblank */
|
|
|
|
CLUTTER_NOTE (BACKEND, "Waiting for vblank");
|
2008-04-04 11:02:11 -04:00
|
|
|
clutter_backend_glx_wait_for_vblank (CLUTTER_BACKEND_GLX (backend));
|
2009-05-13 16:49:45 -04:00
|
|
|
|
|
|
|
/* push on the screen */
|
|
|
|
CLUTTER_NOTE (BACKEND, "glXSwapBuffers (display: %p, window: 0x%lx)",
|
|
|
|
stage_x11->xdpy,
|
|
|
|
(unsigned long) stage_x11->xwin);
|
2007-11-15 09:45:27 -05:00
|
|
|
glXSwapBuffers (stage_x11->xdpy, stage_x11->xwin);
|
2007-05-28 14:49:34 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* offscreen */
|
|
|
|
glXWaitGL ();
|
2009-05-13 16:49:45 -04:00
|
|
|
|
2007-05-28 14:49:34 -04:00
|
|
|
CLUTTER_GLERR ();
|
|
|
|
}
|
2007-11-15 09:45:27 -05:00
|
|
|
}
|
2007-05-28 14:49:34 -04:00
|
|
|
|
2009-05-13 17:21:48 -04:00
|
|
|
static ClutterActor *
|
2008-03-28 18:50:55 -04:00
|
|
|
clutter_backend_glx_create_stage (ClutterBackend *backend,
|
2008-04-04 11:02:11 -04:00
|
|
|
ClutterStage *wrapper,
|
2008-03-28 18:50:55 -04:00
|
|
|
GError **error)
|
2007-11-15 09:45:27 -05:00
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
2008-03-28 18:50:55 -04:00
|
|
|
ClutterStageX11 *stage_x11;
|
|
|
|
ClutterActor *stage;
|
2007-11-15 09:45:27 -05:00
|
|
|
|
2009-03-17 10:12:01 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Creating stage of type '%s'",
|
2008-04-04 11:02:11 -04:00
|
|
|
g_type_name (CLUTTER_STAGE_TYPE));
|
|
|
|
|
2008-05-12 Emmanuele Bassi <ebassi@openedhand.com>
Rework the stage wrapper/implementation relation: remove
duplicated code and all the bookkeeping from the backends into
ClutterStage whenever possible, to reduce the amount of work a
backend must do (and possibly get wrong). Thanks to Tommi
Komulainen.
* clutter/clutter-main.c:
(clutter_init_with_args), (clutter_init): Realize the default
stage after creation. The default stage is special, because we
use it in the initialization sequence. This removes the burden
from the backends and reduces the things a backend can get
wrong.
* clutter/clutter-stage.c:
(clutter_stage_show): Make sure to realize the implementation if
it hasn't been realized yet.
(clutter_stage_realize): Set the REALIZED flag and call
clutter_stage_ensure_current() if the implementation was
successfully realized.
(clutter_stage_unrealized): Call clutter_stage_ensure_current()
on unrealize.
* clutter/glx/clutter-backend-glx.c:
(clutter_backend_glx_create_stage): Do not realize the stage anymore
when creating it, and let the normal realization sequence take
place.
(clutter_backend_glx_ensure_context): Trap for X11 errors.
* clutter/glx/clutter-stage-glx.c:
(clutter_stage_glx_realize): Chain up to the X11 implementation
so that we can set up the window state (title, cursor visibility)
when we actually have a X window. Also, do not call
clutter_stage_ensure_current(), and rely on the wrapper to do
it for us. This means we can drop setting the REALIZED flag on
the wrapper.
(clutter_stage_glx_unrealize): Do not call
clutter_stage_ensure_current() ourselves, and rely on the wrapper
to do it for us.
* clutter/x11/clutter-stage-x11.c:
(set_wm_title), (set_cursor_visible): Move the WM title and
cursor visibility code inside their own functions.
(clutter_stage_x11_realize): Set the window title and whether the
cursor is visible or not after realizing the stage.
(clutter_stage_x11_set_cursor_visible),
(clutter_stage_x11_set_title): Call set_wm_title() and
set_cursor_visible().
(clutter_stage_x11_finalize): Free the title string.
* clutter/x11/clutter-stage-x11.h: Save more of the stage state,
so that we can set it even when the stage hasn't been realized
yet.
* clutter/eglnative/clutter-backend-egl.c:
(clutter_backend_egl_create_stage):
* clutter/eglnative/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglnative backend.
* clutter/eglx/clutter-backend-egl.c:
(clutter_backend_egl_ensure_context),
(clutter_backend_egl_create_stage):
* clutter/eglx/clutter-stage-egl.c:
(clutter_stage_egl_unrealize),
(clutter_stage_egl_realize): Update the eglx backend.
* clutter/sdl/clutter-backend-sdl.c:
(clutter_backend_sdl_create_stage):
* clutter/sdl/clutter-stage-sdl.c:
(clutter_stage_sdl_realize): Update the sdl backend.
* clutter/fruity/clutter-backend-fruity.c:
(clutter_backend_fruity_create_stage):
* clutter/sdl/clutter-stage-fruity.c:
(clutter_stage_fruity_realize): Update the fruity backend.
* tests/test-multistage.c (on_button_press): Bail out if
clutter_stage_new() returns NULL.
* HACKING.backends: Update backend writing documentation.
2008-05-12 11:26:37 -04:00
|
|
|
stage = g_object_new (CLUTTER_TYPE_STAGE_GLX, NULL);
|
2007-11-15 09:45:27 -05:00
|
|
|
|
2008-03-28 18:50:55 -04:00
|
|
|
/* copy backend data into the stage */
|
|
|
|
stage_x11 = CLUTTER_STAGE_X11 (stage);
|
|
|
|
stage_x11->xdpy = backend_x11->xdpy;
|
|
|
|
stage_x11->xwin_root = backend_x11->xwin_root;
|
|
|
|
stage_x11->xscreen = backend_x11->xscreen_num;
|
|
|
|
stage_x11->backend = backend_x11;
|
2008-04-04 11:02:11 -04:00
|
|
|
stage_x11->wrapper = wrapper;
|
|
|
|
|
2009-05-08 12:17:48 -04:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"GLX stage created[%p] (dpy:%p, screen:%d, root:%u, wrap:%p)",
|
|
|
|
stage,
|
2008-03-28 18:50:55 -04:00
|
|
|
stage_x11->xdpy,
|
|
|
|
stage_x11->xscreen,
|
2009-05-08 12:17:48 -04:00
|
|
|
(unsigned int) stage_x11->xwin_root,
|
|
|
|
wrapper);
|
2007-11-15 09:45:27 -05:00
|
|
|
|
2008-03-28 18:50:55 -04:00
|
|
|
return stage;
|
2007-05-28 14:49:34 -04:00
|
|
|
}
|
|
|
|
|
2009-05-13 16:49:45 -04:00
|
|
|
static XVisualInfo *
|
|
|
|
clutter_backend_glx_get_visual_info (ClutterBackendX11 *backend_x11,
|
|
|
|
gboolean for_offscreen)
|
|
|
|
{
|
|
|
|
XVisualInfo *xvisinfo;
|
|
|
|
int onscreen_gl_attributes[] = {
|
|
|
|
GLX_RGBA,
|
|
|
|
GLX_DOUBLEBUFFER,
|
|
|
|
GLX_RED_SIZE, 1,
|
|
|
|
GLX_GREEN_SIZE, 1,
|
|
|
|
GLX_BLUE_SIZE, 1,
|
|
|
|
GLX_STENCIL_SIZE, 1,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
int offscreen_gl_attributes[] = {
|
|
|
|
GLX_RGBA,
|
|
|
|
GLX_USE_GL,
|
|
|
|
GLX_DEPTH_SIZE, 0,
|
|
|
|
GLX_ALPHA_SIZE, 0,
|
|
|
|
GLX_STENCIL_SIZE, 1,
|
|
|
|
GLX_RED_SIZE, 1,
|
|
|
|
GLX_GREEN_SIZE, 1,
|
|
|
|
GLX_BLUE_SIZE, 1,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (backend_x11->xdpy == None || backend_x11->xscreen == None)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"Retrieving GL visual (for %s use), dpy: %p, xscreen; %p (%d)",
|
|
|
|
for_offscreen ? "offscreen" : "onscreen",
|
|
|
|
backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen,
|
|
|
|
backend_x11->xscreen_num);
|
|
|
|
|
|
|
|
xvisinfo = glXChooseVisual (backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num,
|
|
|
|
for_offscreen ? offscreen_gl_attributes
|
|
|
|
: onscreen_gl_attributes);
|
|
|
|
|
|
|
|
return xvisinfo;
|
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
static void
|
2007-05-31 07:13:43 -04:00
|
|
|
clutter_backend_glx_class_init (ClutterBackendGLXClass *klass)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
2009-05-13 16:49:45 -04:00
|
|
|
ClutterBackendX11Class *backendx11_class = CLUTTER_BACKEND_X11_CLASS (klass);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
gobject_class->constructor = clutter_backend_glx_constructor;
|
2008-03-28 18:50:55 -04:00
|
|
|
gobject_class->dispose = clutter_backend_glx_dispose;
|
|
|
|
gobject_class->finalize = clutter_backend_glx_finalize;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2008-04-04 11:02:11 -04:00
|
|
|
backend_class->pre_parse = clutter_backend_glx_pre_parse;
|
|
|
|
backend_class->post_parse = clutter_backend_glx_post_parse;
|
|
|
|
backend_class->create_stage = clutter_backend_glx_create_stage;
|
|
|
|
backend_class->add_options = clutter_backend_glx_add_options;
|
|
|
|
backend_class->get_features = clutter_backend_glx_get_features;
|
|
|
|
backend_class->redraw = clutter_backend_glx_redraw;
|
2009-05-13 17:21:48 -04:00
|
|
|
backend_class->create_context = clutter_backend_glx_create_context;
|
2008-03-28 18:50:55 -04:00
|
|
|
backend_class->ensure_context = clutter_backend_glx_ensure_context;
|
2009-05-13 16:49:45 -04:00
|
|
|
|
|
|
|
backendx11_class->get_visual_info = clutter_backend_glx_get_visual_info;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-31 07:13:43 -04:00
|
|
|
clutter_backend_glx_init (ClutterBackendGLX *backend_glx)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
2008-04-04 11:02:11 -04:00
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* every backend must implement this function */
|
|
|
|
GType
|
|
|
|
_clutter_backend_impl_get_type (void)
|
|
|
|
{
|
|
|
|
return clutter_backend_glx_get_type ();
|
|
|
|
}
|
|
|
|
|
2007-05-16 05:08:30 -04:00
|
|
|
void
|
2007-05-31 07:13:43 -04:00
|
|
|
clutter_backend_glx_wait_for_vblank (ClutterBackendGLX *backend_glx)
|
2007-05-16 05:08:30 -04:00
|
|
|
{
|
|
|
|
switch (backend_glx->vblank_type)
|
|
|
|
{
|
2007-06-14 08:54:47 -04:00
|
|
|
case CLUTTER_VBLANK_GLX_SWAP:
|
|
|
|
{
|
2008-01-31 18:10:30 -05:00
|
|
|
/* Nothing */
|
|
|
|
break;
|
2007-06-14 08:54:47 -04:00
|
|
|
}
|
2007-05-16 05:08:30 -04:00
|
|
|
case CLUTTER_VBLANK_GLX:
|
|
|
|
{
|
2008-01-31 18:10:30 -05:00
|
|
|
unsigned int retraceCount;
|
|
|
|
backend_glx->get_video_sync (&retraceCount);
|
|
|
|
backend_glx->wait_video_sync (2,
|
|
|
|
(retraceCount + 1) % 2,
|
|
|
|
&retraceCount);
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CLUTTER_VBLANK_DRI:
|
|
|
|
#ifdef __linux__
|
|
|
|
{
|
2008-01-31 18:10:30 -05:00
|
|
|
drm_wait_vblank_t blank;
|
|
|
|
blank.request.type = DRM_VBLANK_RELATIVE;
|
|
|
|
blank.request.sequence = 1;
|
|
|
|
blank.request.signal = 0;
|
|
|
|
drm_wait_vblank (backend_glx->dri_fd, &blank);
|
2007-05-16 05:08:30 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case CLUTTER_VBLANK_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|