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 6765949c27
)
This commit is contained in:
parent
17a9714a67
commit
e46d559739
|
@ -78,7 +78,7 @@
|
|||
#include "darwinEvents.h"
|
||||
#include "darwinKeyboard.h"
|
||||
#include "quartz.h"
|
||||
#include "darwinClut8.h"
|
||||
//#include "darwinClut8.h"
|
||||
|
||||
#ifdef ENABLE_DEBUG_LOG
|
||||
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().
|
||||
* Initialize the screen and communicate information about it back to dix.
|
||||
*/
|
||||
static Bool DarwinAddScreen(
|
||||
int index,
|
||||
ScreenPtr pScreen,
|
||||
int argc,
|
||||
char **argv )
|
||||
{
|
||||
int bitsPerRGB, i, dpi;
|
||||
static Bool DarwinAddScreen(int index, ScreenPtr pScreen, int argc, char **argv) {
|
||||
int dpi;
|
||||
static int foundIndex = 0;
|
||||
Bool ret;
|
||||
VisualPtr visual;
|
||||
ColormapPtr pmap;
|
||||
DarwinFramebufferPtr dfb;
|
||||
|
||||
// reset index of found screens for each server generation
|
||||
|
@ -204,28 +197,13 @@ static Bool DarwinAddScreen(
|
|||
if (! ret)
|
||||
return FALSE;
|
||||
|
||||
bitsPerRGB = dfb->bitsPerComponent;
|
||||
|
||||
// reset the visual list
|
||||
miClearVisualTypes();
|
||||
|
||||
// setup a single visual appropriate for our pixel type
|
||||
if (dfb->colorType == TrueColor) {
|
||||
if (!miSetVisualTypes( dfb->colorBitsPerPixel, TrueColorMask,
|
||||
bitsPerRGB, TrueColor )) {
|
||||
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 {
|
||||
if(!miSetVisualTypesAndMasks(dfb->depth, dfb->visuals, dfb->bitsPerRGB,
|
||||
dfb->preferredCVC, dfb->redMask,
|
||||
dfb->greenMask, dfb->blueMask)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -249,20 +227,28 @@ static Bool DarwinAddScreen(
|
|||
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
|
||||
if (dfb->bitsPerPixel > 8) {
|
||||
for (i = 0, visual = pScreen->visuals; // someday we may have more than 1
|
||||
i < pScreen->numVisuals; i++, visual++) {
|
||||
if (visual->class == TrueColor) {
|
||||
visual->offsetRed = bitsPerRGB * 2;
|
||||
visual->offsetGreen = bitsPerRGB;
|
||||
visual->offsetBlue = 0;
|
||||
visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
|
||||
visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
|
||||
visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (dfb->bitsPerPixel > 8) {
|
||||
// for (i = 0, visual = pScreen->visuals; // someday we may have more than 1
|
||||
// i < pScreen->numVisuals; i++, visual++) {
|
||||
// if (visual->class == TrueColor) {
|
||||
// visual->offsetRed = bitsPerRGB * 2;
|
||||
// visual->offsetGreen = bitsPerRGB;
|
||||
// visual->offsetBlue = 0;
|
||||
// visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
|
||||
// visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
|
||||
// visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
#ifdef RENDER
|
||||
if (! fbPictureInit(pScreen, 0, 0)) {
|
||||
|
@ -292,17 +278,16 @@ static Bool DarwinAddScreen(
|
|||
* mode and we're using a fixed color map. Essentially this translates
|
||||
* to Darwin/x86 in 8-bit mode.
|
||||
*/
|
||||
if( (dfb->colorBitsPerPixel == 8) &&
|
||||
(dfb->colorType == StaticColor) )
|
||||
{
|
||||
pmap = miInstalledMaps[pScreen->myNum];
|
||||
visual = pmap->pVisual;
|
||||
for( i = 0; i < visual->ColormapEntries; i++ ) {
|
||||
pmap->red[i].co.local.red = darwinClut8[i].red;
|
||||
pmap->red[i].co.local.green = darwinClut8[i].green;
|
||||
pmap->red[i].co.local.blue = darwinClut8[i].blue;
|
||||
}
|
||||
}
|
||||
// if(dfb->depth == 8) {
|
||||
// ColormapPtr map = RootlessGetColormap (pScreen);
|
||||
// for( i = 0; i < map->pVisual->ColormapEntries; i++ ) {
|
||||
// Entry *ent = map->red + i;
|
||||
// ErrorF("Setting lo %d -> r: %04x g: %04x b: %04x\n", i, darwinClut8[i].red, darwinClut8[i].green, darwinClut8[i].blue);
|
||||
// ent->co.local.red = darwinClut8[i].red;
|
||||
// ent->co.local.green = darwinClut8[i].green;
|
||||
// ent->co.local.blue = darwinClut8[i].blue;
|
||||
// }
|
||||
// }
|
||||
|
||||
dixScreenOrigins[index].x = dfb->x;
|
||||
dixScreenOrigins[index].y = dfb->y;
|
||||
|
@ -793,24 +778,21 @@ int ddxProcessArgument( int argc, char *argv[], int i )
|
|||
}
|
||||
|
||||
if ( !strcmp( argv[i], "-depth" ) ) {
|
||||
int bitDepth;
|
||||
|
||||
if ( i == argc-1 ) {
|
||||
FatalError( "-depth must be followed by a number\n" );
|
||||
}
|
||||
#ifdef OLD_POWERBOOK_G3
|
||||
ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n");
|
||||
#else
|
||||
bitDepth = atoi( argv[i+1] );
|
||||
if (bitDepth == 8)
|
||||
darwinDesiredDepth = 0;
|
||||
else if (bitDepth == 15)
|
||||
darwinDesiredDepth = 1;
|
||||
else if (bitDepth == 24)
|
||||
darwinDesiredDepth = 2;
|
||||
else
|
||||
darwinDesiredDepth = atoi( argv[i+1] );
|
||||
if(darwinDesiredDepth != -1 &&
|
||||
darwinDesiredDepth != 8 &&
|
||||
darwinDesiredDepth != 15 &&
|
||||
darwinDesiredDepth != 24) {
|
||||
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
|
||||
return 2;
|
||||
}
|
||||
|
|
|
@ -40,10 +40,14 @@ typedef struct {
|
|||
int width;
|
||||
int height;
|
||||
int pitch;
|
||||
int colorType;
|
||||
int depth;
|
||||
int visuals;
|
||||
int bitsPerRGB;
|
||||
int bitsPerPixel;
|
||||
int colorBitsPerPixel;
|
||||
int bitsPerComponent;
|
||||
int preferredCVC;
|
||||
Pixel redMask;
|
||||
Pixel greenMask;
|
||||
Pixel blueMask;
|
||||
} DarwinFramebufferRec, *DarwinFramebufferPtr;
|
||||
|
||||
// From darwin.c
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "globals.h"
|
||||
#include "Xplugin.h"
|
||||
#include "applewmExt.h"
|
||||
#include "micmap.h"
|
||||
|
||||
// From xprFrame.c
|
||||
WindowPtr xprGetXWindow(xp_window_id wid);
|
||||
|
@ -249,35 +250,59 @@ static Bool
|
|||
xprAddScreen(int index, ScreenPtr pScreen)
|
||||
{
|
||||
DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
|
||||
|
||||
/* If no specific depth chosen, look for the depth of the main display.
|
||||
Else if 16bpp specified, use that. Else use 32bpp. */
|
||||
|
||||
dfb->colorType = TrueColor;
|
||||
dfb->bitsPerComponent = 8;
|
||||
dfb->bitsPerPixel = 32;
|
||||
dfb->colorBitsPerPixel = 24;
|
||||
|
||||
if (darwinDesiredDepth == -1)
|
||||
{
|
||||
dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
|
||||
dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
|
||||
dfb->colorBitsPerPixel =
|
||||
CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
|
||||
dfb->bitsPerComponent;
|
||||
int depth = darwinDesiredDepth;
|
||||
|
||||
if(depth == -1) {
|
||||
depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
|
||||
//dfb->depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
|
||||
//dfb->bitsPerRGB = CGDisplayBitsPerSample(kCGDirectMainDisplay);
|
||||
//dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
|
||||
}
|
||||
else if (darwinDesiredDepth == 15)
|
||||
{
|
||||
dfb->bitsPerComponent = 5;
|
||||
dfb->bitsPerPixel = 16;
|
||||
dfb->colorBitsPerPixel = 15;
|
||||
}
|
||||
else if (darwinDesiredDepth == 8)
|
||||
{
|
||||
dfb->colorType = PseudoColor;
|
||||
dfb->bitsPerComponent = 8;
|
||||
dfb->bitsPerPixel = 8;
|
||||
dfb->colorBitsPerPixel = 8;
|
||||
|
||||
switch(depth) {
|
||||
case -8: // broken
|
||||
FatalError("Unsupported color depth %d\n", darwinDesiredDepth);
|
||||
dfb->visuals = (1 << StaticGray) | (1 << GrayScale);
|
||||
dfb->preferredCVC = GrayScale;
|
||||
dfb->depth = 8;
|
||||
dfb->bitsPerRGB = 8;
|
||||
dfb->bitsPerPixel = 8;
|
||||
dfb->redMask = 0;
|
||||
dfb->greenMask = 0;
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user