2007-10-12 04:17:00 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-03-22 14:21:59 -04:00
|
|
|
#include "config.h"
|
2007-10-12 04:17:00 -04:00
|
|
|
#endif
|
2007-03-22 14:21:59 -04:00
|
|
|
|
|
|
|
#include "clutter-stage-egl.h"
|
2007-07-06 10:08:03 -04:00
|
|
|
#include "clutter-eglx.h"
|
2007-03-27 17:09:11 -04:00
|
|
|
|
|
|
|
#include "../clutter-main.h"
|
|
|
|
#include "../clutter-feature.h"
|
|
|
|
#include "../clutter-color.h"
|
|
|
|
#include "../clutter-util.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
#include "../clutter-event.h"
|
2007-03-27 17:09:11 -04:00
|
|
|
#include "../clutter-enum-types.h"
|
|
|
|
#include "../clutter-private.h"
|
|
|
|
#include "../clutter-debug.h"
|
2007-05-22 05:31:40 -04:00
|
|
|
#include "../clutter-units.h"
|
2007-03-27 17:09:11 -04:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
G_DEFINE_TYPE (ClutterStageEGL, clutter_stage_egl, CLUTTER_TYPE_STAGE_X11);
|
2007-03-27 17:09:11 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_egl_unrealize (ClutterActor *actor)
|
|
|
|
{
|
2007-05-31 08:35:36 -04:00
|
|
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
2007-11-15 09:45:27 -05:00
|
|
|
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
|
2007-03-27 17:09:11 -04:00
|
|
|
gboolean was_offscreen;
|
|
|
|
|
|
|
|
CLUTTER_MARK();
|
|
|
|
|
|
|
|
g_object_get (actor, "offscreen", &was_offscreen, NULL);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (was_offscreen))
|
|
|
|
{
|
|
|
|
/* No support as yet for this */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-11-15 09:45:27 -05:00
|
|
|
if (stage_x11->xwin != None)
|
2007-03-27 17:09:11 -04:00
|
|
|
{
|
2007-11-15 09:45:27 -05:00
|
|
|
XDestroyWindow (stage_x11->xdpy, stage_x11->xwin);
|
|
|
|
stage_x11->xwin = None;
|
2007-03-27 17:09:11 -04:00
|
|
|
}
|
|
|
|
else
|
2007-11-15 09:45:27 -05:00
|
|
|
stage_x11->xwin = None;
|
2007-03-27 17:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (stage_egl->egl_surface)
|
2007-07-06 09:56:01 -04:00
|
|
|
eglDestroySurface (clutter_eglx_display(), stage_egl->egl_surface);
|
2007-03-27 17:09:11 -04:00
|
|
|
stage_egl->egl_surface = NULL;
|
|
|
|
|
|
|
|
if (stage_egl->egl_context)
|
2007-07-06 09:56:01 -04:00
|
|
|
eglDestroyContext (clutter_eglx_display(), stage_egl->egl_context);
|
2007-03-27 17:09:11 -04:00
|
|
|
stage_egl->egl_context = NULL;
|
|
|
|
|
2007-10-12 04:17:00 -04:00
|
|
|
eglMakeCurrent (clutter_eglx_display(),
|
2007-03-27 17:09:11 -04:00
|
|
|
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
|
|
|
|
|
|
stage_egl->egl_context = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_egl_realize (ClutterActor *actor)
|
|
|
|
{
|
2007-05-31 08:35:36 -04:00
|
|
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
2007-11-15 09:45:27 -05:00
|
|
|
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
|
2007-03-27 17:09:11 -04:00
|
|
|
|
|
|
|
EGLConfig configs[2];
|
|
|
|
EGLint config_count;
|
|
|
|
EGLBoolean status;
|
|
|
|
|
|
|
|
gboolean is_offscreen;
|
|
|
|
|
2007-04-27 20:37:11 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Realizing main stage");
|
2007-03-27 17:09:11 -04:00
|
|
|
|
|
|
|
g_object_get (actor, "offscreen", &is_offscreen, NULL);
|
|
|
|
|
|
|
|
if (G_LIKELY (!is_offscreen))
|
|
|
|
{
|
|
|
|
EGLint cfg_attribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE,
|
|
|
|
EGL_RED_SIZE, 5,
|
|
|
|
EGL_GREEN_SIZE, 6,
|
|
|
|
EGL_BLUE_SIZE, 5,
|
|
|
|
EGL_NONE };
|
2007-10-12 04:17:00 -04:00
|
|
|
|
|
|
|
status = eglGetConfigs (clutter_eglx_display(),
|
|
|
|
configs,
|
|
|
|
2,
|
2007-03-27 17:09:11 -04:00
|
|
|
&config_count);
|
2007-10-12 04:17:00 -04:00
|
|
|
|
2007-03-27 17:09:11 -04:00
|
|
|
if (status != EGL_TRUE)
|
2007-10-12 04:17:00 -04:00
|
|
|
g_warning ("eglGetConfigs");
|
|
|
|
|
|
|
|
status = eglChooseConfig (clutter_eglx_display(),
|
|
|
|
cfg_attribs,
|
|
|
|
configs,
|
|
|
|
sizeof configs / sizeof configs[0],
|
2007-03-27 17:09:11 -04:00
|
|
|
&config_count);
|
2007-04-27 20:37:11 -04:00
|
|
|
|
|
|
|
if (status != EGL_TRUE)
|
2007-10-12 04:17:00 -04:00
|
|
|
g_warning ("eglChooseConfig");
|
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
if (stage_x11->xwin == None)
|
|
|
|
stage_x11->xwin
|
|
|
|
= XCreateSimpleWindow(stage_x11->xdpy,
|
|
|
|
stage_x11->xwin_root,
|
2007-04-27 20:37:11 -04:00
|
|
|
0, 0,
|
2007-11-15 09:45:27 -05:00
|
|
|
stage_x11->xwin_width,
|
|
|
|
stage_x11->xwin_height,
|
2007-10-12 04:17:00 -04:00
|
|
|
0, 0,
|
2007-11-15 09:45:27 -05:00
|
|
|
WhitePixel (stage_x11->xdpy,
|
|
|
|
stage_x11->xscreen));
|
2007-04-27 20:37:11 -04:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
XSelectInput(stage_x11->xdpy,
|
|
|
|
stage_x11->xwin,
|
2007-03-27 17:09:11 -04:00
|
|
|
StructureNotifyMask
|
|
|
|
|ExposureMask
|
|
|
|
/* FIXME: we may want to eplicity enable MotionMask */
|
|
|
|
|PointerMotionMask
|
|
|
|
|KeyPressMask
|
|
|
|
|KeyReleaseMask
|
|
|
|
|ButtonPressMask
|
|
|
|
|ButtonReleaseMask
|
|
|
|
|PropertyChangeMask);
|
|
|
|
|
|
|
|
if (stage_egl->egl_context)
|
2007-07-06 09:56:01 -04:00
|
|
|
eglDestroyContext (clutter_eglx_display(), stage_egl->egl_context);
|
2007-03-27 17:09:11 -04:00
|
|
|
|
|
|
|
if (stage_egl->egl_surface)
|
2007-07-06 09:56:01 -04:00
|
|
|
eglDestroySurface (clutter_eglx_display(), stage_egl->egl_surface);
|
2007-03-27 17:09:11 -04:00
|
|
|
|
2007-10-12 04:17:00 -04:00
|
|
|
stage_egl->egl_surface
|
|
|
|
= eglCreateWindowSurface (clutter_eglx_display(),
|
|
|
|
configs[0],
|
2007-11-15 09:45:27 -05:00
|
|
|
(NativeWindowType)stage_x11->xwin,
|
2007-03-27 17:09:11 -04:00
|
|
|
NULL);
|
2007-04-27 20:37:11 -04:00
|
|
|
|
2007-03-27 17:09:11 -04:00
|
|
|
if (stage_egl->egl_surface == EGL_NO_SURFACE)
|
|
|
|
g_warning ("eglCreateWindowSurface");
|
2007-10-12 04:17:00 -04:00
|
|
|
|
|
|
|
stage_egl->egl_context = eglCreateContext (clutter_eglx_display(),
|
|
|
|
configs[0],
|
|
|
|
EGL_NO_CONTEXT,
|
2007-03-27 17:09:11 -04:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (stage_egl->egl_context == EGL_NO_CONTEXT)
|
|
|
|
g_warning ("eglCreateContext");
|
2007-10-12 04:17:00 -04:00
|
|
|
|
|
|
|
status = eglMakeCurrent (clutter_eglx_display(),
|
|
|
|
stage_egl->egl_surface,
|
|
|
|
stage_egl->egl_surface,
|
2007-03-27 17:09:11 -04:00
|
|
|
stage_egl->egl_context);
|
|
|
|
|
|
|
|
if (status != EGL_TRUE)
|
2007-10-12 04:17:00 -04:00
|
|
|
g_warning ("eglMakeCurrent");
|
2007-03-27 17:09:11 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
}
|
|
|
|
|
2007-09-27 17:38:38 -04:00
|
|
|
CLUTTER_SET_PRIVATE_FLAGS(actor, CLUTTER_ACTOR_SYNC_MATRICES);
|
2007-03-27 17:09:11 -04:00
|
|
|
}
|
|
|
|
|
2007-06-19 10:10:25 -04:00
|
|
|
static GdkPixbuf*
|
2007-03-27 17:09:11 -04:00
|
|
|
clutter_stage_egl_draw_to_pixbuf (ClutterStage *stage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2007-04-25 10:22:24 -04:00
|
|
|
g_warning ("Stage of type `%s' do not support ClutterStage::draw_to_pixbuf",
|
|
|
|
G_OBJECT_TYPE_NAME (stage));
|
2007-06-19 10:10:25 -04:00
|
|
|
return NULL;
|
2007-03-27 17:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_egl_dispose (GObject *gobject)
|
|
|
|
{
|
2007-05-31 08:35:36 -04:00
|
|
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (gobject);
|
2007-11-15 09:45:27 -05:00
|
|
|
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (gobject);
|
2007-03-27 17:09:11 -04:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
if (stage_x11->xwin)
|
2007-03-27 17:09:11 -04:00
|
|
|
clutter_actor_unrealize (CLUTTER_ACTOR (stage_egl));
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_stage_egl_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
static void
|
2007-05-31 08:35:36 -04:00
|
|
|
clutter_stage_egl_class_init (ClutterStageEGLClass *klass)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
2007-03-27 17:09:11 -04:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
|
|
ClutterStageClass *stage_class = CLUTTER_STAGE_CLASS (klass);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-03-27 17:09:11 -04:00
|
|
|
gobject_class->dispose = clutter_stage_egl_dispose;
|
2007-10-12 04:17:00 -04:00
|
|
|
|
2007-03-27 17:09:11 -04:00
|
|
|
actor_class->realize = clutter_stage_egl_realize;
|
|
|
|
actor_class->unrealize = clutter_stage_egl_unrealize;
|
|
|
|
stage_class->draw_to_pixbuf = clutter_stage_egl_draw_to_pixbuf;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-31 08:35:36 -04:00
|
|
|
clutter_stage_egl_init (ClutterStageEGL *stage)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
2007-11-15 09:45:27 -05:00
|
|
|
;
|
2007-03-27 17:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|