2008-04-23 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/eglnative/clutter-backend-egl.[ch]: * clutter/eglnative/clutter-stage-egl.[ch]: * clutter/eglnative/clutter-event-egl.c: Port to the new stage and backend APIs. *WARNING* untested and not compiled. * clutter/eglx/clutter-backend-egl.c: (clutter_backend_egl_init): Set some defaults.
This commit is contained in:
@ -27,11 +27,11 @@ clutter_backend_egl_post_parse (ClutterBackend *backend,
|
||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL(backend);
|
||||
EGLBoolean status;
|
||||
|
||||
backend_egl->edpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
backend_egl->edpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
|
||||
|
||||
status = eglInitialize(backend_egl->edpy,
|
||||
&backend_egl->egl_version_major,
|
||||
&backend_egl->egl_version_minor);
|
||||
status = eglInitialize (backend_egl->edpy,
|
||||
&backend_egl->egl_version_major,
|
||||
&backend_egl->egl_version_minor);
|
||||
|
||||
if (status != EGL_TRUE)
|
||||
{
|
||||
@ -48,33 +48,111 @@ clutter_backend_egl_post_parse (ClutterBackend *backend,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_backend_egl_init_stage (ClutterBackend *backend,
|
||||
GError **error)
|
||||
static void
|
||||
clutter_backend_egl_ensure_context (ClutterBackend *backend,
|
||||
ClutterStage *stage)
|
||||
{
|
||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||
|
||||
if (!backend_egl->stage)
|
||||
if (stage == NULL)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
CLUTTER_NOTE (BACKEND, "Clearing EGL context");
|
||||
eglMakeCurrent (backend_egl->edpy,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClutterStageWindow *impl;
|
||||
ClutterStageEGL *stage_egl;
|
||||
|
||||
stage = g_object_new (CLUTTER_TYPE_STAGE_EGL, NULL);
|
||||
impl = _clutter_stage_get_window (stage);
|
||||
g_assert (impl != NULL);
|
||||
|
||||
g_object_set_data (G_OBJECT (stage), "clutter-backend", backend);
|
||||
stage_egl = CLUTTER_STAGE_EGL (impl);
|
||||
|
||||
backend_egl->stage = g_object_ref_sink (stage);
|
||||
if (!backend_egl->egl_context)
|
||||
return;
|
||||
|
||||
if (stage_egl->egl_surface == EGL_NO_SURFACE)
|
||||
eglMakeCurrent (backend_egl->edpy,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
else
|
||||
eglMakeCurrent (backend_egl->edpy,
|
||||
stage_egl->egl_surface,
|
||||
stage_egl->egl_surface,
|
||||
backend_egl->egl_context);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_egl_redraw (ClutterBackend *backend,
|
||||
ClutterStage *stage)
|
||||
{
|
||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||
ClutterStageEGL *stage_egl;
|
||||
ClutterStageWindow *impl;
|
||||
|
||||
impl = _clutter_stage_get_window (stage);
|
||||
if (!impl)
|
||||
return;
|
||||
|
||||
g_assert (CLUTTER_IS_STAGE_EGL (impl));
|
||||
|
||||
stage_egl = CLUTTER_STAGE_EGL (impl);
|
||||
|
||||
clutter_actor_paint (CLUTTER_ACTOR (stage_egl));
|
||||
|
||||
/* Why this paint is done in backend as likely GL windowing system
|
||||
* specific calls, like swapping buffers.
|
||||
*/
|
||||
/* clutter_feature_wait_for_vblank (); */
|
||||
eglSwapBuffers (backend_egl->edpy, stage_egl->egl_surface);
|
||||
}
|
||||
|
||||
static ClutterActor *
|
||||
clutter_backend_egl_create_stage (ClutterBackend *backend,
|
||||
ClutterStage *wrapper,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||
ClutterStageEGL *stage_egl;
|
||||
ClutterActor *stage;
|
||||
|
||||
if (backend_egl->stage)
|
||||
{
|
||||
g_warning ("The EGL native backend does not support multiple stages");
|
||||
return backend_egl->stage;
|
||||
}
|
||||
|
||||
stage = g_object_new (CLUTTER_TYPE_STAGE_EGL, NULL);
|
||||
|
||||
stage_egl = CLUTTER_STAGE_EGL (stage);
|
||||
stage_egl->edpy = backend_egl->edpy
|
||||
stage_egl->backend = backend_egl;
|
||||
stage_egl->wrapper = wrapper;
|
||||
|
||||
_clutter_stage_set_window (wrapper, CLUTTER_STAGE_WINDOW (stage));
|
||||
|
||||
g_object_set_data (G_OBJECT (stage), "clutter-backend", backend);
|
||||
|
||||
clutter_actor_realize (backend_egl->stage);
|
||||
|
||||
if (!CLUTTER_ACTOR_IS_REALIZED (backend_egl->stage))
|
||||
{
|
||||
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||
CLUTTER_INIT_ERROR_INTERNAL,
|
||||
"Unable to realize the main stage");
|
||||
return FALSE;
|
||||
g_object_unref (stage);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
backend_egl->stage = stage_egl;
|
||||
|
||||
return stage;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -89,23 +167,6 @@ static const GOptionEntry entries[] =
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
clutter_backend_egl_redraw (ClutterBackend *backend)
|
||||
{
|
||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||
ClutterStageEGL *stage_egl;
|
||||
|
||||
stage_egl = CLUTTER_STAGE_EGL(backend_egl->stage);
|
||||
|
||||
clutter_actor_paint (CLUTTER_ACTOR(stage_egl));
|
||||
|
||||
/* Why this paint is done in backend as likely GL windowing system
|
||||
* specific calls, like swapping buffers.
|
||||
*/
|
||||
/* clutter_feature_wait_for_vblank (); */
|
||||
eglSwapBuffers (backend_egl->edpy, stage_egl->egl_surface);
|
||||
}
|
||||
|
||||
static ClutterActor *
|
||||
clutter_backend_egl_get_stage (ClutterBackend *backend)
|
||||
{
|
||||
@ -130,12 +191,10 @@ clutter_backend_egl_dispose (GObject *gobject)
|
||||
|
||||
_clutter_events_uninit (CLUTTER_BACKEND (backend_egl));
|
||||
|
||||
if (backend_egl->stage)
|
||||
if (backend_egl->egl_context)
|
||||
{
|
||||
CLUTTER_UNSET_PRIVATE_FLAGS (backend_egl->stage,
|
||||
CLUTTER_ACTOR_IS_TOPLEVEL);
|
||||
clutter_actor_destroy (backend_egl->stage);
|
||||
backend_egl->stage = NULL;
|
||||
eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
|
||||
backend_egl->egl_context = NULL;
|
||||
}
|
||||
|
||||
if (backend_egl->edpy)
|
||||
@ -174,6 +233,22 @@ clutter_backend_egl_constructor (GType gtype,
|
||||
static ClutterFeatureFlags
|
||||
clutter_backend_egl_get_features (ClutterBackend *backend)
|
||||
{
|
||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Checking features\n"
|
||||
"GL_VENDOR: %s\n"
|
||||
"GL_RENDERER: %s\n"
|
||||
"GL_VERSION: %s\n"
|
||||
"EGL_VENDOR: %s\n"
|
||||
"EGL_VERSION: %s\n"
|
||||
"EGL_EXTENSIONS: %s\n",
|
||||
glGetString (GL_VENDOR),
|
||||
glGetString (GL_RENDERER),
|
||||
glGetString (GL_VERSION),
|
||||
eglQueryString (backend_egl->edpy, EGL_VENDOR),
|
||||
eglQueryString (backend_egl->edpy, EGL_VERSION),
|
||||
eglQueryString (backend_egl->edpy, EGL_EXTENSIONS));
|
||||
|
||||
return CLUTTER_FEATURE_STAGE_STATIC;
|
||||
}
|
||||
|
||||
@ -187,13 +262,13 @@ clutter_backend_egl_class_init (ClutterBackendEGLClass *klass)
|
||||
gobject_class->dispose = clutter_backend_egl_dispose;
|
||||
gobject_class->finalize = clutter_backend_egl_finalize;
|
||||
|
||||
backend_class->pre_parse = clutter_backend_egl_pre_parse;
|
||||
backend_class->post_parse = clutter_backend_egl_post_parse;
|
||||
backend_class->init_stage = clutter_backend_egl_init_stage;
|
||||
backend_class->init_events = clutter_backend_egl_init_events;
|
||||
backend_class->get_stage = clutter_backend_egl_get_stage;
|
||||
backend_class->redraw = clutter_backend_egl_redraw;
|
||||
backend_class->get_features = clutter_backend_egl_get_features;
|
||||
backend_class->pre_parse = clutter_backend_egl_pre_parse;
|
||||
backend_class->post_parse = clutter_backend_egl_post_parse;
|
||||
backend_class->init_events = clutter_backend_egl_init_events;
|
||||
backend_class->create_stage = clutter_backend_egl_init_stage;
|
||||
backend_class->ensure_context = clutter_backend_egl_ensure_context;
|
||||
backend_class->redraw = clutter_backend_egl_redraw;
|
||||
backend_class->get_features = clutter_backend_egl_get_features;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user