xserver-multidpi/hw/xwin/winshadgdi.c

1159 lines
35 KiB
C
Raw Normal View History

2003-11-14 17:48:57 +01:00
/*
2004-06-21 15:19:32 +02:00
*Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
2003-11-14 17:48:57 +01:00
*
*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
2004-06-21 15:19:32 +02:00
*NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
2003-11-14 17:48:57 +01:00
*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.
*
2004-06-21 15:19:32 +02:00
*Except as contained in this notice, the name of Harold L Hunt II
2003-11-14 17:48:57 +01:00
*shall not be used in advertising or otherwise to promote the sale, use
*or other dealings in this Software without prior written authorization
2004-06-21 15:19:32 +02:00
*from Harold L Hunt II.
2003-11-14 17:48:57 +01:00
*
* Authors: Harold L Hunt II
*/
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
2003-11-14 17:48:57 +01:00
#include "win.h"
/*
* Local function prototypes
*/
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
static wBOOL CALLBACK winRedrawAllProcShadowGDI(HWND hwnd, LPARAM lParam);
2003-11-14 17:48:57 +01:00
static wBOOL CALLBACK winRedrawDamagedWindowShadowGDI(HWND hwnd, LPARAM lParam);
2004-06-21 15:19:32 +02:00
#endif
static Bool
winAllocateFBShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static void
winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf);
2004-06-21 15:19:32 +02:00
static Bool
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
winCloseScreenShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static Bool
winInitVisualsShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static Bool
winAdjustVideoModeShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static Bool
winBltExposedRegionsShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static Bool
winActivateAppShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static Bool
winRedrawScreenShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static Bool
winRealizeInstalledPaletteShadowGDI(ScreenPtr pScreen);
2004-06-21 15:19:32 +02:00
static Bool
winInstallColormapShadowGDI(ColormapPtr pColormap);
2004-06-21 15:19:32 +02:00
static Bool
winStoreColorsShadowGDI(ColormapPtr pmap, int ndef, xColorItem * pdefs);
2004-06-21 15:19:32 +02:00
static Bool
winCreateColormapShadowGDI(ColormapPtr pColormap);
2004-06-21 15:19:32 +02:00
static Bool
winDestroyColormapShadowGDI(ColormapPtr pColormap);
2003-11-14 17:48:57 +01:00
/*
* Internal function to get the DIB format that is compatible with the screen
*/
static
Bool
winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
HBITMAP hbmp;
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
LPDWORD pdw = NULL;
2003-11-14 17:48:57 +01:00
#endif
/* Create a memory bitmap compatible with the screen */
hbmp = CreateCompatibleBitmap(pScreenPriv->hdcScreen, 1, 1);
if (hbmp == NULL) {
ErrorF("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Initialize our bitmap info header */
ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
pbmih->biSize = sizeof(BITMAPINFOHEADER);
/* Get the biBitCount */
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;
2003-11-14 17:48:57 +01:00
}
#if CYGDEBUG
/* Get a pointer to bitfields */
pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
2003-11-14 17:48:57 +01:00
winDebug("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
pdw[0], pdw[1], pdw[2]);
2003-11-14 17:48:57 +01:00
#endif
/* Get optimal color table, or the optimal bitfields */
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;
2003-11-14 17:48:57 +01:00
}
/* Free memory */
DeleteObject(hbmp);
2003-11-14 17:48:57 +01:00
return TRUE;
}
2003-11-14 17:48:57 +01:00
/*
* Internal function to determine the GDI bits per rgb and bit masks
*/
static
Bool
winQueryRGBBitsAndMasks(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
BITMAPINFOHEADER *pbmih = NULL;
Bool fReturn = TRUE;
LPDWORD pdw = NULL;
DWORD dwRedBits, dwGreenBits, dwBlueBits;
/* Color masks for 8 bpp are standardized */
if (GetDeviceCaps(pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE) {
/*
* RGB BPP for 8 bit palletes is always 8
* and the color masks are always 0.
*/
pScreenPriv->dwBitsPerRGB = 8;
pScreenPriv->dwRedMask = 0x0L;
pScreenPriv->dwGreenMask = 0x0L;
pScreenPriv->dwBlueMask = 0x0L;
return TRUE;
2003-11-14 17:48:57 +01:00
}
/* Color masks for 24 bpp are standardized */
if (GetDeviceCaps(pScreenPriv->hdcScreen, PLANES)
* GetDeviceCaps(pScreenPriv->hdcScreen, BITSPIXEL) == 24) {
ErrorF("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
"returned 24 for the screen. Using default 24bpp masks.\n");
/* 8 bits per primary color */
pScreenPriv->dwBitsPerRGB = 8;
/* Set screen privates masks */
pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
return TRUE;
2003-11-14 17:48:57 +01:00
}
/* Allocate a bitmap header and color table */
pbmih = malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
if (pbmih == NULL) {
ErrorF("winQueryRGBBitsAndMasks - malloc failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Get screen description */
if (winQueryScreenDIBFormat(pScreen, pbmih)) {
/* Get a pointer to bitfields */
pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
pdw[0], pdw[1], pdw[2]);
winDebug("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount,
pbmih->biPlanes);
winDebug("%s - Compression: %d %s\n", __FUNCTION__,
pbmih->biCompression,
(pbmih->biCompression ==
BI_RGB ? "(BI_RGB)" : (pbmih->biCompression ==
BI_RLE8 ? "(BI_RLE8)" : (pbmih->
biCompression
==
BI_RLE4 ?
"(BI_RLE4)"
: (pbmih->
biCompression
==
BI_BITFIELDS
?
"(BI_BITFIELDS)"
: "")))));
2003-11-14 17:48:57 +01:00
#endif
/* Handle BI_RGB case, which is returned by Wine */
if (pbmih->biCompression == BI_RGB) {
dwRedBits = 5;
dwGreenBits = 5;
dwBlueBits = 5;
pScreenPriv->dwBitsPerRGB = 5;
/* Set screen privates masks */
pScreenPriv->dwRedMask = 0x7c00;
pScreenPriv->dwGreenMask = 0x03e0;
pScreenPriv->dwBlueMask = 0x001f;
}
else {
/* Count the number of bits in each mask */
dwRedBits = winCountBits(pdw[0]);
dwGreenBits = winCountBits(pdw[1]);
dwBlueBits = winCountBits(pdw[2]);
/* Find maximum bits per red, green, blue */
if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
pScreenPriv->dwBitsPerRGB = dwRedBits;
else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
pScreenPriv->dwBitsPerRGB = dwGreenBits;
else
pScreenPriv->dwBitsPerRGB = dwBlueBits;
/* Set screen privates masks */
pScreenPriv->dwRedMask = pdw[0];
pScreenPriv->dwGreenMask = pdw[1];
pScreenPriv->dwBlueMask = pdw[2];
2004-06-21 15:19:32 +02:00
}
2003-11-14 17:48:57 +01:00
}
else {
ErrorF("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
fReturn = FALSE;
2003-11-14 17:48:57 +01:00
}
/* Free memory */
free(pbmih);
2003-11-14 17:48:57 +01:00
return fReturn;
2003-11-14 17:48:57 +01:00
}
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
2003-11-14 17:48:57 +01:00
/*
* Redraw all ---?
*/
static wBOOL CALLBACK
winRedrawAllProcShadowGDI(HWND hwnd, LPARAM lParam)
2003-11-14 17:48:57 +01:00
{
if (hwnd == (HWND) lParam)
return TRUE;
InvalidateRect(hwnd, NULL, FALSE);
UpdateWindow(hwnd);
return TRUE;
2004-06-21 15:19:32 +02:00
}
2003-11-14 17:48:57 +01:00
static wBOOL CALLBACK
winRedrawDamagedWindowShadowGDI(HWND hwnd, LPARAM lParam)
2004-06-21 15:19:32 +02:00
{
BoxPtr pDamage = (BoxPtr) lParam;
RECT rcClient, rcDamage, rcRedraw;
POINT topLeft, bottomRight;
if (IsIconic(hwnd))
return TRUE; /* Don't care minimized windows */
/* Convert the damaged area from Screen coords to Client coords */
topLeft.x = pDamage->x1;
topLeft.y = pDamage->y1;
bottomRight.x = pDamage->x2;
bottomRight.y = pDamage->y2;
topLeft.x += GetSystemMetrics(SM_XVIRTUALSCREEN);
bottomRight.x += GetSystemMetrics(SM_XVIRTUALSCREEN);
topLeft.y += GetSystemMetrics(SM_YVIRTUALSCREEN);
bottomRight.y += GetSystemMetrics(SM_YVIRTUALSCREEN);
ScreenToClient(hwnd, &topLeft);
ScreenToClient(hwnd, &bottomRight);
SetRect(&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
GetClientRect(hwnd, &rcClient);
if (IntersectRect(&rcRedraw, &rcClient, &rcDamage)) {
InvalidateRect(hwnd, &rcRedraw, FALSE);
UpdateWindow(hwnd);
2003-11-14 17:48:57 +01:00
}
return TRUE;
2003-11-14 17:48:57 +01:00
}
2004-06-21 15:19:32 +02:00
#endif
2003-11-14 17:48:57 +01:00
/*
* Allocate a DIB for the shadow framebuffer GDI server
*/
2004-06-21 15:19:32 +02:00
static Bool
winAllocateFBShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
DIBSECTION dibsection;
Bool fReturn = TRUE;
/* Describe shadow bitmap to be created */
pScreenPriv->pbmih->biWidth = pScreenInfo->dwWidth;
pScreenPriv->pbmih->biHeight = -pScreenInfo->dwHeight;
ErrorF("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
"depth: %d\n",
(int) pScreenPriv->pbmih->biWidth,
(int) -pScreenPriv->pbmih->biHeight, pScreenPriv->pbmih->biBitCount);
/* Create a DI shadow bitmap with a bit pointer */
pScreenPriv->hbmpShadow = CreateDIBSection(pScreenPriv->hdcScreen,
(BITMAPINFO *) pScreenPriv->
pbmih, DIB_RGB_COLORS,
(VOID **) &pScreenInfo->pfb,
NULL, 0);
if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL) {
winW32Error(2, "winAllocateFBShadowGDI - CreateDIBSection failed:");
return FALSE;
2003-11-14 17:48:57 +01:00
}
else {
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("winAllocateFBShadowGDI - Shadow buffer allocated\n");
2003-11-14 17:48:57 +01:00
#endif
}
/* Get information about the bitmap that was allocated */
GetObject(pScreenPriv->hbmpShadow, sizeof(dibsection), &dibsection);
2003-11-14 17:48:57 +01:00
#if CYGDEBUG || YES
/* Print information about bitmap allocated */
winDebug("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
"depth: %d size image: %d\n",
(int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight,
dibsection.dsBmih.biBitCount, (int) dibsection.dsBmih.biSizeImage);
2003-11-14 17:48:57 +01:00
#endif
/* Select the shadow bitmap into the shadow DC */
SelectObject(pScreenPriv->hdcShadow, pScreenPriv->hbmpShadow);
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("winAllocateFBShadowGDI - Attempting a shadow blit\n");
2003-11-14 17:48:57 +01:00
#endif
/* Do a test blit from the shadow to the screen, I think */
fReturn = BitBlt(pScreenPriv->hdcScreen,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
if (fReturn) {
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("winAllocateFBShadowGDI - Shadow blit success\n");
2003-11-14 17:48:57 +01:00
#endif
}
else {
winW32Error(2, "winAllocateFBShadowGDI - Shadow blit failure\n");
#if 0
return FALSE;
#else
/* ago: ignore this error. The blit fails with wine, but does not
* cause any problems later. */
fReturn = TRUE;
#endif
2003-11-14 17:48:57 +01:00
}
/* Look for height weirdness */
if (dibsection.dsBmih.biHeight < 0) {
dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
}
/* Set screeninfo stride */
pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
/ dibsection.dsBmih.biHeight)
* 8) / pScreenInfo->dwBPP;
2003-11-14 17:48:57 +01:00
#if CYGDEBUG || YES
winDebug("winAllocateFBShadowGDI - Created shadow stride: %d\n",
(int) pScreenInfo->dwStride);
2003-11-14 17:48:57 +01:00
#endif
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
/* Redraw all windows */
if (pScreenInfo->fMultiWindow)
EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
2004-06-21 15:19:32 +02:00
#endif
2003-11-14 17:48:57 +01:00
return fReturn;
2003-11-14 17:48:57 +01:00
}
static void
winFreeFBShadowGDI(ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
/* Free the shadow bitmap */
DeleteObject(pScreenPriv->hbmpShadow);
/* Invalidate the ScreenInfo's fb pointer */
pScreenInfo->pfb = NULL;
}
2003-11-14 17:48:57 +01:00
/*
* Blit the damaged regions of the shadow fb to the screen
*/
2004-06-21 15:19:32 +02:00
static void
winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
RegionPtr damage = shadowDamage(pBuf);
DWORD dwBox = RegionNumRects(damage);
BoxPtr pBox = RegionRects(damage);
int x, y, w, h;
HRGN hrgnCombined = NULL;
2004-06-21 15:19:32 +02:00
#ifdef XWIN_UPDATESTATS
static DWORD s_dwNonUnitRegions = 0;
static DWORD s_dwTotalUpdates = 0;
static DWORD s_dwTotalBoxes = 0;
2003-11-14 17:48:57 +01:00
#endif
BoxPtr pBoxExtents = RegionExtents(damage);
2003-11-14 17:48:57 +01:00
/*
* Return immediately if the app is not active
* and we are fullscreen, or if we have a bad display depth
*/
if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
|| pScreenPriv->fBadDepth)
return;
2003-11-14 17:48:57 +01:00
2004-06-21 15:19:32 +02:00
#ifdef XWIN_UPDATESTATS
++s_dwTotalUpdates;
s_dwTotalBoxes += dwBox;
2003-11-14 17:48:57 +01:00
if (dwBox != 1) {
++s_dwNonUnitRegions;
ErrorF("winShadowUpdatGDI - dwBox: %d\n", dwBox);
2003-11-14 17:48:57 +01:00
}
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 /* XWIN_UPDATESTATS */
/*
* Handle small regions with multiple blits,
* handle large regions by creating a clipping region and
* doing a single blit constrained to that clipping region.
*/
if (!pScreenInfo->fMultiWindow &&
(pScreenInfo->dwClipUpdatesNBoxes == 0 ||
dwBox < pScreenInfo->dwClipUpdatesNBoxes)) {
/* Loop through all boxes in the damaged region */
while (dwBox--) {
/*
* Calculate x offset, y offset, width, and height for
* current damage box
*/
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);
/* Get a pointer to the next box */
++pBox;
}
2003-11-14 17:48:57 +01:00
}
else if (!pScreenInfo->fMultiWindow) {
/* Compute a GDI region from the damaged region */
hrgnCombined =
CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2,
pBoxExtents->y2);
/* Install the GDI region as a clipping region */
SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
DeleteObject(hrgnCombined);
hrgnCombined = NULL;
/*
* Blit the shadow buffer to the screen,
* constrained to the clipping region.
*/
BitBlt(pScreenPriv->hdcScreen,
pBoxExtents->x1, pBoxExtents->y1,
pBoxExtents->x2 - pBoxExtents->x1,
pBoxExtents->y2 - pBoxExtents->y1,
pScreenPriv->hdcShadow,
pBoxExtents->x1, pBoxExtents->y1, SRCCOPY);
/* Reset the clip region */
SelectClipRgn(pScreenPriv->hdcScreen, NULL);
2003-11-14 17:48:57 +01:00
}
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
/* Redraw all multiwindow windows */
if (pScreenInfo->fMultiWindow)
EnumThreadWindows(g_dwCurrentThreadID,
winRedrawDamagedWindowShadowGDI,
(LPARAM) pBoxExtents);
2004-06-21 15:19:32 +02:00
#endif
2003-11-14 17:48:57 +01:00
}
static Bool
winInitScreenShadowGDI(ScreenPtr pScreen)
{
winScreenPriv(pScreen);
/* Get device contexts for the screen and shadow bitmap */
pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen);
pScreenPriv->hdcShadow = CreateCompatibleDC(pScreenPriv->hdcScreen);
/* Allocate bitmap info header */
pScreenPriv->pbmih = malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
if (pScreenPriv->pbmih == NULL) {
ErrorF("winInitScreenShadowGDI - malloc () failed\n");
return FALSE;
}
/* Query the screen format */
if (!winQueryScreenDIBFormat(pScreen, pScreenPriv->pbmih)) {
ErrorF("winInitScreenShadowGDI - winQueryScreenDIBFormat failed\n");
return FALSE;
}
/* Determine our color masks */
if (!winQueryRGBBitsAndMasks(pScreen)) {
ErrorF("winInitScreenShadowGDI - winQueryRGBBitsAndMasks failed\n");
return FALSE;
}
return winAllocateFBShadowGDI(pScreen);
}
2003-11-14 17:48:57 +01:00
/* See Porting Layer Definition - p. 33 */
/*
* We wrap whatever CloseScreen procedure was specified by fb;
* a pointer to said procedure is stored in our privates.
*/
2004-06-21 15:19:32 +02:00
static Bool
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
winCloseScreenShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
Bool fReturn;
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("winCloseScreenShadowGDI - Freeing screen resources\n");
2003-11-14 17:48:57 +01:00
#endif
/* Flag that the screen is closed */
pScreenPriv->fClosed = TRUE;
pScreenPriv->fActive = FALSE;
2003-11-14 17:48:57 +01:00
/* Call the wrapped CloseScreen procedure */
WIN_UNWRAP(CloseScreen);
if (pScreen->CloseScreen)
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
fReturn = (*pScreen->CloseScreen) (pScreen);
2003-11-14 17:48:57 +01:00
/* Delete the window property */
RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
2003-11-14 17:48:57 +01:00
/* Free the shadow DC; which allows the bitmap to be freed */
DeleteDC(pScreenPriv->hdcShadow);
winFreeFBShadowGDI(pScreen);
2003-11-14 17:48:57 +01:00
/* Free the screen DC */
ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
2003-11-14 17:48:57 +01:00
/* Delete tray icon, if we have one */
if (!pScreenInfo->fNoTrayIcon)
winDeleteNotifyIcon(pScreenPriv);
/* Free the exit confirmation dialog box, if it exists */
if (g_hDlgExit != NULL) {
DestroyWindow(g_hDlgExit);
g_hDlgExit = NULL;
}
/* Kill our window */
if (pScreenPriv->hwndScreen) {
DestroyWindow(pScreenPriv->hwndScreen);
pScreenPriv->hwndScreen = NULL;
2003-11-14 17:48:57 +01:00
}
2004-06-21 15:19:32 +02:00
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
/* Destroy the thread startup mutex */
pthread_mutex_destroy(&pScreenPriv->pmServerStarted);
2004-06-21 15:19:32 +02:00
#endif
2003-11-14 17:48:57 +01:00
/* Invalidate our screeninfo's pointer to the screen */
pScreenInfo->pScreen = NULL;
2003-11-14 17:48:57 +01:00
/* Free the screen privates for this screen */
free((void *) pScreenPriv);
2003-11-14 17:48:57 +01:00
return fReturn;
2003-11-14 17:48:57 +01:00
}
/*
* Tell mi what sort of visuals we need.
*
* Generally we only need one visual, as our screen can only
* handle one format at a time, I believe. You may want
* to verify that last sentence.
*/
2004-06-21 15:19:32 +02:00
static Bool
winInitVisualsShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
/* Display debugging information */
ErrorF("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
"bpp %d\n",
(unsigned int) pScreenPriv->dwRedMask,
(unsigned int) pScreenPriv->dwGreenMask,
(unsigned int) pScreenPriv->dwBlueMask,
(int) pScreenPriv->dwBitsPerRGB,
(int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP);
/* Create a single visual according to the Windows screen depth */
switch (pScreenInfo->dwDepth) {
2003-11-14 17:48:57 +01:00
case 24:
case 16:
case 15:
/* Setup the real visual */
if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
TrueColorMask,
pScreenPriv->dwBitsPerRGB,
-1,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask)) {
ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
"failed\n");
return FALSE;
}
2003-11-14 17:48:57 +01:00
2004-06-21 15:19:32 +02:00
#ifdef XWIN_EMULATEPSEUDO
if (!pScreenInfo->fEmulatePseudo)
break;
/* Setup a pseudocolor visual */
if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) {
ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
"failed for PseudoColor\n");
return FALSE;
}
2003-11-14 17:48:57 +01:00
#endif
break;
2003-11-14 17:48:57 +01:00
case 8:
if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
PseudoColor,
pScreenPriv->dwRedMask,
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask)) {
ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
"failed\n");
return FALSE;
}
break;
2003-11-14 17:48:57 +01:00
default:
ErrorF("winInitVisualsShadowGDI - Unknown screen depth\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
#if CYGDEBUG
winDebug("winInitVisualsShadowGDI - Returning\n");
2003-11-14 17:48:57 +01:00
#endif
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Adjust the proposed video mode
*/
2004-06-21 15:19:32 +02:00
static Bool
winAdjustVideoModeShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
HDC hdc;
DWORD dwBPP;
hdc = GetDC(NULL);
/* We're in serious trouble if we can't get a DC */
if (hdc == NULL) {
ErrorF("winAdjustVideoModeShadowGDI - GetDC () failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Query GDI for current display depth */
dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
2003-11-14 17:48:57 +01:00
/* GDI cannot change the screen depth, so always use GDI's depth */
pScreenInfo->dwBPP = dwBPP;
2003-11-14 17:48:57 +01:00
/* Release our DC */
ReleaseDC(NULL, hdc);
hdc = NULL;
2003-11-14 17:48:57 +01:00
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Blt exposed regions to the screen
*/
2004-06-21 15:19:32 +02:00
static Bool
winBltExposedRegionsShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
winPrivCmapPtr pCmapPriv = NULL;
HDC hdcUpdate;
PAINTSTRUCT ps;
/* BeginPaint gives us an hdc that clips to the invalidated region */
hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps);
/* Realize the palette, if we have one */
if (pScreenPriv->pcmapInstalled != NULL) {
pCmapPriv = winGetCmapPriv(pScreenPriv->pcmapInstalled);
SelectPalette(hdcUpdate, pCmapPriv->hPalette, FALSE);
RealizePalette(hdcUpdate);
2003-11-14 17:48:57 +01:00
}
/* Our BitBlt will be clipped to the invalidated region */
BitBlt(hdcUpdate,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
2003-11-14 17:48:57 +01:00
/* EndPaint frees the DC */
EndPaint(pScreenPriv->hwndScreen, &ps);
2003-11-14 17:48:57 +01:00
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
/* Redraw all windows */
if (pScreenInfo->fMultiWindow)
EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
(LPARAM) pScreenPriv->hwndScreen);
2004-06-21 15:19:32 +02:00
#endif
2003-11-14 17:48:57 +01:00
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Do any engine-specific appliation-activation processing
*/
2004-06-21 15:19:32 +02:00
static Bool
winActivateAppShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
/*
* 2004/04/12 - Harold - We perform the restoring or minimizing
* manually for ShadowGDI in fullscreen modes so that this engine
* will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
* if we do not do this then our fullscreen window will appear in the
* z-order when it is deactivated and it can be uncovered by resizing
* or minimizing another window that is on top of it, which is not how
* the DirectDraw engines work. Therefore we keep this code here to
* make sure that all engines work the same in fullscreen mode.
*/
/*
* Are we active?
* Are we fullscreen?
*/
if (pScreenPriv->fActive && pScreenInfo->fFullScreen) {
/*
* Activating, attempt to bring our window
* to the top of the display
*/
ShowWindow(pScreenPriv->hwndScreen, SW_RESTORE);
2003-11-14 17:48:57 +01:00
}
else if (!pScreenPriv->fActive && pScreenInfo->fFullScreen) {
/*
* Deactivating, stuff our window onto the
* task bar.
*/
ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE);
2003-11-14 17:48:57 +01:00
}
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Reblit the shadow framebuffer to the screen.
*/
2004-06-21 15:19:32 +02:00
static Bool
winRedrawScreenShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
2003-11-14 17:48:57 +01:00
/* Redraw the whole window, to take account for the new colors */
BitBlt(pScreenPriv->hdcScreen,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
2003-11-14 17:48:57 +01:00
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
/* Redraw all windows */
if (pScreenInfo->fMultiWindow)
EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
2004-06-21 15:19:32 +02:00
#endif
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Realize the currently installed colormap
*/
2004-06-21 15:19:32 +02:00
static Bool
winRealizeInstalledPaletteShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winPrivCmapPtr pCmapPriv = NULL;
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("winRealizeInstalledPaletteShadowGDI\n");
2003-11-14 17:48:57 +01:00
#endif
/* Don't do anything if there is not a colormap */
if (pScreenPriv->pcmapInstalled == NULL) {
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("winRealizeInstalledPaletteShadowGDI - No colormap "
"installed\n");
2003-11-14 17:48:57 +01:00
#endif
return TRUE;
2003-11-14 17:48:57 +01:00
}
pCmapPriv = winGetCmapPriv(pScreenPriv->pcmapInstalled);
/* Realize our palette for the screen */
if (RealizePalette(pScreenPriv->hdcScreen) == GDI_ERROR) {
ErrorF("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
"failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Set the DIB color table */
if (SetDIBColorTable(pScreenPriv->hdcShadow,
0,
WIN_NUM_PALETTE_ENTRIES, pCmapPriv->rgbColors) == 0) {
ErrorF("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
"failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
return TRUE;
}
2003-11-14 17:48:57 +01:00
/*
* Install the specified colormap
*/
2004-06-21 15:19:32 +02:00
static Bool
winInstallColormapShadowGDI(ColormapPtr pColormap)
2003-11-14 17:48:57 +01:00
{
ScreenPtr pScreen = pColormap->pScreen;
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
winCmapPriv(pColormap);
/*
* Tell Windows to install the new colormap
*/
if (SelectPalette(pScreenPriv->hdcScreen,
pCmapPriv->hPalette, FALSE) == NULL) {
ErrorF("winInstallColormapShadowGDI - SelectPalette () failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Realize the palette */
if (GDI_ERROR == RealizePalette(pScreenPriv->hdcScreen)) {
ErrorF("winInstallColormapShadowGDI - RealizePalette () failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Set the DIB color table */
if (SetDIBColorTable(pScreenPriv->hdcShadow,
0,
WIN_NUM_PALETTE_ENTRIES, pCmapPriv->rgbColors) == 0) {
ErrorF("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Redraw the whole window, to take account for the new colors */
BitBlt(pScreenPriv->hdcScreen,
0, 0,
pScreenInfo->dwWidth, pScreenInfo->dwHeight,
pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
2003-11-14 17:48:57 +01:00
/* Save a pointer to the newly installed colormap */
pScreenPriv->pcmapInstalled = pColormap;
2003-11-14 17:48:57 +01:00
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
/* Redraw all windows */
if (pScreenInfo->fMultiWindow)
EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
2004-06-21 15:19:32 +02:00
#endif
2003-11-14 17:48:57 +01:00
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Store the specified colors in the specified colormap
*/
2004-06-21 15:19:32 +02:00
static Bool
winStoreColorsShadowGDI(ColormapPtr pColormap, int ndef, xColorItem * pdefs)
2003-11-14 17:48:57 +01:00
{
ScreenPtr pScreen = pColormap->pScreen;
winScreenPriv(pScreen);
winCmapPriv(pColormap);
ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
/* Put the X colormap entries into the Windows logical palette */
if (SetPaletteEntries(pCmapPriv->hPalette,
pdefs[0].pixel,
ndef, pCmapPriv->peColors + pdefs[0].pixel) == 0) {
ErrorF("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Don't install the Windows palette if the colormap is not installed */
if (pColormap != curpmap) {
return TRUE;
2003-11-14 17:48:57 +01:00
}
/* Try to install the newly modified colormap */
if (!winInstallColormapShadowGDI(pColormap)) {
ErrorF("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
"failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
#if 0
/* Tell Windows that the palette has changed */
RealizePalette(pScreenPriv->hdcScreen);
/* Set the DIB color table */
if (SetDIBColorTable(pScreenPriv->hdcShadow,
pdefs[0].pixel,
ndef, pCmapPriv->rgbColors + pdefs[0].pixel) == 0) {
ErrorF("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Save a pointer to the newly installed colormap */
pScreenPriv->pcmapInstalled = pColormap;
2003-11-14 17:48:57 +01:00
#endif
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Colormap initialization procedure
*/
2004-06-21 15:19:32 +02:00
static Bool
winCreateColormapShadowGDI(ColormapPtr pColormap)
2003-11-14 17:48:57 +01:00
{
LPLOGPALETTE lpPaletteNew = NULL;
DWORD dwEntriesMax;
VisualPtr pVisual;
HPALETTE hpalNew = NULL;
winCmapPriv(pColormap);
/* Get a pointer to the visual that the colormap belongs to */
pVisual = pColormap->pVisual;
/* Get the maximum number of palette entries for this visual */
dwEntriesMax = pVisual->ColormapEntries;
/* Allocate a Windows logical color palette with max entries */
lpPaletteNew = malloc(sizeof(LOGPALETTE)
+ (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
if (lpPaletteNew == NULL) {
ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette "
"with %d entries\n", (int) dwEntriesMax);
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Zero out the colormap */
ZeroMemory(lpPaletteNew, sizeof(LOGPALETTE)
+ (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
/* Set the logical palette structure */
lpPaletteNew->palVersion = 0x0300;
lpPaletteNew->palNumEntries = dwEntriesMax;
/* Tell Windows to create the palette */
hpalNew = CreatePalette(lpPaletteNew);
if (hpalNew == NULL) {
ErrorF("winCreateColormapShadowGDI - CreatePalette () failed\n");
free(lpPaletteNew);
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Save the Windows logical palette handle in the X colormaps' privates */
pCmapPriv->hPalette = hpalNew;
2003-11-14 17:48:57 +01:00
/* Free the palette initialization memory */
free(lpPaletteNew);
2003-11-14 17:48:57 +01:00
return TRUE;
2003-11-14 17:48:57 +01:00
}
/*
* Colormap destruction procedure
*/
2004-06-21 15:19:32 +02:00
static Bool
winDestroyColormapShadowGDI(ColormapPtr pColormap)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pColormap->pScreen);
winCmapPriv(pColormap);
/*
* Is colormap to be destroyed the default?
*
* Non-default colormaps should have had winUninstallColormap
* called on them before we get here. The default colormap
* will not have had winUninstallColormap called on it. Thus,
* we need to handle the default colormap in a special way.
*/
if (pColormap->flags & IsDefault) {
2003-11-14 17:48:57 +01:00
#if CYGDEBUG
winDebug("winDestroyColormapShadowGDI - Destroying default "
"colormap\n");
2003-11-14 17:48:57 +01:00
#endif
/*
* FIXME: Walk the list of all screens, popping the default
* palette out of each screen device context.
*/
/* Pop the palette out of the device context */
SelectPalette(pScreenPriv->hdcScreen,
GetStockObject(DEFAULT_PALETTE), FALSE);
/* Clear our private installed colormap pointer */
pScreenPriv->pcmapInstalled = NULL;
2003-11-14 17:48:57 +01:00
}
/* Try to delete the logical palette */
if (DeleteObject(pCmapPriv->hPalette) == 0) {
ErrorF("winDestroyColormap - DeleteObject () failed\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
/* Invalidate the colormap privates */
pCmapPriv->hPalette = NULL;
2003-11-14 17:48:57 +01:00
return TRUE;
}
2003-11-14 17:48:57 +01:00
/*
* Set engine specific funtions
*/
Bool
winSetEngineFunctionsShadowGDI(ScreenPtr pScreen)
2003-11-14 17:48:57 +01:00
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
/* Set our pointers */
pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
pScreenPriv->pwinFreeFB = winFreeFBShadowGDI;
pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
pScreenPriv->pwinInitScreen = winInitScreenShadowGDI;
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 (*)(void)) NoopDDA;
pScreenPriv->pwinCreatePrimarySurface =
(winCreatePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
pScreenPriv->pwinReleasePrimarySurface =
(winReleasePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
2004-06-21 15:19:32 +02:00
#ifdef XWIN_MULTIWINDOW
pScreenPriv->pwinFinishCreateWindowsWindow =
(winFinishCreateWindowsWindowProcPtr) (void (*)(void)) NoopDDA;
2004-06-21 15:19:32 +02:00
#endif
2003-11-14 17:48:57 +01:00
return TRUE;
2003-11-14 17:48:57 +01:00
}