From f8f8873714043efbcbf92718493a94ac9ddf303f Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 20 Oct 2009 16:55:10 +0100 Subject: [PATCH] [stage-x11] Ensure viewport is initialized before first stage paint This ensures that glViewport is called before the first stage paint. Previously _clutter_stage_maybe_setup_viewport (which is done before we start painting) was bailing out without calling cogl_setup_viewport because the CLUTTER_STAGE_IN_RESIZE flag may be set if the stage was resized before the first paint. (NB: The CLUTTER_STAGE_IN_RESIZE flag isn't removed until we get an explicit event back from the X server since the window manager may choose to deny/alter the resize.) We now special case the first resize - where the viewport hasn't previously been initialized and use the requested geometry to initialize the glViewport without waiting for a reply from the server. --- clutter/x11/clutter-stage-x11.c | 18 ++++++++++++++++++ clutter/x11/clutter-stage-x11.h | 7 ++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/clutter/x11/clutter-stage-x11.c b/clutter/x11/clutter-stage-x11.c index 074595f9f..678bbde2f 100644 --- a/clutter/x11/clutter-stage-x11.c +++ b/clutter/x11/clutter-stage-x11.c @@ -210,6 +210,7 @@ clutter_stage_x11_resize (ClutterStageWindow *stage_window, ClutterBackend *backend = clutter_get_default_backend (); ClutterBackendX11 *backend_x11; ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window); + ClutterStage *stage = stage_x11->wrapper; gboolean resize; resize = clutter_stage_get_user_resizable (stage_x11->wrapper); @@ -250,6 +251,22 @@ clutter_stage_x11_resize (ClutterStageWindow *stage_window, stage_x11->xwin, stage_x11->xwin_width, stage_x11->xwin_height); + + /* If the viewport hasn't previously been initialized then even + * though we can't guarantee that the server will honour our request + * we need to ensure a valid viewport is set before our first paint. + */ + if (G_UNLIKELY (!stage_x11->viewport_initialized)) + { + ClutterPerspective perspective; + clutter_stage_get_perspective (stage, &perspective); + _cogl_setup_viewport (stage_x11->xwin_width, + stage_x11->xwin_height, + perspective.fovy, + perspective.aspect, + perspective.z_near, + perspective.z_far); + } } if (!resize) @@ -654,6 +671,7 @@ clutter_stage_x11_init (ClutterStageX11 *stage) stage->is_foreign_xwin = FALSE; stage->fullscreen_on_map = FALSE; stage->is_cursor_visible = TRUE; + stage->viewport_initialized = FALSE; stage->title = NULL; diff --git a/clutter/x11/clutter-stage-x11.h b/clutter/x11/clutter-stage-x11.h index 0929094bc..71b66e348 100644 --- a/clutter/x11/clutter-stage-x11.h +++ b/clutter/x11/clutter-stage-x11.h @@ -50,9 +50,10 @@ struct _ClutterStageX11 { ClutterGroup parent_instance; - guint is_foreign_xwin : 1; - guint fullscreen_on_map : 1; - guint is_cursor_visible : 1; + guint is_foreign_xwin : 1; + guint fullscreen_on_map : 1; + guint is_cursor_visible : 1; + guint viewport_initialized : 1; Window xwin; gint xwin_width;