[xserver-commit] xserver/composite compext.c,1.2,1.3 compinit.c,1.5,1.6 compint.h,1.4,1.5 compwindow.c,1.5,1.6

Keith Packard xserver-commit@pdx.freedesktop.org
Tue, 11 Nov 2003 01:02:24 -0800


Committed by: keithp

Update of /cvs/xserver/xserver/composite
In directory pdx:/tmp/cvs-serv12781/composite

Modified Files:
	compext.c compinit.c compint.h compwindow.c 
Log Message:
	* composite/compext.c: (ProcCompositeCreateRegionFromBorderClip):
	* composite/compinit.c: (compAddArgbVisual), (compScreenInit):
	* composite/compint.h:
	* composite/compwindow.c: (compImplicitRedirect),
	(compReparentWindow), (compCreateWindow),
	(compSetRedirectBorderClip), (compWindowUpdateAutomatic):
	* miext/damage/damage.c: (DamageDamageRegion):
	* render/picture.c: (PictureMatchVisual):
	Add ARGB32 visual type with automatic update as needed.
	Fix a few more issues with damage being saved in window space.
	Damage windows that are moved.
	Fix overflow problem in PicturMatchVisual.


Index: compext.c
===================================================================
RCS file: /cvs/xserver/xserver/composite/compext.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- compext.c	7 Nov 2003 23:29:29 -0000	1.2
+++ compext.c	11 Nov 2003 09:02:22 -0000	1.3
@@ -204,6 +204,7 @@
     pRegion = XFixesRegionCopy (pBorderClip);
     if (!pRegion)
 	return BadAlloc;
+    REGION_TRANSLATE (pScreen, pRegion, -pWin->drawable.x, -pWin->drawable.y);
     
     if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
 	return BadAlloc;

Index: compinit.c
===================================================================
RCS file: /cvs/xserver/xserver/composite/compinit.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- compinit.c	9 Nov 2003 07:05:59 -0000	1.5
+++ compinit.c	11 Nov 2003 09:02:22 -0000	1.6
@@ -83,6 +83,132 @@
     pScreen->BlockHandler = compBlockHandler;
 }
 
+/*
+ * Add depth 32 ARGB visual type
+ */
+
+static Bool
+compAddArgbVisual (ScreenPtr pScreen, CompScreenPtr cs)
+{
+    VisualPtr	    visuals;
+    VisualPtr	    visual;
+    DepthPtr	    depth;
+    int		    i;
+    int		    numVisuals;
+    VisualID	    *vids;
+    PictFormatPtr   pPictFormat;
+    XID		    *installedCmaps;
+    ColormapPtr	    installedCmap;
+    int		    numInstalledCmaps;
+    
+    /*
+     * Find depth 32
+     */
+    for (i = 0; i < pScreen->numDepths; i++)
+    {
+	depth = &pScreen->allowedDepths[i];
+	if (depth->depth == 32)
+	    break;
+    }
+    /*
+     * If there isn't one, then it's gonna be hard to have a depth 32 visual
+     */
+    if (i == pScreen->numDepths)
+	return TRUE;
+    /*
+     * Make sure it doesn't have visuals already
+     */
+    if (depth->numVids)
+	return TRUE;
+    
+    /*
+     * Find the right picture format
+     */
+    pPictFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
+    if (!pPictFormat)
+	return TRUE;
+
+    /*
+     * Ok, create a visual for depth 32
+     */
+    cs->argbVid = FakeClientID (0);
+    numVisuals = pScreen->numVisuals;
+    /*
+     * Allocate vid list for depth 32
+     */
+    vids = xalloc (1 * sizeof (VisualID));
+    if (!vids)
+	return FALSE;
+    /*
+     * Find the installed colormaps
+     */
+    installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID));
+    if (!installedCmaps)
+    {
+	xfree (vids);
+	return FALSE;
+    }
+    numInstalledCmaps = (*pScreen->ListInstalledColormaps) (pScreen, 
+							    installedCmaps);
+    
+    /*
+     * realloc the visual array to fit the new one in place
+     */
+    visuals = xrealloc (pScreen->visuals,
+			(numVisuals + 1) * sizeof (VisualRec));
+    if (!visuals)
+    {
+	xfree (vids);
+	return FALSE;
+    }
+    
+    visual = &visuals[numVisuals];
+    numVisuals++;
+    
+    /*
+     * Fix up the default colormaps
+     */
+    for (i = 0; i < numInstalledCmaps; i++)
+    {
+	int j;
+	
+	installedCmap = LookupIDByType (installedCmaps[i], RT_COLORMAP);
+	if (!installedCmap)
+	    continue;
+	j = installedCmap->pVisual - pScreen->visuals;
+	installedCmap->pVisual = &visuals[j];
+    }
+
+    pScreen->visuals = visuals;
+    pScreen->numVisuals = numVisuals;
+
+    /*
+     * Initialize the visual
+     */
+    visual->class = TrueColor;
+    visual->bitsPerRGBValue = 8;
+    visual->ColormapEntries = (1 << 8);
+    visual->nplanes = 32;
+    visual->vid = cs->argbVid = FakeClientID (0);
+    visual->redMask   = (((unsigned long) pPictFormat->direct.redMask) << 
+			 pPictFormat->direct.red);
+    visual->greenMask = (((unsigned long) pPictFormat->direct.greenMask) << 
+			 pPictFormat->direct.green);
+    visual->blueMask  = (((unsigned long) pPictFormat->direct.blueMask) << 
+			 pPictFormat->direct.blue);
+    visual->offsetRed   = pPictFormat->direct.red;
+    visual->offsetGreen = pPictFormat->direct.green;
+    visual->offsetBlue  = pPictFormat->direct.blue;
+
+    /*
+     * Fix up the depth
+     */
+    vids[0] = cs->argbVid;
+    depth->numVids = 1;
+    depth->vids = vids;
+    return TRUE;
+}
+
 Bool
 compScreenInit (ScreenPtr pScreen)
 {
@@ -115,6 +241,12 @@
 
     cs->damaged = FALSE;
 
+    if (!compAddArgbVisual (pScreen, cs))
+    {
+	xfree (cs);
+	return FALSE;
+    }
+
     cs->PositionWindow = pScreen->PositionWindow;
     pScreen->PositionWindow = compPositionWindow;
 

Index: compint.h
===================================================================
RCS file: /cvs/xserver/xserver/composite/compint.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- compint.h	9 Nov 2003 07:05:59 -0000	1.4
+++ compint.h	11 Nov 2003 09:02:22 -0000	1.5
@@ -62,6 +62,7 @@
     CompClientWindowPtr	    clients;
     int			    oldx;
     int			    oldy;
+    int			    borderClipX, borderClipY;
 } CompWindowRec, *CompWindowPtr;
 
 #define COMP_ORIGIN_INVALID	    0x80000000
@@ -85,6 +86,7 @@
     ScreenBlockHandlerProcPtr	BlockHandler;
     CloseScreenProcPtr		CloseScreen;
     Bool			damaged;
+    XID				argbVid;
 } CompScreenRec, *CompScreenPtr;
 
 #define HasCompRedirect(w)  (wPixmap(w) != wPixmap(w->parent))

Index: compwindow.c
===================================================================
RCS file: /cvs/xserver/xserver/composite/compwindow.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- compwindow.c	9 Nov 2003 07:05:59 -0000	1.5
+++ compwindow.c	11 Nov 2003 09:02:22 -0000	1.6
@@ -170,6 +170,22 @@
     pScreen->PaintWindowBackground = compPaintWindowBackground;
 }
 
+/*
+ * Returns TRUE if the window needs server-provided automatic redirect,
+ * which is true if the child and parent aren't both regular or ARGB visuals
+ */
+
+static Bool
+compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
+{
+    ScreenPtr		pScreen = pWin->drawable.pScreen;
+    CompScreenPtr	cs = GetCompScreen (pScreen);
+    
+    if (!pParent)
+	return FALSE;
+    return (wVisual(pWin) == cs->argbVid) != (wVisual (pParent) == cs->argbVid);
+}
+
 void
 compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
 {
@@ -177,11 +193,36 @@
     CompScreenPtr	cs = GetCompScreen (pScreen);
 
     pScreen->ReparentWindow = cs->ReparentWindow;
+    /*
+     * Remove any implicit redirect due to synthesized visual
+     */
+    if (compImplicitRedirect (pWin, pPriorParent))
+	compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+    /*
+     * Handle subwindows redirection
+     */
     compUnredirectOneSubwindow (pPriorParent, pWin);
     compRedirectOneSubwindow (pWin->parent, pWin);
+    /*
+     * Add any implict redirect due to synthesized visual
+     */
+    if (compImplicitRedirect (pWin, pWin->parent))
+	compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
+    
+    /*
+     * Allocate any necessary redirect pixmap
+     * (this actually should never be true; pWin is always unmapped)
+     */
     compCheckRedirect (pWin);
+    
+    /*
+     * Reset pixmap pointers as appropriate
+     */
     if (pWin->parent && !pWin->redirectDraw)
 	compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent));
+    /*
+     * Call down to next function
+     */
     if (pScreen->ReparentWindow)
 	(*pScreen->ReparentWindow) (pWin, pPriorParent);
     cs->ReparentWindow = pScreen->ReparentWindow;
@@ -250,6 +291,8 @@
 	    for (ccw = csw->clients; ccw; ccw = ccw->next)
 		compRedirectWindow (clients[CLIENT_ID(ccw->id)],
 				    pWin, ccw->update);
+	if (compImplicitRedirect (pWin, pWin->parent))
+	    compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
     }
     cs->CreateWindow = pScreen->CreateWindow;
     pScreen->CreateWindow = compCreateWindow;
@@ -285,14 +328,22 @@
 compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
 {
     CompWindowPtr   cw = GetCompWindow (pWin);
-    RegionRec	    more;
+    RegionRec	    damage;
 
-    REGION_INIT(pScreen, &more, NullBox, 0);
-    REGION_SUBTRACT(pScreen, &more, pRegion, &cw->borderClip);
-    DamageDamageRegion (&pWin->drawable, &more);
-    REGION_UNINIT (pScreen, &more);
+    REGION_INIT (pScreen, &damage, NullBox, 0);
+    
+    REGION_TRANSLATE (pScreen, &cw->borderClip,
+		      pWin->drawable.x - cw->borderClipX,
+		      pWin->drawable.y - cw->borderClipY);
+    REGION_COPY (pScreen, &damage, &cw->borderClip);
+    REGION_SUBTRACT (pScreen, &damage, &damage, pRegion);
+    REGION_INTERSECT (pScreen, &damage, &damage, &pWin->borderSize);
+    DamageDamageRegion (&pWin->drawable, &damage);
+    REGION_UNINIT (pScreen, &damage);
 
     REGION_COPY (pScreen, &cw->borderClip, pRegion);
+    cw->borderClipX = pWin->drawable.x;
+    cw->borderClipY = pWin->drawable.y;
 }
 
 RegionPtr
@@ -348,6 +399,8 @@
 						 serverClient,
 						 &error);
 
+    REGION_TRANSLATE (pScreen, pRegion, 
+		      pSrcPixmap->screen_x, pSrcPixmap->screen_y);
     REGION_INTERSECT (pScreen, pRegion, pRegion, &cw->borderClip);
     
     SetPictureClipRegion (pDstPicture,