xserver: Branch 'transform-proposal' - 4 commits

Keith Packard keithp at kemper.freedesktop.org
Tue Mar 18 16:04:34 PDT 2008


 hw/xfree86/modes/xf86Crtc.c    |    6 ++++++
 hw/xfree86/modes/xf86RandR12.c |   25 +++++++++++++++++++++++++
 hw/xfree86/modes/xf86RandR12.h |    1 +
 hw/xfree86/modes/xf86Rotate.c  |   30 ++++++++++++++++++++++++++++++
 randr/randrstr.h               |    7 +++++++
 randr/rrcrtc.c                 |   17 +++++++++++++----
 render/matrix.c                |    7 ++++---
 7 files changed, 86 insertions(+), 7 deletions(-)

New commits:
commit 71267eb3806bdf441110d76e83e936e410d7f380
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Mar 18 16:06:06 2008 -0700

    Eliminate inverse matrix from randr transform protocol
    
    It is easier, and potentially more precise, to compute the inverse in the
    server where everything can eventually be kept in floating point form.

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 5e3e38a..098254b 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1332,14 +1332,12 @@ ProcRRGetCrtcTransform (ClientPtr client)
     reply->hasTransforms = crtc->transforms;
 
     transform_encode (client, &reply->pendingTransform, &pending->transform);
-    transform_encode (client, &reply->pendingInverse, &pending->inverse);
     extra += transform_filter_encode (client, extra,
 				      &reply->pendingNbytesFilter,
 				      &reply->pendingNparamsFilter,
 				      pending);
 
     transform_encode (client, &reply->currentTransform, &current->transform);
-    transform_encode (client, &reply->currentInverse, &current->inverse);
     extra += transform_filter_encode (client, extra,
 				      &reply->currentNbytesFilter,
 				      &reply->currentNparamsFilter,
commit fd7b5e2c280ca5490b40f93d105e1e8e6636072c
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Mar 18 15:35:44 2008 -0700

    Report whether transforms are support from driver through extension to client
    
    Add APIs to xf86RandR12 support and randr extension to record whether the
    driver supports transforms, report that value in the RRGetCrtcTransform
    reply.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index f94996f..257003e 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -730,11 +730,17 @@ xf86CrtcScreenInit (ScreenPtr screen)
 	    break;
     }
     if (c == config->num_crtc)
+    {
 	xf86RandR12SetRotations (screen, RR_Rotate_0 | RR_Rotate_90 |
 				 RR_Rotate_180 | RR_Rotate_270 |
 				 RR_Reflect_X | RR_Reflect_Y);
+	xf86RandR12SetTransform (screen, TRUE);
+    }
     else
+    {
 	xf86RandR12SetRotations (screen, RR_Rotate_0);
+	xf86RandR12SetTransform (screen, FALSE);
+    }
     
     /* Wrap CreateScreenResources so we can initialize the RandR code */
     config->CreateScreenResources = screen->CreateScreenResources;
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index af02501..75f7ef3 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -586,6 +586,31 @@ xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
 }
 
 _X_EXPORT void
+xf86RandR12SetTransform (ScreenPtr pScreen, Bool transforms)
+{
+    XF86RandRInfoPtr	randrp;
+#if RANDR_13_INTERFACE
+    ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
+    int			c;
+    xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
+#endif
+
+#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
+    if (xf86RandR12Key == NULL)
+	return;
+#endif
+
+    randrp = XF86RANDRINFO(pScreen);
+#if RANDR_13_INTERFACE
+    for (c = 0; c < config->num_crtc; c++) {
+	xf86CrtcPtr    crtc = config->crtc[c];
+
+	RRCrtcSetTransform (crtc->randr_crtc, transforms);
+    }
+#endif
+}
+
+_X_EXPORT void
 xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
 {
     ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
diff --git a/hw/xfree86/modes/xf86RandR12.h b/hw/xfree86/modes/xf86RandR12.h
index 4fd855c..c361b47 100644
--- a/hw/xfree86/modes/xf86RandR12.h
+++ b/hw/xfree86/modes/xf86RandR12.h
@@ -31,6 +31,7 @@
 Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen);
 Bool xf86RandR12Init(ScreenPtr pScreen);
 void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotation);
+void xf86RandR12SetTransform (ScreenPtr pScreen, Bool transforms);
 Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, int rate,
 			RRScreenSizePtr pSize);
 Rotation xf86RandR12GetRotation(ScreenPtr pScreen);
diff --git a/randr/randrstr.h b/randr/randrstr.h
index f97c26d..c3e0003 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -127,6 +127,7 @@ struct _rrCrtc {
     CARD16	    *gammaBlue;
     CARD16	    *gammaGreen;
     void	    *devPrivate;
+    Bool	    transforms;
     RRTransformRec  client_pending_transform;
     RRTransformRec  client_current_transform;
     PictTransform   transform;
@@ -536,6 +537,12 @@ void
 RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations);
 
 /*
+ * Set whether transforms are allowed on a CRTC
+ */
+void
+RRCrtcSetTransform (RRCrtcPtr crtc, Bool transforms);
+
+/*
  * Notify the extension that the Crtc has been reconfigured,
  * the driver calls this whenever it has updated the mode
  */
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index a3e2503..5e3e38a 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -164,6 +164,15 @@ RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations)
 }
 
 /*
+ * Set whether transforms are allowed on a CRTC
+ */
+void
+RRCrtcSetTransform (RRCrtcPtr crtc, Bool transforms)
+{
+    crtc->transforms = transforms;
+}
+
+/*
  * Notify the extension that the Crtc has been reconfigured,
  * the driver calls this whenever it has updated the mode
  */
@@ -608,6 +617,9 @@ RRCrtcTransformSet (RRCrtcPtr		crtc,
     PictFilterPtr   filter = NULL;
     int		    width = 0, height = 0;
 
+    if (!crtc->transforms)
+	return BadValue;
+
     if (filter_len)
     {
 	filter = PictureFindFilter (crtc->pScreen,
@@ -1317,8 +1329,7 @@ ProcRRGetCrtcTransform (ClientPtr client)
     reply->sequenceNumber = client->sequence;
     reply->length = (CrtcTransformExtra + nextra) >> 2;
 
-    /* XXX deal with DDXen that can't do transforms */
-    reply->hasTransforms = xTrue;
+    reply->hasTransforms = crtc->transforms;
 
     transform_encode (client, &reply->pendingTransform, &pending->transform);
     transform_encode (client, &reply->pendingInverse, &pending->inverse);
commit 85ff452bfc12290bd274b8754f82b15c6302ca3d
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Mar 18 15:25:31 2008 -0700

    Clear shadow pixmaps before using them.
    
    This eliminates some ugly flashing, as well as clearing the borders when the
    shadow will not be completely painted.

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 5e8174c..e09d928 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -154,6 +154,35 @@ xf86CrtcDamageShadow (xf86CrtcPtr crtc)
 }
 
 static void
+xf86CrtcShadowClear (xf86CrtcPtr crtc)
+{
+    PixmapPtr		dst_pixmap = crtc->rotatedPixmap;
+    ScrnInfoPtr		scrn = crtc->scrn;
+    ScreenPtr		screen = scrn->pScreen;
+    PicturePtr		dst;
+    PictFormatPtr	format = compWindowFormat (WindowTable[screen->myNum]);
+    static xRenderColor black = { 0, 0, 0, 0 };
+    xRectangle		rect;
+    int			error;
+
+    dst = CreatePicture (None,
+			 &dst_pixmap->drawable,
+			 format,
+			 0L,
+			 NULL,
+			 serverClient,
+			 &error);
+    if (!dst)
+	return;
+    rect.x = 0;
+    rect.y = 0;
+    rect.width = dst_pixmap->drawable.width;
+    rect.height = dst_pixmap->drawable.height;
+    CompositeRects (PictOpSrc, dst, &black, 1, &rect);
+    FreePicture (dst, None);
+}
+
+static void
 xf86RotatePrepare (ScreenPtr pScreen)
 {
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
@@ -170,6 +199,7 @@ xf86RotatePrepare (ScreenPtr pScreen)
 							     crtc->rotatedData,
 							     crtc->mode.HDisplay,
 							     crtc->mode.VDisplay);
+	    xf86CrtcShadowClear (crtc);
 	    if (!xf86_config->rotation_damage_registered)
 	    {
 		/* Hook damage to screen pixmap */
commit 02b8d204e17882f3e48ad3e1944c94acc4c2adf0
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Mar 18 15:15:40 2008 -0700

    When converting from double to fixed, round carefully.
    
    This reduces the matrix representation error after inverting a
    transformation matrix (although it doesn't eliminate it entirely).
    
    Perhaps we should extend Render to include 64-bit floating point transforms...

diff --git a/render/matrix.c b/render/matrix.c
index 6e50205..0d5d962 100644
--- a/render/matrix.c
+++ b/render/matrix.c
@@ -72,9 +72,9 @@ PictureTransformPoint3d (PictTransformPtr transform,
 	    return FALSE;
 	result.vector[j] = (xFixed) v;
     }
+    *vector = result;
     if (!result.vector[2])
 	return FALSE;
-    *vector = result;
     return TRUE;
 }
 
@@ -286,7 +286,8 @@ from_doubles (PictTransformPtr t, double m[3][3])
 	    double  d = m[j][i];
 	    if (d < -32767.0 || d > 32767.0)
 		return FALSE;
-	    t->matrix[j][i] = pixman_double_to_fixed (d);
+	    d = d * 65536.0 + 0.5;
+	    t->matrix[j][i] = (xFixed) floor (d);
 	}
     return TRUE;
 }
@@ -294,7 +295,7 @@ from_doubles (PictTransformPtr t, double m[3][3])
 static Bool
 invert (double r[3][3], double m[3][3])
 {
-    double  det, norm;
+    double  det;
     int	    i, j;
     static int	a[3] = { 2, 2, 1 };
     static int	b[3] = { 1, 0, 0 };


More information about the xorg-commit mailing list