XQuartz: Cleaned up color map configuration.

8 bit color still doesn't work, but the -depth command line argument now works properly.
(cherry picked from commit 6765949c27c053d22882f54337cfd09203aa5383)
This commit is contained in:
Jeremy Huddleston 2007-12-22 15:09:12 -08:00
parent 17a9714a67
commit e46d559739
3 changed files with 105 additions and 94 deletions

View File

@ -78,7 +78,7 @@
#include "darwinEvents.h" #include "darwinEvents.h"
#include "darwinKeyboard.h" #include "darwinKeyboard.h"
#include "quartz.h" #include "quartz.h"
#include "darwinClut8.h" //#include "darwinClut8.h"
#ifdef ENABLE_DEBUG_LOG #ifdef ENABLE_DEBUG_LOG
FILE *debug_log_fp = NULL; FILE *debug_log_fp = NULL;
@ -176,17 +176,10 @@ static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
* This is a callback from dix during AddScreen() from InitOutput(). * This is a callback from dix during AddScreen() from InitOutput().
* Initialize the screen and communicate information about it back to dix. * Initialize the screen and communicate information about it back to dix.
*/ */
static Bool DarwinAddScreen( static Bool DarwinAddScreen(int index, ScreenPtr pScreen, int argc, char **argv) {
int index, int dpi;
ScreenPtr pScreen,
int argc,
char **argv )
{
int bitsPerRGB, i, dpi;
static int foundIndex = 0; static int foundIndex = 0;
Bool ret; Bool ret;
VisualPtr visual;
ColormapPtr pmap;
DarwinFramebufferPtr dfb; DarwinFramebufferPtr dfb;
// reset index of found screens for each server generation // reset index of found screens for each server generation
@ -204,28 +197,13 @@ static Bool DarwinAddScreen(
if (! ret) if (! ret)
return FALSE; return FALSE;
bitsPerRGB = dfb->bitsPerComponent;
// reset the visual list // reset the visual list
miClearVisualTypes(); miClearVisualTypes();
// setup a single visual appropriate for our pixel type // setup a single visual appropriate for our pixel type
if (dfb->colorType == TrueColor) { if(!miSetVisualTypesAndMasks(dfb->depth, dfb->visuals, dfb->bitsPerRGB,
if (!miSetVisualTypes( dfb->colorBitsPerPixel, TrueColorMask, dfb->preferredCVC, dfb->redMask,
bitsPerRGB, TrueColor )) { dfb->greenMask, dfb->blueMask)) {
return FALSE;
}
} else if (dfb->colorType == PseudoColor) {
if (!miSetVisualTypes( dfb->colorBitsPerPixel, PseudoColorMask,
bitsPerRGB, PseudoColor )) {
return FALSE;
}
} else if (dfb->colorType == StaticColor) {
if (!miSetVisualTypes( dfb->colorBitsPerPixel, StaticColorMask,
bitsPerRGB, StaticColor )) {
return FALSE;
}
} else {
return FALSE; return FALSE;
} }
@ -249,20 +227,28 @@ static Bool DarwinAddScreen(
return FALSE; return FALSE;
} }
// ErrorF("Screen type: %d, %d=%d, %d=%d, %d=%d, %x=%x=%x, %x=%x=%x, %x=%x=%x\n", pScreen->visuals->class,
// pScreen->visuals->offsetRed, dfb->bitsPerRGB * 2,
// pScreen->visuals->offsetGreen, dfb->bitsPerRGB,
// pScreen->visuals->offsetBlue, 0,
// pScreen->visuals->redMask, dfb->redMask, ((1<<dfb->bitsPerRGB)-1) << pScreen->visuals->offsetRed,
// pScreen->visuals->greenMask, dfb->greenMask, ((1<<dfb->bitsPerRGB)-1) << pScreen->visuals->offsetGreen,
// pScreen->visuals->blueMask, dfb->blueMask, ((1<<dfb->bitsPerRGB)-1) << pScreen->visuals->offsetBlue);
// set the RGB order correctly for TrueColor // set the RGB order correctly for TrueColor
if (dfb->bitsPerPixel > 8) { // if (dfb->bitsPerPixel > 8) {
for (i = 0, visual = pScreen->visuals; // someday we may have more than 1 // for (i = 0, visual = pScreen->visuals; // someday we may have more than 1
i < pScreen->numVisuals; i++, visual++) { // i < pScreen->numVisuals; i++, visual++) {
if (visual->class == TrueColor) { // if (visual->class == TrueColor) {
visual->offsetRed = bitsPerRGB * 2; // visual->offsetRed = bitsPerRGB * 2;
visual->offsetGreen = bitsPerRGB; // visual->offsetGreen = bitsPerRGB;
visual->offsetBlue = 0; // visual->offsetBlue = 0;
visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed; // visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen; // visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue; // visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
} // }
} // }
} // }
#ifdef RENDER #ifdef RENDER
if (! fbPictureInit(pScreen, 0, 0)) { if (! fbPictureInit(pScreen, 0, 0)) {
@ -292,17 +278,16 @@ static Bool DarwinAddScreen(
* mode and we're using a fixed color map. Essentially this translates * mode and we're using a fixed color map. Essentially this translates
* to Darwin/x86 in 8-bit mode. * to Darwin/x86 in 8-bit mode.
*/ */
if( (dfb->colorBitsPerPixel == 8) && // if(dfb->depth == 8) {
(dfb->colorType == StaticColor) ) // ColormapPtr map = RootlessGetColormap (pScreen);
{ // for( i = 0; i < map->pVisual->ColormapEntries; i++ ) {
pmap = miInstalledMaps[pScreen->myNum]; // Entry *ent = map->red + i;
visual = pmap->pVisual; // ErrorF("Setting lo %d -> r: %04x g: %04x b: %04x\n", i, darwinClut8[i].red, darwinClut8[i].green, darwinClut8[i].blue);
for( i = 0; i < visual->ColormapEntries; i++ ) { // ent->co.local.red = darwinClut8[i].red;
pmap->red[i].co.local.red = darwinClut8[i].red; // ent->co.local.green = darwinClut8[i].green;
pmap->red[i].co.local.green = darwinClut8[i].green; // ent->co.local.blue = darwinClut8[i].blue;
pmap->red[i].co.local.blue = darwinClut8[i].blue; // }
} // }
}
dixScreenOrigins[index].x = dfb->x; dixScreenOrigins[index].x = dfb->x;
dixScreenOrigins[index].y = dfb->y; dixScreenOrigins[index].y = dfb->y;
@ -793,24 +778,21 @@ int ddxProcessArgument( int argc, char *argv[], int i )
} }
if ( !strcmp( argv[i], "-depth" ) ) { if ( !strcmp( argv[i], "-depth" ) ) {
int bitDepth;
if ( i == argc-1 ) { if ( i == argc-1 ) {
FatalError( "-depth must be followed by a number\n" ); FatalError( "-depth must be followed by a number\n" );
} }
#ifdef OLD_POWERBOOK_G3 #ifdef OLD_POWERBOOK_G3
ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n"); ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n");
#else #else
bitDepth = atoi( argv[i+1] ); darwinDesiredDepth = atoi( argv[i+1] );
if (bitDepth == 8) if(darwinDesiredDepth != -1 &&
darwinDesiredDepth = 0; darwinDesiredDepth != 8 &&
else if (bitDepth == 15) darwinDesiredDepth != 15 &&
darwinDesiredDepth = 1; darwinDesiredDepth != 24) {
else if (bitDepth == 24)
darwinDesiredDepth = 2;
else
FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" ); FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
ErrorF( "Attempting to use pixel depth of %i\n", bitDepth ); }
ErrorF( "Attempting to use pixel depth of %i\n", darwinDesiredDepth );
#endif #endif
return 2; return 2;
} }

View File

@ -40,10 +40,14 @@ typedef struct {
int width; int width;
int height; int height;
int pitch; int pitch;
int colorType; int depth;
int visuals;
int bitsPerRGB;
int bitsPerPixel; int bitsPerPixel;
int colorBitsPerPixel; int preferredCVC;
int bitsPerComponent; Pixel redMask;
Pixel greenMask;
Pixel blueMask;
} DarwinFramebufferRec, *DarwinFramebufferPtr; } DarwinFramebufferRec, *DarwinFramebufferPtr;
// From darwin.c // From darwin.c

View File

@ -42,6 +42,7 @@
#include "globals.h" #include "globals.h"
#include "Xplugin.h" #include "Xplugin.h"
#include "applewmExt.h" #include "applewmExt.h"
#include "micmap.h"
// From xprFrame.c // From xprFrame.c
WindowPtr xprGetXWindow(xp_window_id wid); WindowPtr xprGetXWindow(xp_window_id wid);
@ -249,35 +250,59 @@ static Bool
xprAddScreen(int index, ScreenPtr pScreen) xprAddScreen(int index, ScreenPtr pScreen)
{ {
DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen); DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
int depth = darwinDesiredDepth;
/* If no specific depth chosen, look for the depth of the main display.
Else if 16bpp specified, use that. Else use 32bpp. */ if(depth == -1) {
depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
dfb->colorType = TrueColor; //dfb->depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
dfb->bitsPerComponent = 8; //dfb->bitsPerRGB = CGDisplayBitsPerSample(kCGDirectMainDisplay);
dfb->bitsPerPixel = 32; //dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
dfb->colorBitsPerPixel = 24;
if (darwinDesiredDepth == -1)
{
dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
dfb->colorBitsPerPixel =
CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
dfb->bitsPerComponent;
} }
else if (darwinDesiredDepth == 15)
{ switch(depth) {
dfb->bitsPerComponent = 5; case -8: // broken
dfb->bitsPerPixel = 16; FatalError("Unsupported color depth %d\n", darwinDesiredDepth);
dfb->colorBitsPerPixel = 15; dfb->visuals = (1 << StaticGray) | (1 << GrayScale);
} dfb->preferredCVC = GrayScale;
else if (darwinDesiredDepth == 8) dfb->depth = 8;
{ dfb->bitsPerRGB = 8;
dfb->colorType = PseudoColor; dfb->bitsPerPixel = 8;
dfb->bitsPerComponent = 8; dfb->redMask = 0;
dfb->bitsPerPixel = 8; dfb->greenMask = 0;
dfb->colorBitsPerPixel = 8; dfb->blueMask = 0;
break;
case 8: // broken
dfb->visuals = PseudoColorMask;
dfb->preferredCVC = PseudoColor;
dfb->depth = 8;
dfb->bitsPerRGB = 8;
dfb->bitsPerPixel = 8;
dfb->redMask = 0;
dfb->greenMask = 0;
dfb->blueMask = 0;
break;
case 15:
dfb->visuals = LARGE_VISUALS;
dfb->preferredCVC = TrueColor;
dfb->depth = 15;
dfb->bitsPerRGB = 5;
dfb->bitsPerPixel = 16;
dfb->redMask = 0x7c00;
dfb->greenMask = 0x03e0;
dfb->blueMask = 0x001f;
break;
case 24:
dfb->visuals = LARGE_VISUALS;
dfb->preferredCVC = TrueColor;
dfb->depth = 24;
dfb->bitsPerRGB = 8;
dfb->bitsPerPixel = 32;
dfb->redMask = 0x00ff0000;
dfb->greenMask = 0x0000ff00;
dfb->blueMask = 0x000000ff;
break;
default:
FatalError("Unsupported color depth %d\n", darwinDesiredDepth);
} }
if (noPseudoramiXExtension) if (noPseudoramiXExtension)