[xserver-commit] xserver/hw/kdrive/vesa vesa.c,1.26.2.2,1.26.2.3 vesa.h,1.16.2.1,1.16.2.2 vesainit.c,1.10,1.10.2.1

Keith Packard xserver-commit@pdx.freedesktop.org
Fri, 24 Oct 2003 02:34:35 -0700


Committed by: keithp

Update of /cvs/xserver/xserver/hw/kdrive/vesa
In directory pdx:/tmp/cvs-serv4383/hw/kdrive/vesa

Modified Files:
      Tag: xfixes_2_branch
	vesa.c vesa.h vesainit.c 
Log Message:
	* hw/kdrive/fbdev/fbdev.c: (fbdevScreenInitialize),
	(fbdevMapFramebuffer), (fbdevSetScreenSizes),
	(fbdevUnmapFramebuffer), (fbdevSetShadow), (fbdevRandRSetConfig),
	(fbdevInitScreen), (fbdevFinishInitScreen), (fbdevCreateResources):
	* hw/kdrive/fbdev/fbdev.h:
	* hw/kdrive/fbdev/fbinit.c:
	* hw/kdrive/mach64/mach64.c: (mach64CreateResources):
	* hw/kdrive/mga/Makefile.am:
	* hw/kdrive/mga/mga.c: (mgaCreateResources):
	* hw/kdrive/nvidia/Makefile.am:
	* hw/kdrive/nvidia/nvidia.c:
	* hw/kdrive/r128/Makefile.am:
	* hw/kdrive/r128/r128.c:
	* hw/kdrive/r128/r128draw.c: (r128PrepareSolid), (r128PrepareCopy):
	* hw/kdrive/smi/Makefile.am:
	* hw/kdrive/smi/smi.c:
	* hw/kdrive/smi/smi.h:
	* hw/kdrive/src/kdrive.c: (KdCreateScreenResources),
	(KdScreenInit):
	* hw/kdrive/src/kdrive.h:
	* hw/kdrive/src/kshadow.c: (KdShadowFbAlloc), (KdShadowFbFree),
	(KdShadowSet), (KdShadowUnset):
	* hw/kdrive/vesa/vesa.c: (vesaSetScreenSizes), (vesaSetShadow),
	(vesaMapFramebuffer), (vesaUnmapFramebuffer), (vesaRandRSetConfig),
	(vesaInitScreen), (vesaFinishInitScreen), (vesaCreateResources),
	(vesaScreenFini):
	* hw/kdrive/vesa/vesa.h:
	* hw/kdrive/vesa/vesainit.c:
	Add function called at CreateScreenResources to get shadow set up
	on pixmap correctly.  Rework vesa and fbdev code to handle
	shadows right with the non-layer world.
	* mi/misprite.c:
	* mi/mispritest.h:
	Use GetScreenPixmap directly for damage detection of sprite.
	Avoids problems during server shutdown with windows disappearing
	before the sprite layer is closed.


Index: vesa.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/vesa/vesa.c,v
retrieving revision 1.26.2.2
retrieving revision 1.26.2.3
diff -u -d -r1.26.2.2 -r1.26.2.3
--- vesa.c	22 Oct 2003 06:52:44 -0000	1.26.2.2
+++ vesa.c	24 Oct 2003 09:34:33 -0000	1.26.2.3
@@ -789,30 +789,13 @@
 }
 
 void
-vesaConfigureScreen (ScreenPtr pScreen)
+vesaSetScreenSizes (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
     KdScreenInfo	*screen = pScreenPriv->screen;
-    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
-
-    KdMouseMatrix	m;
+    VesaScreenPrivPtr	pscr = screen->driver;
 
-    if (pscr->mapping == VESA_PLANAR || pscr->mapping == VESA_MONO)
-    {
-	pscr->shadow = TRUE;
-	pscr->randr = RR_Rotate_0;
-    } 
-    else if (pscr->mapping == VESA_WINDOWED)
-	pscr->shadow = TRUE;
-    else if (pscr->randr != RR_Rotate_0)
-	pscr->shadow = TRUE;
-    else
-	pscr->shadow = vesa_shadow;
-    
-    KdComputeMouseMatrix (&m, pscr->randr, 
-			  pscr->mode.XResolution, pscr->mode.YResolution);
-    
-    if (m.matrix[0][0])
+    if (pscr->randr & (RR_Rotate_0|RR_Rotate_180))
     {
 	pScreen->width = pscr->mode.XResolution;
 	pScreen->height = pscr->mode.YResolution;
@@ -826,78 +809,46 @@
 	pScreen->mmWidth = screen->height_mm;
 	pScreen->mmHeight = screen->width_mm;
     }
-    KdSetMouseMatrix (&m);
 }
 
-PixmapPtr
-vesaGetPixmap (ScreenPtr pScreen)
+Bool
+vesaSetShadow (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
     KdScreenInfo	*screen = pScreenPriv->screen;
     VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
     ShadowUpdateProc	update;
     ShadowWindowProc	window = 0;
-    PixmapPtr		pShadow, pPixmap;
 
-    if (pscr->shadow)
-    {
-	if (pscr->randr != RR_Rotate_0)
-	    update = shadowUpdateRotatePacked;
+    if (pscr->randr != RR_Rotate_0)
+	update = shadowUpdateRotatePacked;
+    else
+	update = shadowUpdatePacked;
+    switch (pscr->mapping) {
+    case VESA_LINEAR:
+	window = vesaWindowLinear;
+	break;
+    case VESA_WINDOWED:
+	window = vesaWindowWindowed;
+	break;
+    case VESA_PLANAR:
+	pScreen->CreateColormap = vesaCreateColormap16;
+	if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
+	    update = shadowUpdatePlanar4x8;
+	else
+	    update = shadowUpdatePlanar4;
+	window = vesaWindowPlanar;
+	break;
+    case VESA_MONO:
+	update = vesaUpdateMono;
+	if (pscr->mode.mode < 8)
+	    window = vesaWindowCga;
 	else
-	    update = shadowUpdatePacked;
-	switch (pscr->mapping) {
-	case VESA_LINEAR:
 	    window = vesaWindowLinear;
-	    break;
-	case VESA_WINDOWED:
-	    window = vesaWindowWindowed;
-	    break;
-	case VESA_PLANAR:
-	    pScreen->CreateColormap = vesaCreateColormap16;
-	    if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
-		update = shadowUpdatePlanar4x8;
-	    else
-		update = shadowUpdatePlanar4;
-	    window = vesaWindowPlanar;
-	    break;
-	case VESA_MONO:
-	    update = vesaUpdateMono;
-	    if (pscr->mode.mode < 8)
-		window = vesaWindowCga;
-	    else
-		window = vesaWindowLinear;
-	    break;
-	}
-	
-	pPixmap = (*pScreen->CreatePixmap) (pScreen,
-					    pScreen->width,
-					    pScreen->height,
-					    screen->fb[0].depth);
-	if (!pPixmap)
-	    return NullPixmap;
-	if (!shadowSet (pScreen, pPixmap, update, 
-			window, pscr->randr, 0))
-	{
-	    (*pScreen->DestroyPixmap) (pPixmap);
-	    return NullPixmap;
-	}
-	pShadow = pPixmap;
-    }
-    else
-    {
-	pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
-	pShadow = 0;
-	shadowUnset (pScreen);
+	break;
     }
     
-    if (pscr->pShadow)
-        (*pScreen->DestroyPixmap) (pscr->pShadow);
-    pscr->pShadow = pShadow;
-
-    if (vesa_verbose)
-	ErrorF ("Mode selected %dx%dx%d\n",
-		pScreen->width, pScreen->height, screen->fb[0].depth);
-    return pPixmap;
+    return KdShadowSet (pScreen, pscr->randr, update, window);
 }
 
 Bool
@@ -907,11 +858,18 @@
     VesaScreenPrivPtr	pscr = screen->driver;
     int			depth, bpp, fbbpp;
     Pixel		allbits;
+    KdMouseMatrix	m;
 
     if (vesa_linear_fb)
+    {
 	pscr->mapping = VESA_LINEAR;
+	pscr->shadow = FALSE;
+    }
     else
+    {
 	pscr->mapping = VESA_WINDOWED;
+	pscr->shadow = TRUE;
+    }
     
     depth = vesaDepth (&pscr->mode);
     bpp = pscr->mode.BitsPerPixel;
@@ -972,9 +930,10 @@
 			bpp, depth);
 	}
 	pscr->randr = RR_Rotate_0;
+	pscr->shadow = TRUE;
 	break;
     default:
-	return 0;
+	return FALSE;
     }
 
     switch (fbbpp) {
@@ -987,15 +946,17 @@
 	break;
     }
     
-    screen->width = pscr->mode.XResolution;
-    screen->height = pscr->mode.YResolution;
-    screen->fb[0].depth = depth;
-    screen->fb[0].bitsPerPixel = bpp;
-    screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
-    screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / fbbpp);
+    if (pscr->randr != RR_Rotate_0)
+	pscr->shadow = TRUE;
+    
+    if (vesa_shadow)
+	pscr->shadow = vesa_shadow;
 
     if (pscr->mapping == VESA_LINEAR && !(pscr->mode.ModeAttributes & MODE_LINEAR))
+    {
 	pscr->mapping = VESA_WINDOWED;
+	pscr->shadow = TRUE;
+    }
     
     screen->softCursor = TRUE;
 
@@ -1022,10 +983,34 @@
 	pscr->fb = NULL;
 	break;
     }
+    
+    KdComputeMouseMatrix (&m, pscr->randr, 
+			  pscr->mode.XResolution, pscr->mode.YResolution);
+    
+    KdSetMouseMatrix (&m);
+    
+    screen->width = pscr->mode.XResolution;
+    screen->height = pscr->mode.YResolution;
     screen->memory_base = pscr->fb;
     screen->memory_size = pscr->fb_size;
-    screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb);
-    screen->off_screen_base = screen->fb[0].byteStride * screen->height;
+    screen->fb[0].depth = depth;
+    screen->fb[0].bitsPerPixel = bpp;
+    
+    if (pscr->shadow)
+    {
+	if (!KdShadowFbAlloc (screen, 0, 
+			      pscr->randr & (RR_Rotate_90|RR_Rotate_270)))
+	    return FALSE;
+	screen->off_screen_base = screen->memory_size;
+    }
+    else
+    {
+	screen->fb[0].frameBuffer = (CARD8 *) (pscr->fb);
+	screen->off_screen_base = screen->fb[0].byteStride * screen->height;
+	screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
+	screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / 
+				     screen->fb[0].bitsPerPixel);
+    }
     
     return TRUE;
 }
@@ -1036,6 +1021,7 @@
     VesaCardPrivPtr	    priv = screen->card->driver;
     VesaScreenPrivPtr	    pscr = screen->driver;
     
+    KdShadowFbFree (screen, 0);
     if (pscr->fb)
     {
 	if (pscr->mode.vbe)
@@ -1121,17 +1107,6 @@
     return TRUE;
 }
 
-int
-vesaPixmapSet (WindowPtr pWin, pointer value)
-{
-    ScreenPtr	    pScreen = pWin->drawable.pScreen;
-    PixmapPtr	    pPixmap = value;
-
-    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-    (*pScreen->SetWindowPixmap) (pWin, pPixmap);
-    return WT_WALKCHILDREN;
-}
-
 Bool
 vesaRandRSetConfig (ScreenPtr		pScreen,
 		    Rotation		randr,
@@ -1229,46 +1204,25 @@
     KdOffscreenSwapOut (screen->pScreen);
     
     vesaUnmapFramebuffer (screen);
+    
     if (!vesaMapFramebuffer (screen))
 	goto bail3;
     
-#if 0
-    /*
-     * XXX can't switch depths
-     */
-    screen->fb[0].depth = depth;
-    screen->fb[0].bitsPerPixel = bpp;
-#endif
-    screen->fb[0].byteStride = mode->BytesPerScanLine;
-    screen->fb[0].pixelStride = ((mode->BytesPerScanLine * 8) / screen->fb[0].bitsPerPixel);
+    vesaSetScreenSizes (screen->pScreen);
+    
+    if (!vesaSetShadow (screen->pScreen))
+	goto bail4;
     
-    /*
-     * Compute screen geometry 
-     */
-    vesaConfigureScreen (pScreen);
-
     /*
      * Set frame buffer mapping
      */
-    if (!pscr->shadow)
-    {
-	(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
-					pScreen->width,
-					pScreen->height,
-					screen->fb[0].depth,
-					screen->fb[0].bitsPerPixel,
-					screen->fb[0].byteStride,
-					screen->fb[0].frameBuffer);
-    }
-	
-    /*
-     * Get the pixmap that windows live in
-     */
-    pPixmap = vesaGetPixmap (pScreen);
-    if (!pPixmap)
-	goto bail4;
-    
-    WalkTree (pScreen, vesaPixmapSet, (pointer) pPixmap);
+    (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+				    pScreen->width,
+				    pScreen->height,
+				    screen->fb[0].depth,
+				    screen->fb[0].bitsPerPixel,
+				    screen->fb[0].byteStride,
+				    screen->fb[0].frameBuffer);
     
     /* set the subpixel order */
     KdSetSubpixelOrder (pScreen, pscr->randr);
@@ -1292,22 +1246,7 @@
 bail2:
     *pscr = oldscr;
     
-    /*
-     * Set frame buffer mapping
-     */
-    if (!pscr->shadow)
-    {
-	(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
-					pScreen->width,
-					pScreen->height,
-					screen->fb[0].depth,
-					screen->fb[0].bitsPerPixel,
-					screen->fb[0].byteStride,
-					screen->fb[0].frameBuffer);
-    }
-
     (void) vesaSetMode (pScreen, &pscr->mode);
-
 bail1:
     if (wasEnabled)
 	KdEnableScreen (pScreen);
@@ -1334,23 +1273,17 @@
 Bool
 vesaInitScreen(ScreenPtr pScreen)
 {
+    KdScreenPriv(pScreen);
+
     return TRUE;
 }
 
 Bool
 vesaFinishInitScreen (ScreenPtr pScreen)
 {
-    PixmapPtr		pPixmap;
-    
-    vesaConfigureScreen (pScreen);
-
     if (!shadowSetup (pScreen))
 	return FALSE;
     
-    pPixmap = vesaGetPixmap (pScreen);
-    if (!pPixmap)
-	return FALSE;
-    
 #ifdef RANDR
     if (!vesaRandRInit (pScreen))
 	return FALSE;
@@ -1360,6 +1293,12 @@
 }
 
 Bool
+vesaCreateResources (ScreenPtr pScreen)
+{
+    return vesaSetShadow (pScreen);
+}
+
+Bool
 vesaSetMode (ScreenPtr	    pScreen,
 	     VesaModePtr    mode)
 {
@@ -1656,11 +1595,7 @@
 {
     VesaScreenPrivPtr	pscr = screen->driver;
     
-    if (pscr->pShadow)
-    {
-	(*screen->pScreen->DestroyPixmap) (pscr->pShadow);
-	pscr->pShadow = 0;
-    }
+    KdShadowFbFree (screen, 0);
     vesaUnmapFramebuffer (screen);
     screen->fb[0].depth = pscr->origDepth;
 }

Index: vesa.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/vesa/vesa.h,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -d -r1.16.2.1 -r1.16.2.2
--- vesa.h	22 Oct 2003 06:00:50 -0000	1.16.2.1
+++ vesa.h	24 Oct 2003 09:34:33 -0000	1.16.2.2
@@ -157,6 +157,9 @@
 vesaFinishInitScreen(ScreenPtr pScreen);
 
 Bool
+vesaCreateResources (ScreenPtr pScreen);
+
+Bool
 vesaSetMode (ScreenPtr	    pScreen,
 	     VesaModePtr    mode);
 

Index: vesainit.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/vesa/vesainit.c,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- vesainit.c	11 Sep 2003 05:12:51 -0000	1.10
+++ vesainit.c	24 Oct 2003 09:34:33 -0000	1.10.2.1
@@ -30,6 +30,8 @@
     vesaCardInit,               /* cardinit */
     vesaScreenInit,             /* scrinit */
     vesaInitScreen,             /* initScreen */
+    vesaFinishInitScreen,	/* finishInitScreen */
+    vesaCreateResources,	/* createRes */
     vesaPreserve,               /* preserve */
     vesaEnable,                 /* enable */
     vesaDPMS,                   /* dpms */
@@ -52,8 +54,6 @@
     
     vesaGetColors,              /* getColors */
     vesaPutColors,              /* putColors */
-
-    vesaFinishInitScreen,	/* finishInitScreen */
 };
 
 void