[PATCH 3/3] present: Do not replace Pixmaps on redirected Window on unflip

Michel Dänzer michel at daenzer.net
Thu Nov 19 01:21:42 PST 2015


On 08.02.2015 18:47, Chris Wilson wrote:
> When unflipping, we may find that our flip window has been redirected.
> If we replace the redirected Window with the Screen Pixmap we then have
> mutliple fullscreen Windows believing that their own the Screen Pixmap -
> multiple fullscreen Windows that are being flipped by Clients, and so
> continue to flip causing popping between e.g. the compositor and the
> game.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  present/present.c | 28 +++++++++++++++++++---------
>  1 file changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/present/present.c b/present/present.c
> index a53dc11..ba88f79 100644
> --- a/present/present.c
> +++ b/present/present.c
> @@ -374,12 +374,17 @@ present_set_tree_pixmap_visit(WindowPtr window, void *data)
>  }
>  
>  static void
> -present_set_tree_pixmap(WindowPtr window, PixmapPtr pixmap)
> +present_set_tree_pixmap(WindowPtr window,
> +                        PixmapPtr expected,
> +                        PixmapPtr pixmap)
>  {
>      struct pixmap_visit visit;
>      ScreenPtr           screen = window->drawable.pScreen;
>  
>      visit.old = (*screen->GetWindowPixmap)(window);
> +    if (expected && visit.old != expected)
> +        return;
> +
>      visit.new = pixmap;
>      if (visit.old == visit.new)
>          return;
> @@ -390,6 +395,7 @@ static void
>  present_set_abort_flip(ScreenPtr screen)
>  {
>      present_screen_priv_ptr screen_priv = present_screen_priv(screen);
> +    PixmapPtr pixmap = (*screen->GetScreenPixmap)(screen);
>  
>      /* Switch back to using the screen pixmap now to avoid
>       * 2D applications drawing to the wrong pixmap.
> @@ -397,10 +403,11 @@ present_set_abort_flip(ScreenPtr screen)
>  
>      if (screen_priv->flip_window)
>          present_set_tree_pixmap(screen_priv->flip_window,
> -                                  (*screen->GetScreenPixmap)(screen));
> +                                screen_priv->flip_pixmap,
> +                                pixmap);
>  
>      if (screen->root)
> -        present_set_tree_pixmap(screen->root, (*screen->GetScreenPixmap)(screen));
> +        present_set_tree_pixmap(screen->root, NULL, pixmap);
>  
>      screen_priv->flip_pending->abort_flip = TRUE;
>  }
> @@ -414,10 +421,12 @@ present_unflip(ScreenPtr screen)
>      assert (!screen_priv->unflip_event_id);
>      assert (!screen_priv->flip_pending);
>  
> -    if (screen_priv->flip_window)
> -        present_set_tree_pixmap(screen_priv->flip_window, pixmap);
> +    if (screen_priv->flip_pixmap && screen_priv->flip_window)
> +        present_set_tree_pixmap(screen_priv->flip_window,
> +                                screen_priv->flip_pixmap,
> +                                pixmap);
>  
> -    present_set_tree_pixmap(screen->root, pixmap);
> +    present_set_tree_pixmap(screen->root, NULL, pixmap);
>  
>      /* Update the screen pixmap with the current flip pixmap contents
>       */
> @@ -645,9 +654,10 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
>                   */
>                  if (screen_priv->flip_window && screen_priv->flip_window != window)
>                      present_set_tree_pixmap(screen_priv->flip_window,
> -                                              (*screen->GetScreenPixmap)(screen));
> -                present_set_tree_pixmap(window, pixmap);
> -                present_set_tree_pixmap(screen->root, pixmap);
> +                                            screen_priv->flip_pixmap,
> +                                            (*screen->GetScreenPixmap)(screen));
> +                present_set_tree_pixmap(window, NULL, pixmap);
> +                present_set_tree_pixmap(screen->root, NULL, pixmap);
>  
>                  /* Report update region as damaged
>                   */
> 

Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the xorg-devel mailing list