mirror of
https://github.com/brl/mutter.git
synced 2025-04-22 18:09:39 +00:00
[eglx] Update the EGLX Stage to the new StageWindow API
Move the ::realize and ::unrealize implementations over to the StageWindow instead of using Actor.
This commit is contained in:
parent
a799f6ccec
commit
14e12ae4fd
@ -19,6 +19,8 @@
|
|||||||
#include "../clutter-stage.h"
|
#include "../clutter-stage.h"
|
||||||
#include "../clutter-stage-window.h"
|
#include "../clutter-stage-window.h"
|
||||||
|
|
||||||
|
static ClutterStageWindowIface *clutter_stage_egl_parent_iface = NULL;
|
||||||
|
|
||||||
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (ClutterStageEGL,
|
G_DEFINE_TYPE_WITH_CODE (ClutterStageEGL,
|
||||||
@ -28,19 +30,16 @@ G_DEFINE_TYPE_WITH_CODE (ClutterStageEGL,
|
|||||||
clutter_stage_window_iface_init));
|
clutter_stage_window_iface_init));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_egl_unrealize (ClutterActor *actor)
|
clutter_stage_egl_unrealize (ClutterStageWindow *stage_window)
|
||||||
{
|
{
|
||||||
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
|
||||||
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
|
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
|
||||||
gboolean was_offscreen;
|
gboolean was_offscreen;
|
||||||
|
|
||||||
CLUTTER_MARK();
|
CLUTTER_NOTE (BACKEND, "Unrealizing stage");
|
||||||
|
|
||||||
g_object_get (stage_x11->wrapper, "offscreen", &was_offscreen, NULL);
|
g_object_get (stage_x11->wrapper, "offscreen", &was_offscreen, NULL);
|
||||||
|
|
||||||
if (CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->unrealize != NULL)
|
|
||||||
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->unrealize (actor);
|
|
||||||
|
|
||||||
clutter_x11_trap_x_errors ();
|
clutter_x11_trap_x_errors ();
|
||||||
|
|
||||||
if (G_UNLIKELY (was_offscreen))
|
if (G_UNLIKELY (was_offscreen))
|
||||||
@ -67,15 +66,14 @@ clutter_stage_egl_unrealize (ClutterActor *actor)
|
|||||||
XSync (stage_x11->xdpy, False);
|
XSync (stage_x11->xdpy, False);
|
||||||
|
|
||||||
clutter_x11_untrap_x_errors ();
|
clutter_x11_untrap_x_errors ();
|
||||||
|
|
||||||
CLUTTER_MARK ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
clutter_stage_egl_realize (ClutterActor *actor)
|
clutter_stage_egl_realize (ClutterStageWindow *stage_window)
|
||||||
{
|
{
|
||||||
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor);
|
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (stage_window);
|
||||||
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
|
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
|
||||||
|
ClutterBackend *backend;
|
||||||
ClutterBackendEGL *backend_egl;
|
ClutterBackendEGL *backend_egl;
|
||||||
ClutterBackendX11 *backend_x11;
|
ClutterBackendX11 *backend_x11;
|
||||||
EGLConfig configs[2];
|
EGLConfig configs[2];
|
||||||
@ -87,11 +85,13 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
|
|
||||||
g_object_get (stage_x11->wrapper, "offscreen", &is_offscreen, NULL);
|
g_object_get (stage_x11->wrapper, "offscreen", &is_offscreen, NULL);
|
||||||
|
|
||||||
backend_egl = CLUTTER_BACKEND_EGL (clutter_get_default_backend ());
|
backend = clutter_get_default_backend ();
|
||||||
backend_x11 = CLUTTER_BACKEND_X11 (clutter_get_default_backend ());
|
backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||||
|
backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
||||||
|
|
||||||
if (G_LIKELY (!is_offscreen))
|
if (G_LIKELY (!is_offscreen))
|
||||||
{
|
{
|
||||||
|
Display *xdpy = clutter_eglx_display ();
|
||||||
int c;
|
int c;
|
||||||
int num_configs;
|
int num_configs;
|
||||||
EGLConfig *all_configs;
|
EGLConfig *all_configs;
|
||||||
@ -111,15 +111,15 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
status = eglGetConfigs (backend_egl->edpy,
|
status = eglGetConfigs (xdpy,
|
||||||
configs,
|
configs,
|
||||||
2,
|
2,
|
||||||
&config_count);
|
&config_count);
|
||||||
|
|
||||||
eglGetConfigs (clutter_eglx_display (), NULL, 0, &num_configs);
|
eglGetConfigs (xdpy, NULL, 0, &num_configs);
|
||||||
|
|
||||||
all_configs = g_malloc (num_configs * sizeof (EGLConfig));
|
all_configs = g_malloc (num_configs * sizeof (EGLConfig));
|
||||||
eglGetConfigs (clutter_eglx_display (),
|
eglGetConfigs (xdpy,
|
||||||
all_configs,
|
all_configs,
|
||||||
num_configs,
|
num_configs,
|
||||||
&num_configs);
|
&num_configs);
|
||||||
@ -128,22 +128,24 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
{
|
{
|
||||||
EGLint red = -1, green = -1, blue = -1, alpha = -1, stencil = -1;
|
EGLint red = -1, green = -1, blue = -1, alpha = -1, stencil = -1;
|
||||||
|
|
||||||
eglGetConfigAttrib (clutter_eglx_display (),
|
eglGetConfigAttrib (xdpy,
|
||||||
all_configs[c],
|
all_configs[c],
|
||||||
EGL_RED_SIZE, &red);
|
EGL_RED_SIZE, &red);
|
||||||
eglGetConfigAttrib (clutter_eglx_display (),
|
eglGetConfigAttrib (xdpy,
|
||||||
all_configs[c],
|
all_configs[c],
|
||||||
EGL_GREEN_SIZE, &green);
|
EGL_GREEN_SIZE, &green);
|
||||||
eglGetConfigAttrib (clutter_eglx_display (),
|
eglGetConfigAttrib (xdpy,
|
||||||
all_configs[c],
|
all_configs[c],
|
||||||
EGL_BLUE_SIZE, &blue);
|
EGL_BLUE_SIZE, &blue);
|
||||||
eglGetConfigAttrib (clutter_eglx_display (),
|
eglGetConfigAttrib (xdpy,
|
||||||
all_configs[c],
|
all_configs[c],
|
||||||
EGL_ALPHA_SIZE, &alpha);
|
EGL_ALPHA_SIZE, &alpha);
|
||||||
eglGetConfigAttrib (clutter_eglx_display (),
|
eglGetConfigAttrib (xdpy,
|
||||||
all_configs[c],
|
all_configs[c],
|
||||||
EGL_STENCIL_SIZE, &stencil);
|
EGL_STENCIL_SIZE, &stencil);
|
||||||
CLUTTER_NOTE (BACKEND, "EGLConfig == R:%d G:%d B:%d A:%d S:%d \n",
|
|
||||||
|
CLUTTER_NOTE (BACKEND,
|
||||||
|
"EGLConfig == R:%d G:%d B:%d A:%d S:%d",
|
||||||
red, green, blue, alpha, stencil);
|
red, green, blue, alpha, stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,10 +157,9 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = eglChooseConfig (backend_egl->edpy,
|
status = eglChooseConfig (xdpy,
|
||||||
cfg_attribs,
|
cfg_attribs,
|
||||||
configs,
|
configs, G_N_ELEMENTS (configs),
|
||||||
G_N_ELEMENTS (configs),
|
|
||||||
&config_count);
|
&config_count);
|
||||||
|
|
||||||
if (status != EGL_TRUE)
|
if (status != EGL_TRUE)
|
||||||
@ -168,8 +169,9 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stage_x11->xwin == None)
|
if (stage_x11->xwin == None)
|
||||||
|
{
|
||||||
stage_x11->xwin =
|
stage_x11->xwin =
|
||||||
XCreateSimpleWindow (stage_x11->xdpy,
|
XCreateSimpleWindow (xdpy,
|
||||||
stage_x11->xwin_root,
|
stage_x11->xwin_root,
|
||||||
0, 0,
|
0, 0,
|
||||||
stage_x11->xwin_width,
|
stage_x11->xwin_width,
|
||||||
@ -177,12 +179,13 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
0, 0,
|
0, 0,
|
||||||
WhitePixel (stage_x11->xdpy,
|
WhitePixel (stage_x11->xdpy,
|
||||||
stage_x11->xscreen));
|
stage_x11->xscreen));
|
||||||
|
}
|
||||||
|
|
||||||
if (clutter_x11_has_event_retrieval ())
|
if (clutter_x11_has_event_retrieval ())
|
||||||
{
|
{
|
||||||
if (clutter_x11_has_xinput ())
|
if (clutter_x11_has_xinput ())
|
||||||
{
|
{
|
||||||
XSelectInput (stage_x11->xdpy, stage_x11->xwin,
|
XSelectInput (xdpy, stage_x11->xwin,
|
||||||
StructureNotifyMask |
|
StructureNotifyMask |
|
||||||
FocusChangeMask |
|
FocusChangeMask |
|
||||||
ExposureMask |
|
ExposureMask |
|
||||||
@ -193,7 +196,7 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
XSelectInput (stage_x11->xdpy, stage_x11->xwin,
|
XSelectInput (xdpy, stage_x11->xwin,
|
||||||
StructureNotifyMask |
|
StructureNotifyMask |
|
||||||
FocusChangeMask |
|
FocusChangeMask |
|
||||||
ExposureMask |
|
ExposureMask |
|
||||||
@ -204,18 +207,17 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
PropertyChangeMask);
|
PropertyChangeMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME, do these in a clutterstage_x11_realise? */
|
|
||||||
clutter_stage_x11_fix_window_size (stage_x11, -1, -1);
|
clutter_stage_x11_fix_window_size (stage_x11, -1, -1);
|
||||||
clutter_stage_x11_set_wm_protocols (stage_x11);
|
clutter_stage_x11_set_wm_protocols (stage_x11);
|
||||||
|
|
||||||
if (stage_egl->egl_surface != EGL_NO_SURFACE)
|
if (stage_egl->egl_surface != EGL_NO_SURFACE)
|
||||||
{
|
{
|
||||||
eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface);
|
eglDestroySurface (xdpy, stage_egl->egl_surface);
|
||||||
stage_egl->egl_surface = EGL_NO_SURFACE;
|
stage_egl->egl_surface = EGL_NO_SURFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
stage_egl->egl_surface =
|
stage_egl->egl_surface =
|
||||||
eglCreateWindowSurface (backend_egl->edpy,
|
eglCreateWindowSurface (xdpy,
|
||||||
configs[0],
|
configs[0],
|
||||||
(NativeWindowType) stage_x11->xwin,
|
(NativeWindowType) stage_x11->xwin,
|
||||||
NULL);
|
NULL);
|
||||||
@ -232,13 +234,13 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
static const EGLint attribs[3]
|
static const EGLint attribs[3]
|
||||||
= { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
= { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
|
||||||
|
|
||||||
backend_egl->egl_context = eglCreateContext (backend_egl->edpy,
|
backend_egl->egl_context = eglCreateContext (xdpy,
|
||||||
configs[0],
|
configs[0],
|
||||||
EGL_NO_CONTEXT,
|
EGL_NO_CONTEXT,
|
||||||
attribs);
|
attribs);
|
||||||
#else
|
#else
|
||||||
/* Seems some GLES implementations 1.x do not like attribs... */
|
/* Seems some GLES implementations 1.x do not like attribs... */
|
||||||
backend_egl->egl_context = eglCreateContext (backend_egl->edpy,
|
backend_egl->egl_context = eglCreateContext (xdpy,
|
||||||
configs[0],
|
configs[0],
|
||||||
EGL_NO_CONTEXT,
|
EGL_NO_CONTEXT,
|
||||||
NULL);
|
NULL);
|
||||||
@ -248,6 +250,7 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
g_critical ("Unable to create a suitable EGL context");
|
g_critical ("Unable to create a suitable EGL context");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
backend_egl->egl_config = configs[0];
|
backend_egl->egl_config = configs[0];
|
||||||
CLUTTER_NOTE (GL, "Created EGL Context");
|
CLUTTER_NOTE (GL, "Created EGL Context");
|
||||||
}
|
}
|
||||||
@ -258,28 +261,29 @@ clutter_stage_egl_realize (ClutterActor *actor)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we need to chain up to the X11 stage implementation in order to
|
CLUTTER_NOTE (BACKEND, "Successfully realized stage");
|
||||||
* set the window state in case we set it before realizing the stage
|
|
||||||
*/
|
return clutter_stage_egl_parent_iface->realize (stage_window);
|
||||||
CLUTTER_ACTOR_CLASS (clutter_stage_egl_parent_class)->realize (actor);
|
|
||||||
return;
|
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_egl_dispose (GObject *gobject)
|
clutter_stage_egl_dispose (GObject *gobject)
|
||||||
{
|
{
|
||||||
ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (gobject);
|
|
||||||
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (gobject);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (clutter_stage_egl_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (clutter_stage_egl_parent_class)->dispose (gobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||||
{
|
{
|
||||||
|
clutter_stage_egl_parent_iface = g_type_interface_peek_parent (iface);
|
||||||
|
|
||||||
|
iface->realize = clutter_stage_egl_realize;
|
||||||
|
iface->unrealize = clutter_stage_egl_unrealize;
|
||||||
|
|
||||||
/* the rest is inherited from ClutterStageX11 */
|
/* the rest is inherited from ClutterStageX11 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,12 +291,8 @@ static void
|
|||||||
clutter_stage_egl_class_init (ClutterStageEGLClass *klass)
|
clutter_stage_egl_class_init (ClutterStageEGLClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
||||||
|
|
||||||
gobject_class->dispose = clutter_stage_egl_dispose;
|
gobject_class->dispose = clutter_stage_egl_dispose;
|
||||||
|
|
||||||
actor_class->realize = clutter_stage_egl_realize;
|
|
||||||
actor_class->unrealize = clutter_stage_egl_unrealize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user