xserver: Branch 'transform-proposal' - 4 commits

Keith Packard keithp at kemper.freedesktop.org
Mon Mar 17 15:21:01 PDT 2008


 hw/xfree86/modes/xf86Crtc.c   |   12 +++++++++
 hw/xfree86/modes/xf86Crtc.h   |    2 +
 hw/xfree86/modes/xf86Rotate.c |   53 +++++++++++++++++++++++++++---------------
 randr/randrstr.h              |    2 +
 randr/rrcrtc.c                |   28 ++++++++++++++--------
 render/filter.c               |   27 +++++++++++++++------
 render/picturestr.h           |    8 ++++--
 7 files changed, 95 insertions(+), 37 deletions(-)

New commits:
commit 18d6f5b8011c13ac4c5f600c98b9f2052f995a82
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Mar 17 15:22:06 2008 -0700

    Handle filter widths in xf86Rotate

diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 6f3fcd4..8a4776f 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -309,6 +309,8 @@ struct _xf86Crtc {
     PictFilterPtr   filter;
     xFixed	    *params;
     int		    nparams;
+    int		    filter_width;
+    int		    filter_height;
     Bool	    transform_in_use;
     /**
      * Bounding box in screen space
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 91b1861..b00d11a 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -118,6 +118,10 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
 	BoxRec	dst_box;
 
 	dst_box = *b;
+	dst_box.x1 -= crtc->filter_width >> 2;
+	dst_box.x2 += crtc->filter_width >> 2;
+	dst_box.y1 -= crtc->filter_width >> 2;
+	dst_box.y2 += crtc->filter_width >> 2;
 	PictureTransformBounds (&dst_box, &crtc->framebuffer_to_crtc);
 	CompositePicture (PictOpSrc,
 			  src, NULL, dst,
@@ -305,6 +309,11 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
     /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
     ScreenPtr		pScreen = screenInfo.screens[pScrn->scrnIndex];
     PictTransform	crtc_to_fb, fb_to_crtc;
+    xFixed		*new_params = NULL;
+    int			new_nparams = 0;
+    PictFilterPtr	new_filter = NULL;
+    int			new_width = 0;
+    int			new_height = 0;
     
     PictureTransformInitIdentity (&crtc_to_fb);
     PictureTransformInitIdentity (&fb_to_crtc);
@@ -368,9 +377,6 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
 #ifdef RANDR_12_INTERFACE
     if (crtc->randr_crtc)
     {
-	xFixed		*new_params = NULL;
-	int		new_nparams = 0;
-	PictFilterPtr   new_filter = NULL;
 
 	RRTransformPtr	transform = RRCrtcGetTransform (crtc->randr_crtc);
 	if (transform)
@@ -388,11 +394,6 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
 	    PictureTransformMultiply (&crtc_to_fb, &transform->transform, &crtc_to_fb);
 	    PictureTransformMultiply (&fb_to_crtc, &fb_to_crtc, &transform->inverse);
 	}
-	if (crtc->params)
-	    xfree (crtc->params);
-	crtc->params = new_params;
-	crtc->nparams = new_nparams;
-	crtc->filter = new_filter;
     }
 #endif
     /*
@@ -401,12 +402,19 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
      */
     if (PictureTransformIsIdentity (&crtc_to_fb))
     {
-	crtc->transform_in_use = FALSE;
-	PictureTransformInitTranslate (&crtc->crtc_to_framebuffer, 
+	PictureTransformInitTranslate (&crtc_to_fb,
 				       F (-crtc->x), F (-crtc->y));
-	PictureTransformInitTranslate (&crtc->framebuffer_to_crtc,
+	PictureTransformInitTranslate (&fb_to_crtc,
 				       F ( crtc->x), F ( crtc->y));
 	xf86RotateDestroy (crtc);
+	crtc->transform_in_use = FALSE;
+	if (new_params)
+	    xfree (new_params);
+	new_params = NULL;
+	new_nparams = 0;
+	new_filter = NULL;
+	new_width = 0;
+	new_height = 0;
     }
     else
     {
@@ -473,17 +481,26 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
 								  NULL,
 								  old_width,
 								  old_height);
+	    if (new_params)
+		xfree (new_params);
 	    return FALSE;
 	}
 	crtc->transform_in_use = TRUE;
-	crtc->crtc_to_framebuffer = crtc_to_fb;
-	crtc->framebuffer_to_crtc = fb_to_crtc;
-	crtc->bounds.x1 = 0;
-	crtc->bounds.x2 = crtc->mode.HDisplay;
-	crtc->bounds.y1 = 0;
-	crtc->bounds.y2 = crtc->mode.VDisplay;
-	PictureTransformBounds (&crtc->bounds, &crtc_to_fb);
     }
+    crtc->crtc_to_framebuffer = crtc_to_fb;
+    crtc->framebuffer_to_crtc = fb_to_crtc;
+    if (crtc->params)
+	xfree (crtc->params);
+    crtc->params = new_params;
+    crtc->nparams = new_nparams;
+    crtc->filter = new_filter;
+    crtc->filter_width = new_width;
+    crtc->filter_height = new_height;
+    crtc->bounds.x1 = 0;
+    crtc->bounds.x2 = crtc->mode.HDisplay;
+    crtc->bounds.y1 = 0;
+    crtc->bounds.y2 = crtc->mode.VDisplay;
+    PictureTransformBounds (&crtc->bounds, &crtc_to_fb);
     
     /* All done */
     return TRUE;
commit 3b0552541f8ea493b9e34b9abb8230d7c8cec76e
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Mar 17 15:21:26 2008 -0700

    Initialize and cleanup new filter fields in xf86Crtc.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 9b1f603..f94996f 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -103,6 +103,16 @@ xf86CrtcCreate (ScrnInfoPtr		scrn,
 #endif
     crtc->rotation = RR_Rotate_0;
     crtc->desiredRotation = RR_Rotate_0;
+    PictureTransformInitIdentity (&crtc->crtc_to_framebuffer);
+    PictureTransformInitIdentity (&crtc->framebuffer_to_crtc);
+    crtc->filter = NULL;
+    crtc->params = NULL;
+    crtc->nparams = 0;
+    crtc->filter_width = 0;
+    crtc->filter_height = 0;
+    crtc->transform_in_use = FALSE;
+    memset (&crtc->bounds, '\0', sizeof (crtc->bounds));
+
     if (xf86_config->crtc)
 	crtcs = xrealloc (xf86_config->crtc,
 			  (xf86_config->num_crtc + 1) * sizeof (xf86CrtcPtr));
@@ -134,6 +144,8 @@ xf86CrtcDestroy (xf86CrtcPtr crtc)
 	    xf86_config->num_crtc--;
 	    break;
 	}
+    if (crtc->params)
+	xfree (crtc->params);
     xfree (crtc);
 }
 
commit 1970640dc649833e0236581fd769117f313ab7f6
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Mar 17 15:20:52 2008 -0700

    Pass filter kernel size through transforms

diff --git a/randr/randrstr.h b/randr/randrstr.h
index e6e65d0..f97c26d 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -108,6 +108,8 @@ struct _rrTransform {
     PictFilterPtr   filter;
     xFixed	    *params;
     int		    nparams;
+    int		    width;
+    int		    height;
 };
 
 struct _rrCrtc {
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index f73a9c0..9032b61 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -62,7 +62,9 @@ static Bool
 RRTransformSetFilter (RRTransformPtr	dst,
 		      PictFilterPtr	filter,
 		      xFixed		*params,
-		      int		nparams)
+		      int		nparams,
+		      int		width,
+		      int		height)
 {
     xFixed  *new_params;
 
@@ -80,6 +82,8 @@ RRTransformSetFilter (RRTransformPtr	dst,
     dst->filter = filter;
     dst->params = new_params;
     dst->nparams = nparams;
+    dst->width = width;
+    dst->height = height;
     return TRUE;
 }
 
@@ -87,7 +91,7 @@ static Bool
 RRTransformCopy (RRTransformPtr dst, RRTransformPtr src)
 {
     if (!RRTransformSetFilter (dst, src->filter,
-			       src->params, src->nparams))
+			       src->params, src->nparams, src->width, src->height))
 	return FALSE;
     dst->transform = src->transform;
     dst->inverse = src->inverse;
@@ -602,6 +606,7 @@ RRCrtcTransformSet (RRCrtcPtr		crtc,
 		    int			nparams)
 {
     PictFilterPtr   filter = NULL;
+    int		    width = 0, height = 0;
 
     if (!PictureTransformIsInverse (transform, inverse))
 	return BadMatch;
@@ -615,9 +620,13 @@ RRCrtcTransformSet (RRCrtcPtr		crtc,
 	if (filter->ValidateParams)
 	{
 	    if (!filter->ValidateParams (crtc->pScreen, filter->id,
-					 params, nparams))
+					 params, nparams, &width, &height))
 		return BadMatch;
 	}
+	else {
+	    width = filter->width;
+	    height = filter->height;
+	}
     }
     else
     {
@@ -625,7 +634,7 @@ RRCrtcTransformSet (RRCrtcPtr		crtc,
 	    return BadMatch;
     }
     if (!RRTransformSetFilter (&crtc->client_pending_transform,
-			       filter, params, nparams))
+			       filter, params, nparams, width, height))
 	return BadAlloc;
 
     crtc->client_pending_transform.transform = *transform;
@@ -1037,12 +1046,11 @@ ProcRRSetCrtcConfig (ClientPtr client)
 	    int	source_height;
 	    PictTransform transform, inverse;
 
-	    if (!RRComputeTransform (mode, stuff->rotation,
-				     stuff->x, stuff->y,
-				     &crtc->client_pending_transform.transform,
-				     &crtc->client_pending_transform.inverse,
-				     &transform, &inverse))
-		return BadMatch;
+	    RRComputeTransform (mode, stuff->rotation,
+				stuff->x, stuff->y,
+				&crtc->client_pending_transform.transform,
+				&crtc->client_pending_transform.inverse,
+				&transform, &inverse);
 
 	    RRModeGetScanoutSize (mode, &transform, &source_width, &source_height);
 	    if (stuff->x + source_width > pScreen->width)
commit 698047944f7be3121addbaf0b8b2466f3343c352
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Mar 17 15:19:17 2008 -0700

    Add kernel size to Render filters.
    
    This width/height value lets filter users know how far the filter spreads
    into the source image.

diff --git a/render/filter.c b/render/filter.c
index bc742e5..485b2a1 100644
--- a/render/filter.c
+++ b/render/filter.c
@@ -126,7 +126,9 @@ PictureFreeFilterIds (void)
 _X_EXPORT int
 PictureAddFilter (ScreenPtr			    pScreen,
 		  char				    *filter,
-		  PictFilterValidateParamsProcPtr   ValidateParams)
+		  PictFilterValidateParamsProcPtr   ValidateParams,
+		  int				    width,
+		  int				    height)
 {
     PictureScreenPtr    ps = GetPictureScreen(pScreen);
     int			id = PictureGetFilterId (filter, -1,  TRUE);
@@ -152,6 +154,8 @@ PictureAddFilter (ScreenPtr			    pScreen,
     ps->filters[i].name = PictureGetFilterName (id);
     ps->filters[i].id = id;
     ps->filters[i].ValidateParams = ValidateParams;
+    ps->filters[i].width = width;
+    ps->filters[i].height = height;
     return id;
 }
 
@@ -216,18 +220,26 @@ static Bool
 convolutionFilterValidateParams (ScreenPtr pScreen,
                                  int	   filter,
                                  xFixed	   *params,
-                                 int	   nparams)
+                                 int	   nparams,
+				 int       *width,
+				 int	   *height)
 {
+    int	w, h;
     if (nparams < 3)
         return FALSE;
 
     if (xFixedFrac (params[0]) || xFixedFrac (params[1]))
         return FALSE;
 
+    w = xFixedToInt (params[0]);
+    h = xFixedToInt (params[1]);
+
     nparams -= 2;
-    if ((xFixedToInt (params[0]) * xFixedToInt (params[1])) > nparams)
+    if (w * h > nparams)
         return FALSE;
 
+    *width = w;
+    *height = h;
     return TRUE;
 }
 
@@ -238,9 +250,9 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
     if (!filterNames)
 	if (!PictureSetDefaultIds ())
 	    return FALSE;
-    if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
+    if (PictureAddFilter (pScreen, FilterNearest, 0, 1, 1) < 0)
 	return FALSE;
-    if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
+    if (PictureAddFilter (pScreen, FilterBilinear, 0, 4, 4) < 0)
 	return FALSE;
 
     if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
@@ -250,7 +262,7 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
     if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterBest))
 	return FALSE;
 
-    if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams) < 0)
+    if (PictureAddFilter (pScreen, FilterConvolution, convolutionFilterValidateParams, 0, 0) < 0)
         return FALSE;
 
     return TRUE;
@@ -314,7 +326,8 @@ SetPicturePictFilter (PicturePtr pPicture, PictFilterPtr pFilter,
 
     if (pFilter->ValidateParams)
     {
-	if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams))
+	int width, height;
+	if (!(*pFilter->ValidateParams) (pScreen, pFilter->id, params, nparams, &width, &height))
 	    return BadMatch;
     }
     else if (nparams)
diff --git a/render/picturestr.h b/render/picturestr.h
index 805c85c..4a07070 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -185,11 +185,13 @@ typedef struct _Picture {
 } PictureRec;
 
 typedef Bool (*PictFilterValidateParamsProcPtr) (ScreenPtr pScreen, int id,
-						 xFixed *params, int nparams);
+						 xFixed *params, int nparams,
+						 int *width, int *height);
 typedef struct {
     char			    *name;
     int				    id;
     PictFilterValidateParamsProcPtr ValidateParams;
+    int				    width, height;
 } PictFilterRec, *PictFilterPtr;
 
 #define PictFilterNearest	0
@@ -461,7 +463,9 @@ PictureGetFilterName (int id);
 int
 PictureAddFilter (ScreenPtr			    pScreen,
 		  char				    *filter,
-		  PictFilterValidateParamsProcPtr   ValidateParams);
+		  PictFilterValidateParamsProcPtr   ValidateParams,
+		  int				    width,
+		  int				    height);
 
 Bool
 PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);


More information about the xorg-commit mailing list