From 0ce25fd7904c792924c3e0ee6fc21a5f1bec1a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 3 Dec 2010 17:42:16 +0200 Subject: [PATCH 1/2] dri2: Don't page flip when the window size doesn't match the pixmap size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the drawable size doesn't match the pixmap size page flipping should not be allowed. If the window is larger than the pixmap, page flipping might need to reposition the CRTC somewhere in the middle of the pixmap. I didn't spot any code that would handle that at least in the intel driver. Also the root pixmap could then move to some negative screen coordinates. Not sure if all bits of code could handle that. Perhaps when composite is enabled screen_x/y would make it work, but without composite there's no way that it would work AFAICS. Signed-off-by: Ville Syrjälä Reviewed-by: Alex Deucher --- hw/xfree86/dri2/dri2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index e4693d92e..39996f946 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -640,6 +640,17 @@ DRI2CanFlip(DrawablePtr pDraw) if (!RegionEqual(&pWin->clipList, &pRoot->winSize)) return FALSE; + /* Does the window match the pixmap exactly? */ + if (pDraw->x != 0 || + pDraw->y != 0 || +#ifdef COMPOSITE + pDraw->x != pWinPixmap->screen_x || + pDraw->y != pWinPixmap->screen_y || +#endif + pDraw->width != pWinPixmap->drawable.width || + pDraw->height != pWinPixmap->drawable.height) + return FALSE; + return TRUE; } From 2e781457d43ec4bf0d633257ac6852cde3b00541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Thu, 16 Dec 2010 18:22:13 +0200 Subject: [PATCH 2/2] xfree86/modes: Take rotation into account when checking mode size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assume that a mode can be used in either landscape or portrait orientation. I suppose the correct thing to do would be to collect all the supported rotations from the CRTCs that can be used with a specific output, but that information doesn't seem to be readily available when these checks are done. So just assume that either orientation is fine. Signed-off-by: Ville Syrjälä Reviewed-by: Adam Jackson --- hw/xfree86/modes/xf86Modes.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index 75584cf87..c2dc3dc75 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -355,15 +355,32 @@ xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, { DisplayModePtr mode; + if (maxPitch <= 0) + maxPitch = MAXINT; + if (maxX <= 0) + maxX = MAXINT; + if (maxY <= 0) + maxY = MAXINT; + for (mode = modeList; mode != NULL; mode = mode->next) { - if (maxPitch > 0 && mode->HDisplay > maxPitch) - mode->status = MODE_BAD_WIDTH; + if ((xf86ModeWidth(mode, RR_Rotate_0) > maxPitch || + xf86ModeWidth(mode, RR_Rotate_0) > maxX || + xf86ModeHeight(mode, RR_Rotate_0) > maxY) && + (xf86ModeWidth(mode, RR_Rotate_90) > maxPitch || + xf86ModeWidth(mode, RR_Rotate_90) > maxX || + xf86ModeHeight(mode, RR_Rotate_90) > maxY)) { + if (xf86ModeWidth(mode, RR_Rotate_0) > maxPitch || + xf86ModeWidth(mode, RR_Rotate_90) > maxPitch) + mode->status = MODE_BAD_WIDTH; - if (maxX > 0 && mode->HDisplay > maxX) - mode->status = MODE_VIRTUAL_X; + if (xf86ModeWidth(mode, RR_Rotate_0) > maxX || + xf86ModeWidth(mode, RR_Rotate_90) > maxX) + mode->status = MODE_VIRTUAL_X; - if (maxY > 0 && mode->VDisplay > maxY) - mode->status = MODE_VIRTUAL_Y; + if (xf86ModeHeight(mode, RR_Rotate_0) > maxY || + xf86ModeHeight(mode, RR_Rotate_90) > maxY) + mode->status = MODE_VIRTUAL_Y; + } if (mode->next == modeList) break;