From 03a7c50202f61030830ff639fccf52091e02156c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 15 Aug 2016 10:44:57 +0200 Subject: [PATCH] modesetting: ms_dri2_create_buffer: check screen of existing front buffers If a frontbuffer drawable already has a pixmap, make sure it was created on the right screen. Reviewed-by: Adam Jackson Signed-off-by: Hans de Goede --- hw/xfree86/drivers/modesetting/dri2.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c index cbef2e64a..6ab648135 100644 --- a/hw/xfree86/drivers/modesetting/dri2.c +++ b/hw/xfree86/drivers/modesetting/dri2.c @@ -118,17 +118,6 @@ get_drawable_pixmap(DrawablePtr drawable) return screen->GetWindowPixmap((WindowPtr) drawable); } -static PixmapPtr -get_front_buffer(DrawablePtr drawable) -{ - PixmapPtr pixmap; - - pixmap = get_drawable_pixmap(drawable); - pixmap->refcnt++; - - return pixmap; -} - static DRI2Buffer2Ptr ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, unsigned int format) @@ -152,8 +141,13 @@ ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, } pixmap = NULL; - if (attachment == DRI2BufferFrontLeft) - pixmap = get_front_buffer(drawable); + if (attachment == DRI2BufferFrontLeft) { + pixmap = get_drawable_pixmap(drawable); + if (pixmap && pixmap->drawable.pScreen != screen) + pixmap = NULL; + if (pixmap) + pixmap->refcnt++; + } if (pixmap == NULL) { int pixmap_width = drawable->width;