randr: Take panning into account when computing CRTC bounds

Submitted by Rui Matos on June 29, 2011, 11:32 a.m.

Details

Message ID 1309321926-21433-1-git-send-email-tiagomatos@gmail.com
State Superseded, archived
Headers show

Commit Message

Rui Matos June 29, 2011, 11:32 a.m.
Fixes regression introduced in 56c90e29f04727c903bd0f084d23bf44eb1a0a11.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
---
 randr/rrcrtc.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 0437795..a940847 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -297,20 +297,60 @@  RRCrtcPendingProperties (RRCrtcPtr crtc)
 static void
 crtc_bounds(RRCrtcPtr crtc, int *left, int *right, int *top, int *bottom)
 {
-    *left = crtc->x;
-    *top = crtc->y;
+    ScreenPtr pScreen = crtc->pScreen;
+    rrScrPriv (pScreen);
+    BoxRec panned_area;
+    Bool x_pan = FALSE;
+    Bool y_pan = FALSE;
+
+    if (pScrPriv->rrGetPanning &&
+        pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL))
+    {
+        x_pan = panned_area.x2 > panned_area.x1;
+        y_pan = panned_area.y2 > panned_area.y1;
+    }
 
     switch (crtc->rotation) {
     case RR_Rotate_0:
     case RR_Rotate_180:
     default:
-       *right = crtc->x + crtc->mode->mode.width;
-       *bottom = crtc->y + crtc->mode->mode.height;
-       return;
+
+        if (x_pan) {
+            *left = panned_area.x1;
+            *right = panned_area.x2;
+        } else {
+            *left = crtc->x;
+            *right = crtc->x + crtc->mode->mode.width;
+        }
+
+        if (y_pan) {
+            *top = panned_area.y1;
+            *bottom = panned_area.y2;
+        } else {
+            *top = crtc->y;
+            *bottom = crtc->y + crtc->mode->mode.height;
+        }
+
+        return;
     case RR_Rotate_90:
     case RR_Rotate_270:
-       *right = crtc->x + crtc->mode->mode.height;
-       *bottom = crtc->y + crtc->mode->mode.width;
+
+        if (x_pan) {
+            *left = panned_area.x1;
+            *right = panned_area.x2;
+        } else {
+            *left = crtc->x;
+            *right = crtc->x + crtc->mode->mode.height;
+        }
+
+        if (y_pan) {
+            *top = panned_area.y1;
+            *bottom = panned_area.y2;
+        } else {
+            *top = crtc->y;
+            *bottom = crtc->y + crtc->mode->mode.width;
+        }
+
        return;
     }
 }