[xserver-commit] xserver/hw/kdrive/src kdrive.c,1.35.2.1,1.35.2.2 kdrive.h,1.40.2.1,1.40.2.2 kshadow.c,1.6,1.6.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/src
In directory pdx:/tmp/cvs-serv4383/hw/kdrive/src

Modified Files:
      Tag: xfixes_2_branch
	kdrive.c kdrive.h kshadow.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: kdrive.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kdrive.c,v
retrieving revision 1.35.2.1
retrieving revision 1.35.2.2
diff -u -d -r1.35.2.1 -r1.35.2.2
--- kdrive.c	22 Oct 2003 06:00:49 -0000	1.35.2.1
+++ kdrive.c	24 Oct 2003 09:34:33 -0000	1.35.2.2
@@ -833,6 +833,23 @@
 }
 
 Bool
+KdCreateScreenResources (ScreenPtr pScreen)
+{
+    KdScreenPriv(pScreen);
+    KdScreenInfo    *screen = pScreenPriv->screen;
+    KdCardInfo	    *card = pScreenPriv->card;
+    Bool ret;
+
+    pScreen->CreateScreenResources = pScreenPriv->CreateScreenResources;
+    ret = (*pScreen->CreateScreenResources) (pScreen);
+    pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
+    pScreen->CreateScreenResources = KdCreateScreenResources;
+    if (ret && card->cfuncs->createRes)
+	ret = (*card->cfuncs->createRes) (pScreen);
+    return ret;
+}
+
+Bool
 KdCloseScreen (int index, ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
@@ -1015,11 +1032,32 @@
     KdCardInfo		*card = screen->card;
     KdPrivScreenPtr	pScreenPriv;
     int			fb;
+    /*
+     * note that screen->fb is set up for the nominal orientation
+     * of the screen; that means if randr is rotated, the values
+     * there should reflect a rotated frame buffer (or shadow).
+     */
+    Bool		rotated = (screen->randr & (RR_Rotate_90|RR_Rotate_270)) != 0;
+    int			width, height, *width_mmp, *height_mmp;
 
     KdAllocatePrivates (pScreen);
 
     pScreenPriv = KdGetScreenPriv(pScreen);
     
+    if (!rotated)
+    {
+	width = screen->width;
+	height = screen->height;
+	width_mmp = &screen->width_mm;
+	height_mmp = &screen->height_mm;
+    }
+    else
+    {
+	width = screen->height;
+	height = screen->width;
+	width_mmp = &screen->height_mm;
+	height_mmp = &screen->width_mm;
+    }
     screen->pScreen = pScreen;
     pScreenPriv->screen = screen;
     pScreenPriv->card = card;
@@ -1039,7 +1077,7 @@
      */
     if (!fbSetupScreen (pScreen, 
 			screen->fb[0].frameBuffer, 
-			screen->width, screen->height, 
+			width, height, 
 			monitorResolution, monitorResolution, 
 			screen->fb[0].pixelStride,
 			screen->fb[0].bitsPerPixel))
@@ -1072,7 +1110,7 @@
 	if (!fbOverlayFinishScreenInit (pScreen, 
 					screen->fb[0].frameBuffer, 
 					screen->fb[1].frameBuffer, 
-					screen->width, screen->height, 
+					width, height, 
 					monitorResolution, monitorResolution,
 					screen->fb[0].pixelStride,
 					screen->fb[1].pixelStride,
@@ -1089,7 +1127,7 @@
     {
 	if (!fbFinishScreenInit (pScreen, 
 				 screen->fb[0].frameBuffer, 
-				 screen->width, screen->height,
+				 width, height,
 				 monitorResolution, monitorResolution,
 				 screen->fb[0].pixelStride,
 				 screen->fb[0].bitsPerPixel))
@@ -1102,14 +1140,14 @@
      * Fix screen sizes; for some reason mi takes dpi instead of mm.
      * Rounding errors are annoying
      */
-    if (screen->width_mm)
-	pScreen->mmWidth = screen->width_mm;
+    if (*width_mmp)
+	pScreen->mmWidth = *width_mmp;
     else
-	screen->width_mm = pScreen->mmWidth;
-    if (screen->height_mm)
-	pScreen->mmHeight = screen->height_mm;
+	*width_mmp = pScreen->mmWidth;
+    if (*height_mmp)
+	pScreen->mmHeight = *height_mmp;
     else
-	screen->height_mm = pScreen->mmHeight;
+	*height_mmp = pScreen->mmHeight;
     
     /*
      * Plug in our own block/wakeup handlers.
@@ -1163,6 +1201,9 @@
      */
     pScreenPriv->CloseScreen = pScreen->CloseScreen;
     pScreen->CloseScreen = KdCloseScreen;
+
+    pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
+    pScreen->CreateScreenResources = KdCreateScreenResources;
     
     if (screen->softCursor ||
 	!card->cfuncs->initCursor || 

Index: kdrive.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kdrive.h,v
retrieving revision 1.40.2.1
retrieving revision 1.40.2.2
diff -u -d -r1.40.2.1 -r1.40.2.2
--- kdrive.h	22 Oct 2003 06:00:49 -0000	1.40.2.1
+++ kdrive.h	24 Oct 2003 09:34:33 -0000	1.40.2.2
@@ -93,6 +93,7 @@
     int		bitsPerPixel;
     int		pixelStride;
     int		byteStride;
+    Bool	shadow;
     unsigned long   visuals;
     Pixel       redMask, greenMask, blueMask;
     void	*closure;
@@ -128,6 +129,8 @@
     Bool	(*cardinit) (KdCardInfo *); /* detect and map device */
     Bool	(*scrinit) (KdScreenInfo *);/* initialize screen information */
     Bool	(*initScreen) (ScreenPtr);  /* initialize ScreenRec */
+    Bool	(*finishInitScreen) (ScreenPtr pScreen);
+    Bool	(*createRes) (ScreenPtr);   /* create screen resources */
     void	(*preserve) (KdCardInfo *); /* save graphics card state */
     Bool        (*enable) (ScreenPtr);      /* set up for rendering */
     Bool	(*dpms) (ScreenPtr, int);   /* set DPMS screen saver */
@@ -151,7 +154,6 @@
     void        (*getColors) (ScreenPtr, int, int, xColorItem *);
     void        (*putColors) (ScreenPtr, int, int, xColorItem *);
 
-    Bool	(*finishInitScreen) (ScreenPtr pScreen);
 } KdCardFuncs;
 
 #define KD_MAX_PSEUDO_DEPTH 8
@@ -170,6 +172,7 @@
     ColormapPtr     pInstalledmap[KD_MAX_FB];         /* current colormap */
     xColorItem      systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
 
+    CreateScreenResourcesProcPtr    CreateScreenResources;
     CloseScreenProcPtr  CloseScreen;
 #ifdef FB_OLD_SCREEN
     miBSFuncRec	    BackingStoreFuncs;
@@ -568,6 +571,9 @@
 KdAllocatePrivates (ScreenPtr pScreen);
 
 Bool
+KdCreateScreenResources (ScreenPtr pScreen);
+
+Bool
 KdCloseScreen (int index, ScreenPtr pScreen);
 
 Bool
@@ -774,13 +780,16 @@
 
 /* kshadow.c */
 Bool
-KdShadowScreenInit (KdScreenInfo *screen);
+KdShadowFbAlloc (KdScreenInfo *screen, int fb, Bool rotate);
 
-Bool
-KdShadowInitScreen (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window);
+void
+KdShadowFbFree (KdScreenInfo *screen, int fb);
 
+Bool
+KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window);
+    
 void
-KdShadowScreenFini (KdScreenInfo *screen);
+KdShadowUnset (ScreenPtr pScreen);
 
 /* ktest.c */
 Bool

Index: kshadow.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kshadow.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- kshadow.c	14 Oct 2003 05:07:39 -0000	1.6
+++ kshadow.c	24 Oct 2003 09:34:33 -0000	1.6.2.1
@@ -28,29 +28,58 @@
 #include "kdrive.h"
 
 Bool
-KdShadowScreenInit (KdScreenInfo *screen)
+KdShadowFbAlloc (KdScreenInfo *screen, int fb, Bool rotate)
 {
+    int	    paddedWidth;
     void    *buf;
+    int	    width = rotate ? screen->height : screen->width;
+    int	    height = rotate ? screen->width : screen->height;
+    int	    bpp = screen->fb[fb].bitsPerPixel;
 
-    buf = shadowAlloc (screen->width, screen->height, screen->fb[0].bitsPerPixel);
+    /* use fb computation for width */
+    paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
+    buf = xalloc (paddedWidth * height);
     if (!buf)
 	return FALSE;
-    screen->fb[0].frameBuffer = buf;
-    screen->fb[0].byteStride = BitmapBytePad (screen->width * screen->fb[0].bitsPerPixel);
-    screen->fb[0].pixelStride = screen->fb[0].byteStride * 8 / screen->fb[0].bitsPerPixel;
-    screen->dumb = TRUE;
+    if (screen->fb[fb].shadow)
+	xfree (screen->fb[fb].frameBuffer);
+    screen->fb[fb].shadow = TRUE;
+    screen->fb[fb].frameBuffer = buf;
+    screen->fb[fb].byteStride = paddedWidth;
+    screen->fb[fb].pixelStride = paddedWidth * 8 / bpp;
     return TRUE;
 }
 
+void
+KdShadowFbFree (KdScreenInfo *screen, int fb)
+{
+    if (screen->fb[fb].shadow)
+    {
+	xfree (screen->fb[fb].frameBuffer);
+	screen->fb[fb].frameBuffer = 0;
+	screen->fb[fb].shadow = FALSE;
+    }
+}
+
 Bool
-KdShadowInitScreen (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window)
+KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window)
 {
-    return shadowInit (pScreen, update, window);
+    KdScreenPriv(pScreen);
+    KdScreenInfo *screen = pScreenPriv->screen;
+    int	 fb;
+
+    for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+    {
+	if (screen->fb[fb].shadow)
+	    return shadowSet (pScreen, (*pScreen->GetScreenPixmap) (pScreen), 
+			      update, window, randr, 0);
+	else
+	    shadowUnset (pScreen);
+    }
 }
 
 void
-KdShadowScreenFini (KdScreenInfo *screen)
+KdShadowUnset (ScreenPtr pScreen)
 {
-    if (screen->fb[0].frameBuffer)
-	xfree (screen->fb[0].frameBuffer);
+    shadowUnset (pScreen);
 }