Improved icon support. Patch by Tim Jobling.

svn path=/trunk/; revision=4835
This commit is contained in:
Eric Kohl 2003-06-03 22:26:52 +00:00
parent e25101088c
commit b1b828a434
13 changed files with 1075 additions and 252 deletions

View file

@ -0,0 +1,109 @@
#ifndef __WIN32K_CURSORICON_H
#define __WIN32K_CURSORICON_H
#include <win32k/dc.h>
#include <win32k/gdiobj.h>
/* Structures for reading icon/cursor files and resources */
// Structures for reading icon files and resources
typedef struct _ICONIMAGE
{
BITMAPINFOHEADER icHeader; // DIB header
RGBQUAD icColors[1]; // Color table
BYTE icXOR[1]; // DIB bits for XOR mask
BYTE icAND[1]; // DIB bits for AND mask
} ICONIMAGE, *LPICONIMAGE __attribute__((packed));
typedef struct
{
BYTE bWidth; // Width, in pixels, of the icon image
BYTE bHeight; // Height, in pixels, of the icon image
BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
BYTE bReserved; // Reserved ( must be 0)
} ICONDIR __attribute__((packed));
typedef struct
{
WORD wWidth; //Width, in pixels of the cursor image
WORD wHeight; //Hight, in pixles of the cursor image
} CURSORDIR __attribute__((packed));
typedef struct
{ union
{ ICONDIR icon;
CURSORDIR cursor;
} Info;
WORD wPlanes; // Number of Color Planes in the XOR image
WORD wBitCount; // Bits per pixel in the XOR image
DWORD dwBytesInRes; // How many bytes in this resource?
DWORD dwImageOffset; // Where in the file is this image?
} CURSORICONDIRENTRY __attribute__((packed));
typedef struct
{
WORD idReserved; // Reserved (must be 0)
WORD idType; // Resource Type (1 for icons, 0 for cursors)
WORD idCount; // How many images?
CURSORICONDIRENTRY idEntries[1] __attribute__((packed)); // An entry for idCount number of images
} CURSORICONDIR __attribute__((packed));
typedef struct
{ union
{ ICONDIR icon;
CURSORDIR cursor;
} Info;
WORD wPlanes; // Color Planes
WORD wBitCount; // Bits per pixel
DWORD dwBytesInRes; // how many bytes in this resource?
WORD nID; // the ID
} GRPICONDIRENTRY __attribute__((packed));
typedef struct
{
WORD idReserved; // Reserved (must be 0)
WORD idType; // Resource type (1 for icons)
WORD idCount; // How many images?
GRPICONDIRENTRY idEntries[1] __attribute__((packed)); // The entries for each image
} GRPICONDIR __attribute__((packed));
/* GDI logical Icon/Cursor object */
typedef struct _ICONCURSOROBJ
{
BOOL fIcon;
DWORD xHotspot;
DWORD yHotspot;
BITMAP ANDBitmap;
BITMAP XORBitmap;
} ICONCURSOROBJ, *PICONCURSOROBJ;
/* Internal interfaces */
#define ICONCURSOROBJ_AllocIconCursor() \
((HICON) GDIOBJ_AllocObj (sizeof (ICONCURSOROBJ), GO_ICONCURSOR_MAGIC))
#define ICONCURSOROBJ_HandleToPtr(hICObj) \
((PICONCURSOROBJ) GDIOBJ_LockObj ((HGDIOBJ) hICObj, GO_ICONCURSOR_MAGIC))
#define ICONCURSOROBJ_ReleasePtr(hICObj) GDIOBJ_UnlockObj ((HGDIOBJ) hICObj, GO_ICONCURSOR_MAGIC)
BOOL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor );
/* User Entry Points */
HICON
STDCALL
W32kCreateIcon (
BOOL fIcon,
INT Width,
INT Height,
UINT Planes,
UINT BitsPerPel,
DWORD xHotspot,
DWORD yHotspot,
const VOID *ANDBits,
const VOID *XORBits
);
#endif

View file

@ -29,6 +29,7 @@
#define GO_ENHMETAFILE_MAGIC 0x4f52
#define GO_ENHMETAFILE_DC_MAGIC 0x4f53
#define GO_DCE_MAGIC 0x4f54
#define GO_ICONCURSOR_MAGIC 0x4f55
#define GO_MAGIC_DONTCARE 0xffff
//@}
/* (RJJ) swiped stock handles from wine */

View file

@ -5,6 +5,7 @@
#include <win32k/cliprgn.h>
#include <win32k/color.h>
#include <win32k/coord.h>
#include <win32k/cursoricon.h>
#include <win32k/dc.h>
#include <win32k/debug.h>
#include <win32k/fillshap.h>

View file

@ -654,12 +654,12 @@ NtUserGetGUIThreadInfo(
DWORD
STDCALL
NtUserGetIconInfo(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3,
DWORD Unknown4,
DWORD Unknown5);
HICON hIcon,
PBOOL fIcon,
PDWORD xHotspot,
PDWORD yHotspot,
HBITMAP *hbmMask,
HBITMAP *hbmColor);
DWORD
STDCALL

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.18 2003/05/27 07:23:04 gvg Exp $
/* $Id: stubs.c,v 1.19 2003/06/03 22:24:51 ekohl Exp $
*
* reactos/lib/gdi32/misc/stubs.c
*
@ -1230,30 +1230,6 @@ SetPixelFormat(
}
BOOL
STDCALL
StretchBlt(
HDC a0,
int a1,
int a2,
int a3,
int a4,
HDC a5,
int a6,
int a7,
int a8,
int a9,
DWORD a10
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
int
STDCALL
SetROP2(

View file

@ -6,6 +6,7 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <win32k/kapi.h>
#include <debug.h>
BOOL
STDCALL
@ -175,8 +176,43 @@ SetDIBitsToDevice(HDC hDC,
Bits, bmi, ColorUse);
}
int
STDCALL
BOOL
STDCALL
StretchBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
DWORD dwRop // raster operation code
)
{
//SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
if ( (nWidthDest==nWidthSrc) && (nHeightDest==nHeightSrc) )
{
return BitBlt(hdcDest,
nXOriginDest, // x-coord of destination upper-left corner
nYOriginDest, // y-coord of destination upper-left corner
nWidthDest, // width of destination rectangle
nHeightDest, // height of destination rectangle
hdcSrc, // handle to source DC
nXOriginSrc, // x-coordinate of source upper-left corner
nYOriginSrc, // y-coordinate of source upper-left corner
dwRop // raster operation code
);
}
DPRINT1("FIXME: StretchBlt can only Blt, not Stretch!\n");
return FALSE;
}
int
STDCALL
StretchDIBits(HDC hDC,
INT XDest,
INT YDest,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: bitmap.c,v 1.9 2003/05/22 21:41:20 sedwards Exp $
/* $Id: bitmap.c,v 1.10 2003/06/03 22:25:37 ekohl Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c
@ -32,6 +32,12 @@
#include <windows.h>
#include <user32.h>
#include <debug.h>
#include <stdlib.h>
/*forward declerations... actualy in user32\windows\icon.c but usful here****/
HICON ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired);
CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width, int height, int colors);
/* FUNCTIONS *****************************************************************/
@ -63,6 +69,178 @@ LoadImageA(HINSTANCE hinst,
return(Handle);
}
HANDLE STATIC
LoadCursorImage(HINSTANCE hinst, LPCWSTR lpszName, UINT fuLoad)
{
DbgPrint("FIXME: Need support for loading cursor images.\n");
return(NULL);
}
HANDLE STATIC
LoadIconImage(HINSTANCE hinst, LPCWSTR lpszName, INT width, INT height, UINT fuLoad)
{
HANDLE hResource;
HANDLE h2Resource;
HANDLE hFile;
HANDLE hSection;
CURSORICONDIR* IconDIR;
HDC hScreenDc;
HANDLE hIcon;
ULONG HeaderSize;
ULONG ColourCount;
PVOID Data;
CURSORICONDIRENTRY* dirEntry;
ICONIMAGE* SafeIconImage;
GRPICONDIR* IconResDir;
INT id;
ICONIMAGE *ResIcon;
if (fuLoad & LR_SHARED)
DbgPrint("FIXME: need LR_SHARED support Loading icon images\n");
if (!(fuLoad & LR_LOADFROMFILE))
{
if (hinst == NULL)
{
hinst = GetModuleHandle(L"USER32");
}
hResource = FindResourceW(hinst, lpszName, RT_GROUP_ICON);
if (hResource == NULL)
{
return(NULL);
}
hResource = LoadResource(hinst, hResource);
if (hResource == NULL)
{
return(NULL);
}
IconResDir = LockResource(hResource);
if (IconResDir == NULL)
{
return(NULL);
}
//find the best fitting in the IconResDir for this resolution
id = LookupIconIdFromDirectoryEx((PBYTE) IconResDir, TRUE,
width, height, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
h2Resource = FindResource(hinst,
MAKEINTRESOURCE(id),
MAKEINTRESOURCE(RT_ICON));
hResource = LoadResource(hinst, h2Resource);
if (hResource == NULL)
{
return(NULL);
}
ResIcon = LockResource(hResource);
if (ResIcon == NULL)
{
return(NULL);
}
return CreateIconFromResourceEx((PBYTE) ResIcon,
SizeofResource(hinst, h2Resource), TRUE, 0x00030000,
width, height, fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
}
else
{
hFile = CreateFile(lpszName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hFile == NULL)
{
return(NULL);
}
hSection = CreateFileMapping(hFile,
NULL,
PAGE_READONLY,
0,
0,
NULL);
CloseHandle(hFile);
if (hSection == NULL)
{
return(NULL);
}
IconDIR = MapViewOfFile(hSection,
FILE_MAP_READ,
0,
0,
0);
CloseHandle(hSection);
if (IconDIR == NULL)
{
return(NULL);
}
//pick the best size.
dirEntry = (CURSORICONDIRENTRY *) CURSORICON_FindBestIcon( IconDIR, width, height, 1);
if (!dirEntry)
{
if (fuLoad & LR_LOADFROMFILE)
{
UnmapViewOfFile(IconDIR);
}
return(NULL);
}
SafeIconImage = RtlAllocateHeap(RtlGetProcessHeap(), 0, dirEntry->dwBytesInRes);
memcpy(SafeIconImage, ((PBYTE)IconDIR) + dirEntry->dwImageOffset, dirEntry->dwBytesInRes);
}
//at this point we have a copy of the icon image to play with
SafeIconImage->icHeader.biHeight = SafeIconImage->icHeader.biHeight /2;
if (SafeIconImage->icHeader.biSize == sizeof(BITMAPCOREHEADER))
{
BITMAPCOREHEADER* Core = (BITMAPCOREHEADER*)SafeIconImage;
ColourCount = (Core->bcBitCount <= 8) ? (1 << Core->bcBitCount) : 0;
HeaderSize = sizeof(BITMAPCOREHEADER) + ColourCount * sizeof(RGBTRIPLE);
}
else
{
ColourCount = SafeIconImage->icHeader.biClrUsed;
if (ColourCount == 0 && SafeIconImage->icHeader.biBitCount <= 8)
{
ColourCount = 1 << SafeIconImage->icHeader.biBitCount;
}
HeaderSize = sizeof(BITMAPINFOHEADER) + ColourCount * sizeof(RGBQUAD);
}
//make data point to the start of the XOR image data
Data = (PBYTE)SafeIconImage + HeaderSize;
//get a handle to the screen dc, the icon we create is going to be compatable with this
hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
if (hScreenDc == NULL)
{
if (fuLoad & LR_LOADFROMFILE)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage);
UnmapViewOfFile(IconDIR);
}
return(NULL);
}
hIcon = ICON_CreateIconFromData(hScreenDc, Data, SafeIconImage, width, height);
RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage);
return hIcon;
}
HANDLE STATIC
LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
{
@ -123,9 +301,9 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
{
return(NULL);
}
BitmapInfo = MapViewOfFile(hSection,
BitmapInfo = MapViewOfFile(hSection,
FILE_MAP_READ,
0,
0,
0,
0);
CloseHandle(hSection);
@ -246,8 +424,11 @@ LoadImageW(HINSTANCE hinst,
}
case IMAGE_CURSOR:
{
DbgPrint("FIXME: Need support for loading cursor images.\n");
return(NULL);
return(LoadCursorImage(hinst, lpszName, fuLoad));
}
case IMAGE_ICON:
{
return(LoadIconImage(hinst, lpszName, cxDesired, cyDesired, fuLoad));
}
default:
DbgBreakPoint();

View file

@ -16,11 +16,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: icon.c,v 1.4 2003/05/12 19:30:00 jfilby Exp $
/* $Id: icon.c,v 1.5 2003/06/03 22:25:37 ekohl Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c
* PURPOSE: Input
* FILE: lib/user32/windows/icon.c
* PURPOSE: Icon
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* UPDATE HISTORY:
* 09-05-2001 CSH Created
@ -30,18 +30,88 @@
#include <windows.h>
#include <user32.h>
#include <string.h>
#include <stdlib.h>
#include <debug.h>
/* FUNCTIONS *****************************************************************/
HICON
ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired)
{
HANDLE hXORBitmap;
HANDLE hANDBitmap;
BITMAPINFO* bwBIH;
ICONINFO IconInfo;
HICON hIcon;
//load the XOR bitmap
hXORBitmap = CreateDIBitmap(hDC, &IconImage->icHeader, CBM_INIT,
ImageData, (BITMAPINFO*)IconImage, DIB_RGB_COLORS);
//make ImageData point to the start of the AND image data
ImageData = ((PBYTE)ImageData) + (((IconImage->icHeader.biWidth *
IconImage->icHeader.biBitCount + 31) & ~31) >> 3) *
(IconImage->icHeader.biHeight );
//create a BITMAPINFO header for the monocrome part of the icon
bwBIH = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof (BITMAPINFOHEADER)+2*sizeof(RGBQUAD));
bwBIH->bmiHeader.biBitCount = 1;
bwBIH->bmiHeader.biWidth = IconImage->icHeader.biWidth;
bwBIH->bmiHeader.biHeight = IconImage->icHeader.biHeight;
bwBIH->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bwBIH->bmiHeader.biPlanes = 1;
bwBIH->bmiHeader.biSizeImage = (((IconImage->icHeader.biWidth * 1 + 31) & ~31) >> 3) *
(IconImage->icHeader.biHeight );
bwBIH->bmiHeader.biCompression = BI_RGB;
bwBIH->bmiHeader.biClrImportant = 0;
bwBIH->bmiHeader.biClrUsed = 0;
bwBIH->bmiHeader.biXPelsPerMeter = 0;
bwBIH->bmiHeader.biYPelsPerMeter = 0;
bwBIH->bmiColors[0].rgbBlue = 0;
bwBIH->bmiColors[0].rgbGreen = 0;
bwBIH->bmiColors[0].rgbRed = 0;
bwBIH->bmiColors[0].rgbReserved = 0;
bwBIH->bmiColors[1].rgbBlue = 0xff;
bwBIH->bmiColors[1].rgbGreen = 0xff;
bwBIH->bmiColors[1].rgbRed = 0xff;
bwBIH->bmiColors[1].rgbReserved = 0;
//load the AND bitmap
hANDBitmap = CreateDIBitmap(hDC, &bwBIH->bmiHeader, CBM_INIT,
ImageData, bwBIH, DIB_RGB_COLORS);
RtlFreeHeap(RtlGetProcessHeap(), 0, bwBIH);
IconInfo.fIcon = TRUE;
IconInfo.xHotspot = cxDesired/2;
IconInfo.yHotspot = cyDesired/2;
IconInfo.hbmColor = hXORBitmap;
IconInfo.hbmMask = hANDBitmap;
//Create the icon based on everything we have so far
hIcon = CreateIconIndirect(&IconInfo);
//clean up
DeleteObject(hXORBitmap);
DeleteObject(hANDBitmap);
return hIcon;
}
HICON
STDCALL
CopyIcon(
HICON hIcon)
{
UNIMPLEMENTED;
return (HICON)0;
ICONINFO IconInfo;
GetIconInfo(hIcon, &IconInfo);
return CreateIconIndirect(&IconInfo);
}
HICON
STDCALL
CreateIcon(
@ -53,8 +123,16 @@ CreateIcon(
CONST BYTE *lpbANDbits,
CONST BYTE *lpbXORbits)
{
UNIMPLEMENTED;
return (HICON)0;
DPRINT("hInstance not used in this implementation\n");
return W32kCreateIcon(TRUE,
nWidth,
nHeight,
cPlanes,
cBitsPixel,
nWidth/2,
nHeight/2,
lpbANDbits,
lpbXORbits);
}
HICON
@ -65,8 +143,7 @@ CreateIconFromResource(
WINBOOL fIcon,
DWORD dwVer)
{
UNIMPLEMENTED;
return (HICON)0;
return CreateIconFromResourceEx( presbits, dwResSize, fIcon, dwVer, 0,0,0);
}
HICON
@ -80,8 +157,49 @@ CreateIconFromResourceEx(
int cyDesired,
UINT uFlags)
{
UNIMPLEMENTED;
return (HICON)0;
ICONIMAGE* SafeIconImage;
HICON hIcon;
ULONG HeaderSize;
ULONG ColourCount;
PVOID Data;
HDC hScreenDc;
DPRINT("fIcon, dwVersion, cxDesired, cyDesired are all ignored in this implementation!\n");
//get an safe copy of the icon data
SafeIconImage = RtlAllocateHeap(RtlGetProcessHeap(), 0, cbIconBits);
memcpy(SafeIconImage, pbIconBits, cbIconBits);
//take into acount the origonal hight was for both the AND and XOR images
SafeIconImage->icHeader.biHeight /= 2;
if (SafeIconImage->icHeader.biSize == sizeof(BITMAPCOREHEADER))
{
BITMAPCOREHEADER* Core = (BITMAPCOREHEADER*)SafeIconImage;
ColourCount = (Core->bcBitCount <= 8) ? (1 << Core->bcBitCount) : 0;
HeaderSize = sizeof(BITMAPCOREHEADER) + ColourCount * sizeof(RGBTRIPLE);
}
else
{
ColourCount = (SafeIconImage->icHeader.biBitCount <= 8) ?
(1 << SafeIconImage->icHeader.biBitCount) : 0;
HeaderSize = sizeof(BITMAPINFOHEADER) + ColourCount * sizeof(RGBQUAD);
}
//make data point to the start of the XOR image data
Data = (PBYTE)SafeIconImage + HeaderSize;
//get a handle to the screen dc, the icon we create is going to be compatable with this
hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
if (hScreenDc == NULL)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage);
return(NULL);
}
hIcon = ICON_CreateIconFromData(hScreenDc, Data, SafeIconImage, cxDesired, cyDesired);
RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage);
return hIcon;
}
HICON
@ -89,8 +207,21 @@ STDCALL
CreateIconIndirect(
PICONINFO piconinfo)
{
UNIMPLEMENTED;
return (HICON)0;
BITMAP bmMask;
BITMAP bmColor;
W32kGetObject( piconinfo->hbmMask, sizeof(BITMAP), &bmMask );
W32kGetObject( piconinfo->hbmColor, sizeof(BITMAP), &bmColor );
return W32kCreateIcon(piconinfo->fIcon,
bmColor.bmWidth,
bmColor.bmHeight,
bmColor.bmPlanes,
bmColor.bmBitsPixel,
piconinfo->xHotspot,
piconinfo->yHotspot,
bmMask.bmBits,
bmColor.bmBits);
}
WINBOOL
@ -98,8 +229,7 @@ STDCALL
DestroyIcon(
HICON hIcon)
{
UNIMPLEMENTED;
return FALSE;
return W32kDeleteObject(hIcon);
}
WINBOOL
@ -110,10 +240,10 @@ DrawIcon(
int Y,
HICON hIcon)
{
UNIMPLEMENTED;
return FALSE;
return DrawIconEx (hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE);
}
/* Ported from WINE20030408 */
WINBOOL
STDCALL
DrawIconEx(
@ -127,8 +257,132 @@ DrawIconEx(
HBRUSH hbrFlickerFreeDraw,
UINT diFlags)
{
UNIMPLEMENTED;
return FALSE;
ICONINFO IconInfo;
BITMAP XORBitmap;
HDC hDC_off = 0, hMemDC;
BOOL result = FALSE, DoOffscreen;
HBITMAP hB_off = 0, hOld = 0;
if (!GetIconInfo(hIcon, &IconInfo))
return FALSE;
W32kGetObject(IconInfo.hbmColor, sizeof(BITMAP), &XORBitmap);
DPRINT("(hdc=%p,pos=%d.%d,hicon=%p,extend=%d.%d,istep=%d,br=%p,flags=0x%08x)\n",
hdc,xLeft,yTop,hIcon,cxWidth,cyWidth,istepIfAniCur,hbrFlickerFreeDraw,diFlags );
hMemDC = CreateCompatibleDC (hdc);
if (diFlags & DI_COMPAT)
DPRINT("Ignoring flag DI_COMPAT\n");
if (!diFlags)
{
diFlags = DI_NORMAL;
}
// Calculate the size of the destination image.
if (cxWidth == 0)
{
if (diFlags & DI_DEFAULTSIZE)
cxWidth = GetSystemMetrics (SM_CXICON);
else
cxWidth = XORBitmap.bmWidth;
}
if (cyWidth == 0)
{
if (diFlags & DI_DEFAULTSIZE)
cyWidth = GetSystemMetrics (SM_CYICON);
else
cyWidth = XORBitmap.bmHeight;
}
DoOffscreen = (GetObjectType( hbrFlickerFreeDraw ) == OBJ_BRUSH);
if (DoOffscreen)
{
RECT r;
r.left = 0;
r.top = 0;
r.right = cxWidth;
r.bottom = cxWidth;
DbgPrint("in DrawIconEx calling: CreateCompatibleDC\n");
hDC_off = CreateCompatibleDC(hdc);
DbgPrint("in DrawIconEx calling: CreateCompatibleBitmap\n");
hB_off = CreateCompatibleBitmap(hdc, cxWidth, cyWidth);
if (hDC_off && hB_off)
{
DbgPrint("in DrawIconEx calling: SelectObject\n");
hOld = SelectObject(hDC_off, hB_off);
DbgPrint("in DrawIconEx calling: FillRect\n");
FillRect(hDC_off, &r, hbrFlickerFreeDraw);
}
}
if (hMemDC && (!DoOffscreen || (hDC_off && hB_off)))
{
COLORREF oldFg, oldBg;
INT nStretchMode;
nStretchMode = SetStretchBltMode (hdc, STRETCH_DELETESCANS);
oldFg = SetTextColor( hdc, RGB(0,0,0) );
oldBg = SetBkColor( hdc, RGB(255,255,255) );
if (IconInfo.hbmColor && IconInfo.hbmMask)
{
HBITMAP hBitTemp = SelectObject( hMemDC, IconInfo.hbmMask );
if (diFlags & DI_MASK)
{
if (DoOffscreen)
StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCAND);
else
StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCAND);
}
SelectObject( hMemDC, IconInfo.hbmColor );
if (diFlags & DI_IMAGE)
{
if (DoOffscreen)
StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCPAINT);
else
StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCPAINT);
}
SelectObject( hMemDC, hBitTemp );
result = TRUE;
}
SetTextColor( hdc, oldFg );
SetBkColor( hdc, oldBg );
if (IconInfo.hbmColor)
DeleteObject( IconInfo.hbmColor );
if (IconInfo.hbmMask)
DeleteObject( IconInfo.hbmMask );
SetStretchBltMode (hdc, nStretchMode);
if (DoOffscreen)
{
BitBlt(hdc, xLeft, yTop, cxWidth, cyWidth, hDC_off, 0, 0, SRCCOPY);
SelectObject(hDC_off, hOld);
}
}
if (hMemDC)
DeleteDC( hMemDC );
if (hDC_off)
DeleteDC(hDC_off);
if (hB_off)
DeleteObject(hB_off);
return result;
}
WINBOOL
@ -137,8 +391,12 @@ GetIconInfo(
HICON hIcon,
PICONINFO piconinfo)
{
UNIMPLEMENTED;
return FALSE;
return NtUserGetIconInfo(hIcon,
&piconinfo->fIcon,
&piconinfo->xHotspot,
&piconinfo->yHotspot,
&piconinfo->hbmMask,
&piconinfo->hbmColor);
}
HICON
@ -147,8 +405,7 @@ LoadIconA(
HINSTANCE hInstance,
LPCSTR lpIconName)
{
UNIMPLEMENTED;
return (HICON)0;
return(LoadImageA(hInstance, lpIconName, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE));
}
HICON
@ -157,8 +414,7 @@ LoadIconW(
HINSTANCE hInstance,
LPCWSTR lpIconName)
{
UNIMPLEMENTED;
return (HICON)0;
return(LoadImageW(hInstance, lpIconName, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE));
}
int
@ -167,10 +423,116 @@ LookupIconIdFromDirectory(
PBYTE presbits,
WINBOOL fIcon)
{
UNIMPLEMENTED;
return 0;
return LookupIconIdFromDirectoryEx( presbits, fIcon,
fIcon ? GetSystemMetrics(SM_CXICON) : GetSystemMetrics(SM_CXCURSOR),
fIcon ? GetSystemMetrics(SM_CYICON) : GetSystemMetrics(SM_CYCURSOR), LR_DEFAULTCOLOR );
}
/* Ported from WINE20030408 */
CURSORICONDIRENTRY*
CURSORICON_FindBestCursor( CURSORICONDIR *dir, int width, int height, int colors)
{
int i;
CURSORICONDIRENTRY *entry, *bestEntry = NULL;
UINT iTotalDiff, iXDiff=0, iYDiff=0, iColorDiff;
UINT iTempXDiff, iTempYDiff, iTempColorDiff;
if (dir->idCount < 1)
{
DPRINT("Empty directory!\n");
return NULL;
}
if (dir->idCount == 1)
return &dir->idEntries[0]; /* No choice... */
/* Find Best Fit */
iTotalDiff = 0xFFFFFFFF;
iColorDiff = 0xFFFFFFFF;
for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
{
iTempXDiff = abs(width - entry->Info.icon.bWidth);
iTempYDiff = abs(height - entry->Info.icon.bHeight);
if(iTotalDiff > (iTempXDiff + iTempYDiff))
{
iXDiff = iTempXDiff;
iYDiff = iTempYDiff;
iTotalDiff = iXDiff + iYDiff;
}
}
/* Find Best Colors for Best Fit */
for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
{
if(abs(width - entry->Info.icon.bWidth) == iXDiff &&
abs(height - entry->Info.icon.bHeight) == iYDiff)
{
iTempColorDiff = abs(colors - entry->Info.icon.bColorCount);
if(iColorDiff > iTempColorDiff)
{
bestEntry = entry;
iColorDiff = iTempColorDiff;
}
}
}
return bestEntry;
}
/* Ported from WINE20030408 */
CURSORICONDIRENTRY*
CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width, int height, int colors)
{
int i;
CURSORICONDIRENTRY *entry, *bestEntry = NULL;
UINT iTotalDiff, iXDiff=0, iYDiff=0, iColorDiff;
UINT iTempXDiff, iTempYDiff, iTempColorDiff;
if (dir->idCount < 1)
{
DPRINT("Empty directory!\n");
return NULL;
}
if (dir->idCount == 1)
return &dir->idEntries[0]; /* No choice... */
/* Find Best Fit */
iTotalDiff = 0xFFFFFFFF;
iColorDiff = 0xFFFFFFFF;
for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
{
iTempXDiff = abs(width - entry->Info.icon.bWidth);
iTempYDiff = abs(height - entry->Info.icon.bHeight);
if(iTotalDiff > (iTempXDiff + iTempYDiff))
{
iXDiff = iTempXDiff;
iYDiff = iTempYDiff;
iTotalDiff = iXDiff + iYDiff;
}
}
/* Find Best Colors for Best Fit */
for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
{
if(abs(width - entry->Info.icon.bWidth) == iXDiff &&
abs(height - entry->Info.icon.bHeight) == iYDiff)
{
iTempColorDiff = abs(colors - entry->Info.icon.bColorCount);
if(iColorDiff > iTempColorDiff)
{
bestEntry = entry;
iColorDiff = iTempColorDiff;
}
}
}
return bestEntry;
}
/* Ported from WINE20030408 */
int
STDCALL
LookupIconIdFromDirectoryEx(
@ -180,6 +542,37 @@ LookupIconIdFromDirectoryEx(
int cyDesired,
UINT Flags)
{
UNIMPLEMENTED;
return 0;
GRPICONDIR *dir = (GRPICONDIR*)presbits;
UINT retVal = 0;
if( dir && !dir->idReserved && (dir->idType & 3) )
{
GRPICONDIRENTRY* entry;
HDC hdc;
UINT palEnts;
int colors;
hdc = GetDC(0);
#if 0
palEnts = GetSystemPaletteEntries(hdc, 0, 0, NULL);
if (palEnts == 0)
palEnts = 256;
#endif
palEnts = 16; //use this until GetSystemPaletteEntries works
colors = (Flags & LR_MONOCHROME) ? 2 : palEnts;
ReleaseDC(0, hdc);
entry = (GRPICONDIRENTRY*)CURSORICON_FindBestIcon( (CURSORICONDIR*)dir,
cxDesired,
cyDesired,
colors );
if( entry )
retVal = entry->nID;
}
else
{
DbgPrint("invalid resource directory\n");
}
return retVal;
}

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.63 2003/05/26 18:52:37 gvg Exp $
# $Id: makefile,v 1.64 2003/06/03 22:25:53 ekohl Exp $
PATH_TO_TOP = ../..
@ -59,19 +59,12 @@ OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
objects/path.o objects/pen.o objects/print.o \
objects/region.o objects/text.o objects/wingl.o \
objects/bezier.o objects/objconv.o objects/dib.o \
objects/palette.o objects/rect.o objects/polyfill.o
objects/palette.o objects/rect.o objects/polyfill.o \
objects/cursoricon.o
DIB_OBJECTS = dib/dib.o dib/dib1bpp.o dib/dib4bpp.o dib/dib8bpp.o dib/dib16bpp.o \
dib/dib24bpp.o dib/dib32bpp.o
FREETYPE_OBJECTS = freetype/ctype.o freetype/grfont.o \
freetype/src/base/ftsystem.o freetype/src/base/ftdebug.o \
freetype/src/base/ftinit.o freetype/src/base/ftbase.o \
freetype/src/base/ftglyph.o freetype/src/base/ftmm.o \
freetype/src/autohint/autohint.o freetype/src/cff/cff.o \
freetype/src/cid/type1cid.o freetype/src/psnames/psnames.o \
freetype/src/winfonts/winfnt.o freetype/src/raster1/raster1.o \
freetype/src/sfnt/sfnt.o freetype/src/smooth/smooth.o \
freetype/src/truetype/truetype.o freetype/src/type1z/type1z.o
STUBS_OBJECTS = stubs/stubs.o
TARGET_OBJECTS = \
@ -82,7 +75,6 @@ TARGET_OBJECTS = \
TARGET_CLEAN = $(DEP_FILES) \
dib/*.o \
eng/*.o \
freetype/*.o \
ldr/*.o \
main/*.o \
misc/*.o \
@ -107,7 +99,7 @@ main/svctabm.o: main/svctab.c
etags $(@D)/\*.c -o $(@D)/TAGS
etags: TAGS
TAGS: main/TAGS eng/TAGS ldr/TAGS misc/TAGS objects/TAGS stubs/TAGS ntuser/TAGS dib/TAGS freetype/TAGS
etags -i main/TAGS -i eng/TAGS -i ldr/TAGS -i misc/TAGS -i objects/TAGS -i stubs/TAGS -i ntuser/TAGS -i dib/TAGS -i freetype/TAGS
TAGS: main/TAGS eng/TAGS ldr/TAGS misc/TAGS objects/TAGS stubs/TAGS ntuser/TAGS dib/TAGS
etags -i main/TAGS -i eng/TAGS -i ldr/TAGS -i misc/TAGS -i objects/TAGS -i stubs/TAGS -i ntuser/TAGS -i dib/TAGS
# EOF

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.11 2003/05/26 18:52:37 gvg Exp $
/* $Id: stubs.c,v 1.12 2003/06/03 22:26:12 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -220,16 +220,6 @@ NtUserCheckMenuItem(
return 0;
}
DWORD
STDCALL
NtUserClipCursor(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserCloseClipboard(VOID)
@ -379,17 +369,6 @@ NtUserDestroyAcceleratorTable(
return 0;
}
DWORD
STDCALL
NtUserDestroyCursor(
DWORD Unknown0,
DWORD Unknown1)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserDestroyMenu(
@ -592,18 +571,6 @@ NtUserExcludeUpdateRgn(
return 0;
}
DWORD
STDCALL
NtUserFindExistingCursorIcon(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetAltTabInfo(
@ -698,16 +665,6 @@ NtUserGetClipboardViewer(VOID)
return 0;
}
DWORD
STDCALL
NtUserGetClipCursor(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetComboBoxInfo(
@ -756,29 +713,6 @@ NtUserGetCPD(
return 0;
}
DWORD
STDCALL
NtUserGetCursorFrameInfo(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetCursorInfo(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetDoubleClickTime(VOID)
@ -810,34 +744,6 @@ NtUserGetGUIThreadInfo(
return 0;
}
DWORD
STDCALL
NtUserGetIconInfo(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3,
DWORD Unknown4,
DWORD Unknown5)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetIconSize(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetImeHotKey(
@ -1344,40 +1250,6 @@ NtUserSetConsoleReserveKeys(
return 0;
}
DWORD
STDCALL
NtUserSetCursor(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetCursorContents(
DWORD Unknown0,
DWORD Unknown1)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetCursorIconData(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetDbgTag(
@ -1503,17 +1375,6 @@ NtUserSetSysColors(
return 0;
}
DWORD
STDCALL
NtUserSetSystemCursor(
DWORD Unknown0,
DWORD Unknown1)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetSystemMenu(

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: bitmaps.c,v 1.27 2003/05/18 17:16:17 ea Exp $ */
/* $Id: bitmaps.c,v 1.28 2003/06/03 22:26:52 ekohl Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
@ -456,6 +456,7 @@ BOOL STDCALL W32kStretchBlt(HDC hDCDest,
INT FASTCALL
BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp)
{
#if 0
switch(bpp)
{
case 1:
@ -481,6 +482,9 @@ BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp)
}
return -1;
#endif
return ((bmWidth * bpp + 31) & ~31) >> 3;
}
HBITMAP FASTCALL BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)

View file

@ -0,0 +1,265 @@
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <win32k/cursoricon.h>
#include <win32k/bitmaps.h>
#define NDEBUG
#include <win32k/debug1.h>
BOOL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor )
{
ASSERT( pIconCursor );
if( pIconCursor->ANDBitmap.bmBits )
ExFreePool(pIconCursor->ANDBitmap.bmBits);
if( pIconCursor->XORBitmap.bmBits )
ExFreePool(pIconCursor->XORBitmap.bmBits);
return TRUE;
}
HICON STDCALL W32kCreateIcon(BOOL fIcon,
INT Width,
INT Height,
UINT Planes,
UINT BitsPerPel,
DWORD xHotspot,
DWORD yHotspot,
CONST VOID *ANDBits,
CONST VOID *XORBits)
{
PICONCURSOROBJ icon;
HICON hIcon;
Planes = (BYTE) Planes;
BitsPerPel = (BYTE) BitsPerPel;
/* Check parameters */
if (!Height || !Width)
{
return 0;
}
if (Planes != 1)
{
UNIMPLEMENTED;
return 0;
}
/* Create the ICONCURSOROBJ object*/
hIcon = ICONCURSOROBJ_AllocIconCursor ();
if (!hIcon)
{
DPRINT("W32kCreateIcon: ICONCURSOROBJ_AllocIconCursor() returned 0\n");
return 0;
}
icon = ICONCURSOROBJ_HandleToPtr(hIcon);
/* Set up the basic icon stuff */
icon->fIcon = TRUE;
icon->xHotspot = xHotspot;
icon->yHotspot = yHotspot;
/* Setup the icon mask and icon color bitmaps */
icon->ANDBitmap.bmType = 0;
icon->ANDBitmap.bmWidth = Width;
icon->ANDBitmap.bmHeight = Height;
icon->ANDBitmap.bmPlanes = 1;
icon->ANDBitmap.bmBitsPixel = 1;
icon->ANDBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, 1);
icon->ANDBitmap.bmBits = NULL;
icon->XORBitmap.bmType = 0;
icon->XORBitmap.bmWidth = Width;
icon->XORBitmap.bmHeight = Height;
icon->XORBitmap.bmPlanes = Planes;
icon->XORBitmap.bmBitsPixel = BitsPerPel;
icon->XORBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, BitsPerPel);
icon->XORBitmap.bmBits = NULL;
/* allocate memory for the icon mask and icon color bitmaps,
this will be freed in IconCursor_InternalDelete */
icon->ANDBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->ANDBitmap.bmWidthBytes);
icon->XORBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->XORBitmap.bmWidthBytes);
/* set the bits of the mask and color bitmaps */
if (ANDBits)
{
memcpy(icon->ANDBitmap.bmBits, (PVOID)ANDBits, Height * icon->ANDBitmap.bmWidthBytes);
}
if (XORBits)
{
memcpy(icon->XORBitmap.bmBits, (PVOID)XORBits, Height * icon->XORBitmap.bmWidthBytes);
}
ICONCURSOROBJ_ReleasePtr( hIcon );
return hIcon;
}
DWORD
STDCALL
NtUserGetIconInfo(
HICON hIcon,
PBOOL fIcon,
PDWORD xHotspot,
PDWORD yHotspot,
HBITMAP *hbmMask,
HBITMAP *hbmColor)
{
PICONCURSOROBJ icon;
icon = ICONCURSOROBJ_HandleToPtr(hIcon);
if (!icon)
{
DbgPrint("NtUserGetIconInfo: ICONCURSOROBJ_HandleToPtr() returned 0\n");
return FALSE;
}
*fIcon = icon->fIcon ;
*xHotspot = icon->xHotspot;
*yHotspot = icon->yHotspot;
*hbmMask = W32kCreateBitmap(icon->ANDBitmap.bmWidth,
icon->ANDBitmap.bmHeight,
icon->ANDBitmap.bmPlanes,
icon->ANDBitmap.bmBitsPixel,
icon->ANDBitmap.bmBits);
*hbmColor = W32kCreateBitmap(icon->XORBitmap.bmWidth,
icon->XORBitmap.bmHeight,
icon->XORBitmap.bmPlanes,
icon->XORBitmap.bmBitsPixel,
icon->XORBitmap.bmBits);
ICONCURSOROBJ_ReleasePtr(hIcon);
if (!*hbmMask || !*hbmColor)
return FALSE;
return TRUE;
}
DWORD
STDCALL
NtUserGetIconSize(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetCursorFrameInfo(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetCursorInfo(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserClipCursor(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserDestroyCursor(
DWORD Unknown0,
DWORD Unknown1)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserFindExistingCursorIcon(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetClipCursor(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetCursor(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetCursorContents(
DWORD Unknown0,
DWORD Unknown1)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetCursorIconData(
DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2,
DWORD Unknown3)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserSetSystemCursor(
DWORD Unknown0,
DWORD Unknown1)
{
UNIMPLEMENTED
return 0;
}

View file

@ -19,7 +19,7 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
* $Id: gdiobj.c,v 1.25 2003/05/29 13:18:39 gvg Exp $
* $Id: gdiobj.c,v 1.26 2003/06/03 22:26:52 ekohl Exp $
*
*/
@ -35,6 +35,7 @@
#include <win32k/dc.h>
#include <win32k/bitmaps.h>
#include <win32k/region.h>
#include <win32k/cursoricon.h>
#include <include/palette.h>
#define NDEBUG
#include <win32k/debug1.h>
@ -243,71 +244,74 @@ HGDIOBJ FASTCALL GDIOBJ_AllocObj(WORD Size, WORD Magic)
*/
BOOL STDCALL GDIOBJ_FreeObj(HGDIOBJ hObj, WORD Magic, DWORD Flag)
{
PGDIOBJHDR objectHeader;
PGDI_HANDLE_ENTRY handleEntry;
PGDIOBJHDR objectHeader;
PGDI_HANDLE_ENTRY handleEntry;
PGDIOBJ Obj;
BOOL bRet = TRUE;
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)hObj & 0xffff);
handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD)hObj & 0xffff);
DPRINT("GDIOBJ_FreeObj: hObj: %d, magic: %x, handleEntry: %x\n", (WORD)hObj & 0xffff, Magic, handleEntry );
if (handleEntry == 0 || (handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE )
if (handleEntry == 0 || (handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE )
|| ((handleEntry->hProcessId != PsGetCurrentProcessId()) && !(Flag & GDIOBJFLAG_IGNOREPID))){
DPRINT("Can't Delete hObj: %d, magic: %x, pid:%d\n currpid:%d, flag:%d, hmm:%d\n",(WORD)hObj & 0xffff, handleEntry->wMagic, handleEntry->hProcessId, PsGetCurrentProcessId(), (Flag&GDIOBJFLAG_IGNOREPID), ((handleEntry->hProcessId != PsGetCurrentProcessId()) && !(Flag&GDIOBJFLAG_IGNOREPID)) );
return FALSE;
return FALSE;
}
objectHeader = (PGDIOBJHDR) handleEntry->pObject;
ASSERT(objectHeader);
DPRINT("FreeObj: locks: %x\n", objectHeader->dwCount );
if( !(Flag & GDIOBJFLAG_IGNORELOCK) ){
// check that the reference count is zero. if not then set flag
// and delete object when releaseobj is called
ExAcquireFastMutex(&RefCountHandling);
if( ( objectHeader->dwCount & ~0x80000000 ) > 0 ){
// check that the reference count is zero. if not then set flag
// and delete object when releaseobj is called
ExAcquireFastMutex(&RefCountHandling);
if( ( objectHeader->dwCount & ~0x80000000 ) > 0 ){
DPRINT("GDIOBJ_FreeObj: delayed object deletion: count %d\n", objectHeader->dwCount);
objectHeader->dwCount |= 0x80000000;
ExReleaseFastMutex(&RefCountHandling);
objectHeader->dwCount |= 0x80000000;
ExReleaseFastMutex(&RefCountHandling);
return TRUE;
}
ExReleaseFastMutex(&RefCountHandling);
}
ExReleaseFastMutex(&RefCountHandling);
}
//allow object to delete internal data
Obj = (PGDIOBJ)((PCHAR)handleEntry->pObject + sizeof(GDIOBJHDR));
switch( handleEntry->wMagic ){
case GO_REGION_MAGIC:
case GO_REGION_MAGIC:
bRet = RGNDATA_InternalDelete( (PROSRGNDATA) Obj );
break;
case GO_BITMAP_MAGIC:
case GO_BITMAP_MAGIC:
bRet = Bitmap_InternalDelete( (PBITMAPOBJ) Obj );
break;
case GO_DC_MAGIC:
case GO_DC_MAGIC:
bRet = DC_InternalDeleteDC( (PDC) Obj );
break;
case GO_PEN_MAGIC:
case GO_PALETTE_MAGIC:
case GO_DISABLED_DC_MAGIC:
case GO_META_DC_MAGIC:
case GO_METAFILE_MAGIC:
case GO_METAFILE_DC_MAGIC:
case GO_ENHMETAFILE_MAGIC:
case GO_ENHMETAFILE_DC_MAGIC:
case GO_PEN_MAGIC:
case GO_PALETTE_MAGIC:
case GO_DISABLED_DC_MAGIC:
case GO_META_DC_MAGIC:
case GO_METAFILE_MAGIC:
case GO_METAFILE_DC_MAGIC:
case GO_ENHMETAFILE_MAGIC:
case GO_ENHMETAFILE_DC_MAGIC:
case GO_BRUSH_MAGIC:
case GO_FONT_MAGIC:
case GO_BRUSH_MAGIC:
case GO_FONT_MAGIC:
break;
case GO_DCE_MAGIC:
bRet = DCE_InternalDelete( (PDCE) Obj );
break;
case GO_ICONCURSOR_MAGIC:
bRet = IconCursor_InternalDelete( (PICONCURSOROBJ) Obj );
break;
}
handleEntry->hProcessId = 0;
handleEntry->hProcessId = 0;
ExFreePool (handleEntry->pObject);
handleEntry->pObject = 0;
handleEntry->wMagic = 0;
handleEntry->wMagic = 0;
return TRUE;
return TRUE;
}
/*!