2004-09-06 21:15:46 +00:00
|
|
|
/*
|
|
|
|
* ReactOS GDI lib
|
|
|
|
* Copyright (C) 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-09-06 21:15:46 +00:00
|
|
|
*/
|
2009-12-30 22:56:09 +00:00
|
|
|
/*
|
2004-09-06 21:15:46 +00:00
|
|
|
* PROJECT: ReactOS gdi32.dll
|
2009-12-30 22:56:09 +00:00
|
|
|
* FILE: dll/win32/gdi32/misc/misc.c
|
2004-09-06 21:15:46 +00:00
|
|
|
* PURPOSE: Miscellaneous functions
|
|
|
|
* PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 2004/09/04 Created
|
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include <precomp.h>
|
2004-09-06 21:15:46 +00:00
|
|
|
|
2009-05-27 04:49:29 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2004-09-06 21:15:46 +00:00
|
|
|
PGDI_TABLE_ENTRY GdiHandleTable = NULL;
|
2007-12-15 08:08:11 +00:00
|
|
|
PGDI_SHARED_HANDLE_TABLE GdiSharedHandleTable = NULL;
|
2005-02-18 15:13:02 +00:00
|
|
|
HANDLE CurrentProcessId = NULL;
|
2006-10-17 05:30:54 +00:00
|
|
|
DWORD GDI_BatchLimit = 1;
|
2014-10-28 21:09:01 +00:00
|
|
|
extern PGDIHANDLECACHE GdiHandleCache;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GdiFlush()
|
|
|
|
{
|
|
|
|
NtGdiFlush();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2014-12-29 13:12:29 +00:00
|
|
|
INT
|
2014-10-28 21:09:01 +00:00
|
|
|
WINAPI
|
2014-12-29 13:12:29 +00:00
|
|
|
Escape(
|
|
|
|
_In_ HDC hdc,
|
|
|
|
_In_ INT nEscape,
|
|
|
|
_In_ INT cbInput,
|
|
|
|
_In_ LPCSTR lpvInData,
|
|
|
|
_Out_ LPVOID lpvOutData)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
2014-12-29 13:12:29 +00:00
|
|
|
INT retValue = SP_ERROR;
|
|
|
|
ULONG ulObjType;
|
2014-10-28 21:09:01 +00:00
|
|
|
|
2014-12-29 13:12:29 +00:00
|
|
|
ulObjType = GDI_HANDLE_GET_TYPE(hdc);
|
2014-10-28 21:09:01 +00:00
|
|
|
|
2014-12-29 13:12:29 +00:00
|
|
|
if (ulObjType == GDILoObjType_LO_METADC16_TYPE)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
/* FIXME we do not support metafile */
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
2014-12-29 13:12:29 +00:00
|
|
|
return SP_ERROR;
|
2014-10-28 21:09:01 +00:00
|
|
|
}
|
2014-12-29 13:12:29 +00:00
|
|
|
|
|
|
|
switch (nEscape)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
case ABORTDOC:
|
2014-12-29 13:12:29 +00:00
|
|
|
/* Note: Windows checks if the handle has any user data for the ABORTDOC command
|
|
|
|
* ReactOS copies this behavior to be compatible with windows 2003
|
2014-10-28 21:09:01 +00:00
|
|
|
*/
|
2014-12-29 13:12:29 +00:00
|
|
|
if (GdiGetDcAttr(hdc) == NULL)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
GdiSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
retValue = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retValue = AbortDoc(hdc);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAFTMODE:
|
|
|
|
case FLUSHOUTPUT:
|
|
|
|
case SETCOLORTABLE:
|
2014-12-29 13:12:29 +00:00
|
|
|
/* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE are outdated */
|
|
|
|
/* Note 2: Windows checks if the handle has any user data for the DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE commands
|
|
|
|
* ReactOS copies this behavior to be compatible with windows 2003
|
2014-10-28 21:09:01 +00:00
|
|
|
*/
|
2014-12-29 13:12:29 +00:00
|
|
|
if (GdiGetDcAttr(hdc) == NULL)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
GdiSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
}
|
|
|
|
retValue = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SETABORTPROC:
|
2014-12-29 13:12:29 +00:00
|
|
|
/* Note: Windows checks if the handle has any user data for the SETABORTPROC command
|
|
|
|
* ReactOS copies this behavior to be compatible with windows 2003
|
2014-10-28 21:09:01 +00:00
|
|
|
*/
|
2014-12-29 13:12:29 +00:00
|
|
|
if (GdiGetDcAttr(hdc) == NULL)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
GdiSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
retValue = FALSE;
|
|
|
|
}
|
|
|
|
retValue = SetAbortProc(hdc, (ABORTPROC)lpvInData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GETCOLORTABLE:
|
|
|
|
retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData);
|
2014-12-29 13:12:29 +00:00
|
|
|
if (!retValue)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
retValue = SP_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ENDDOC:
|
2014-12-29 13:12:29 +00:00
|
|
|
/* Note: Windows checks if the handle has any user data for the ENDDOC command
|
|
|
|
* ReactOS copies this behavior to be compatible with windows 2003
|
2014-10-28 21:09:01 +00:00
|
|
|
*/
|
2014-12-29 13:12:29 +00:00
|
|
|
if (GdiGetDcAttr(hdc) == NULL)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
GdiSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
retValue = FALSE;
|
|
|
|
}
|
|
|
|
retValue = EndDoc(hdc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GETSCALINGFACTOR:
|
|
|
|
/* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */
|
2014-12-29 13:12:29 +00:00
|
|
|
if (ulObjType == GDI_OBJECT_TYPE_DC)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
2014-12-29 13:12:29 +00:00
|
|
|
if (lpvOutData)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
2014-12-29 13:12:29 +00:00
|
|
|
PPOINT ptr = (PPOINT)lpvOutData;
|
2014-10-28 21:09:01 +00:00
|
|
|
ptr->x = 0;
|
|
|
|
ptr->y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
retValue = FALSE;
|
|
|
|
break;
|
2004-09-06 21:15:46 +00:00
|
|
|
|
2014-10-28 21:09:01 +00:00
|
|
|
case GETEXTENDEDTEXTMETRICS:
|
2014-12-29 13:12:29 +00:00
|
|
|
retValue = GetETM(hdc, (EXTTEXTMETRIC *)lpvOutData) != 0;
|
2014-10-28 21:09:01 +00:00
|
|
|
break;
|
2007-04-20 21:21:15 +00:00
|
|
|
|
2014-12-29 13:12:29 +00:00
|
|
|
case STARTDOC:
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
2014-12-29 13:12:29 +00:00
|
|
|
DOCINFOA di;
|
2014-10-28 21:09:01 +00:00
|
|
|
|
2014-12-29 13:12:29 +00:00
|
|
|
/* Note: Windows checks if the handle has any user data for the STARTDOC command
|
|
|
|
* ReactOS copies this behavior to be compatible with windows 2003
|
2014-10-28 21:09:01 +00:00
|
|
|
*/
|
2014-12-29 13:12:29 +00:00
|
|
|
if (GdiGetDcAttr(hdc) == NULL)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
GdiSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
retValue = FALSE;
|
|
|
|
}
|
|
|
|
|
2014-12-29 13:12:29 +00:00
|
|
|
di.cbSize = sizeof(DOCINFOA);
|
|
|
|
di.lpszOutput = 0;
|
|
|
|
di.lpszDatatype = 0;
|
|
|
|
di.fwType = 0;
|
|
|
|
di.lpszDocName = lpvInData;
|
2014-10-28 21:09:01 +00:00
|
|
|
|
|
|
|
/* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */
|
2014-12-29 13:12:29 +00:00
|
|
|
retValue = StartDocA(hdc, &di);
|
2014-10-28 21:09:01 +00:00
|
|
|
|
2014-12-29 13:12:29 +00:00
|
|
|
/* Check if StartDocA failed */
|
2014-10-28 21:09:01 +00:00
|
|
|
if (retValue < 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
retValue = GetLastError();
|
|
|
|
|
|
|
|
/* Translate StartDocA error code to STARTDOC error code
|
|
|
|
* see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx
|
|
|
|
*/
|
|
|
|
switch(retValue)
|
|
|
|
{
|
|
|
|
case ERROR_NOT_ENOUGH_MEMORY:
|
|
|
|
retValue = SP_OUTOFMEMORY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ERROR_PRINT_CANCELLED:
|
|
|
|
retValue = SP_USERABORT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ERROR_DISK_FULL:
|
|
|
|
retValue = SP_OUTOFDISK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
retValue = SP_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT
|
|
|
|
WINAPI
|
|
|
|
ExtEscape(HDC hDC,
|
|
|
|
int nEscape,
|
|
|
|
int cbInput,
|
|
|
|
LPCSTR lpszInData,
|
|
|
|
int cbOutput,
|
|
|
|
LPSTR lpszOutData)
|
|
|
|
{
|
|
|
|
return NtGdiExtEscape(hDC, NULL, 0, nEscape, cbInput, (LPSTR)lpszInData, cbOutput, lpszOutData);
|
|
|
|
}
|
|
|
|
|
|
|
|
INT
|
|
|
|
WINAPI
|
|
|
|
NamedEscape(HDC hdc,
|
|
|
|
PWCHAR pDriver,
|
|
|
|
INT iEsc,
|
|
|
|
INT cjIn,
|
|
|
|
LPSTR pjIn,
|
|
|
|
INT cjOut,
|
|
|
|
LPSTR pjOut)
|
|
|
|
{
|
|
|
|
/* FIXME metadc, metadc are done most in user mode, and we do not support it
|
|
|
|
* Windows 2000/XP/Vista ignore the current hdc, that are being pass and always set hdc to NULL
|
|
|
|
* when it calls to NtGdiExtEscape from NamedEscape
|
|
|
|
*/
|
|
|
|
return NtGdiExtEscape(NULL,pDriver,wcslen(pDriver),iEsc,cjIn,pjIn,cjOut,pjOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
WINAPI
|
|
|
|
DrawEscape(HDC hDC,
|
|
|
|
INT nEscape,
|
|
|
|
INT cbInput,
|
|
|
|
LPCSTR lpszInData)
|
|
|
|
{
|
|
|
|
if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
|
|
|
|
return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData);
|
|
|
|
|
|
|
|
if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC)
|
|
|
|
{
|
|
|
|
PLDC pLDC = GdiGetLDC(hDC);
|
|
|
|
if ( pLDC )
|
|
|
|
{
|
|
|
|
if (pLDC->Flags & LDC_META_PRINT)
|
|
|
|
{
|
|
|
|
// if (nEscape != QUERYESCSUPPORT)
|
|
|
|
// return EMFDRV_WriteEscape(hDC, nEscape, cbInput, lpszInData, EMR_DRAWESCAPE);
|
|
|
|
|
|
|
|
return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2007-08-09 06:48:07 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2014-10-28 21:09:01 +00:00
|
|
|
GdiDrawStream(HDC dc, ULONG l, VOID *v) // See Bug 4784
|
2007-08-09 06:48:07 +00:00
|
|
|
{
|
2014-10-28 21:09:01 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GdiValidateHandle(HGDIOBJ hobj)
|
|
|
|
{
|
|
|
|
PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hobj);
|
|
|
|
if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 &&
|
|
|
|
( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) ==
|
|
|
|
GDI_HANDLE_GET_TYPE(hobj) )
|
|
|
|
{
|
|
|
|
HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
|
|
|
|
if(pid == NULL || pid == CurrentProcessId)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
|
2007-08-09 06:48:07 +00:00
|
|
|
}
|
|
|
|
|
2007-04-20 21:21:15 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2007-10-19 23:21:45 +00:00
|
|
|
HGDIOBJ
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2007-04-20 21:21:15 +00:00
|
|
|
GdiFixUpHandle(HGDIOBJ hGdiObj)
|
|
|
|
{
|
2007-09-25 20:44:53 +00:00
|
|
|
PGDI_TABLE_ENTRY Entry;
|
|
|
|
|
|
|
|
if (((ULONG_PTR)(hGdiObj)) & GDI_HANDLE_UPPER_MASK )
|
|
|
|
{
|
|
|
|
return hGdiObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME is this right ?? */
|
|
|
|
|
|
|
|
Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);
|
|
|
|
|
2010-12-27 16:23:59 +00:00
|
|
|
/* Rebuild handle for Object */
|
2007-09-25 20:44:53 +00:00
|
|
|
return hGdiObj = (HGDIOBJ)(((LONG_PTR)(hGdiObj)) | (Entry->Type << GDI_ENTRY_UPPER_SHIFT));
|
2007-04-20 21:21:15 +00:00
|
|
|
}
|
|
|
|
|
2004-09-06 21:15:46 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
PVOID
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2004-09-06 21:15:46 +00:00
|
|
|
GdiQueryTable(VOID)
|
|
|
|
{
|
2010-12-27 16:23:59 +00:00
|
|
|
return (PVOID)GdiHandleTable;
|
2004-09-06 21:15:46 +00:00
|
|
|
}
|
2005-02-18 15:13:02 +00:00
|
|
|
|
|
|
|
BOOL GdiIsHandleValid(HGDIOBJ hGdiObj)
|
|
|
|
{
|
2010-12-27 16:23:59 +00:00
|
|
|
PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);
|
2008-04-21 18:28:35 +00:00
|
|
|
// We are only looking for TYPE not the rest here, and why is FullUnique filled up with CRAP!?
|
|
|
|
// DPRINT1("FullUnique -> %x\n", Entry->FullUnique);
|
2010-12-27 16:23:59 +00:00
|
|
|
if((Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 &&
|
|
|
|
( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) ==
|
|
|
|
GDI_HANDLE_GET_TYPE(hGdiObj))
|
2005-02-18 15:13:02 +00:00
|
|
|
{
|
2010-12-27 16:23:59 +00:00
|
|
|
HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
|
|
|
|
if(pid == NULL || pid == CurrentProcessId)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-02-18 15:13:02 +00:00
|
|
|
}
|
2010-12-27 16:23:59 +00:00
|
|
|
return FALSE;
|
2005-02-18 15:13:02 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 05:21:19 +00:00
|
|
|
BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, DWORD ObjectType, PVOID *UserData)
|
2005-02-18 15:13:02 +00:00
|
|
|
{
|
2010-12-27 16:23:59 +00:00
|
|
|
PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hGdiObj);
|
2011-03-26 15:24:05 +00:00
|
|
|
|
|
|
|
/* Check if twe have the correct type */
|
|
|
|
if (GDI_HANDLE_GET_TYPE(hGdiObj) != ObjectType ||
|
|
|
|
((Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK) != ObjectType ||
|
|
|
|
(Entry->Type & GDI_ENTRY_BASETYPE_MASK) != (ObjectType & GDI_ENTRY_BASETYPE_MASK))
|
2009-05-29 07:13:43 +00:00
|
|
|
{
|
2011-03-26 15:24:05 +00:00
|
|
|
return FALSE;
|
2009-05-29 07:13:43 +00:00
|
|
|
}
|
2011-03-26 15:24:05 +00:00
|
|
|
|
|
|
|
/* Check if we are the owner */
|
|
|
|
if ((HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1) != CurrentProcessId)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*UserData = Entry->UserData;
|
|
|
|
return TRUE;
|
2005-02-18 15:13:02 +00:00
|
|
|
}
|
2006-10-17 05:30:54 +00:00
|
|
|
|
2009-05-27 04:49:29 +00:00
|
|
|
PLDC
|
|
|
|
FASTCALL
|
2014-10-28 00:16:18 +00:00
|
|
|
GdiGetLDC(HDC hdc)
|
2006-11-27 21:58:46 +00:00
|
|
|
{
|
2014-10-28 00:16:18 +00:00
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
|
|
|
|
/* Get the DC attribute */
|
|
|
|
pdcattr = GdiGetDcAttr(hdc);
|
|
|
|
if (pdcattr == NULL)
|
2010-12-27 16:23:59 +00:00
|
|
|
{
|
2014-10-28 00:16:18 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-12-27 16:23:59 +00:00
|
|
|
|
2014-10-28 00:16:18 +00:00
|
|
|
/* Return the LDC pointer */
|
|
|
|
return pdcattr->pvLDC;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
FASTCALL
|
|
|
|
GdiSetLDC(HDC hdc, PVOID pvLDC)
|
|
|
|
{
|
|
|
|
PDC_ATTR pdcattr;
|
|
|
|
|
|
|
|
/* Get the DC attribute */
|
|
|
|
pdcattr = GdiGetDcAttr(hdc);
|
|
|
|
if (pdcattr == NULL)
|
|
|
|
{
|
|
|
|
return FALSE;
|
2010-12-27 16:23:59 +00:00
|
|
|
}
|
2014-10-28 00:16:18 +00:00
|
|
|
|
|
|
|
/* Set the LDC pointer */
|
|
|
|
pdcattr->pvLDC = pvLDC;
|
|
|
|
return TRUE;
|
2006-11-27 21:58:46 +00:00
|
|
|
}
|
2006-10-17 05:30:54 +00:00
|
|
|
|
2014-10-28 00:16:18 +00:00
|
|
|
|
2009-05-24 04:07:47 +00:00
|
|
|
VOID GdiSAPCallback(PLDC pldc)
|
|
|
|
{
|
|
|
|
DWORD Time, NewTime = GetTickCount();
|
|
|
|
|
|
|
|
Time = NewTime - pldc->CallBackTick;
|
|
|
|
|
|
|
|
if ( Time < SAPCALLBACKDELAY) return;
|
|
|
|
|
|
|
|
pldc->CallBackTick = NewTime;
|
|
|
|
|
2009-05-24 04:14:48 +00:00
|
|
|
if ( !pldc->pAbortProc(pldc->hDC, 0) )
|
2009-05-24 04:07:47 +00:00
|
|
|
{
|
2010-12-27 16:23:59 +00:00
|
|
|
CancelDC(pldc->hDC);
|
|
|
|
AbortDoc(pldc->hDC);
|
2009-05-24 04:07:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-17 05:30:54 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2006-10-17 05:30:54 +00:00
|
|
|
GdiSetBatchLimit(DWORD Limit)
|
|
|
|
{
|
2007-09-25 20:44:53 +00:00
|
|
|
DWORD OldLimit = GDI_BatchLimit;
|
|
|
|
|
|
|
|
if ( (!Limit) ||
|
2010-12-27 16:23:59 +00:00
|
|
|
(Limit >= GDI_BATCH_LIMIT))
|
2007-09-25 20:44:53 +00:00
|
|
|
{
|
|
|
|
return Limit;
|
|
|
|
}
|
|
|
|
|
2006-10-17 05:30:54 +00:00
|
|
|
GdiFlush();
|
|
|
|
GDI_BatchLimit = Limit;
|
|
|
|
return OldLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2006-10-17 05:30:54 +00:00
|
|
|
GdiGetBatchLimit()
|
|
|
|
{
|
|
|
|
return GDI_BatchLimit;
|
|
|
|
}
|
2007-04-20 21:21:15 +00:00
|
|
|
|
2007-09-25 13:27:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2007-09-25 13:27:09 +00:00
|
|
|
GdiSetLastError(DWORD dwErrCode)
|
|
|
|
{
|
2008-10-17 04:34:21 +00:00
|
|
|
NtCurrentTeb()->LastErrorValue = (ULONG) dwErrCode;
|
2007-09-25 13:27:09 +00:00
|
|
|
}
|
2008-05-24 19:02:23 +00:00
|
|
|
|
2009-12-24 07:42:38 +00:00
|
|
|
HGDIOBJ
|
|
|
|
FASTCALL
|
|
|
|
hGetPEBHandle(HANDLECACHETYPE Type, COLORREF cr)
|
|
|
|
{
|
2011-03-28 00:17:21 +00:00
|
|
|
int Number, Offset, MaxNum, GdiType;
|
2010-12-27 16:23:59 +00:00
|
|
|
HANDLE Lock;
|
|
|
|
HGDIOBJ Handle = NULL;
|
|
|
|
|
|
|
|
Lock = InterlockedCompareExchangePointer( (PVOID*)&GdiHandleCache->ulLock,
|
|
|
|
NtCurrentTeb(),
|
|
|
|
NULL );
|
|
|
|
|
|
|
|
if (Lock) return Handle;
|
|
|
|
|
|
|
|
Number = GdiHandleCache->ulNumHandles[Type];
|
|
|
|
|
2011-03-27 05:40:30 +00:00
|
|
|
if (Type == hctBrushHandle)
|
2010-12-27 16:23:59 +00:00
|
|
|
{
|
2011-03-28 00:17:21 +00:00
|
|
|
Offset = 0;
|
2011-03-27 05:40:30 +00:00
|
|
|
MaxNum = CACHE_BRUSH_ENTRIES;
|
|
|
|
GdiType = GDILoObjType_LO_BRUSH_TYPE;
|
|
|
|
}
|
|
|
|
else if (Type == hctPenHandle)
|
|
|
|
{
|
2011-03-28 00:17:21 +00:00
|
|
|
Offset = CACHE_BRUSH_ENTRIES;
|
2011-03-27 05:40:30 +00:00
|
|
|
MaxNum = CACHE_PEN_ENTRIES;
|
|
|
|
GdiType = GDILoObjType_LO_PEN_TYPE;
|
|
|
|
}
|
|
|
|
else if (Type == hctRegionHandle)
|
|
|
|
{
|
2011-03-28 00:17:21 +00:00
|
|
|
Offset = CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES;
|
2011-03-27 05:40:30 +00:00
|
|
|
MaxNum = CACHE_REGION_ENTRIES;
|
|
|
|
GdiType = GDILoObjType_LO_REGION_TYPE;
|
|
|
|
}
|
|
|
|
else // Font is not supported here.
|
|
|
|
{
|
|
|
|
return Handle;
|
|
|
|
}
|
2010-12-27 16:23:59 +00:00
|
|
|
|
2011-03-27 05:40:30 +00:00
|
|
|
if ( Number && Number <= MaxNum )
|
|
|
|
{
|
|
|
|
PBRUSH_ATTR pBrush_Attr;
|
|
|
|
HGDIOBJ *hPtr;
|
2011-03-28 00:17:21 +00:00
|
|
|
hPtr = GdiHandleCache->Handle + Offset;
|
2011-03-27 05:40:30 +00:00
|
|
|
Handle = hPtr[Number - 1];
|
|
|
|
|
|
|
|
if (GdiGetHandleUserData( Handle, GdiType, (PVOID) &pBrush_Attr))
|
|
|
|
{
|
|
|
|
if (pBrush_Attr->AttrFlags & ATTR_CACHED)
|
|
|
|
{
|
2013-08-30 10:51:12 +00:00
|
|
|
DPRINT("Get Handle! Type %d Count %lu PEB 0x%p\n", Type, GdiHandleCache->ulNumHandles[Type], NtCurrentTeb()->ProcessEnvironmentBlock);
|
2011-03-27 05:40:30 +00:00
|
|
|
pBrush_Attr->AttrFlags &= ~ATTR_CACHED;
|
|
|
|
hPtr[Number - 1] = NULL;
|
|
|
|
GdiHandleCache->ulNumHandles[Type]--;
|
|
|
|
if ( Type == hctBrushHandle ) // Handle only brush.
|
|
|
|
{
|
|
|
|
if ( pBrush_Attr->lbColor != cr )
|
2010-12-27 16:23:59 +00:00
|
|
|
{
|
2011-03-27 05:40:30 +00:00
|
|
|
pBrush_Attr->lbColor = cr ;
|
|
|
|
pBrush_Attr->AttrFlags |= ATTR_NEW_COLOR;
|
2010-12-27 16:23:59 +00:00
|
|
|
}
|
2011-03-27 05:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-28 00:17:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Handle = NULL;
|
|
|
|
}
|
2010-12-27 16:23:59 +00:00
|
|
|
}
|
|
|
|
(void)InterlockedExchangePointer((PVOID*)&GdiHandleCache->ulLock, Lock);
|
|
|
|
return Handle;
|
2009-12-24 07:42:38 +00:00
|
|
|
}
|
|
|
|
|
2014-10-28 21:09:01 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
bMakePathNameW(LPWSTR lpBuffer,LPCWSTR lpFileName,LPWSTR *lpFilePart,DWORD unknown)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DEVMODEW *
|
|
|
|
WINAPI
|
|
|
|
GdiConvertToDevmodeW(const DEVMODEA *dmA)
|
|
|
|
{
|
|
|
|
DEVMODEW *dmW;
|
|
|
|
WORD dmW_size, dmA_size;
|
|
|
|
|
|
|
|
dmA_size = dmA->dmSize;
|
|
|
|
|
|
|
|
/* this is the minimal dmSize that XP accepts */
|
|
|
|
if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (dmA_size > sizeof(DEVMODEA))
|
|
|
|
dmA_size = sizeof(DEVMODEA);
|
|
|
|
|
|
|
|
dmW_size = dmA_size + CCHDEVICENAME;
|
|
|
|
if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
|
|
|
|
dmW_size += CCHFORMNAME;
|
|
|
|
|
|
|
|
dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
|
|
|
|
if (!dmW) return NULL;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME,
|
|
|
|
dmW->dmDeviceName, CCHDEVICENAME);
|
|
|
|
/* copy slightly more, to avoid long computations */
|
|
|
|
memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
|
|
|
|
|
|
|
|
if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME,
|
|
|
|
dmW->dmFormName, CCHFORMNAME);
|
|
|
|
if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
|
|
|
|
memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dmA->dmDriverExtra)
|
|
|
|
memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
|
|
|
|
|
|
|
|
dmW->dmSize = dmW_size;
|
|
|
|
|
|
|
|
return dmW;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GdiRealizationInfo(HDC hdc,
|
|
|
|
PREALIZATION_INFO pri)
|
|
|
|
{
|
|
|
|
// ATM we do not support local font data and Language Pack.
|
|
|
|
return NtGdiGetRealizationInfo(hdc, pri, (HFONT) NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
VOID WINAPI GdiInitializeLanguagePack(DWORD InitParam)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GdiAddGlsBounds(HDC hdc,LPRECT prc)
|
|
|
|
{
|
|
|
|
//FIXME: Lookup what 0x8000 means
|
|
|
|
return NtGdiSetBoundsRect(hdc, prc, 0x8000 | DCB_ACCUMULATE ) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GdiAddGlsRecord(HDC hdc,
|
|
|
|
DWORD unknown1,
|
|
|
|
LPCSTR unknown2,
|
|
|
|
LPRECT unknown3)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|