glx: Clean up GLX implementation

Like commit a277b4091a, but targeted at
the GLX backend.
This commit is contained in:
Emmanuele Bassi 2011-01-21 10:49:12 +00:00
parent 6da51f6ed3
commit 7514f5fe92
3 changed files with 38 additions and 43 deletions

View File

@ -51,8 +51,9 @@
#include "cogl/cogl.h" #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 */ /* singleton object */
static ClutterBackendGLX *backend_singleton = NULL; static ClutterBackendGLX *backend_singleton = NULL;
@ -70,7 +71,7 @@ clutter_backend_glx_pre_parse (ClutterBackend *backend,
GError **error) GError **error)
{ {
ClutterBackendClass *parent_class = ClutterBackendClass *parent_class =
CLUTTER_BACKEND_CLASS (_clutter_backend_glx_parent_class); CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
const gchar *env_string; const gchar *env_string;
env_string = g_getenv ("CLUTTER_VBLANK"); env_string = g_getenv ("CLUTTER_VBLANK");
@ -90,7 +91,7 @@ clutter_backend_glx_post_parse (ClutterBackend *backend,
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend); ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend); ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (backend);
ClutterBackendClass *parent_class = ClutterBackendClass *parent_class =
CLUTTER_BACKEND_CLASS (_clutter_backend_glx_parent_class); CLUTTER_BACKEND_CLASS (clutter_backend_glx_parent_class);
int glx_major, glx_minor; int glx_major, glx_minor;
if (!parent_class->post_parse (backend, error)) if (!parent_class->post_parse (backend, error))
@ -137,7 +138,7 @@ clutter_backend_glx_add_options (ClutterBackend *backend,
GOptionGroup *group) GOptionGroup *group)
{ {
ClutterBackendClass *parent_class = 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); g_option_group_add_entries (group, entries);
@ -150,7 +151,7 @@ clutter_backend_glx_finalize (GObject *gobject)
if (backend_singleton) if (backend_singleton)
backend_singleton = NULL; 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 static void
@ -181,7 +182,7 @@ clutter_backend_glx_dispose (GObject *gobject)
backend_glx->dummy_xwin = None; 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 * static GObject *
@ -194,7 +195,7 @@ clutter_backend_glx_constructor (GType gtype,
if (!backend_singleton) 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); retval = parent_class->constructor (gtype, n_params, params);
backend_singleton = CLUTTER_BACKEND_GLX (retval); backend_singleton = CLUTTER_BACKEND_GLX (retval);
@ -227,7 +228,7 @@ clutter_backend_glx_get_features (ClutterBackend *backend)
ClutterFeatureFlags flags; ClutterFeatureFlags flags;
gboolean use_dri = FALSE; 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 = parent_class->get_features (backend);
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE; flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
@ -824,7 +825,7 @@ clutter_backend_glx_create_stage (ClutterBackend *backend,
} }
static void static void
_clutter_backend_glx_class_init (ClutterBackendGLXClass *klass) clutter_backend_glx_class_init (ClutterBackendGLXClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass); ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
@ -847,9 +848,8 @@ _clutter_backend_glx_class_init (ClutterBackendGLXClass *klass)
} }
static void static void
_clutter_backend_glx_init (ClutterBackendGLX *backend_glx) clutter_backend_glx_init (ClutterBackendGLX *backend_glx)
{ {
} }
/* every backend must implement this function */ /* every backend must implement this function */

View File

@ -55,10 +55,13 @@
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface); static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *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, G_DEFINE_TYPE_WITH_CODE (ClutterStageGLX,
_clutter_stage_glx, clutter_stage_glx,
CLUTTER_TYPE_STAGE_X11, CLUTTER_TYPE_STAGE_X11,
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW, G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
clutter_stage_window_iface_init) clutter_stage_window_iface_init)
@ -150,7 +153,7 @@ clutter_stage_glx_realize (ClutterStageWindow *stage_window)
#endif /* GLX_INTEL_swap_event */ #endif /* GLX_INTEL_swap_event */
/* chain up to the StageX11 implementation */ /* 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 static int
@ -162,21 +165,12 @@ clutter_stage_glx_get_pending_swaps (ClutterStageWindow *stage_window)
} }
static void 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 static void
_clutter_stage_glx_class_init (ClutterStageGLXClass *klass) clutter_stage_glx_init (ClutterStageGLX *stage)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = clutter_stage_glx_dispose;
}
static void
_clutter_stage_glx_init (ClutterStageGLX *stage)
{ {
} }
@ -320,7 +314,7 @@ clutter_stage_glx_add_redraw_clip (ClutterStageWindow *stage_window,
static void static void
clutter_stage_window_iface_init (ClutterStageWindowIface *iface) 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->realize = clutter_stage_glx_realize;
iface->unrealize = clutter_stage_glx_unrealize; iface->unrealize = clutter_stage_glx_unrealize;
@ -333,8 +327,6 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
/* the rest is inherited from ClutterStageX11 */ /* the rest is inherited from ClutterStageX11 */
} }
static ClutterEventTranslatorIface *event_translator_parent_iface = NULL;
static ClutterTranslateReturn static ClutterTranslateReturn
clutter_stage_glx_translate_event (ClutterEventTranslator *translator, clutter_stage_glx_translate_event (ClutterEventTranslator *translator,
gpointer native, gpointer native,
@ -371,7 +363,7 @@ clutter_stage_glx_translate_event (ClutterEventTranslator *translator,
#endif #endif
/* chain up to the common X11 implementation */ /* chain up to the common X11 implementation */
return event_translator_parent_iface->translate_event (translator, return clutter_event_translator_parent_iface->translate_event (translator,
native, native,
event); event);
} }
@ -379,7 +371,7 @@ clutter_stage_glx_translate_event (ClutterEventTranslator *translator,
static void static void
clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface) 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; 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", "The time spent in _glx_blit_sub_buffer",
0 /* no application private data */); 0 /* no application private data */);
stage_x11 = CLUTTER_STAGE_X11 (stage_glx);
if (stage_x11->xwin == None)
return;
backend = clutter_get_default_backend (); backend = clutter_get_default_backend ();
backend_x11 = CLUTTER_BACKEND_X11 (backend); backend_x11 = CLUTTER_BACKEND_X11 (backend);
backend_glx = CLUTTER_BACKEND_GLX (backend); backend_glx = CLUTTER_BACKEND_GLX (backend);
stage_x11 = CLUTTER_STAGE_X11 (stage_glx);
CLUTTER_TIMER_START (_clutter_uprof_context, painting_timer); CLUTTER_TIMER_START (_clutter_uprof_context, painting_timer);
if (G_LIKELY (backend_glx->can_blit_sub_buffer) && 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 * artefacts. See clutter-event-x11.c:event_translate for a
* detailed explanation */ * detailed explanation */
G_LIKELY (stage_x11->clipped_redraws_cool_off == 0)) G_LIKELY (stage_x11->clipped_redraws_cool_off == 0))
{
may_use_clipped_redraw = TRUE; may_use_clipped_redraw = TRUE;
}
else else
may_use_clipped_redraw = FALSE; may_use_clipped_redraw = FALSE;
@ -503,7 +499,7 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx,
else else
_clutter_stage_do_paint (stage, NULL); _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) may_use_clipped_redraw)
{ {
ClutterGeometry *clip = &stage_glx->bounding_redraw_clip; ClutterGeometry *clip = &stage_glx->bounding_redraw_clip;
@ -552,10 +548,9 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx,
cogl_flush (); cogl_flush ();
CLUTTER_TIMER_STOP (_clutter_uprof_context, painting_timer); CLUTTER_TIMER_STOP (_clutter_uprof_context, painting_timer);
if (stage_x11->xwin == None) drawable = stage_glx->glxwin
return; ? 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 /* 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 * 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. * anyway so it should only exhibit temporary artefacts.
*/ */
copy_area.y = clutter_actor_get_height (CLUTTER_ACTOR (stage)) 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.x = clip->x;
copy_area.width = clip->width; copy_area.width = clip->width;
copy_area.height = clip->height; copy_area.height = clip->height;
@ -691,4 +687,3 @@ _clutter_stage_glx_redraw (ClutterStageGLX *stage_glx,
stage_glx->frame_count++; stage_glx->frame_count++;
} }