[PATCH randr] randr: Applying current transformation on Crtc

Nikhil Mahale nmahale at nvidia.com
Sat Sep 22 09:24:46 PDT 2012


Screen size should be large enough to accommodate all crtcs,
Applying current rotation/transformation, and find out bounds of Crtc.
Not translating bounds by crtc->[xy], because that translation already present in "transform" matrix.

Signed-off-by: Nikhil Mahale <nmahale at nvidia.com>
---
 randr/rrscreen.c    |   41 ++++++++++++++++++++++++++++++++---------
 render/matrix.c     |    6 ++++++
 render/picturestr.h |    3 +++
 3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 39340cc..120eadd 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -232,6 +232,34 @@ ProcRRGetScreenSizeRange(ClientPtr client)
     return Success;
 }
 
+static BoxRec
+rrGetModeBounds(RRModePtr mode, Rotation rotation,
+                PictTransformPtr transform)
+{
+    BoxRec box = {0, 0, 0, 0};
+    int source_width;
+    int source_height;
+
+
+    if (mode == NULL) {
+        return box;
+    }
+
+    source_width = mode->mode.width;
+    source_height = mode->mode.height;
+    if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) {
+        source_width = mode->mode.height;
+        source_height = mode->mode.width;
+    }
+
+    box.x2 = source_width;
+    box.y2 = source_height;
+
+    PictureTransformBounds(transform, &box);
+
+    return box;
+}
+
 int
 ProcRRSetScreenSize(ClientPtr client)
 {
@@ -265,17 +293,12 @@ ProcRRSetScreenSize(ClientPtr client)
         RRModePtr mode = crtc->mode;
 
         if (mode) {
-            int source_width = mode->mode.width;
-            int source_height = mode->mode.height;
-            Rotation rotation = crtc->rotation;
+            BoxRec bounds;
 
-            if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) {
-                source_width = mode->mode.height;
-                source_height = mode->mode.width;
-            }
+            bounds = rrGetModeBounds(mode, crtc->rotation, &crtc->transform);
 
-            if (crtc->x + source_width > stuff->width ||
-                crtc->y + source_height > stuff->height)
+            if (bounds.x2 > stuff->width || bounds.y2 > stuff->height ||
+                bounds.x1 < 0 || bounds.y1 < 0)
                 return BadMatch;
         }
     }
diff --git a/render/matrix.c b/render/matrix.c
index 83cd66c..aec15d9 100644
--- a/render/matrix.c
+++ b/render/matrix.c
@@ -80,6 +80,12 @@ PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector)
 }
 
 Bool
+PictureTransformBounds(PictTransformPtr transform, BoxRec *box)
+{
+    return pixman_transform_bounds(transform, box);
+}
+
+Bool
 PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector)
 {
     return pixman_transform_point_3d(transform, vector);
diff --git a/render/picturestr.h b/render/picturestr.h
index dc00f41..51a1b4b 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -609,6 +609,9 @@ extern _X_EXPORT Bool
  PictureTransformPoint(PictTransformPtr transform, PictVectorPtr vector);
 
 extern _X_EXPORT Bool
+PictureTransformBounds(PictTransformPtr transform, BoxRec *box);
+
+extern _X_EXPORT Bool
  PictureTransformPoint3d(PictTransformPtr transform, PictVectorPtr vector);
 
 #endif                          /* _PICTURESTR_H_ */
-- 
1.7.6.5


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------


More information about the xorg-devel mailing list