diff options
author | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2009-07-31 15:32:07 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@freedesktop.org> | 2009-07-31 15:34:13 -0700 |
commit | ae65daab080c6269f0eadc6be1a48bf27866c542 (patch) | |
tree | 4f32c5d07f08094dab8b62d028748f5fa56df004 /hw | |
parent | 4a53fed41d711f270c7d8a7fbeaafb4fb619e879 (diff) |
XQuartz: Unify how we set our bitmasks for visuals
(cherry picked from commit c230b52c27ce50ac6c27011ec8e88f1b263b25f9)
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xquartz/GL/visualConfigs.c | 30 | ||||
-rw-r--r-- | hw/xquartz/Makefile.am | 1 | ||||
-rw-r--r-- | hw/xquartz/darwin.c | 34 | ||||
-rw-r--r-- | hw/xquartz/darwin.h | 17 | ||||
-rw-r--r-- | hw/xquartz/darwinfb.h | 56 | ||||
-rw-r--r-- | hw/xquartz/xpr/xprScreen.c | 25 |
6 files changed, 77 insertions, 86 deletions
diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c index 46addaf8a..fee665d1d 100644 --- a/hw/xquartz/GL/visualConfigs.c +++ b/hw/xquartz/GL/visualConfigs.c @@ -55,8 +55,7 @@ #include "capabilities.h" #include "visualConfigs.h" - -#define MASK(l,h) (((1 << (1 + h - l)) - 1) << l) +#include "darwinfb.h" /* Based originally on code from indirect.c which was based on code from i830_dri.c. */ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) { @@ -182,29 +181,22 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) } // Color - c->rgbBits = 0; - - c->blueBits = conf->color_buffers[color].b; - c->blueMask = MASK(c->rgbBits, c->rgbBits + c->blueBits - 1); - c->rgbBits += c->blueBits; - - c->greenBits = conf->color_buffers[color].g; - c->greenMask = MASK(c->rgbBits, c->rgbBits + c->greenBits - 1); - c->rgbBits += c->greenBits; - - c->redBits = conf->color_buffers[color].r; - c->redMask = MASK(c->rgbBits, c->rgbBits + c->redBits - 1); - c->rgbBits += c->redBits; - if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) { c->alphaBits = conf->color_buffers[color].a; - c->alphaMask = MASK(c->rgbBits, c->rgbBits + c->alphaBits - 1); - c->rgbBits += c->alphaBits; } else { c->alphaBits = 0; - c->alphaMask = 0; } + c->redBits = conf->color_buffers[color].r; + c->greenBits = conf->color_buffers[color].g; + c->blueBits = conf->color_buffers[color].b; + c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits; + + c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + c->redMask = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + c->blueMask = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + // Accumulation Buffers if(conf->total_accum_buffers > 0) { c->accumRedBits = conf->accum_buffers[accum].r; diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am index 653ae130a..ae8aa7f53 100644 --- a/hw/xquartz/Makefile.am +++ b/hw/xquartz/Makefile.am @@ -42,6 +42,7 @@ EXTRA_DIST = \ X11Controller.h \ applewmExt.h \ darwin.h \ + darwinfb.h \ darwinEvents.h \ keysym2ucs.h \ pseudoramiX.h \ diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c index 00f7ce35e..7129ac61f 100644 --- a/hw/xquartz/darwin.c +++ b/hw/xquartz/darwin.c @@ -217,17 +217,10 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv // TODO: Make PseudoColor visuals not suck in TrueColor mode // if(dfb->depth > 8) // miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0); - -#if 0 - /* - * These aren't used anymore. xpr/xprScreen.c initializes the dfb struct - * above based on the display properties. - */ if(dfb->depth > 15) - miSetVisualTypesAndMasks(15, LARGE_VISUALS, 5, TrueColor, 0x7c00, 0x03e0, 0x001f); + miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor, RM_ARGB(0,5,5,5), GM_ARGB(0,5,5,5), BM_ARGB(0,5,5,5)); if(dfb->depth > 24) - miSetVisualTypesAndMasks(24, LARGE_VISUALS, 8, TrueColor, 0x00ff0000, 0x0000ff00, 0x000000ff); -#endif + miSetVisualTypesAndMasks(24, TrueColorMask, 8, TrueColor, RM_ARGB(0,8,8,8), GM_ARGB(0,8,8,8), BM_ARGB(0,8,8,8)); miSetPixmapDepths(); @@ -249,29 +242,6 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv 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; -// } -// } -// } - #ifdef RENDER if (! fbPictureInit(pScreen, 0, 0)) { return FALSE; diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h index 7fb9396e5..586044fba 100644 --- a/hw/xquartz/darwin.h +++ b/hw/xquartz/darwin.h @@ -36,22 +36,7 @@ #include "threadSafety.h" -typedef struct { - void *framebuffer; - int x; - int y; - int width; - int height; - int pitch; - int depth; - int visuals; - int bitsPerRGB; - int bitsPerPixel; - int preferredCVC; - Pixel redMask; - Pixel greenMask; - Pixel blueMask; -} DarwinFramebufferRec, *DarwinFramebufferPtr; +#include "darwinfb.h" // From darwin.c void DarwinPrintBanner(void); diff --git a/hw/xquartz/darwinfb.h b/hw/xquartz/darwinfb.h new file mode 100644 index 000000000..dab6d4b86 --- /dev/null +++ b/hw/xquartz/darwinfb.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple, Inc. + * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written authorization. + */ + +#ifndef _DARWIN_FB_H +#define _DARWIN_DB_H + +#include "scrnintstr.h" + +typedef struct { + void *framebuffer; + int x; + int y; + int width; + int height; + int pitch; + int depth; + int visuals; + int bitsPerRGB; + int bitsPerPixel; + int preferredCVC; + Pixel redMask; + Pixel greenMask; + Pixel blueMask; +} DarwinFramebufferRec, *DarwinFramebufferPtr; + +#define MASK_LH(l,h) (((1 << (1 + (h) - (l))) - 1) << (l)) +#define BM_ARGB(a,r,g,b) MASK_LH(0, (b) - 1) +#define GM_ARGB(a,r,g,b) MASK_LH(b, (b) + (g) - 1) +#define RM_ARGB(a,r,g,b) MASK_LH((b) + (g), (b) + (g) + (r) - 1) +#define AM_ARGB(a,r,g,b) MASK_LH((b) + (g) + (r), (b) + (g) + (r) + (a) - 1) + +#endif /* _DARWIN_FB_H */ diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c index 3ffb926ac..3387ecf0a 100644 --- a/hw/xquartz/xpr/xprScreen.c +++ b/hw/xquartz/xpr/xprScreen.c @@ -277,22 +277,9 @@ xprAddScreen(int index, ScreenPtr pScreen) if(depth == -1) { depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay); - //dfb->depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay); - //dfb->bitsPerRGB = CGDisplayBitsPerSample(kCGDirectMainDisplay); - //dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay); } switch(depth) { -// case -8: // broken -// 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: // pseudo-working dfb->visuals = PseudoColorMask; dfb->preferredCVC = PseudoColor; @@ -309,9 +296,9 @@ xprAddScreen(int index, ScreenPtr pScreen) dfb->depth = 15; dfb->bitsPerRGB = 5; dfb->bitsPerPixel = 16; - dfb->redMask = 0x7c00; - dfb->greenMask = 0x03e0; - dfb->blueMask = 0x001f; + dfb->redMask = RM_ARGB(0,5,5,5); + dfb->greenMask = GM_ARGB(0,5,5,5); + dfb->blueMask = BM_ARGB(0,5,5,5); break; // case 24: default: @@ -322,9 +309,9 @@ xprAddScreen(int index, ScreenPtr pScreen) dfb->depth = 24; dfb->bitsPerRGB = 8; dfb->bitsPerPixel = 32; - dfb->redMask = 0x00ff0000; - dfb->greenMask = 0x0000ff00; - dfb->blueMask = 0x000000ff; + dfb->redMask = RM_ARGB(0,8,8,8); + dfb->greenMask = GM_ARGB(0,8,8,8); + dfb->blueMask = BM_ARGB(0,8,8,8); break; } |