#include "win.h"
BOOL CALLBACK
winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam);
static
Bool
winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
{
winScreenPriv(pScreen);
HBITMAP hbmp;
#if CYGDEBUG
LPDWORD pdw = NULL;
#endif
hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
if (hbmp == NULL)
{
ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
return FALSE;
}
ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
pbmih->biSize = sizeof (BITMAPINFOHEADER);
if (!GetDIBits (pScreenPriv->hdcScreen,
hbmp,
0, 1,
NULL,
(BITMAPINFO*) pbmih,
DIB_RGB_COLORS))
{
ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
DeleteObject (hbmp);
return FALSE;
}
#if CYGDEBUG
pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
ErrorF ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
pdw[0], pdw[1], pdw[2]);
#endif
if (!GetDIBits (pScreenPriv->hdcScreen,
hbmp,
0, 1,
NULL,
(BITMAPINFO*)pbmih,
DIB_RGB_COLORS))
{
ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits "
"failed\n");
DeleteObject (hbmp);
return FALSE;
}
DeleteObject (hbmp);
return TRUE;
}
static
Bool
winQueryRGBBitsAndMasks (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
BITMAPINFOHEADER *pbmih = NULL;
Bool fReturn = TRUE;
LPDWORD pdw = NULL;
DWORD dwRedBits, dwGreenBits, dwBlueBits;
if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
{
pScreenPriv->dwBitsPerRGB = 8;
pScreenPriv->dwRedMask = 0x0L;
pScreenPriv->dwGreenMask = 0x0L;
pScreenPriv->dwBlueMask = 0x0L;
return TRUE;
}
if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
* GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
{
ErrorF ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
"returned 24 for the screen. Using default 24bpp masks.\n");
pScreenPriv->dwBitsPerRGB = 8;
pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
return TRUE;
}
pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ 256 * sizeof (RGBQUAD));
if (pbmih == NULL)
{
ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
return FALSE;
}
if (winQueryScreenDIBFormat (pScreen, pbmih))
{
pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
#if CYGDEBUG
ErrorF ("winQueryRGBBitsAndMasks - Masks: %08x %08x %08x\n",
pdw[0], pdw[1], pdw[2]);
#endif
dwRedBits = winCountBits (pdw[0]);
dwGreenBits = winCountBits (pdw[1]);
dwBlueBits = winCountBits (pdw[2]);
if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
pScreenPriv->dwBitsPerRGB = dwRedBits;
else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
pScreenPriv->dwBitsPerRGB = dwGreenBits;
else
pScreenPriv->dwBitsPerRGB = dwBlueBits;
pScreenPriv->dwRedMask = pdw[0];
pScreenPriv->dwGreenMask = pdw[1];
pScreenPriv->dwBlueMask = pdw[2];
}
else
{
ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
free (pbmih);
fReturn = FALSE;
}
free (pbmih);
return fReturn;
}
BOOL CALLBACK
winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam)
{
char strClassName[100];
if (GetClassName (hwnd, strClassName, 100))
{
if (strncmp (WINDOW_CLASS_X, strClassName, strlen (WINDOW_CLASS_X)) == 0)
{
InvalidateRect (hwnd, NULL, FALSE);
UpdateWindow (hwnd);
}
}
return TRUE;
}
Bool
winAllocateFBShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
BITMAPINFOHEADER *pbmih = NULL;
DIBSECTION dibsection;
Bool fReturn = TRUE;
pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen);
pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ 256 * sizeof (RGBQUAD));
if (pbmih == NULL)
{
ErrorF ("winAllocateFBShadowGDI - malloc () failed\n");
return FALSE;
}
fReturn = winQueryScreenDIBFormat (pScreen, pbmih);
pbmih->biWidth = pScreenInfo->dwWidth;
pbmih->biHeight = -pScreenInfo->dwHeight;
ErrorF ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
"depth: %d\n",
pbmih->biWidth, -pbmih->biHeight, pbmih->biBitCount);
pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen,
(BITMAPINFO *) pbmih,
DIB_RGB_COLORS,
(VOID**) &pScreenInfo->pfb,
NULL,
0);
if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
{
ErrorF ("winAllocateFBShadowGDI - CreateDIBSection failed\n");
return FALSE;
}
else
{
#if CYGDEBUG
ErrorF ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
#endif
}
GetObject (pScreenPriv->hbmpShadow,
sizeof (dibsection),
&dibsection);
#if CYGDEBUG || YES
ErrorF ("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
"depth: %d size image: %d\n",
dibsection.dsBmih.biWidth, dibsection.dsBmih.biHeight,
dibsection.dsBmih.biBitCount,
dibsection.dsBmih.biSizeImage);
#endif
SelectObject (pScreenPriv->hdcShadow,
pScreenPriv->hbmpShadow);
#if CYGDEBUG
ErrorF ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
#endif
fReturn = BitBlt (pScreenPriv->hdcScreen,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow,
0, 0,
SRCCOPY);
if (fReturn)
{
#if CYGDEBUG
ErrorF ("winAllocateFBShadowGDI - Shadow blit success\n");
#endif
}
else
{
ErrorF ("winAllocateFBShadowGDI - Shadow blit failure\n");
return FALSE;
}
if (dibsection.dsBmih.biHeight < 0)
{
ErrorF ("winAllocateFBShadowGDI - WEIRDNESS - biHeight "
"still negative: %d\n"
"winAllocateFBShadowGDI - WEIRDNESS - Flipping biHeight sign\n",
dibsection.dsBmih.biHeight);
dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
}
pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
/ dibsection.dsBmih.biHeight)
* 8) / pScreenInfo->dwBPP;
#if CYGDEBUG || YES
ErrorF ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
pScreenInfo->dwStride);
#endif
if (pScreenInfo->dwWidth * pScreenInfo->dwHeight * pScreenInfo->dwBPP
>= WIN_DIB_MAXIMUM_SIZE)
{
ErrorF ("winAllocateFBShadowGDI - Requested DIB (bitmap) "
"will be larger than %d MB. The surface may fail to be "
"allocated on Windows 95, 98, or Me, due to a %d MB limit in "
"DIB size. This limit does not apply to Windows NT/2000, and "
"this message may be ignored on those platforms.\n",
WIN_DIB_MAXIMUM_SIZE_MB, WIN_DIB_MAXIMUM_SIZE_MB);
}
if (!winQueryRGBBitsAndMasks (pScreen))
{
ErrorF ("winAllocateFBShadowGDI - winQueryRGBBitsAndMasks failed\n");
return FALSE;
}
if (pScreenInfo->fMultiWindow) EnumWindows(winRedrawAllProcShadowGDI, 0);
return fReturn;
}
void
winShadowUpdateGDI (ScreenPtr pScreen,
shadowBufPtr pBuf)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
RegionPtr damage = &pBuf->damage;
DWORD dwBox = REGION_NUM_RECTS (damage);
BoxPtr pBox = REGION_RECTS (damage);
int x, y, w, h;
HRGN hrgnTemp = NULL, hrgnCombined = NULL;
#if WIN_UPDATE_STATS
static DWORD s_dwNonUnitRegions = 0;
static DWORD s_dwTotalUpdates = 0;
static DWORD s_dwTotalBoxes = 0;
#endif
if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
|| pScreenPriv->fBadDepth) return;
#if WIN_UPDATE_STATS
++s_dwTotalUpdates;
s_dwTotalBoxes += dwBox;
if (dwBox != 1)
{
++s_dwNonUnitRegions;
ErrorF ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
}
if ((s_dwTotalUpdates % 100) == 0)
ErrorF ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
"nu: %d tu: %d\n",
(s_dwNonUnitRegions * 100) / s_dwTotalUpdates,
s_dwTotalBoxes / s_dwTotalUpdates,
s_dwNonUnitRegions, s_dwTotalUpdates);
#endif
if (pScreenInfo->dwClipUpdatesNBoxes == 0
|| dwBox < pScreenInfo->dwClipUpdatesNBoxes)
{
while (dwBox--)
{
x = pBox->x1;
y = pBox->y1;
w = pBox->x2 - pBox->x1;
h = pBox->y2 - pBox->y1;
BitBlt (pScreenPriv->hdcScreen,
x, y,
w, h,
pScreenPriv->hdcShadow,
x, y,
SRCCOPY);
++pBox;
}
}
else
{
BoxPtr pBoxExtents = REGION_EXTENTS (pScreen, damage);
hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
dwBox--;
pBox++;
while (dwBox--)
{
hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
DeleteObject (hrgnTemp);
pBox++;
}
SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
DeleteObject (hrgnCombined);
hrgnCombined = NULL;
BitBlt (pScreenPriv->hdcScreen,
pBoxExtents->x1, pBoxExtents->y1,
pBoxExtents->x2 - pBoxExtents->x1,
pBoxExtents->y2 - pBoxExtents->y1,
pScreenPriv->hdcShadow,
pBoxExtents->x1, pBoxExtents->y1,
SRCCOPY);
SelectClipRgn (pScreenPriv->hdcScreen, NULL);
}
if (pScreenInfo->fMultiWindow) EnumWindows(winRedrawAllProcShadowGDI, 0);
}
Bool
winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn;
#if CYGDEBUG
ErrorF ("winCloseScreenShadowGDI - Freeing screen resources\n");
#endif
pScreenPriv->fClosed = TRUE;
pScreenPriv->fActive = FALSE;
pScreen->CloseScreen = pScreenPriv->CloseScreen;
fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
DeleteDC (pScreenPriv->hdcShadow);
DeleteObject (pScreenPriv->hbmpShadow);
ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
if (!pScreenInfo->fNoTrayIcon)
winDeleteNotifyIcon (pScreenPriv);
if (g_hDlgExit != NULL)
{
DestroyWindow (g_hDlgExit);
g_hDlgExit = NULL;
}
if (pScreenPriv->hwndScreen)
{
DestroyWindow (pScreenPriv->hwndScreen);
pScreenPriv->hwndScreen = NULL;
}
pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
pScreenInfo->pScreen = NULL;
pScreenInfo->pfb = NULL;
free ((pointer) pScreenPriv);
return fReturn;
}
Bool
winInitVisualsShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
ErrorF ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
"bpp %d\n",
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask,
pScreenPriv->dwBitsPerRGB,
pScreenInfo->dwDepth,
pScreenInfo->dwBPP);
switch (pScreenInfo->dwDepth)
{
case 24:
case 16:
case 15:
#if defined(XFree86Server)
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
TrueColorMask,
pScreenPriv->dwBitsPerRGB,
-1,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
"failed\n");
return FALSE;
}
#if WIN_EMULATE_PSEUDO_SUPPORT
if (!pScreenInfo->fEmulatePseudo)
break;
if (!miSetVisualTypesAndMasks (8,
PseudoColorMask,
8,
-1,
0,
0,
0))
{
ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
"failed for PseudoColor\n");
return FALSE;
}
#endif
#else
if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
TrueColorMask,
pScreenPriv->dwBitsPerRGB,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
"failed for TrueColor\n");
return FALSE;
}
#if WIN_EMULATE_PSEUDO_SUPPORT
if (!pScreenInfo->fEmulatePseudo)
break;
if (!fbSetVisualTypesAndMasks (8,
PseudoColorMask,
8,
0,
0,
0))
{
ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
"failed for PseudoColor\n");
return FALSE;
}
#endif
#endif
break;
case 8:
#if defined(XFree86Server)
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
PseudoColor,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
"failed\n");
return FALSE;
}
#else
if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
"failed\n");
return FALSE;
}
#endif
break;
default:
ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n");
return FALSE;
}
#if CYGDEBUG
ErrorF ("winInitVisualsShadowGDI - Returning\n");
#endif
return TRUE;
}
Bool
winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
HDC hdc;
DWORD dwBPP;
hdc = GetDC (NULL);
if (hdc == NULL)
{
ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n");
return FALSE;
}
dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
{
ErrorF ("winAdjustVideoModeShadowGDI - Using Windows display "
"depth of %d bits per pixel\n", dwBPP);
pScreenInfo->dwBPP = dwBPP;
}
else if (dwBPP != pScreenInfo->dwBPP)
{
ErrorF ("winAdjustVideoModeShadowGDI - Command line bpp: %d, "\
"using bpp: %d\n", pScreenInfo->dwBPP, dwBPP);
pScreenInfo->dwBPP = dwBPP;
}
ReleaseDC (NULL, hdc);
hdc = NULL;
return TRUE;
}
Bool
winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
winPrivCmapPtr pCmapPriv = NULL;
HDC hdcUpdate;
PAINTSTRUCT ps;
hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
if (pScreenPriv->pcmapInstalled != NULL)
{
pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
RealizePalette (hdcUpdate);
}
BitBlt (hdcUpdate,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow,
0, 0,
SRCCOPY);
EndPaint (pScreenPriv->hwndScreen, &ps);
if (pScreenInfo->fMultiWindow) EnumWindows(winRedrawAllProcShadowGDI, 0);
return TRUE;
}
Bool
winActivateAppShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
#if CYGDEBUG
ErrorF ("winActivateAppShadowGDI\n");
#endif
if (pScreenPriv->fActive
&& pScreenInfo->fFullScreen)
{
ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
}
else if (!pScreenPriv->fActive
&& pScreenInfo->fFullScreen)
{
ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
}
#if CYGDEBUG
ErrorF ("winActivateAppShadowGDI - Returning\n");
#endif
return TRUE;
}
Bool
winRedrawScreenShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
BitBlt (pScreenPriv->hdcScreen,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow,
0, 0,
SRCCOPY);
if (pScreenInfo->fMultiWindow) EnumWindows(winRedrawAllProcShadowGDI, 0);
return TRUE;
}
Bool
winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winPrivCmapPtr pCmapPriv = NULL;
#if CYGDEBUG
ErrorF ("winRealizeInstalledPaletteShadowGDI\n");
#endif
if (pScreenPriv->pcmapInstalled == NULL)
{
#if CYGDEBUG
ErrorF ("winRealizeInstalledPaletteShadowGDI - No colormap "
"installed\n");
#endif
return TRUE;
}
pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
{
ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
"failed\n");
return FALSE;
}
if (SetDIBColorTable (pScreenPriv->hdcShadow,
0,
WIN_NUM_PALETTE_ENTRIES,
pCmapPriv->rgbColors) == 0)
{
ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
"failed\n");
return FALSE;
}
return TRUE;
}
Bool
winInstallColormapShadowGDI (ColormapPtr pColormap)
{
ScreenPtr pScreen = pColormap->pScreen;
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
winCmapPriv(pColormap);
if (SelectPalette (pScreenPriv->hdcScreen,
pCmapPriv->hPalette,
FALSE) == NULL)
{
ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
return FALSE;
}
if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
{
ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
return FALSE;
}
if (SetDIBColorTable (pScreenPriv->hdcShadow,
0,
WIN_NUM_PALETTE_ENTRIES,
pCmapPriv->rgbColors) == 0)
{
ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
return FALSE;
}
BitBlt (pScreenPriv->hdcScreen,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow,
0, 0,
SRCCOPY);
pScreenPriv->pcmapInstalled = pColormap;
if (pScreenInfo->fMultiWindow) EnumWindows(winRedrawAllProcShadowGDI, 0);
return TRUE;
}
Bool
winStoreColorsShadowGDI (ColormapPtr pColormap,
int ndef,
xColorItem *pdefs)
{
ScreenPtr pScreen = pColormap->pScreen;
winScreenPriv(pScreen);
winCmapPriv(pColormap);
ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
if (SetPaletteEntries (pCmapPriv->hPalette,
pdefs[0].pixel,
ndef,
pCmapPriv->peColors + pdefs[0].pixel) == 0)
{
ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
return FALSE;
}
if (pColormap != curpmap)
{
return TRUE;
}
if (!winInstallColormapShadowGDI (pColormap))
{
ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
"failed\n");
return FALSE;
}
#if 0
RealizePalette (pScreenPriv->hdcScreen);
if (SetDIBColorTable (pScreenPriv->hdcShadow,
pdefs[0].pixel,
ndef,
pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
{
ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
return FALSE;
}
pScreenPriv->pcmapInstalled = pColormap;
#endif
return TRUE;
}
Bool
winCreateColormapShadowGDI (ColormapPtr pColormap)
{
LPLOGPALETTE lpPaletteNew = NULL;
DWORD dwEntriesMax;
VisualPtr pVisual;
HPALETTE hpalNew = NULL;
winCmapPriv(pColormap);
pVisual = pColormap->pVisual;
dwEntriesMax = pVisual->ColormapEntries;
lpPaletteNew = malloc (sizeof (LOGPALETTE)
+ (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
if (lpPaletteNew == NULL)
{
ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
"with %d entries\n",
dwEntriesMax);
return FALSE;
}
ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
+ (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
lpPaletteNew->palVersion = 0x0300;
lpPaletteNew->palNumEntries = dwEntriesMax;
hpalNew = CreatePalette (lpPaletteNew);
if (hpalNew == NULL)
{
ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
free (lpPaletteNew);
return FALSE;
}
pCmapPriv->hPalette = hpalNew;
free (lpPaletteNew);
return TRUE;
}
Bool
winDestroyColormapShadowGDI (ColormapPtr pColormap)
{
winScreenPriv(pColormap->pScreen);
winCmapPriv(pColormap);
if (pColormap->flags & IsDefault)
{
#if CYGDEBUG
ErrorF ("winDestroyColormapShadowGDI - Destroying default "
"colormap\n");
#endif
SelectPalette (pScreenPriv->hdcScreen,
GetStockObject (DEFAULT_PALETTE),
FALSE);
pScreenPriv->pcmapInstalled = NULL;
}
if (DeleteObject (pCmapPriv->hPalette) == 0)
{
ErrorF ("winDestroyColormap - DeleteObject () failed\n");
return FALSE;
}
pCmapPriv->hPalette = NULL;
return TRUE;
}
Bool
winSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
if (pScreenInfo->fFullScreen)
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
else
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
pScreenPriv->pwinRealizeInstalledPalette =
winRealizeInstalledPaletteShadowGDI;
pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)())NoopDDA;
pScreenPriv->pwinCreatePrimarySurface
= (winCreatePrimarySurfaceProcPtr) (void (*)())NoopDDA;
pScreenPriv->pwinReleasePrimarySurface
= (winReleasePrimarySurfaceProcPtr) (void (*)())NoopDDA;
return TRUE;
}