From 7514f5fe92844a57d33a4811fd20687bbb391c8b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 21 Jan 2011 10:49:12 +0000 Subject: [PATCH] glx: Clean up GLX implementation Like commit a277b4091a3fa09a39cf001809c3048eb27f3952, but targeted at the GLX backend. --- clutter/glx/clutter-backend-glx.c | 22 ++++++------ clutter/glx/clutter-stage-glx.c | 57 ++++++++++++++----------------- clutter/glx/clutter-stage-glx.h | 2 +- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/clutter/glx/clutter-backend-glx.c b/clutter/glx/clutter-backend-glx.c index 2b6dcbd30..46bb6ff2a 100644 --- a/clutter/glx/clutter-backend-glx.c +++ b/clutter/glx/clutter-backend-glx.c @@ -51,8 +51,9 @@ #include "cogl/cogl.h" +#define clutter_backend_glx_get_type _clutter_backend_glx_get_type -G_DEFINE_TYPE (ClutterBackendGLX, _clutter_backend_glx, CLUTTER_TYPE_BACKEND_X11); +G_DEFINE_TYPE (ClutterBackendGLX, clutter_backend_glx, CLUTTER_TYPE_BACKEND_X11); /* singleton object */ static ClutterBackendGLX *backend_singleton = NULL; @@ -70,7 +71,7 @@ clutter_backend_glx_pre_parse (ClutterBackend *backend, GError **error) { ClutterBackendClass *parent_class = - CLUTTER_BACKEND_CLASS (_clutter_backend_glx_parent_class); + CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class); const gchar *env_string; env_string = g_getenv ("CLUTTER_VBLANK"); @@ -90,7 +91,7 @@ clutter_backend_glx_post_parse (ClutterBackend *backend, ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend); ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend); ClutterBackendClass *parent_class = - CLUTTER_BACKEND_CLASS (_clutter_backend_glx_parent_class); + CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class); int glx_major, glx_minor; if (!parent_class->post_parse (backend, error)) @@ -137,7 +138,7 @@ clutter_backend_glx_add_options (ClutterBackend *backend, GOptionGroup *group) { ClutterBackendClass *parent_class = - CLUTTER_BACKEND_CLASS (_clutter_backend_glx_parent_class); + CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class); g_option_group_add_entries (group, entries); @@ -150,7 +151,7 @@ clutter_backend_glx_finalize (GObject *gobject) if (backend_singleton) backend_singleton = NULL; - G_OBJECT_CLASS (_clutter_backend_glx_parent_class)->finalize (gobject); + G_OBJECT_CLASS (clutter_backend_glx_parent_class)->finalize (gobject); } static void @@ -181,7 +182,7 @@ clutter_backend_glx_dispose (GObject *gobject) backend_glx->dummy_xwin = None; } - G_OBJECT_CLASS (_clutter_backend_glx_parent_class)->dispose (gobject); + G_OBJECT_CLASS (clutter_backend_glx_parent_class)->dispose (gobject); } static GObject * @@ -194,7 +195,7 @@ clutter_backend_glx_constructor (GType gtype, if (!backend_singleton) { - parent_class = G_OBJECT_CLASS (_clutter_backend_glx_parent_class); + parent_class = G_OBJECT_CLASS (clutter_backend_glx_parent_class); retval = parent_class->constructor (gtype, n_params, params); backend_singleton = CLUTTER_BACKEND_GLX (retval); @@ -227,7 +228,7 @@ clutter_backend_glx_get_features (ClutterBackend *backend) ClutterFeatureFlags flags; gboolean use_dri = FALSE; - parent_class = CLUTTER_BACKEND_CLASS (_clutter_backend_glx_parent_class); + parent_class = CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class); flags = parent_class->get_features (backend); flags |= CLUTTER_FEATURE_STAGE_MULTIPLE; @@ -824,7 +825,7 @@ clutter_backend_glx_create_stage (ClutterBackend *backend, } static void -_clutter_backend_glx_class_init (ClutterBackendGLXClass *klass) +clutter_backend_glx_class_init (ClutterBackendGLXClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass); @@ -847,9 +848,8 @@ _clutter_backend_glx_class_init (ClutterBackendGLXClass *klass) } static void -_clutter_backend_glx_init (ClutterBackendGLX *backend_glx) +clutter_backend_glx_init (ClutterBackendGLX *backend_glx) { - } /* every backend must implement this function */ diff --git a/clutter/glx/clutter-stage-glx.c b/clutter/glx/clutter-stage-glx.c index f3dc2cb3f..f393cc0af 100644 --- a/clutter/glx/clutter-stage-glx.c +++ b/clutter/glx/clutter-stage-glx.c @@ -55,10 +55,13 @@ static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface); static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface); -static ClutterStageWindowIface *clutter_stage_glx_parent_iface = NULL; +static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL; +static ClutterEventTranslatorIface *clutter_event_translator_parent_iface = NULL; + +#define clutter_stage_glx_get_type _clutter_stage_glx_get_type G_DEFINE_TYPE_WITH_CODE (ClutterStageGLX, - _clutter_stage_glx, + clutter_stage_glx, CLUTTER_TYPE_STAGE_X11, G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW, clutter_stage_window_iface_init) @@ -150,7 +153,7 @@ clutter_stage_glx_realize (ClutterStageWindow *stage_window) #endif /* GLX_INTEL_swap_event */ /* chain up to the StageX11 implementation */ - return clutter_stage_glx_parent_iface->realize (stage_window); + return clutter_stage_window_parent_iface->realize (stage_window); } static int @@ -162,21 +165,12 @@ clutter_stage_glx_get_pending_swaps (ClutterStageWindow *stage_window) } static void -clutter_stage_glx_dispose (GObject *gobject) +clutter_stage_glx_class_init (ClutterStageGLXClass *klass) { - G_OBJECT_CLASS (_clutter_stage_glx_parent_class)->dispose (gobject); } static void -_clutter_stage_glx_class_init (ClutterStageGLXClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->dispose = clutter_stage_glx_dispose; -} - -static void -_clutter_stage_glx_init (ClutterStageGLX *stage) +clutter_stage_glx_init (ClutterStageGLX *stage) { } @@ -320,7 +314,7 @@ clutter_stage_glx_add_redraw_clip (ClutterStageWindow *stage_window, static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface) { - clutter_stage_glx_parent_iface = g_type_interface_peek_parent (iface); + clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface); iface->realize = clutter_stage_glx_realize; iface->unrealize = clutter_stage_glx_unrealize; @@ -333,8 +327,6 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface) /* the rest is inherited from ClutterStageX11 */ } -static ClutterEventTranslatorIface *event_translator_parent_iface = NULL; - static ClutterTranslateReturn clutter_stage_glx_translate_event (ClutterEventTranslator *translator, gpointer native, @@ -371,15 +363,15 @@ clutter_stage_glx_translate_event (ClutterEventTranslator *translator, #endif /* chain up to the common X11 implementation */ - return event_translator_parent_iface->translate_event (translator, - native, - event); + return clutter_event_translator_parent_iface->translate_event (translator, + native, + event); } static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface) { - event_translator_parent_iface = g_type_interface_peek_parent (iface); + clutter_event_translator_parent_iface = g_type_interface_peek_parent (iface); iface->translate_event = clutter_stage_glx_translate_event; } @@ -462,12 +454,14 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx, "The time spent in _glx_blit_sub_buffer", 0 /* no application private data */); + stage_x11 = CLUTTER_STAGE_X11 (stage_glx); + if (stage_x11->xwin == None) + return; + backend = clutter_get_default_backend (); backend_x11 = CLUTTER_BACKEND_X11 (backend); backend_glx = CLUTTER_BACKEND_GLX (backend); - stage_x11 = CLUTTER_STAGE_X11 (stage_glx); - CLUTTER_TIMER_START (_clutter_uprof_context, painting_timer); if (G_LIKELY (backend_glx->can_blit_sub_buffer) && @@ -480,7 +474,9 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx, * artefacts. See clutter-event-x11.c:event_translate for a * detailed explanation */ G_LIKELY (stage_x11->clipped_redraws_cool_off == 0)) - may_use_clipped_redraw = TRUE; + { + may_use_clipped_redraw = TRUE; + } else may_use_clipped_redraw = FALSE; @@ -503,7 +499,7 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx, else _clutter_stage_do_paint (stage, NULL); - if (clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS && + if ((clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS) && may_use_clipped_redraw) { ClutterGeometry *clip = &stage_glx->bounding_redraw_clip; @@ -552,10 +548,9 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx, cogl_flush (); CLUTTER_TIMER_STOP (_clutter_uprof_context, painting_timer); - if (stage_x11->xwin == None) - return; - - drawable = stage_glx->glxwin ? stage_glx->glxwin : stage_x11->xwin; + drawable = stage_glx->glxwin + ? stage_glx->glxwin + : stage_x11->xwin; /* If we might ever use _clutter_backend_glx_blit_sub_buffer then we * always need to keep track of the video_sync_count so that we can @@ -592,7 +587,8 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx, * anyway so it should only exhibit temporary artefacts. */ copy_area.y = clutter_actor_get_height (CLUTTER_ACTOR (stage)) - - clip->y - clip->height; + - clip->y + - clip->height; copy_area.x = clip->x; copy_area.width = clip->width; copy_area.height = clip->height; @@ -691,4 +687,3 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx, stage_glx->frame_count++; } - diff --git a/clutter/glx/clutter-stage-glx.h b/clutter/glx/clutter-stage-glx.h index bc81f0baa..0fdf1dcf6 100644 --- a/clutter/glx/clutter-stage-glx.h +++ b/clutter/glx/clutter-stage-glx.h @@ -70,7 +70,7 @@ struct _ClutterStageGLXClass GType _clutter_stage_glx_get_type (void) G_GNUC_CONST; void _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx, - ClutterStage *stage); + ClutterStage *stage); G_END_DECLS