From 52872a0de67226eff6100d8353f5c712e94e9e9d Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 10 Mar 2017 16:29:24 +0100 Subject: dix: Move AddScreen() over into dispatch.c and introduce init_screen() Partially pruned out of X.org commits: commit 987579c930bda803427a28cb82773c389f5110d6 Author: Peter Hutterer Date: Wed Apr 22 13:26:40 2009 +1000 dix: remove all but main() from main.c All other functions are pushed into where they seemed to fit. main.c is now linked separately into libmain.a and linked in by the various DDXs. Signed-off-by: Peter Hutterer commit 3478af3374abffa0c226ee077fda1fcfc0751e74 Author: Dave Airlie Date: Tue Jun 5 17:01:21 2012 +0100 screen: split out screen init code. (v2) This is a precursor for reusing this code to init gpu screens. v2: fixup int check as per Keith's review. Reviewed-by: Keith Packard Signed-off-by: Dave Airlie Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/dix/dispatch.c | 212 ++++++++++++++++++++++++++++++++ nx-X11/programs/Xserver/dix/main.c | 217 +-------------------------------- 2 files changed, 214 insertions(+), 215 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 438436526..3a414eca8 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -125,6 +125,8 @@ int ProcInitialConnection(); extern xConnSetupPrefix connSetupPrefix; extern char *ConnectionInfo; +extern int screenPrivateCount; + Selection *CurrentSelections; int NumCurrentSelections; CallbackListPtr SelectionCallback = NULL; @@ -3976,3 +3978,213 @@ MarkClientException(ClientPtr client) { client->noClientException = -1; } + +/* + * This array encodes the answer to the question "what is the log base 2 + * of the number of pixels that fit in a scanline pad unit?" + * Note that ~0 is an invalid entry (mostly for the benefit of the reader). + */ +static int answer[6][4] = { + /* pad pad pad pad*/ + /* 8 16 32 64 */ + + { 3, 4, 5 , 6 }, /* 1 bit per pixel */ + { 1, 2, 3 , 4 }, /* 4 bits per pixel */ + { 0, 1, 2 , 3 }, /* 8 bits per pixel */ + { ~0, 0, 1 , 2 }, /* 16 bits per pixel */ + { ~0, ~0, 0 , 1 }, /* 24 bits per pixel */ + { ~0, ~0, 0 , 1 } /* 32 bits per pixel */ +}; + +/* + * This array gives the bytesperPixel value for cases where the number + * of bits per pixel is a multiple of 8 but not a power of 2. + */ +static int answerBytesPerPixel[ 33 ] = { + ~0, 0, ~0, ~0, /* 1 bit per pixel */ + 0, ~0, ~0, ~0, /* 4 bits per pixel */ + 0, ~0, ~0, ~0, /* 8 bits per pixel */ + ~0,~0, ~0, ~0, + 0, ~0, ~0, ~0, /* 16 bits per pixel */ + ~0,~0, ~0, ~0, + 3, ~0, ~0, ~0, /* 24 bits per pixel */ + ~0,~0, ~0, ~0, + 0 /* 32 bits per pixel */ +}; + +/* + * This array gives the answer to the question "what is the first index for + * the answer array above given the number of bits per pixel?" + * Note that ~0 is an invalid entry (mostly for the benefit of the reader). + */ +static int indexForBitsPerPixel[ 33 ] = { + ~0, 0, ~0, ~0, /* 1 bit per pixel */ + 1, ~0, ~0, ~0, /* 4 bits per pixel */ + 2, ~0, ~0, ~0, /* 8 bits per pixel */ + ~0,~0, ~0, ~0, + 3, ~0, ~0, ~0, /* 16 bits per pixel */ + ~0,~0, ~0, ~0, + 4, ~0, ~0, ~0, /* 24 bits per pixel */ + ~0,~0, ~0, ~0, + 5 /* 32 bits per pixel */ +}; + +/* + * This array gives the answer to the question "what is the second index for + * the answer array above given the number of bits per scanline pad unit?" + * Note that ~0 is an invalid entry (mostly for the benefit of the reader). + */ +static int indexForScanlinePad[ 65 ] = { + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + 0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */ + ~0, ~0, ~0, ~0, + 1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */ + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + 2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */ + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, + 3 /* 64 bits per scanline pad unit */ +}; + +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +static int init_screen(ScreenPtr pScreen, int i) +{ + int scanlinepad, format, depth, bitsPerPixel, j, k; +#ifdef DEBUG + void (**jNI) (); +#endif /* DEBUG */ + + pScreen->myNum = i; + pScreen->WindowPrivateLen = 0; + pScreen->WindowPrivateSizes = (unsigned *)NULL; + pScreen->totalWindowSize = + ((sizeof(WindowRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); + pScreen->GCPrivateLen = 0; + pScreen->GCPrivateSizes = (unsigned *)NULL; + pScreen->totalGCSize = + ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); +#ifdef PIXPRIV + pScreen->PixmapPrivateLen = 0; + pScreen->PixmapPrivateSizes = (unsigned *)NULL; + pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8); +#endif + pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ + pScreen->CreateScreenResources = 0; + +#ifdef DEBUG + for (jNI = &pScreen->QueryBestSize; + jNI < (void (**) ()) &pScreen->SendGraphicsExpose; + jNI++) + *jNI = NotImplemented; +#endif /* DEBUG */ + + /* + * This loop gets run once for every Screen that gets added, + * but thats ok. If the ddx layer initializes the formats + * one at a time calling AddScreen() after each, then each + * iteration will make it a little more accurate. Worst case + * we do this loop N * numPixmapFormats where N is # of screens. + * Anyway, this must be called after InitOutput and before the + * screen init routine is called. + */ + for (format=0; formatdevPrivates = (DevUnion *)calloc(sizeof(DevUnion), + screenPrivateCount); + if (!pScreen->devPrivates && screenPrivateCount) + return -1; + + ret = init_screen(pScreen, i); + if (ret != 0) { + free(pScreen); + return ret; + } + /* This is where screen specific stuff gets initialized. Load the + screen structure, call the hardware, whatever. + This is also where the default colormap should be allocated and + also pixel values for blackPixel, whitePixel, and the cursor + Note that InitScreen is NOT allowed to modify argc, argv, or + any of the strings pointed to by argv. They may be passed to + multiple screens. + */ + pScreen->rgf = ~0L; /* there are no scratch GCs yet*/ + screenInfo.screens[i] = pScreen; + screenInfo.numScreens++; + if (!(*pfnInit)(pScreen, argc, argv)) + { + FreeScreen(pScreen); + screenInfo.numScreens--; + return -1; + } + return i; +} + +void +FreeScreen(ScreenPtr pScreen) +{ + pScreen->root = NullWindow; + free(pScreen->WindowPrivateSizes); + free(pScreen->GCPrivateSizes); +#ifdef PIXPRIV + free(pScreen->PixmapPrivateSizes); +#endif + free(pScreen->devPrivates); + free(pScreen); +} diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index 72ed40108..4e1051efd 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -121,18 +121,17 @@ extern void Dispatch(void); xConnSetupPrefix connSetupPrefix; extern FontPtr defaultFont; -extern int screenPrivateCount; extern void InitProcVectors(void); extern Bool CreateGCperDepthArray(void); +extern void FreeScreen(ScreenPtr pScreen); + #ifndef PANORAMIX static #endif Bool CreateConnectionBlock(void); -static void FreeScreen(ScreenPtr); - PaddingInfo PixmapWidthPaddingInfo[33]; int connBlockScreenStart; @@ -159,85 +158,6 @@ ReplyNotSwappd( FatalError("Not implemented"); } -/* - * This array encodes the answer to the question "what is the log base 2 - * of the number of pixels that fit in a scanline pad unit?" - * Note that ~0 is an invalid entry (mostly for the benefit of the reader). - */ -static int answer[6][4] = { - /* pad pad pad pad*/ - /* 8 16 32 64 */ - - { 3, 4, 5 , 6 }, /* 1 bit per pixel */ - { 1, 2, 3 , 4 }, /* 4 bits per pixel */ - { 0, 1, 2 , 3 }, /* 8 bits per pixel */ - { ~0, 0, 1 , 2 }, /* 16 bits per pixel */ - { ~0, ~0, 0 , 1 }, /* 24 bits per pixel */ - { ~0, ~0, 0 , 1 } /* 32 bits per pixel */ -}; - -/* - * This array gives the answer to the question "what is the first index for - * the answer array above given the number of bits per pixel?" - * Note that ~0 is an invalid entry (mostly for the benefit of the reader). - */ -static int indexForBitsPerPixel[ 33 ] = { - ~0, 0, ~0, ~0, /* 1 bit per pixel */ - 1, ~0, ~0, ~0, /* 4 bits per pixel */ - 2, ~0, ~0, ~0, /* 8 bits per pixel */ - ~0,~0, ~0, ~0, - 3, ~0, ~0, ~0, /* 16 bits per pixel */ - ~0,~0, ~0, ~0, - 4, ~0, ~0, ~0, /* 24 bits per pixel */ - ~0,~0, ~0, ~0, - 5 /* 32 bits per pixel */ -}; - -/* - * This array gives the bytesperPixel value for cases where the number - * of bits per pixel is a multiple of 8 but not a power of 2. - */ -static int answerBytesPerPixel[ 33 ] = { - ~0, 0, ~0, ~0, /* 1 bit per pixel */ - 0, ~0, ~0, ~0, /* 4 bits per pixel */ - 0, ~0, ~0, ~0, /* 8 bits per pixel */ - ~0,~0, ~0, ~0, - 0, ~0, ~0, ~0, /* 16 bits per pixel */ - ~0,~0, ~0, ~0, - 3, ~0, ~0, ~0, /* 24 bits per pixel */ - ~0,~0, ~0, ~0, - 0 /* 32 bits per pixel */ -}; - -/* - * This array gives the answer to the question "what is the second index for - * the answer array above given the number of bits per scanline pad unit?" - * Note that ~0 is an invalid entry (mostly for the benefit of the reader). - */ -static int indexForScanlinePad[ 65 ] = { - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - 0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */ - ~0, ~0, ~0, ~0, - 1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */ - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - 2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */ - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - ~0, ~0, ~0, ~0, - 3 /* 64 bits per scanline pad unit */ -}; - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - int main(int argc, char *argv[], char *envp[]) { @@ -658,136 +578,3 @@ CreateConnectionBlock() connSetupPrefix.minorVersion = X_PROTOCOL_REVISION; return TRUE; } - -/* - grow the array of screenRecs if necessary. - call the device-supplied initialization procedure -with its screen number, a pointer to its ScreenRec, argc, and argv. - return the number of successfully installed screens. - -*/ - -int -AddScreen( - Bool (* pfnInit)( - int /*index*/, - ScreenPtr /*pScreen*/, - int /*argc*/, - char ** /*argv*/ - ), - int argc, - char **argv) -{ - - int i; - int scanlinepad, format, depth, bitsPerPixel, j, k; - ScreenPtr pScreen; -#ifdef DEBUG - void (**jNI) (); -#endif /* DEBUG */ - - i = screenInfo.numScreens; - if (i == MAXSCREENS) - return -1; - - pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); - if (!pScreen) - return -1; - - pScreen->devPrivates = (DevUnion *)calloc(sizeof(DevUnion), - screenPrivateCount); - if (!pScreen->devPrivates && screenPrivateCount) - { - free(pScreen); - return -1; - } - pScreen->myNum = i; - pScreen->WindowPrivateLen = 0; - pScreen->WindowPrivateSizes = (unsigned *)NULL; - pScreen->totalWindowSize = - ((sizeof(WindowRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); - pScreen->GCPrivateLen = 0; - pScreen->GCPrivateSizes = (unsigned *)NULL; - pScreen->totalGCSize = - ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); -#ifdef PIXPRIV - pScreen->PixmapPrivateLen = 0; - pScreen->PixmapPrivateSizes = (unsigned *)NULL; - pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8); -#endif - pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ - pScreen->CreateScreenResources = 0; - -#ifdef DEBUG - for (jNI = &pScreen->QueryBestSize; - jNI < (void (**) ()) &pScreen->SendGraphicsExpose; - jNI++) - *jNI = NotImplemented; -#endif /* DEBUG */ - - /* - * This loop gets run once for every Screen that gets added, - * but thats ok. If the ddx layer initializes the formats - * one at a time calling AddScreen() after each, then each - * iteration will make it a little more accurate. Worst case - * we do this loop N * numPixmapFormats where N is # of screens. - * Anyway, this must be called after InitOutput and before the - * screen init routine is called. - */ - for (format=0; formatrgf = ~0L; /* there are no scratch GCs yet*/ - screenInfo.screens[i] = pScreen; - screenInfo.numScreens++; - if (!(*pfnInit)(i, pScreen, argc, argv)) - { - FreeScreen(pScreen); - screenInfo.numScreens--; - return -1; - } - return i; -} - -static void -FreeScreen(ScreenPtr pScreen) -{ - pScreen->root = NullWindow; - free(pScreen->WindowPrivateSizes); - free(pScreen->GCPrivateSizes); -#ifdef PIXPRIV - free(pScreen->PixmapPrivateSizes); -#endif - free(pScreen->devPrivates); - free(pScreen); -} -- cgit v1.2.3 From cb9e50c2f7de225b336721a7c0723f1d28da3607 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 10 Mar 2017 16:48:54 +0100 Subject: Move AddScreen() comment where it actually belongs. Should be done in X.org, too. --- nx-X11/programs/Xserver/dix/dispatch.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 3a414eca8..8294a583a 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -4127,6 +4127,13 @@ static int init_screen(ScreenPtr pScreen, int i) void FreeScreen(ScreenPtr); +/* + grow the array of screenRecs if necessary. + call the device-supplied initialization procedure + with its screen number, a pointer to its ScreenRec, argc, and argv. + return the number of successfully installed screens. +*/ + int AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , int /*argc */ , -- cgit v1.2.3 From c1fc4ba7890728cd3afb0e9b6ae1c6c41e0d5376 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sat, 11 Mar 2017 00:48:03 +0100 Subject: dix: Remove insane BC hacks commit 6b5206e7cb8e5279816b48f014d47d3f03f16972 Author: Daniel Stone Date: Fri Jul 18 15:38:10 2008 +0300 dix: Remove insane BC hacks If your DDX needs a 1bpp mode and doesn't set it up, your DDX is incompetent. Backported-to-NX-by: Mike Gabriel --- nx-X11/programs/Xserver/dix/main.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index 4e1051efd..68b1c17f6 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -161,7 +161,7 @@ ReplyNotSwappd( int main(int argc, char *argv[], char *envp[]) { - int i, j, k, error; + int i, error; char *xauthfile; HWEventQueueType alwaysCheckForInput[2]; @@ -250,17 +250,6 @@ main(int argc, char *argv[], char *envp[]) screenInfo.numScreens = 0; screenInfo.numVideoScreens = -1; - /* - * Just in case the ddx doesnt supply a format for depth 1 (like qvss). - */ - j = indexForBitsPerPixel[ 1 ]; - k = indexForScanlinePad[ BITMAP_SCANLINE_PAD ]; - PixmapWidthPaddingInfo[1].padRoundUp = BITMAP_SCANLINE_PAD-1; - PixmapWidthPaddingInfo[1].padPixelsLog2 = answer[j][k]; - j = indexForBitsPerPixel[8]; /* bits per byte */ - PixmapWidthPaddingInfo[1].padBytesLog2 = answer[j][k]; - PixmapWidthPaddingInfo[1].bitsPerPixel = 1; - InitAtoms(); InitEvents(); InitGlyphCaching(); -- cgit v1.2.3