2008-01-31 Rob Bradford <rob@openedhand.com>

* clutter/glx/clutter-stage-glx.c:
	* clutter/glx/clutter-backend-glx.c:
	* clutter/glx/clutter-backend-glx.h:
	Fix formatting.
This commit is contained in:
Robert Bradford 2008-01-31 23:10:30 +00:00
parent adf89a2e17
commit 756d2223da
4 changed files with 203 additions and 195 deletions

View File

@ -1,3 +1,10 @@
2008-01-31 Rob Bradford <rob@openedhand.com>
* clutter/glx/clutter-stage-glx.c:
* clutter/glx/clutter-backend-glx.c:
* clutter/glx/clutter-backend-glx.h:
Fix formatting.
2008-01-31 Emmanuele Bassi <ebassi@sprite>
* clutter/clutter-timeline.c (clutter_timeline_skip): Don't

View File

@ -86,9 +86,9 @@ static int drm_wait_vblank(int fd, drm_wait_vblank_t *vbl)
do
{
ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
vbl->request.type &= ~DRM_VBLANK_RELATIVE;
rc = errno;
ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
vbl->request.type &= ~DRM_VBLANK_RELATIVE;
rc = errno;
}
while (ret && rc == EINTR);
@ -129,13 +129,13 @@ clutter_backend_glx_post_parse (ClutterBackend *backend,
if (clutter_backend_x11_post_parse (backend, error))
{
if (!glXQueryVersion (backend_x11->xdpy, &glx_major, &glx_minor)
|| !(glx_major > 1 || glx_minor > 1))
{
g_set_error (error, CLUTTER_INIT_ERROR,
CLUTTER_INIT_ERROR_BACKEND,
"XServer appears to lack required GLX support");
return 1;
}
|| !(glx_major > 1 || glx_minor > 1))
{
g_set_error (error, CLUTTER_INIT_ERROR,
CLUTTER_INIT_ERROR_BACKEND,
"XServer appears to lack required GLX support");
return 1;
}
}
return TRUE;
@ -218,14 +218,14 @@ clutter_backend_glx_get_features (ClutterBackend *backend)
/* FIXME: we really need to check if gl context is set */
CLUTTER_NOTE (BACKEND, "Checking features\n"
"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));
"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));
glx_extensions =
glXQueryExtensionsString (clutter_x11_get_default_display (),
@ -253,70 +253,70 @@ clutter_backend_glx_get_features (ClutterBackend *backend)
* no effect.
*/
if (!check_vblank_env ("dri") &&
cogl_check_extension ("GLX_SGI_swap_control", glx_extensions))
{
backend_glx->swap_interval =
(SwapIntervalProc) cogl_get_proc_address ("glXSwapIntervalSGI");
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");
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 (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");
}
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
CLUTTER_NOTE (BACKEND, "glXSwapIntervalSGI vblank setup failed");
}
if (!check_vblank_env ("dri") &&
!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK) &&
cogl_check_extension ("GLX_SGI_video_sync", glx_extensions))
{
CLUTTER_NOTE (BACKEND, "attempting glXGetVideoSyncSGI vblank setup");
!(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->get_video_sync =
(GetVideoSyncProc) cogl_get_proc_address ("glXGetVideoSyncSGI");
backend_glx->wait_video_sync =
(WaitVideoSyncProc) cogl_get_proc_address ("glXWaitVideoSyncSGI");
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");
if ((backend_glx->get_video_sync != NULL) &&
(backend_glx->wait_video_sync != NULL))
{
CLUTTER_NOTE (BACKEND,
"glXGetVideoSyncSGI vblank setup success");
backend_glx->vblank_type = CLUTTER_VBLANK_GLX;
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
}
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
}
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
CLUTTER_NOTE (BACKEND, "glXGetVideoSyncSGI vblank setup failed");
}
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
CLUTTER_NOTE (BACKEND, "glXGetVideoSyncSGI vblank setup failed");
}
#ifdef __linux__
/*
* DRI is really an extreme fallback -rumoured to work with Via chipsets
*/
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
{
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;
}
{
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");
}
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
CLUTTER_NOTE (BACKEND, "DRI vblank setup failed");
}
#endif
if (!(flags & CLUTTER_FEATURE_SYNC_TO_VBLANK))
{
@ -440,26 +440,26 @@ clutter_backend_glx_wait_for_vblank (ClutterBackendGLX *backend_glx)
{
case CLUTTER_VBLANK_GLX_SWAP:
{
/* Nothing */
break;
/* Nothing */
break;
}
case CLUTTER_VBLANK_GLX:
{
unsigned int retraceCount;
backend_glx->get_video_sync (&retraceCount);
backend_glx->wait_video_sync (2,
(retraceCount + 1) % 2,
&retraceCount);
unsigned int retraceCount;
backend_glx->get_video_sync (&retraceCount);
backend_glx->wait_video_sync (2,
(retraceCount + 1) % 2,
&retraceCount);
}
break;
case CLUTTER_VBLANK_DRI:
#ifdef __linux__
{
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);
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);
}
#endif
break;

View File

@ -56,8 +56,8 @@ typedef enum ClutterGLXVBlankType
typedef int (*GetVideoSyncProc) (unsigned int *count);
typedef int (*WaitVideoSyncProc) (int divisor,
int remainder,
unsigned int *count);
int remainder,
unsigned int *count);
typedef int (*SwapIntervalProc) (int interval);
struct _ClutterBackendGLX

View File

@ -74,26 +74,26 @@ clutter_stage_glx_unrealize (ClutterActor *actor)
if (G_UNLIKELY (was_offscreen))
{
if (stage_glx->glxpixmap)
{
glXDestroyGLXPixmap (stage_x11->xdpy,stage_glx->glxpixmap);
stage_glx->glxpixmap = None;
}
{
glXDestroyGLXPixmap (stage_x11->xdpy,stage_glx->glxpixmap);
stage_glx->glxpixmap = None;
}
if (stage_x11->xpixmap)
{
XFreePixmap (stage_x11->xdpy, stage_x11->xpixmap);
stage_x11->xpixmap = None;
}
{
XFreePixmap (stage_x11->xdpy, stage_x11->xpixmap);
stage_x11->xpixmap = None;
}
}
else
{
if (!stage_x11->is_foreign_xwin && stage_x11->xwin != None)
{
XDestroyWindow (stage_x11->xdpy, stage_x11->xwin);
stage_x11->xwin = None;
}
{
XDestroyWindow (stage_x11->xdpy, stage_x11->xwin);
stage_x11->xwin = None;
}
else
stage_x11->xwin = None;
stage_x11->xwin = None;
}
glXMakeCurrent (stage_x11->xdpy, None, NULL);
@ -125,70 +125,70 @@ clutter_stage_glx_realize (ClutterActor *actor)
if (G_LIKELY (!is_offscreen))
{
int gl_attributes[] =
{
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_STENCIL_SIZE, 1,
0
};
{
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_STENCIL_SIZE, 1,
0
};
if (stage_x11->xvisinfo)
XFree (stage_x11->xvisinfo);
stage_x11->xvisinfo = NULL;
/* The following check seems strange */
/* The following check seems strange */
if (stage_x11->xvisinfo == None)
stage_x11->xvisinfo = glXChooseVisual (stage_x11->xdpy,
stage_x11->xvisinfo = glXChooseVisual (stage_x11->xdpy,
stage_x11->xscreen,
gl_attributes);
gl_attributes);
if (!stage_x11->xvisinfo)
{
g_critical ("Unable to find suitable GL visual.");
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
return;
}
{
g_critical ("Unable to find suitable GL visual.");
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
return;
}
if (stage_x11->xwin == None)
{
XSetWindowAttributes xattr;
unsigned long mask;
CLUTTER_NOTE (MISC, "Creating stage X window");
XSetWindowAttributes xattr;
unsigned long mask;
/* window attributes */
xattr.background_pixel = WhitePixel (stage_x11->xdpy,
stage_x11->xscreen);
xattr.border_pixel = 0;
xattr.colormap = XCreateColormap (stage_x11->xdpy,
stage_x11->xwin_root,
stage_x11->xvisinfo->visual,
AllocNone);
mask = CWBackPixel | CWBorderPixel | CWColormap;
stage_x11->xwin = XCreateWindow (stage_x11->xdpy,
CLUTTER_NOTE (MISC, "Creating stage X window");
/* window attributes */
xattr.background_pixel = WhitePixel (stage_x11->xdpy,
stage_x11->xscreen);
xattr.border_pixel = 0;
xattr.colormap = XCreateColormap (stage_x11->xdpy,
stage_x11->xwin_root,
0, 0,
stage_x11->xwin_width,
stage_x11->xwin_height,
0,
stage_x11->xvisinfo->depth,
InputOutput,
stage_x11->xvisinfo->visual,
mask, &xattr);
AllocNone);
mask = CWBackPixel | CWBorderPixel | CWColormap;
stage_x11->xwin = XCreateWindow (stage_x11->xdpy,
stage_x11->xwin_root,
0, 0,
stage_x11->xwin_width,
stage_x11->xwin_height,
0,
stage_x11->xvisinfo->depth,
InputOutput,
stage_x11->xvisinfo->visual,
mask, &xattr);
}
CLUTTER_NOTE (MISC, "XSelectInput");
XSelectInput (stage_x11->xdpy, stage_x11->xwin,
StructureNotifyMask |
FocusChangeMask |
FocusChangeMask |
ExposureMask |
/* FIXME: we may want to eplicity enable MotionMask */
PointerMotionMask |
KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask |
PropertyChangeMask);
/* FIXME: we may want to eplicity enable MotionMask */
PointerMotionMask |
KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask |
PropertyChangeMask);
/* no user resize.. */
clutter_stage_x11_fix_window_size (stage_x11);
@ -196,22 +196,22 @@ clutter_stage_glx_realize (ClutterActor *actor)
clutter_stage_x11_set_wm_protocols (stage_x11);
if (stage_glx->gl_context)
glXDestroyContext (stage_x11->xdpy, stage_glx->gl_context);
glXDestroyContext (stage_x11->xdpy, stage_glx->gl_context);
CLUTTER_NOTE (GL, "Creating GL Context");
stage_glx->gl_context = glXCreateContext (stage_x11->xdpy,
stage_x11->xvisinfo,
0,
True);
if (stage_glx->gl_context == None)
{
g_critical ("Unable to create suitable GL context.");
stage_x11->xvisinfo,
0,
True);
if (stage_glx->gl_context == None)
{
g_critical ("Unable to create suitable GL context.");
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
return;
}
}
CLUTTER_NOTE (GL, "glXMakeCurrent");
glXMakeCurrent (stage_x11->xdpy, stage_x11->xwin, stage_glx->gl_context);
@ -219,49 +219,50 @@ clutter_stage_glx_realize (ClutterActor *actor)
else
{
int gl_attributes[] = {
GLX_DEPTH_SIZE, 0,
GLX_ALPHA_SIZE, 0,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_USE_GL,
GLX_RGBA,
0
GLX_DEPTH_SIZE, 0,
GLX_ALPHA_SIZE, 0,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_USE_GL,
GLX_RGBA,
0
};
if (stage_x11->xvisinfo )
XFree (stage_x11->xvisinfo);
stage_x11->xvisinfo = NULL;
if (stage_x11->xvisinfo)
XFree (stage_x11->xvisinfo);
stage_x11->xvisinfo = NULL;
CLUTTER_NOTE (GL, "glXChooseVisual");
stage_x11->xvisinfo = glXChooseVisual (stage_x11->xdpy,
stage_x11->xscreen,
gl_attributes);
stage_x11->xscreen,
gl_attributes);
if (!stage_x11->xvisinfo)
{
g_critical ("Unable to find suitable GL visual.");
goto fail;
}
{
g_critical ("Unable to find suitable GL visual.");
goto fail;
}
if (stage_glx->gl_context)
glXDestroyContext (stage_x11->xdpy, stage_glx->gl_context);
glXDestroyContext (stage_x11->xdpy, stage_glx->gl_context);
stage_x11->xpixmap = XCreatePixmap (stage_x11->xdpy,
stage_x11->xwin_root,
stage_x11->xwin_width,
stage_x11->xwin_height,
DefaultDepth (stage_x11->xdpy,
stage_x11->xscreen));
stage_x11->xwin_root,
stage_x11->xwin_width,
stage_x11->xwin_height,
DefaultDepth (stage_x11->xdpy,
stage_x11->xscreen));
stage_glx->glxpixmap = glXCreateGLXPixmap (stage_x11->xdpy,
stage_x11->xvisinfo,
stage_x11->xpixmap);
stage_x11->xvisinfo,
stage_x11->xpixmap);
/* indirect */
stage_glx->gl_context = glXCreateContext (stage_x11->xdpy,
stage_x11->xvisinfo,
0,
False);
stage_x11->xvisinfo,
0,
False);
clutter_x11_trap_x_errors ();
@ -270,10 +271,10 @@ clutter_stage_glx_realize (ClutterActor *actor)
stage_glx->gl_context);
if (clutter_x11_untrap_x_errors ())
{
g_critical ("Unable to set up offscreen context.");
goto fail;
}
{
g_critical ("Unable to set up offscreen context.");
goto fail;
}
}
/* Make sure the viewport gets set up correctly */
@ -289,7 +290,7 @@ clutter_stage_glx_realize (ClutterActor *actor)
static void
snapshot_pixbuf_free (guchar *pixels,
gpointer data)
gpointer data)
{
g_free (pixels);
}
@ -343,19 +344,19 @@ clutter_stage_glx_draw_to_pixbuf (ClutterStage *stage,
data = g_malloc0 (sizeof (guchar) * stride * height);
glReadPixels (x,
clutter_actor_get_height (actor) - y - height,
width,
height, GL_RGBA, GL_UNSIGNED_BYTE, data);
clutter_actor_get_height (actor) - y - height,
width,
height, GL_RGBA, GL_UNSIGNED_BYTE, data);
tmp = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB,
TRUE,
8,
width, height,
stride,
snapshot_pixbuf_free,
NULL);
GDK_COLORSPACE_RGB,
TRUE,
8,
width, height,
stride,
snapshot_pixbuf_free,
NULL);
tmp2 = gdk_pixbuf_flip (tmp, TRUE);
g_object_unref (tmp);