summaryrefslogtreecommitdiff
path: root/GL/glx
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2007-06-11 09:23:19 +0200
committerMichel Dänzer <michel@tungstengraphics.com>2007-06-11 09:23:19 +0200
commit1aceec61ff203848576c47a1eab13f90a67d7176 (patch)
tree7a5d0d37f92898ffb5234ea03eebecce835a7d1a /GL/glx
parent5d896e43fd056d935935b4eb66562791edc247a1 (diff)
DRI: Clip cliprects obtained from DRIGetDrawableInfo to screen dimensions.
This is to avoid issues with redirected windows which are located partly or fully outside of a screen edge, resulting in unusual cliprects which the 3D drivers generally can't handle. The symptoms in such cases would be incorrect rendering or even crashes or hangs.
Diffstat (limited to 'GL/glx')
-rw-r--r--GL/glx/glxdri.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index 156e8468c..efa02f842 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -886,8 +886,32 @@ getDrawableInfo(__DRInativeDisplay *dpy, int screen,
if (*numClipRects > 0) {
size = sizeof (drm_clip_rect_t) * *numClipRects;
*ppClipRects = xalloc (size);
- if (*ppClipRects != NULL)
- memcpy (*ppClipRects, pClipRects, size);
+
+ /* Clip cliprects to screen dimensions (redirected windows) */
+ if (*ppClipRects != NULL) {
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ int i, j;
+
+ for (i = 0, j = 0; i < *numClipRects; i++) {
+ (*ppClipRects)[j].x1 = max(pClipRects[i].x1, 0);
+ (*ppClipRects)[j].y1 = max(pClipRects[i].y1, 0);
+ (*ppClipRects)[j].x2 = min(pClipRects[i].x2, pScreen->width);
+ (*ppClipRects)[j].y2 = min(pClipRects[i].y2, pScreen->height);
+
+ if ((*ppClipRects)[j].x1 < (*ppClipRects)[j].x2 &&
+ (*ppClipRects)[j].y1 < (*ppClipRects)[j].y2) {
+ j++;
+ }
+ }
+
+ if (*numClipRects != j) {
+ *numClipRects = j;
+ *ppClipRects = xrealloc (*ppClipRects,
+ sizeof (drm_clip_rect_t) *
+ *numClipRects);
+ }
+ } else
+ *numClipRects = 0;
}
else {
*ppClipRects = NULL;