From 24133ddadcd71af74f52b009b178e0ffa9e51374 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 9 Dec 2010 15:11:37 +0000 Subject: [PATCH] Rename the EGLDisplay accessors The accessor for the EGL display should be namespaced for the correct backend-specific API. --- clutter/egl/clutter-backend-egl.c | 19 +++++++++---- clutter/egl/clutter-egl.h | 28 ++++++++++++++----- clutter/fruity/clutter-backend-fruity.c | 32 ++++++++++++++++++++++ clutter/fruity/clutter-fruity.h | 9 ++++-- clutter/fruity/clutter-stage-fruity.c | 3 +- clutter/wayland/clutter-backend-wayland.c | 24 ++++++++-------- clutter/wayland/clutter-stage-wayland.c | 4 +-- clutter/wayland/clutter-wayland.h | 7 +++-- doc/reference/clutter/clutter-sections.txt | 3 +- 9 files changed, 95 insertions(+), 34 deletions(-) diff --git a/clutter/egl/clutter-backend-egl.c b/clutter/egl/clutter-backend-egl.c index 36e26c5ea..e747046b2 100644 --- a/clutter/egl/clutter-backend-egl.c +++ b/clutter/egl/clutter-backend-egl.c @@ -222,7 +222,7 @@ clutter_backend_egl_create_context (ClutterBackend *backend, if (backend_egl->egl_context != EGL_NO_CONTEXT) return TRUE; - edpy = clutter_egl_display (); + edpy = clutter_egl_get_egl_display (); /* XXX: we should get rid of this goto yukkyness, there is a fail: * goto at the end and this retry: goto at the top, but we should just @@ -903,17 +903,26 @@ _clutter_backend_impl_get_type (void) } #endif -#ifdef COGL_HAS_XLIB_SUPPORT EGLDisplay clutter_eglx_display (void) { - return backend_singleton->edpy; + return clutter_egl_get_egl_display (); } -#endif /* COGL_HAS_XLIB_SUPPORT */ EGLDisplay clutter_egl_display (void) { - return backend_singleton->edpy; + return clutter_egl_get_egl_display (); } +EGLDisplay +clutter_egl_get_egl_display (void) +{ + if (backend_singleton == NULL) + { + g_critical (G_STRFUNC " has been called before clutter_init()"); + return 0; + } + + return backend_singleton->edpy; +} diff --git a/clutter/egl/clutter-egl.h b/clutter/egl/clutter-egl.h index 223e64004..53ee7b563 100644 --- a/clutter/egl/clutter-egl.h +++ b/clutter/egl/clutter-egl.h @@ -49,19 +49,20 @@ G_BEGIN_DECLS -#ifdef COGL_HAS_XLIB_SUPPORT +#ifndef CLUTTER_DISABLE_DEPRECATED /** * clutter_eglx_display: * - * Retrieves the EGLDisplay used by Clutter + * Retrieves the EGLDisplay used by Clutter, + * if Clutter has been compiled with EGL and X11 support. * * Return value: the EGL display * * Since: 0.4 + * + * Deprecated: 1.6: Use clutter_egl_get_egl_display() instead */ -EGLDisplay -clutter_eglx_display (void); -#endif +EGLDisplay clutter_eglx_display (void); /** * clutter_egl_display: @@ -69,9 +70,22 @@ clutter_eglx_display (void); * Retrieves the EGLDisplay used by Clutter * * Return value: the EGL display + * + * Deprecated: 1.6: Use clutter_egl_get_egl_display() instead */ -EGLDisplay -clutter_egl_display (void); +EGLDisplay clutter_egl_display (void); +#endif /* CLUTTER_DISABLE_DEPRECATED */ + +/** + * clutter_egl_get_egl_display: + * + * Retrieves the EGLDisplay used by Clutter. + * + * Return value: the EGL display + * + * Since: 1.6 + */ +EGLDisplay clutter_egl_get_egl_display (void); G_END_DECLS diff --git a/clutter/fruity/clutter-backend-fruity.c b/clutter/fruity/clutter-backend-fruity.c index a6e9142e4..880ebf26b 100644 --- a/clutter/fruity/clutter-backend-fruity.c +++ b/clutter/fruity/clutter-backend-fruity.c @@ -253,12 +253,44 @@ _clutter_backend_impl_get_type (void) return clutter_backend_egl_get_type (); } +/** + * clutter_egl_display: + * + * Retrieves the EGLDisplay used by Clutter. + * + * Return value: the EGL display + * + * Deprecated: 1.6: Use clutter_fruity_get_egl_display() instead + * + * Since: 0.6 + */ EGLDisplay clutter_egl_display (void) { return backend_singleton->edpy; } +/** + * clutter_fruity_egl_display: + * + * Retrieves the EGLDisplay used by Clutter. + * + * Return value: the EGL display + * + * Since: 1.6 + */ +EGLDisplay +clutter_fruity_get_egl_display (void) +{ + if (backend_singleton == NULL) + { + g_critical (G_STRFUNC " has been called before clutter_init()"); + return 0; + } + + return backend_singleton->edpy; +} + void *rpl_malloc (size_t allocation) { return g_malloc (allocation); diff --git a/clutter/fruity/clutter-fruity.h b/clutter/fruity/clutter-fruity.h index ba24e9745..f704188b9 100644 --- a/clutter/fruity/clutter-fruity.h +++ b/clutter/fruity/clutter-fruity.h @@ -40,8 +40,13 @@ G_BEGIN_DECLS -EGLDisplay clutter_egl_display (void); -void clutter_uikit_main (void); +#ifndef CLUTTER_DISABLE_DEPRECATED +EGLDisplay clutter_egl_display (void); +#endif + +EGLDisplay clutter_fruity_get_egl_display (void); + +void clutter_uikit_main (void); G_END_DECLS diff --git a/clutter/fruity/clutter-stage-fruity.c b/clutter/fruity/clutter-stage-fruity.c index 650272a6a..8fb881fdb 100644 --- a/clutter/fruity/clutter-stage-fruity.c +++ b/clutter/fruity/clutter-stage-fruity.c @@ -50,7 +50,8 @@ clutter_stage_egl_unrealize (ClutterActor *actor) if (stage_egl->egl_surface) { - eglDestroySurface (clutter_egl_display (), stage_egl->egl_surface); + eglDestroySurface (clutter_fruity_get_egl_display (), + stage_egl->egl_surface); stage_egl->egl_surface = EGL_NO_SURFACE; } } diff --git a/clutter/wayland/clutter-backend-wayland.c b/clutter/wayland/clutter-backend-wayland.c index 29d83d02d..ee8dac350 100644 --- a/clutter/wayland/clutter-backend-wayland.c +++ b/clutter/wayland/clutter-backend-wayland.c @@ -284,11 +284,8 @@ try_create_context (ClutterBackend *backend, GError **error) { ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); - EGLDisplay edpy; const char *error_message; - edpy = clutter_egl_display (); - eglBindAPI (EGL_OPENGL_API); if (backend_wayland->egl_context == EGL_NO_CONTEXT) @@ -300,10 +297,11 @@ try_create_context (ClutterBackend *backend, static const EGLint *attribs = NULL; #endif - backend_wayland->egl_context = eglCreateContext (edpy, - NULL, - EGL_NO_CONTEXT, - attribs); + backend_wayland->egl_context = + eglCreateContext (backend_wayland->edpy, + NULL, + EGL_NO_CONTEXT, + attribs); if (backend_wayland->egl_context == EGL_NO_CONTEXT) { error_message = "Unable to create a suitable EGL context"; @@ -313,7 +311,10 @@ try_create_context (ClutterBackend *backend, CLUTTER_NOTE (GL, "Created EGL Context"); } - if (!eglMakeCurrent (edpy, NULL, NULL, backend_wayland->egl_context)) + if (!eglMakeCurrent (backend_wayland->edpy, + NULL, + NULL, + backend_wayland->egl_context)) { g_set_error (error, CLUTTER_INIT_ERROR, CLUTTER_INIT_ERROR_BACKEND, @@ -338,7 +339,6 @@ clutter_backend_wayland_create_context (ClutterBackend *backend, GError **error) { ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); - EGLDisplay edpy; const gchar *egl_extensions = NULL; gboolean status; int retry_cookie; @@ -348,9 +348,7 @@ clutter_backend_wayland_create_context (ClutterBackend *backend, if (backend_wayland->egl_context != EGL_NO_CONTEXT) return TRUE; - edpy = clutter_egl_display (); - - egl_extensions = eglQueryString (edpy, EGL_EXTENSIONS); + egl_extensions = eglQueryString (backend_wayland->edpy, EGL_EXTENSIONS); if (!_cogl_check_extension ("EGL_KHR_surfaceless_opengl", egl_extensions)) { @@ -555,7 +553,7 @@ _clutter_backend_impl_get_type (void) } EGLDisplay -clutter_egl_display (void) +clutter_wayland_get_egl_display (void) { return backend_singleton->edpy; } diff --git a/clutter/wayland/clutter-stage-wayland.c b/clutter/wayland/clutter-stage-wayland.c index 26eb03ad7..19c4b530b 100644 --- a/clutter/wayland/clutter-stage-wayland.c +++ b/clutter/wayland/clutter-stage-wayland.c @@ -65,7 +65,7 @@ wayland_create_buffer (ClutterStageWayland *stage_wayland, { ClutterBackend *backend = clutter_get_default_backend (); ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); - EGLDisplay edpy = clutter_egl_display (); + EGLDisplay edpy = clutter_wayland_get_egl_display (); ClutterStageWaylandWaylandBuffer *buffer; EGLint image_attribs[] = { EGL_WIDTH, 0, @@ -122,7 +122,7 @@ wayland_free_buffer (ClutterStageWaylandWaylandBuffer *buffer) { ClutterBackend *backend = clutter_get_default_backend (); ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); - EGLDisplay edpy = clutter_egl_display (); + EGLDisplay edpy = clutter_wayland_get_egl_display (); cogl_handle_unref (buffer->tex); wl_buffer_destroy (buffer->wayland_buffer); diff --git a/clutter/wayland/clutter-wayland.h b/clutter/wayland/clutter-wayland.h index ac2d7133c..26b1680c8 100644 --- a/clutter/wayland/clutter-wayland.h +++ b/clutter/wayland/clutter-wayland.h @@ -46,14 +46,15 @@ G_BEGIN_DECLS /** - * clutter_egl_display: + * clutter_wayland_get_egl_display: * * Retrieves the EGLDisplay used by Clutter * * Return value: the EGL display + * + * Since: 1.6 */ -EGLDisplay -clutter_egl_display (void); +EGLDisplay clutter_wayland_get_egl_display (void); G_END_DECLS diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index c4c232ca7..1fb80b08e 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1268,7 +1268,7 @@ clutter_win32_handle_event
clutter-wayland Wayland Specific Support -clutter_egl_display +clutter_wayland_get_egl_display
@@ -1872,6 +1872,7 @@ ClutterGLXTexturePixmapPrivate clutter-egl clutter_egl_display clutter_eglx_display +clutter_egl_get_egl_display