summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Haesen <marha@users.sourceforge.net>2012-07-21 21:18:44 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2012-08-03 22:58:08 +0100
commitf6e7b82acadfca8239edc0f7e72cd0f3f9cfc2c4 (patch)
tree431de4ef0d6354c6e9f3be54dcaaad71a13f0c23
parent45c432871d6a244e9e558a6a4e7c36e90764135e (diff)
hw/xwin: Fixes to pixelFormat <-> fbConfig conversion in WGL mode
Fix FIXME in fbConfigToPixelFormat() to correctly populate RGBA-mask shift parameters. Also request colourindex pixelFormats correctly. Now that they are requested correctly, don't skip colorindex visuals when converting pixelFormats to fbConfigs. Populate transparent colour information when converting pixelFormat from DescribePixelFormats() to a fbConfig. Signed-off-by: Marc Haesen <marha@users.sourceforge.net> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
-rw-r--r--hw/xwin/glx/indirect.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 3f34146e5..97b6045b7 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -1626,6 +1626,18 @@ glxWinCreateContext(__GLXscreen * screen,
*/
static int
+GetShift(int Mask)
+{
+ int Shift = 0;
+
+ while ((Mask &1) == 0) {
+ Shift++;
+ Mask >>=1;
+ }
+ return Shift;
+}
+
+static int
fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret,
int drawableTypeOverride)
{
@@ -1661,16 +1673,26 @@ fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret,
pfd.dwFlags |= PFD_DOUBLEBUFFER;
}
- pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = mode->redBits + mode->greenBits + mode->blueBits;
pfd.cRedBits = mode->redBits;
- pfd.cRedShift = 0; /* FIXME */
+ pfd.cRedShift = GetShift(mode->redMask);
pfd.cGreenBits = mode->greenBits;
- pfd.cGreenShift = 0; /* FIXME */
+ pfd.cGreenShift = GetShift(mode->greenMask);
pfd.cBlueBits = mode->blueBits;
- pfd.cBlueShift = 0; /* FIXME */
+ pfd.cBlueShift = GetShift(mode->blueMask);
pfd.cAlphaBits = mode->alphaBits;
- pfd.cAlphaShift = 0; /* FIXME */
+ pfd.cAlphaShift = GetShift(mode->alphaMask);
+
+ if (mode->visualType == GLX_TRUE_COLOR) {
+ pfd.iPixelType = PFD_TYPE_RGBA;
+ pfd.dwVisibleMask =
+ (pfd.cRedBits << pfd.cRedShift) | (pfd.cGreenBits << pfd.cGreenShift) |
+ (pfd.cBlueBits << pfd.cBlueShift) | (pfd.cAlphaBits << pfd.cAlphaShift);
+ }
+ else {
+ pfd.iPixelType = PFD_TYPE_COLORINDEX;
+ pfd.dwVisibleMask = mode->transparentIndex;
+ }
pfd.cAccumBits =
mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits +
@@ -1910,25 +1932,27 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
/* EXT_visual_info / GLX 1.2 */
if (pfd.iPixelType == PFD_TYPE_COLORINDEX) {
c->base.visualType = GLX_STATIC_COLOR;
-
- if (!getenv("GLWIN_ENABLE_COLORINDEX_FBCONFIGS")) {
- GLWIN_DEBUG_MSG
- ("pixelFormat %d is PFD_TYPE_COLORINDEX, skipping", i + 1);
- continue;
- }
+ c->base.transparentRed = GLX_NONE;
+ c->base.transparentGreen = GLX_NONE;
+ c->base.transparentBlue = GLX_NONE;
+ c->base.transparentAlpha = GLX_NONE;
+ c->base.transparentIndex = pfd.dwVisibleMask;
+ c->base.transparentPixel = GLX_TRANSPARENT_INDEX;
}
else {
c->base.visualType = GLX_TRUE_COLOR;
+ c->base.transparentRed =
+ (pfd.dwVisibleMask & c->base.redMask) >> pfd.cRedShift;
+ c->base.transparentGreen =
+ (pfd.dwVisibleMask & c->base.greenMask) >> pfd.cGreenShift;
+ c->base.transparentBlue =
+ (pfd.dwVisibleMask & c->base.blueMask) >> pfd.cBlueShift;
+ c->base.transparentAlpha =
+ (pfd.dwVisibleMask & c->base.alphaMask) >> pfd.cAlphaShift;
+ c->base.transparentIndex = GLX_NONE;
+ c->base.transparentPixel = GLX_TRANSPARENT_RGB;
}
- // pfd.dwVisibleMask; ???
- c->base.transparentPixel = GLX_NONE;
- c->base.transparentRed = GLX_NONE;
- c->base.transparentGreen = GLX_NONE;
- c->base.transparentBlue = GLX_NONE;
- c->base.transparentAlpha = GLX_NONE;
- c->base.transparentIndex = GLX_NONE;
-
/* ARB_multisample / SGIS_multisample */
c->base.sampleBuffers = 0;
c->base.samples = 0;
@@ -2180,14 +2204,6 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
c->base.indexBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
c->base.rgbBits = 0;
c->base.visualType = GLX_STATIC_COLOR;
-
- if (!getenv("GLWIN_ENABLE_COLORINDEX_FBCONFIGS")) {
- GLWIN_DEBUG_MSG
- ("pixelFormat %d is WGL_TYPE_COLORINDEX_ARB, skipping",
- i + 1);
- continue;
- }
-
break;
case WGL_TYPE_RGBA_FLOAT_ARB: