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
|
2015-10-17 14:41:47 +00:00
|
|
|
* FILE: win32ss/gdi/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
|
2015-09-04 00:11:49 +00:00
|
|
|
GdiFlush(VOID)
|
2014-10-28 21:09:01 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2014-12-29 14:25:30 +00:00
|
|
|
return METADC16_Escape(hdc, nEscape, cbInput, lpvInData, lpvOutData);
|
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;
|
|
|
|
}
|
|
|
|
|
2017-04-07 14:09:24 +00:00
|
|
|
#define ALPHABLEND_NONE 0
|
|
|
|
#define ALPHABLEND_BINARY 1
|
|
|
|
#define ALPHABLEND_FULL 2
|
|
|
|
|
|
|
|
typedef struct _MARGINS {
|
|
|
|
int cxLeftWidth;
|
|
|
|
int cxRightWidth;
|
|
|
|
int cyTopHeight;
|
|
|
|
int cyBottomHeight;
|
|
|
|
} MARGINS, *PMARGINS;
|
|
|
|
|
|
|
|
enum SIZINGTYPE {
|
|
|
|
ST_TRUESIZE = 0,
|
|
|
|
ST_STRETCH = 1,
|
|
|
|
ST_TILE = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TransparentBlt GdiTransparentBlt
|
|
|
|
#define AlphaBlend GdiAlphaBlend
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UXTHEME_StretchBlt
|
|
|
|
*
|
|
|
|
* Pseudo TransparentBlt/StretchBlt
|
|
|
|
*/
|
|
|
|
static inline BOOL UXTHEME_StretchBlt(HDC hdcDst, int nXOriginDst, int nYOriginDst, int nWidthDst, int nHeightDst,
|
|
|
|
HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc,
|
|
|
|
INT transparent, COLORREF transcolor)
|
|
|
|
{
|
|
|
|
static const BLENDFUNCTION blendFunc =
|
|
|
|
{
|
|
|
|
AC_SRC_OVER, /* BlendOp */
|
|
|
|
0, /* BlendFlag */
|
|
|
|
255, /* SourceConstantAlpha */
|
|
|
|
AC_SRC_ALPHA /* AlphaFormat */
|
|
|
|
};
|
|
|
|
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
int old_stretch_mode;
|
|
|
|
POINT old_brush_org;
|
|
|
|
|
|
|
|
old_stretch_mode = SetStretchBltMode(hdcDst, HALFTONE);
|
|
|
|
SetBrushOrgEx(hdcDst, nXOriginDst, nYOriginDst, &old_brush_org);
|
|
|
|
|
|
|
|
if (transparent == ALPHABLEND_BINARY) {
|
|
|
|
/* Ensure we don't pass any negative values to TransparentBlt */
|
|
|
|
ret = TransparentBlt(hdcDst, nXOriginDst, nYOriginDst, abs(nWidthDst), abs(nHeightDst),
|
|
|
|
hdcSrc, nXOriginSrc, nYOriginSrc, abs(nWidthSrc), abs(nHeightSrc),
|
|
|
|
transcolor);
|
|
|
|
} else if ((transparent == ALPHABLEND_NONE) ||
|
|
|
|
!AlphaBlend(hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
|
|
|
|
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
|
|
|
|
blendFunc))
|
|
|
|
{
|
|
|
|
ret = StretchBlt(hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
|
|
|
|
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
|
|
|
|
SRCCOPY);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetBrushOrgEx(hdcDst, old_brush_org.x, old_brush_org.y, NULL);
|
|
|
|
SetStretchBltMode(hdcDst, old_stretch_mode);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UXTHEME_Blt
|
|
|
|
*
|
|
|
|
* Simplify sending same width/height for both source and dest
|
|
|
|
*/
|
|
|
|
static inline BOOL UXTHEME_Blt(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest,
|
|
|
|
HDC hdcSrc, int nXOriginSrc, int nYOriginSrc,
|
|
|
|
INT transparent, COLORREF transcolor)
|
|
|
|
{
|
|
|
|
return UXTHEME_StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
|
|
|
|
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthDest, nHeightDest,
|
|
|
|
transparent, transcolor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UXTHEME_SizedBlt
|
|
|
|
*
|
|
|
|
* Stretches or tiles, depending on sizingtype.
|
|
|
|
*/
|
|
|
|
static inline BOOL UXTHEME_SizedBlt (HDC hdcDst, int nXOriginDst, int nYOriginDst,
|
|
|
|
int nWidthDst, int nHeightDst,
|
|
|
|
HDC hdcSrc, int nXOriginSrc, int nYOriginSrc,
|
|
|
|
int nWidthSrc, int nHeightSrc,
|
|
|
|
int sizingtype,
|
|
|
|
INT transparent, COLORREF transcolor)
|
|
|
|
{
|
|
|
|
if (sizingtype == ST_TILE)
|
|
|
|
{
|
|
|
|
HDC hdcTemp;
|
|
|
|
BOOL result = FALSE;
|
|
|
|
|
|
|
|
if (!nWidthSrc || !nHeightSrc) return TRUE;
|
|
|
|
|
|
|
|
/* For destination width/height less than or equal to source
|
|
|
|
width/height, do not bother with memory bitmap optimization */
|
|
|
|
if (nWidthSrc >= nWidthDst && nHeightSrc >= nHeightDst)
|
|
|
|
{
|
|
|
|
int bltWidth = min (nWidthDst, nWidthSrc);
|
|
|
|
int bltHeight = min (nHeightDst, nHeightSrc);
|
|
|
|
|
|
|
|
return UXTHEME_Blt (hdcDst, nXOriginDst, nYOriginDst, bltWidth, bltHeight,
|
|
|
|
hdcSrc, nXOriginSrc, nYOriginSrc,
|
|
|
|
transparent, transcolor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a DC with a bitmap consisting of a tiling of the source
|
|
|
|
bitmap, with standard GDI functions. This is faster than an
|
|
|
|
iteration with UXTHEME_Blt(). */
|
|
|
|
hdcTemp = CreateCompatibleDC(hdcSrc);
|
|
|
|
if (hdcTemp != 0)
|
|
|
|
{
|
|
|
|
HBITMAP bitmapTemp;
|
|
|
|
HBITMAP bitmapOrig;
|
|
|
|
int nWidthTemp, nHeightTemp;
|
|
|
|
int xOfs, xRemaining;
|
|
|
|
int yOfs, yRemaining;
|
|
|
|
int growSize;
|
|
|
|
|
|
|
|
/* Calculate temp dimensions of integer multiples of source dimensions */
|
|
|
|
nWidthTemp = ((nWidthDst + nWidthSrc - 1) / nWidthSrc) * nWidthSrc;
|
|
|
|
nHeightTemp = ((nHeightDst + nHeightSrc - 1) / nHeightSrc) * nHeightSrc;
|
|
|
|
bitmapTemp = CreateCompatibleBitmap(hdcSrc, nWidthTemp, nHeightTemp);
|
|
|
|
bitmapOrig = SelectObject(hdcTemp, bitmapTemp);
|
|
|
|
|
|
|
|
/* Initial copy of bitmap */
|
|
|
|
BitBlt(hdcTemp, 0, 0, nWidthSrc, nHeightSrc, hdcSrc, nXOriginSrc, nYOriginSrc, SRCCOPY);
|
|
|
|
|
|
|
|
/* Extend bitmap in the X direction. Growth of width is exponential */
|
|
|
|
xOfs = nWidthSrc;
|
|
|
|
xRemaining = nWidthTemp - nWidthSrc;
|
|
|
|
growSize = nWidthSrc;
|
|
|
|
while (xRemaining > 0)
|
|
|
|
{
|
|
|
|
growSize = min(growSize, xRemaining);
|
|
|
|
BitBlt(hdcTemp, xOfs, 0, growSize, nHeightSrc, hdcTemp, 0, 0, SRCCOPY);
|
|
|
|
xOfs += growSize;
|
|
|
|
xRemaining -= growSize;
|
|
|
|
growSize *= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extend bitmap in the Y direction. Growth of height is exponential */
|
|
|
|
yOfs = nHeightSrc;
|
|
|
|
yRemaining = nHeightTemp - nHeightSrc;
|
|
|
|
growSize = nHeightSrc;
|
|
|
|
while (yRemaining > 0)
|
|
|
|
{
|
|
|
|
growSize = min(growSize, yRemaining);
|
|
|
|
BitBlt(hdcTemp, 0, yOfs, nWidthTemp, growSize, hdcTemp, 0, 0, SRCCOPY);
|
|
|
|
yOfs += growSize;
|
|
|
|
yRemaining -= growSize;
|
|
|
|
growSize *= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use temporary hdc for source */
|
|
|
|
result = UXTHEME_Blt (hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
|
|
|
|
hdcTemp, 0, 0,
|
|
|
|
transparent, transcolor);
|
|
|
|
|
|
|
|
SelectObject(hdcTemp, bitmapOrig);
|
|
|
|
DeleteObject(bitmapTemp);
|
|
|
|
}
|
|
|
|
DeleteDC(hdcTemp);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return UXTHEME_StretchBlt (hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
|
|
|
|
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
|
|
|
|
transparent, transcolor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UXTHEME_DrawImageBackground
|
|
|
|
*
|
|
|
|
* Draw an imagefile background
|
|
|
|
*/
|
|
|
|
static HRESULT UXTHEME_DrawImageBackground(HDC hdc, HBITMAP bmpSrc, RECT *prcSrc, INT transparent,
|
|
|
|
COLORREF transparentcolor, BOOL borderonly, int sizingtype, MARGINS *psm, RECT *pRect)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
HBITMAP bmpSrcResized = NULL;
|
|
|
|
HGDIOBJ oldSrc;
|
|
|
|
HDC hdcSrc, hdcOrigSrc = NULL;
|
|
|
|
RECT rcDst;
|
|
|
|
POINT dstSize;
|
|
|
|
POINT srcSize;
|
|
|
|
RECT rcSrc;
|
|
|
|
MARGINS sm;
|
|
|
|
|
|
|
|
rcDst = *pRect;
|
|
|
|
rcSrc = *prcSrc;
|
|
|
|
sm = *psm;
|
|
|
|
|
|
|
|
hdcSrc = CreateCompatibleDC(hdc);
|
|
|
|
if(!hdcSrc) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
oldSrc = SelectObject(hdcSrc, bmpSrc);
|
|
|
|
|
|
|
|
dstSize.x = rcDst.right-rcDst.left;
|
|
|
|
dstSize.y = rcDst.bottom-rcDst.top;
|
|
|
|
srcSize.x = rcSrc.right-rcSrc.left;
|
|
|
|
srcSize.y = rcSrc.bottom-rcSrc.top;
|
|
|
|
|
|
|
|
if(sizingtype == ST_TRUESIZE) {
|
|
|
|
if(!UXTHEME_StretchBlt(hdc, rcDst.left, rcDst.top, dstSize.x, dstSize.y,
|
|
|
|
hdcSrc, rcSrc.left, rcSrc.top, srcSize.x, srcSize.y,
|
|
|
|
transparent, transparentcolor))
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
HDC hdcDst = NULL;
|
|
|
|
POINT org;
|
|
|
|
|
|
|
|
dstSize.x = abs(dstSize.x);
|
|
|
|
dstSize.y = abs(dstSize.y);
|
|
|
|
|
|
|
|
/* Resize source image if destination smaller than margins */
|
|
|
|
#ifndef __REACTOS__
|
|
|
|
/* Revert Wine Commit 2b650fa as it breaks themed Explorer Toolbar Separators
|
|
|
|
FIXME: Revisit this when the bug is fixed. CORE-9636 and Wine Bug #38538 */
|
|
|
|
if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y || sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
|
|
|
|
if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y) {
|
|
|
|
sm.cyTopHeight = MulDiv(sm.cyTopHeight, dstSize.y, srcSize.y);
|
|
|
|
sm.cyBottomHeight = dstSize.y - sm.cyTopHeight;
|
|
|
|
srcSize.y = dstSize.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
|
|
|
|
sm.cxLeftWidth = MulDiv(sm.cxLeftWidth, dstSize.x, srcSize.x);
|
|
|
|
sm.cxRightWidth = dstSize.x - sm.cxLeftWidth;
|
|
|
|
srcSize.x = dstSize.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdcOrigSrc = hdcSrc;
|
|
|
|
hdcSrc = CreateCompatibleDC(NULL);
|
|
|
|
bmpSrcResized = CreateBitmap(srcSize.x, srcSize.y, 1, 32, NULL);
|
|
|
|
SelectObject(hdcSrc, bmpSrcResized);
|
|
|
|
|
|
|
|
UXTHEME_StretchBlt(hdcSrc, 0, 0, srcSize.x, srcSize.y, hdcOrigSrc, rcSrc.left, rcSrc.top,
|
|
|
|
rcSrc.right - rcSrc.left, rcSrc.bottom - rcSrc.top, transparent, transparentcolor);
|
|
|
|
|
|
|
|
rcSrc.left = 0;
|
|
|
|
rcSrc.top = 0;
|
|
|
|
rcSrc.right = srcSize.x;
|
|
|
|
rcSrc.bottom = srcSize.y;
|
|
|
|
}
|
|
|
|
#endif /* __REACTOS__ */
|
|
|
|
|
|
|
|
hdcDst = hdc;
|
|
|
|
OffsetViewportOrgEx(hdcDst, rcDst.left, rcDst.top, &org);
|
|
|
|
|
|
|
|
/* Upper left corner */
|
|
|
|
if(!UXTHEME_Blt(hdcDst, 0, 0, sm.cxLeftWidth, sm.cyTopHeight,
|
|
|
|
hdcSrc, rcSrc.left, rcSrc.top,
|
|
|
|
transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
/* Upper right corner */
|
|
|
|
if(!UXTHEME_Blt (hdcDst, dstSize.x-sm.cxRightWidth, 0,
|
|
|
|
sm.cxRightWidth, sm.cyTopHeight,
|
|
|
|
hdcSrc, rcSrc.right-sm.cxRightWidth, rcSrc.top,
|
|
|
|
transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
/* Lower left corner */
|
|
|
|
if(!UXTHEME_Blt (hdcDst, 0, dstSize.y-sm.cyBottomHeight,
|
|
|
|
sm.cxLeftWidth, sm.cyBottomHeight,
|
|
|
|
hdcSrc, rcSrc.left, rcSrc.bottom-sm.cyBottomHeight,
|
|
|
|
transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
/* Lower right corner */
|
|
|
|
if(!UXTHEME_Blt (hdcDst, dstSize.x-sm.cxRightWidth, dstSize.y-sm.cyBottomHeight,
|
|
|
|
sm.cxRightWidth, sm.cyBottomHeight,
|
|
|
|
hdcSrc, rcSrc.right-sm.cxRightWidth, rcSrc.bottom-sm.cyBottomHeight,
|
|
|
|
transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((sizingtype == ST_STRETCH) || (sizingtype == ST_TILE)) {
|
|
|
|
int destCenterWidth = dstSize.x - (sm.cxLeftWidth + sm.cxRightWidth);
|
|
|
|
int srcCenterWidth = srcSize.x - (sm.cxLeftWidth + sm.cxRightWidth);
|
|
|
|
int destCenterHeight = dstSize.y - (sm.cyTopHeight + sm.cyBottomHeight);
|
|
|
|
int srcCenterHeight = srcSize.y - (sm.cyTopHeight + sm.cyBottomHeight);
|
|
|
|
|
|
|
|
if(destCenterWidth > 0) {
|
|
|
|
/* Center top */
|
|
|
|
if(!UXTHEME_SizedBlt (hdcDst, sm.cxLeftWidth, 0,
|
|
|
|
destCenterWidth, sm.cyTopHeight,
|
|
|
|
hdcSrc, rcSrc.left+sm.cxLeftWidth, rcSrc.top,
|
|
|
|
srcCenterWidth, sm.cyTopHeight,
|
|
|
|
sizingtype, transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
/* Center bottom */
|
|
|
|
if(!UXTHEME_SizedBlt (hdcDst, sm.cxLeftWidth, dstSize.y-sm.cyBottomHeight,
|
|
|
|
destCenterWidth, sm.cyBottomHeight,
|
|
|
|
hdcSrc, rcSrc.left+sm.cxLeftWidth, rcSrc.bottom-sm.cyBottomHeight,
|
|
|
|
srcCenterWidth, sm.cyBottomHeight,
|
|
|
|
sizingtype, transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(destCenterHeight > 0) {
|
|
|
|
/* Left center */
|
|
|
|
if(!UXTHEME_SizedBlt (hdcDst, 0, sm.cyTopHeight,
|
|
|
|
sm.cxLeftWidth, destCenterHeight,
|
|
|
|
hdcSrc, rcSrc.left, rcSrc.top+sm.cyTopHeight,
|
|
|
|
sm.cxLeftWidth, srcCenterHeight,
|
|
|
|
sizingtype,
|
|
|
|
transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
/* Right center */
|
|
|
|
if(!UXTHEME_SizedBlt (hdcDst, dstSize.x-sm.cxRightWidth, sm.cyTopHeight,
|
|
|
|
sm.cxRightWidth, destCenterHeight,
|
|
|
|
hdcSrc, rcSrc.right-sm.cxRightWidth, rcSrc.top+sm.cyTopHeight,
|
|
|
|
sm.cxRightWidth, srcCenterHeight,
|
|
|
|
sizingtype, transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(destCenterHeight > 0 && destCenterWidth > 0) {
|
|
|
|
if(!borderonly) {
|
|
|
|
/* Center */
|
|
|
|
if(!UXTHEME_SizedBlt (hdcDst, sm.cxLeftWidth, sm.cyTopHeight,
|
|
|
|
destCenterWidth, destCenterHeight,
|
|
|
|
hdcSrc, rcSrc.left+sm.cxLeftWidth, rcSrc.top+sm.cyTopHeight,
|
|
|
|
srcCenterWidth, srcCenterHeight,
|
|
|
|
sizingtype, transparent, transparentcolor)) {
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
goto draw_error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
draw_error:
|
|
|
|
SetViewportOrgEx (hdcDst, org.x, org.y, NULL);
|
|
|
|
}
|
|
|
|
SelectObject(hdcSrc, oldSrc);
|
|
|
|
DeleteDC(hdcSrc);
|
|
|
|
if (bmpSrcResized) DeleteObject(bmpSrcResized);
|
|
|
|
if (hdcOrigSrc) DeleteDC(hdcOrigSrc);
|
|
|
|
*pRect = rcDst;
|
|
|
|
return hr;
|
|
|
|
}
|
2014-10-28 21:09:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2007-08-09 06:48:07 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2017-04-07 14:09:24 +00:00
|
|
|
GdiDrawStream(HDC dc, ULONG l, PGDI_DRAW_STREAM pDS)
|
2007-08-09 06:48:07 +00:00
|
|
|
{
|
2017-04-07 14:09:24 +00:00
|
|
|
if (!pDS || l != sizeof(*pDS))
|
|
|
|
{
|
|
|
|
DPRINT1("GdiDrawStream: Invalid params\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDS->signature != 0x44727753 ||
|
|
|
|
pDS->reserved != 0 ||
|
|
|
|
pDS->unknown1 != 1 ||
|
|
|
|
pDS->unknown2 != 9)
|
|
|
|
{
|
|
|
|
DPRINT1("GdiDrawStream: Got unknown pDS data\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
MARGINS sm = {pDS->leftSizingMargin, pDS->rightSizingMargin, pDS->topSizingMargin, pDS->bottomSizingMargin};
|
|
|
|
INT transparent = 0;
|
|
|
|
int sizingtype;
|
|
|
|
|
2017-05-03 10:55:54 +00:00
|
|
|
if (pDS->drawOption & DS_TRANSPARENTALPHA)
|
2017-04-07 14:09:24 +00:00
|
|
|
transparent = ALPHABLEND_FULL;
|
2017-05-03 10:55:54 +00:00
|
|
|
else if (pDS->drawOption & DS_TRANSPARENTCLR)
|
2017-04-07 14:09:24 +00:00
|
|
|
transparent = ALPHABLEND_BINARY;
|
|
|
|
else
|
|
|
|
transparent = ALPHABLEND_NONE;
|
|
|
|
|
2017-05-03 10:55:54 +00:00
|
|
|
if (pDS->drawOption & DS_TILE)
|
2017-04-07 14:09:24 +00:00
|
|
|
sizingtype = ST_TILE;
|
2017-05-03 10:55:54 +00:00
|
|
|
else if (pDS->drawOption & DS_TRUESIZE)
|
2017-04-07 14:09:24 +00:00
|
|
|
sizingtype = ST_TRUESIZE;
|
|
|
|
else
|
|
|
|
sizingtype = ST_STRETCH;
|
|
|
|
|
|
|
|
UXTHEME_DrawImageBackground(pDS->hDC,
|
|
|
|
pDS->hImage,
|
|
|
|
&pDS->rcSrc,
|
|
|
|
transparent,
|
|
|
|
pDS->crTransparent,
|
|
|
|
FALSE,
|
|
|
|
sizingtype,
|
|
|
|
&sm,
|
|
|
|
&pDS->rcDest);
|
|
|
|
}
|
2014-10-28 21:09:01 +00:00
|
|
|
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
|
|
|
|
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
|
2015-09-04 00:11:49 +00:00
|
|
|
GdiGetBatchLimit(VOID)
|
2006-10-17 05:30:54 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2017-07-06 18:52:22 +00:00
|
|
|
return NtGdiSetBoundsRect(hdc, prc, DCB_WINDOWMGR|DCB_ACCUMULATE ) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GetBoundsRectAlt(HDC hdc,LPRECT prc,UINT flags)
|
|
|
|
{
|
|
|
|
return NtGdiGetBoundsRect(hdc, prc, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
SetBoundsRectAlt(HDC hdc,LPRECT prc,UINT flags)
|
|
|
|
{
|
|
|
|
return NtGdiSetBoundsRect(hdc, prc, flags );
|
2014-10-28 21:09:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
GdiAddGlsRecord(HDC hdc,
|
|
|
|
DWORD unknown1,
|
|
|
|
LPCSTR unknown2,
|
|
|
|
LPRECT unknown3)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|