ReactOS  0.4.13-dev-985-gcbf4784
misc.c File Reference
#include <precomp.h>
#include <debug.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Classes

struct  _MARGINS
 

Macros

#define NDEBUG
 
#define ALPHABLEND_NONE   0
 
#define ALPHABLEND_BINARY   1
 
#define ALPHABLEND_FULL   2
 
#define TransparentBlt   GdiTransparentBlt
 
#define AlphaBlend   GdiAlphaBlend
 

Typedefs

typedef struct _MARGINS MARGINS
 
typedef struct _MARGINSPMARGINS
 

Enumerations

enum  SIZINGTYPE {
  ST_TRUESIZE = 0, ST_STRETCH = 1, ST_TILE = 2, ST_TRUESIZE = 0,
  ST_STRETCH = 1, ST_TILE = 2
}
 

Functions

BOOL WINAPI GdiFlush (VOID)
 
INT WINAPI Escape (_In_ HDC hdc, _In_ INT nEscape, _In_ INT cbInput, _In_ LPCSTR lpvInData, _Out_ LPVOID lpvOutData)
 
INT WINAPI ExtEscape (HDC hDC, int nEscape, int cbInput, LPCSTR lpszInData, int cbOutput, LPSTR lpszOutData)
 
INT WINAPI NamedEscape (HDC hdc, PWCHAR pDriver, INT iEsc, INT cjIn, LPSTR pjIn, INT cjOut, LPSTR pjOut)
 
int WINAPI DrawEscape (HDC hDC, INT nEscape, INT cbInput, LPCSTR lpszInData)
 
static 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 BOOL UXTHEME_Blt (HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, INT transparent, COLORREF transcolor)
 
static 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)
 
static HRESULT UXTHEME_DrawImageBackground (HDC hdc, HBITMAP bmpSrc, RECT *prcSrc, INT transparent, COLORREF transparentcolor, BOOL borderonly, int sizingtype, MARGINS *psm, RECT *pRect)
 
BOOL WINAPI GdiDrawStream (HDC dc, ULONG l, PGDI_DRAW_STREAM pDS)
 
BOOL WINAPI GdiValidateHandle (HGDIOBJ hobj)
 
HGDIOBJ WINAPI GdiFixUpHandle (HGDIOBJ hGdiObj)
 
PVOID WINAPI GdiQueryTable (VOID)
 
BOOL GdiGetHandleUserData (HGDIOBJ hGdiObj, DWORD ObjectType, PVOID *UserData)
 
PLDC FASTCALL GdiGetLDC (HDC hdc)
 
BOOL FASTCALL GdiSetLDC (HDC hdc, PVOID pvLDC)
 
VOID GdiSAPCallback (PLDC pldc)
 
DWORD WINAPI GdiSetBatchLimit (DWORD Limit)
 
DWORD WINAPI GdiGetBatchLimit (VOID)
 
VOID WINAPI GdiSetLastError (DWORD dwErrCode)
 
HGDIOBJ FASTCALL hGetPEBHandle (HANDLECACHETYPE Type, COLORREF cr)
 
BOOL WINAPI bMakePathNameW (LPWSTR lpBuffer, LPCWSTR lpFileName, LPWSTR *lpFilePart, DWORD unknown)
 
DEVMODEW *WINAPI GdiConvertToDevmodeW (const DEVMODEA *dmA)
 
BOOL WINAPI GdiRealizationInfo (HDC hdc, PREALIZATION_INFO pri)
 
VOID WINAPI GdiInitializeLanguagePack (DWORD InitParam)
 
BOOL WINAPI GdiAddGlsBounds (HDC hdc, LPRECT prc)
 
BOOL WINAPI GetBoundsRectAlt (HDC hdc, LPRECT prc, UINT flags)
 
BOOL WINAPI SetBoundsRectAlt (HDC hdc, LPRECT prc, UINT flags)
 
BOOL WINAPI GdiAddGlsRecord (HDC hdc, DWORD unknown1, LPCSTR unknown2, LPRECT unknown3)
 

Variables

PGDI_TABLE_ENTRY GdiHandleTable = NULL
 
PGDI_SHARED_HANDLE_TABLE GdiSharedHandleTable = NULL
 
HANDLE CurrentProcessId = NULL
 
DWORD GDI_BatchLimit = 1
 
PGDIHANDLECACHE GdiHandleCache
 

Macro Definition Documentation

◆ AlphaBlend

#define AlphaBlend   GdiAlphaBlend

Definition at line 293 of file misc.c.

◆ ALPHABLEND_BINARY

#define ALPHABLEND_BINARY   1

Definition at line 276 of file misc.c.

◆ ALPHABLEND_FULL

#define ALPHABLEND_FULL   2

Definition at line 277 of file misc.c.

◆ ALPHABLEND_NONE

#define ALPHABLEND_NONE   0

Definition at line 275 of file misc.c.

◆ NDEBUG

#define NDEBUG

Definition at line 30 of file misc.c.

◆ TransparentBlt

#define TransparentBlt   GdiTransparentBlt

Definition at line 292 of file misc.c.

Typedef Documentation

◆ MARGINS

◆ PMARGINS

Enumeration Type Documentation

◆ SIZINGTYPE

Enumerator
ST_TRUESIZE 
ST_STRETCH 
ST_TILE 
ST_TRUESIZE 
ST_STRETCH 
ST_TILE 

Definition at line 286 of file misc.c.

286  {
287  ST_TRUESIZE = 0,
288  ST_STRETCH = 1,
289  ST_TILE = 2,
290 };
Definition: misc.c:289

Function Documentation

◆ bMakePathNameW()

BOOL WINAPI bMakePathNameW ( LPWSTR  lpBuffer,
LPCWSTR  lpFileName,
LPWSTR lpFilePart,
DWORD  unknown 
)

Definition at line 956 of file misc.c.

957 {
960  return 0;
961 }
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114

◆ DrawEscape()

int WINAPI DrawEscape ( HDC  hDC,
INT  nEscape,
INT  cbInput,
LPCSTR  lpszInData 
)

Definition at line 249 of file misc.c.

253 {
255  return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData);
256 
258  {
259  PLDC pLDC = GdiGetLDC(hDC);
260  if ( pLDC )
261  {
262  if (pLDC->Flags & LDC_META_PRINT)
263  {
264 // if (nEscape != QUERYESCSUPPORT)
265 // return EMFDRV_WriteEscape(hDC, nEscape, cbInput, lpszInData, EMR_DRAWESCAPE);
266 
267  return NtGdiDrawEscape(hDC, nEscape, cbInput, (LPSTR) lpszInData);
268  }
269  }
271  }
272  return 0;
273 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
char * LPSTR
Definition: xmlstorage.h:182
ULONG Flags
Definition: ntgdihdl.h:278
__kernel_entry W32KAPI INT APIENTRY NtGdiDrawEscape(_In_ HDC hdc, _In_ INT iEsc, _In_ INT cjIn, _In_reads_bytes_opt_(cjIn) LPSTR pjIn)
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define LDC_META_PRINT
Definition: ntgdihdl.h:179
#define SetLastError(x)
Definition: compat.h:409
#define GDI_OBJECT_TYPE_METADC
Definition: gdi.h:57
Definition: ntgdihdl.h:275
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
static HDC hDC
Definition: 3dtext.c:33
PLDC FASTCALL GdiGetLDC(HDC hdc)
Definition: misc.c:785

◆ Escape()

INT WINAPI Escape ( _In_ HDC  hdc,
_In_ INT  nEscape,
_In_ INT  cbInput,
_In_ LPCSTR  lpvInData,
_Out_ LPVOID  lpvOutData 
)

Definition at line 55 of file misc.c.

61 {
62  INT retValue = SP_ERROR;
63  ULONG ulObjType;
64 
65  ulObjType = GDI_HANDLE_GET_TYPE(hdc);
66 
67  if (ulObjType == GDILoObjType_LO_METADC16_TYPE)
68  {
69  return METADC16_Escape(hdc, nEscape, cbInput, lpvInData, lpvOutData);
70  }
71 
72  switch (nEscape)
73  {
74  case ABORTDOC:
75  /* Note: Windows checks if the handle has any user data for the ABORTDOC command
76  * ReactOS copies this behavior to be compatible with windows 2003
77  */
78  if (GdiGetDcAttr(hdc) == NULL)
79  {
81  retValue = FALSE;
82  }
83  else
84  {
85  retValue = AbortDoc(hdc);
86  }
87  break;
88 
89  case DRAFTMODE:
90  case FLUSHOUTPUT:
91  case SETCOLORTABLE:
92  /* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE are outdated */
93  /* Note 2: Windows checks if the handle has any user data for the DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE commands
94  * ReactOS copies this behavior to be compatible with windows 2003
95  */
96  if (GdiGetDcAttr(hdc) == NULL)
97  {
99  }
100  retValue = FALSE;
101  break;
102 
103  case SETABORTPROC:
104  /* Note: Windows checks if the handle has any user data for the SETABORTPROC command
105  * ReactOS copies this behavior to be compatible with windows 2003
106  */
107  if (GdiGetDcAttr(hdc) == NULL)
108  {
110  retValue = FALSE;
111  }
112  retValue = SetAbortProc(hdc, (ABORTPROC)lpvInData);
113  break;
114 
115  case GETCOLORTABLE:
116  retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData);
117  if (!retValue)
118  {
119  retValue = SP_ERROR;
120  }
121  break;
122 
123  case ENDDOC:
124  /* Note: Windows checks if the handle has any user data for the ENDDOC command
125  * ReactOS copies this behavior to be compatible with windows 2003
126  */
127  if (GdiGetDcAttr(hdc) == NULL)
128  {
130  retValue = FALSE;
131  }
132  retValue = EndDoc(hdc);
133  break;
134 
135  case GETSCALINGFACTOR:
136  /* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */
137  if (ulObjType == GDI_OBJECT_TYPE_DC)
138  {
139  if (lpvOutData)
140  {
141  PPOINT ptr = (PPOINT)lpvOutData;
142  ptr->x = 0;
143  ptr->y = 0;
144  }
145  }
146  retValue = FALSE;
147  break;
148 
150  retValue = GetETM(hdc, (EXTTEXTMETRIC *)lpvOutData) != 0;
151  break;
152 
153  case STARTDOC:
154  {
155  DOCINFOA di;
156 
157  /* Note: Windows checks if the handle has any user data for the STARTDOC command
158  * ReactOS copies this behavior to be compatible with windows 2003
159  */
160  if (GdiGetDcAttr(hdc) == NULL)
161  {
163  retValue = FALSE;
164  }
165 
166  di.cbSize = sizeof(DOCINFOA);
167  di.lpszOutput = 0;
168  di.lpszDatatype = 0;
169  di.fwType = 0;
170  di.lpszDocName = lpvInData;
171 
172  /* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */
173  retValue = StartDocA(hdc, &di);
174 
175  /* Check if StartDocA failed */
176  if (retValue < 0)
177  {
178  {
179  retValue = GetLastError();
180 
181  /* Translate StartDocA error code to STARTDOC error code
182  * see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx
183  */
184  switch(retValue)
185  {
187  retValue = SP_OUTOFMEMORY;
188  break;
189 
191  retValue = SP_USERABORT;
192  break;
193 
194  case ERROR_DISK_FULL:
195  retValue = SP_OUTOFDISK;
196  break;
197 
198  default:
199  retValue = SP_ERROR;
200  break;
201  }
202  }
203  }
204  }
205  break;
206 
207  default:
210  }
211 
212  return retValue;
213 }
#define SP_ERROR
Definition: wingdi.h:317
#define ERROR_DISK_FULL
Definition: winerror.h:186
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define DRAFTMODE
Definition: wingdi.h:989
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
VOID WINAPI GdiSetLastError(DWORD dwErrCode)
Definition: misc.c:873
UINT WINAPI GetSystemPaletteEntries(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _Out_writes_opt_(cEntries) LPPALETTEENTRY pPalEntries)
int32_t INT
Definition: typedefs.h:56
#define SP_OUTOFMEMORY
Definition: wingdi.h:319
#define FLUSHOUTPUT
Definition: wingdi.h:988
INT WINAPI AbortDoc(_In_ HDC hdc)
static PVOID ptr
Definition: dispmode.c:27
#define ERROR_PRINT_CANCELLED
Definition: winerror.h:155
smooth NULL
Definition: ftsmooth.c:416
#define SETCOLORTABLE
Definition: wingdi.h:986
#define SETABORTPROC
Definition: wingdi.h:991
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
DWORD fwType
Definition: wingdi.h:1665
LPCSTR lpszOutput
Definition: wingdi.h:1663
BOOL(CALLBACK * ABORTPROC)(HDC, int)
Definition: wingdi.h:2896
#define ABORTDOC
Definition: wingdi.h:984
#define SetLastError(x)
Definition: compat.h:409
LPCSTR lpszDatatype
Definition: wingdi.h:1664
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
HDC hdc
Definition: main.c:9
#define SP_USERABORT
Definition: wingdi.h:320
#define SP_OUTOFDISK
Definition: wingdi.h:318
struct _DOCINFOA DOCINFOA
int cbSize
Definition: wingdi.h:1661
int WINAPI StartDocA(_In_ HDC, _In_ const DOCINFOA *)
#define GETEXTENDEDTEXTMETRICS
Definition: wingdi.h:1024
LPCSTR lpszDocName
Definition: wingdi.h:1662
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI GetETM(HDC hdc, EXTTEXTMETRIC *petm)
#define STARTDOC
Definition: wingdi.h:992
int WINAPI SetAbortProc(_In_ HDC, _In_ ABORTPROC)
unsigned int ULONG
Definition: retypes.h:1
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114
#define GETCOLORTABLE
Definition: wingdi.h:987
#define ENDDOC
Definition: wingdi.h:993
#define PPOINT
Definition: precomp.h:32
#define GETSCALINGFACTOR
Definition: wingdi.h:996
INT WINAPI METADC16_Escape(_In_ HDC hdc, _In_ INT nEscape, _In_ INT cbInput, _In_ LPCSTR lpvInData, _Out_ LPVOID lpvOutData)
Definition: rosglue.c:1284
int WINAPI EndDoc(_In_ HDC)

◆ ExtEscape()

INT WINAPI ExtEscape ( HDC  hDC,
int  nEscape,
int  cbInput,
LPCSTR  lpszInData,
int  cbOutput,
LPSTR  lpszOutData 
)

Definition at line 217 of file misc.c.

223 {
224  return NtGdiExtEscape(hDC, NULL, 0, nEscape, cbInput, (LPSTR)lpszInData, cbOutput, lpszOutData);
225 }
char * LPSTR
Definition: xmlstorage.h:182
smooth NULL
Definition: ftsmooth.c:416
__kernel_entry W32KAPI INT APIENTRY NtGdiExtEscape(_In_opt_ HDC hdc, _In_reads_opt_(cwcDriver) PWCHAR pDriver, _In_ INT cwcDriver, _In_ INT iEsc, _In_ INT cjIn, _In_reads_bytes_opt_(cjIn) LPSTR pjIn, _In_ INT cjOut, _Out_writes_bytes_opt_(cjOut) LPSTR pjOut)
static HDC hDC
Definition: 3dtext.c:33

◆ GdiAddGlsBounds()

BOOL WINAPI GdiAddGlsBounds ( HDC  hdc,
LPRECT  prc 
)

Definition at line 1056 of file misc.c.

1057 {
1059 }
#define TRUE
Definition: types.h:120
#define DCB_WINDOWMGR
Definition: ntgdityp.h:243
__kernel_entry W32KAPI DWORD APIENTRY NtGdiSetBoundsRect(_In_ HDC hdc, _In_ LPRECT prc, _In_ DWORD f)
HDC hdc
Definition: main.c:9
#define DCB_ACCUMULATE
Definition: wingdi.h:688
_Out_ LPRECT prc
Definition: ntgdi.h:1658

◆ GdiAddGlsRecord()

BOOL WINAPI GdiAddGlsRecord ( HDC  hdc,
DWORD  unknown1,
LPCSTR  unknown2,
LPRECT  unknown3 
)

Definition at line 1080 of file misc.c.

1084 {
1085  UNIMPLEMENTED;
1087  return 0;
1088 }
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114

◆ GdiConvertToDevmodeW()

DEVMODEW* WINAPI GdiConvertToDevmodeW ( const DEVMODEA dmA)

Definition at line 968 of file misc.c.

969 {
970  DEVMODEW *dmW;
971  WORD dmW_size, dmA_size;
972 
973  dmA_size = dmA->dmSize;
974 
975  /* this is the minimal dmSize that XP accepts */
976  if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
977  return NULL;
978 
979  if (dmA_size > sizeof(DEVMODEA))
980  dmA_size = sizeof(DEVMODEA);
981 
982  dmW_size = dmA_size + CCHDEVICENAME;
983  if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
984  dmW_size += CCHFORMNAME;
985 
986  dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
987  if (!dmW) return NULL;
988 
989  MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, CCHDEVICENAME,
991  /* copy slightly more, to avoid long computations */
992  memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
993 
994  if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
995  {
996  MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, CCHFORMNAME,
997  dmW->dmFormName, CCHFORMNAME);
998  if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
999  memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
1000  }
1001 
1002  if (dmA->dmDriverExtra)
1003  memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
1004 
1005  dmW->dmSize = dmW_size;
1006 
1007  return dmW;
1008 }
WORD dmSize
Definition: wingdi.h:1553
#define CP_ACP
Definition: compat.h:99
WORD dmDriverExtra
Definition: wingdi.h:1554
WCHAR dmFormName[CCHFORMNAME]
Definition: wingdi.h:1630
BYTE dmFormName[CCHFORMNAME]
Definition: wingdi.h:1578
WORD dmLogPixels
Definition: wingdi.h:1631
smooth NULL
Definition: ftsmooth.c:416
WORD dmSpecVersion
Definition: wingdi.h:1551
WORD dmSpecVersion
Definition: wingdi.h:1603
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WORD dmSize
Definition: wingdi.h:1605
unsigned short WORD
Definition: ntddk_ex.h:93
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1602
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CCHFORMNAME
Definition: wingdi.h:67
struct _devicemodeA DEVMODEA
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
WORD dmLogPixels
Definition: wingdi.h:1579
BYTE dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1550
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by ChangeDisplaySettingsExA(), CreateDCA(), CreateDesktopA(), CreateICA(), OpenPrinterA(), pagesetup_get_devmode(), and ResetDCA().

◆ GdiDrawStream()

BOOL WINAPI GdiDrawStream ( HDC  dc,
ULONG  l,
PGDI_DRAW_STREAM  pDS 
)

Definition at line 644 of file misc.c.

645 {
646  if (!pDS || l != sizeof(*pDS))
647  {
648  DPRINT1("GdiDrawStream: Invalid params\n");
649  return 0;
650  }
651 
652  if (pDS->signature != 0x44727753 ||
653  pDS->reserved != 0 ||
654  pDS->unknown1 != 1 ||
655  pDS->unknown2 != 9)
656  {
657  DPRINT1("GdiDrawStream: Got unknown pDS data\n");
658  return 0;
659  }
660 
661  {
663  INT transparent = 0;
664  int sizingtype;
665 
666  if (pDS->drawOption & DS_TRANSPARENTALPHA)
667  transparent = ALPHABLEND_FULL;
668  else if (pDS->drawOption & DS_TRANSPARENTCLR)
669  transparent = ALPHABLEND_BINARY;
670  else
671  transparent = ALPHABLEND_NONE;
672 
673  if (pDS->drawOption & DS_TILE)
674  sizingtype = ST_TILE;
675  else if (pDS->drawOption & DS_TRUESIZE)
676  sizingtype = ST_TRUESIZE;
677  else
678  sizingtype = ST_STRETCH;
679 
680  if (pDS->rcDest.right < pDS->rcDest.left || pDS->rcDest.bottom < pDS->rcDest.top)
681  return 0;
682 
683  if (sm.cxLeftWidth + sm.cxRightWidth > pDS->rcDest.right - pDS->rcDest.left)
684  {
685  sm.cxLeftWidth = sm.cxRightWidth = 0;
686  }
687 
688  if (sm.cyTopHeight + sm.cyBottomHeight > pDS->rcDest.bottom - pDS->rcDest.top)
689  {
690  sm.cyTopHeight = sm.cyBottomHeight = 0;
691  }
692 
694  pDS->hImage,
695  &pDS->rcSrc,
696  transparent,
697  pDS->crTransparent,
698  FALSE,
699  sizingtype,
700  &sm,
701  &pDS->rcDest);
702  }
703  return 0;
704 }
#define DS_TRANSPARENTALPHA
Definition: undocgdi.h:6
#define DS_TILE
Definition: undocgdi.h:5
#define ALPHABLEND_BINARY
Definition: misc.c:276
LONG top
Definition: windef.h:292
#define DS_TRANSPARENTCLR
Definition: undocgdi.h:7
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
Definition: misc.c:279
DWORD bottomSizingMargin
Definition: undocgdi.h:25
#define ALPHABLEND_FULL
Definition: misc.c:277
DWORD leftSizingMargin
Definition: undocgdi.h:22
int cyBottomHeight
Definition: misc.c:283
DWORD rightSizingMargin
Definition: undocgdi.h:23
DWORD topSizingMargin
Definition: undocgdi.h:24
#define ALPHABLEND_NONE
Definition: misc.c:275
r l[0]
Definition: byte_order.h:167
int cyTopHeight
Definition: misc.c:282
int cxLeftWidth
Definition: misc.c:280
Definition: misc.c:289
#define DPRINT1
Definition: precomp.h:8
#define DS_TRUESIZE
Definition: undocgdi.h:8
LONG bottom
Definition: windef.h:294
int cxRightWidth
Definition: misc.c:281
static HRESULT UXTHEME_DrawImageBackground(HDC hdc, HBITMAP bmpSrc, RECT *prcSrc, INT transparent, COLORREF transparentcolor, BOOL borderonly, int sizingtype, MARGINS *psm, RECT *pRect)
Definition: misc.c:457

Referenced by UXTHEME_DrawImageBackground(), and UXTHEME_DrawImageGlyph().

◆ GdiFixUpHandle()

HGDIOBJ WINAPI GdiFixUpHandle ( HGDIOBJ  hGdiObj)

Definition at line 734 of file misc.c.

735 {
737 
738  if (((ULONG_PTR)(hGdiObj)) & GDI_HANDLE_UPPER_MASK )
739  {
740  return hGdiObj;
741  }
742 
743  /* FIXME is this right ?? */
744 
746 
747  /* Rebuild handle for Object */
748  return hGdiObj = (HGDIOBJ)(((LONG_PTR)(hGdiObj)) | (Entry->Type << GDI_ENTRY_UPPER_SHIFT));
749 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
struct _Entry Entry
Definition: kefuncs.h:640
uint32_t ULONG_PTR
Definition: typedefs.h:63
PGDI_TABLE_ENTRY GdiHandleTable
Definition: misc.c:33
void * HGDIOBJ
Definition: windef.h:252
Definition: gdi.h:1
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GDI_ENTRY_UPPER_SHIFT
Definition: ntgdihdl.h:35
#define GDI_HANDLE_UPPER_MASK
Definition: gdi.h:22
base of all file and directory entries
Definition: entries.h:82

Referenced by GetObjectW(), and SelectObject().

◆ GdiFlush()

BOOL WINAPI GdiFlush ( VOID  )

Definition at line 44 of file misc.c.

45 {
46  NtGdiFlush();
47  return TRUE;
48 }
#define TRUE
Definition: types.h:120
__kernel_entry W32KAPI NTSTATUS APIENTRY NtGdiFlush(VOID)
Definition: gdibatch.c:471

Referenced by ddraw_surface7_ReleaseDC(), RdpClientUI::Display_PaintBitmap(), RdpClientUI::Display_RestoreDesktop(), RdpClientUI::Display_SaveDesktop(), DrawShadowText(), GdipFlush(), and GdiSetBatchLimit().

◆ GdiGetBatchLimit()

DWORD WINAPI GdiGetBatchLimit ( VOID  )

Definition at line 862 of file misc.c.

863 {
864  return GDI_BatchLimit;
865 }
DWORD GDI_BatchLimit
Definition: misc.c:36

◆ GdiGetHandleUserData()

BOOL GdiGetHandleUserData ( HGDIOBJ  hGdiObj,
DWORD  ObjectType,
PVOID UserData 
)

Definition at line 761 of file misc.c.

762 {
764 
765  /* Check if twe have the correct type */
766  if (GDI_HANDLE_GET_TYPE(hGdiObj) != ObjectType ||
769  {
770  return FALSE;
771  }
772 
773  /* Check if we are the owner */
774  if ((HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1) != CurrentProcessId)
775  {
776  return FALSE;
777  }
778 
779  *UserData = Entry->UserData;
780  return TRUE;
781 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
ObjectType
Definition: metafile.c:80
#define TRUE
Definition: types.h:120
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define GDI_ENTRY_BASETYPE_MASK
Definition: ntgdihdl.h:34
PGDI_TABLE_ENTRY GdiHandleTable
Definition: misc.c:33
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
HANDLE CurrentProcessId
Definition: misc.c:35
Definition: gdi.h:1
#define GDI_ENTRY_UPPER_SHIFT
Definition: ntgdihdl.h:35
#define GDI_HANDLE_TYPE_MASK
Definition: gdi.h:17
base of all file and directory entries
Definition: entries.h:82

Referenced by GdiGetDcAttr(), GdiGetRgnAttr(), and hGetPEBHandle().

◆ GdiGetLDC()

PLDC FASTCALL GdiGetLDC ( HDC  hdc)

Definition at line 785 of file misc.c.

786 {
787  PDC_ATTR pdcattr;
788 
789  /* Get the DC attribute */
790  pdcattr = GdiGetDcAttr(hdc);
791  if (pdcattr == NULL)
792  {
793  return NULL;
794  }
795 
796  /* Return the LDC pointer */
797  return pdcattr->pvLDC;
798 }
PVOID pvLDC
Definition: ntgdihdl.h:297
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9

Referenced by AbortDoc(), CancelDC(), DeleteDC(), DeleteObject(), DrawEscape(), EndDoc(), free_dc_ptr(), GDI_GetObjPtr(), GdiConvertAndCheckDC(), GdiIsMetaFileDC(), GdiIsMetaPrintDC(), GdiIsPlayMetafileDC(), get_dc_ptr(), IntEndPage(), METADC_Dispatch(), SetAbortProc(), SetBrushOrgEx(), SetColorSpace(), SetDIBitsToDevice(), SetMetaRgn(), StartDocW(), StartPage(), and StretchDIBits().

◆ GdiInitializeLanguagePack()

VOID WINAPI GdiInitializeLanguagePack ( DWORD  InitParam)

Definition at line 1026 of file misc.c.

1027 {
1028  /* Lpk function pointers to be passed to user32 */
1029 #if 0
1030  FARPROC hookfuncs[4];
1031 #endif
1032 
1033 #ifdef LANGPACK
1034  if (!LoadLPK(LPK_INIT)) // no lpk found!
1035 #endif
1036  return;
1037 
1038  /* Call InitializeLpkHooks with 4 procedure addresses
1039  loaded from lpk.dll but currently only one of them is currently implemented.
1040  Then InitializeLpkHooks (in user32) uses these to replace certain internal functions
1041  and ORs a DWORD being used also by ClientThreadSetup and calls
1042  NtUserOneParam with parameter 54 which is ONEPARAM_ROUTINE_REGISTERLPK
1043  which most likely changes the value of dwLpkEntryPoints in the
1044  PROCESSINFO struct */
1045 
1046 #if 0
1047  hookfuncs[0] = GetProcAddress(hLpk, "LpkPSMTextOut");
1048  InitializeLpkHooks(hookfuncs);
1049 #endif
1050 
1051  gbLpk = TRUE;
1052 }
#define TRUE
Definition: types.h:120
BOOL WINAPI LoadLPK(INT LpkFunctionID)
Definition: utils.c:423
VOID WINAPI InitializeLpkHooks(PUSER32_INTERN_INITIALIZEHOOKS)
HINSTANCE hLpk
Definition: utils.c:4
BOOL gbLpk
Definition: dllmain.c:11
#define LPK_INIT
Definition: gdi32p.h:81
#define GetProcAddress(x, y)
Definition: compat.h:410
int(* FARPROC)()
Definition: compat.h:28

◆ GdiQueryTable()

PVOID WINAPI GdiQueryTable ( VOID  )

Definition at line 756 of file misc.c.

757 {
758  return (PVOID)GdiHandleTable;
759 }
PGDI_TABLE_ENTRY GdiHandleTable
Definition: misc.c:33

◆ GdiRealizationInfo()

BOOL WINAPI GdiRealizationInfo ( HDC  hdc,
PREALIZATION_INFO  pri 
)

Definition at line 1015 of file misc.c.

1017 {
1018  // ATM we do not support local font data and Language Pack.
1019  return NtGdiGetRealizationInfo(hdc, pri, (HFONT) NULL);
1020 }
BOOL APIENTRY NtGdiGetRealizationInfo(IN HDC hdc, OUT PREALIZATION_INFO pri, IN HFONT hf)
Definition: font.c:1071
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)

◆ GdiSAPCallback()

VOID GdiSAPCallback ( PLDC  pldc)

Definition at line 819 of file misc.c.

820 {
821  DWORD Time, NewTime = GetTickCount();
822 
823  Time = NewTime - pldc->CallBackTick;
824 
825  if ( Time < SAPCALLBACKDELAY) return;
826 
827  pldc->CallBackTick = NewTime;
828 
829  if ( !pldc->pAbortProc(pldc->hDC, 0) )
830  {
831  CancelDC(pldc->hDC);
832  AbortDoc(pldc->hDC);
833  }
834 }
DWORD CallBackTick
Definition: ntgdihdl.h:283
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
BOOL WINAPI CancelDC(_In_ HDC hdc)
INT WINAPI AbortDoc(_In_ HDC hdc)
HDC hDC
Definition: ntgdihdl.h:277
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SAPCALLBACKDELAY
Definition: gdi32p.h:79
ABORTPROC pAbortProc
Definition: ntgdihdl.h:282
static PLARGE_INTEGER Time
Definition: time.c:105

Referenced by GdiConvertAndCheckDC(), IntEndPage(), SetDIBitsToDevice(), and StartDocW().

◆ GdiSetBatchLimit()

DWORD WINAPI GdiSetBatchLimit ( DWORD  Limit)

Definition at line 841 of file misc.c.

842 {
843  DWORD OldLimit = GDI_BatchLimit;
844 
845  if ( (!Limit) ||
846  (Limit >= GDI_BATCH_LIMIT))
847  {
848  return Limit;
849  }
850 
851  GdiFlush();
853  return OldLimit;
854 }
DWORD GDI_BatchLimit
Definition: misc.c:36
#define GDI_BATCH_LIMIT
Definition: ntgdityp.h:200
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI GdiFlush(VOID)
Definition: misc.c:44
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:328

◆ GdiSetLastError()

VOID WINAPI GdiSetLastError ( DWORD  dwErrCode)

Definition at line 873 of file misc.c.

874 {
875  NtCurrentTeb()->LastErrorValue = (ULONG) dwErrCode;
876 }
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
unsigned int ULONG
Definition: retypes.h:1

Referenced by CreateDIBitmap(), Escape(), GetDIBits(), GetTextFaceA(), GetTextFaceAliasW(), GetTextFaceW(), and TranslateCharsetInfo().

◆ GdiSetLDC()

BOOL FASTCALL GdiSetLDC ( HDC  hdc,
PVOID  pvLDC 
)

Definition at line 802 of file misc.c.

803 {
804  PDC_ATTR pdcattr;
805 
806  /* Get the DC attribute */
807  pdcattr = GdiGetDcAttr(hdc);
808  if (pdcattr == NULL)
809  {
810  return FALSE;
811  }
812 
813  /* Set the LDC pointer */
814  pdcattr->pvLDC = pvLDC;
815  return TRUE;
816 }
#define TRUE
Definition: types.h:120
PVOID pvLDC
Definition: ntgdihdl.h:297
FORCEINLINE PDC_ATTR GdiGetDcAttr(HDC hdc)
Definition: gdi32p.h:451
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9

Referenced by alloc_dc_ptr(), and free_dc_ptr().

◆ GdiValidateHandle()

BOOL WINAPI GdiValidateHandle ( HGDIOBJ  hobj)

Definition at line 712 of file misc.c.

713 {
715  if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 &&
717  GDI_HANDLE_GET_TYPE(hobj) )
718  {
719  HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
720  if(pid == NULL || pid == CurrentProcessId)
721  {
722  return TRUE;
723  }
724  }
725  return FALSE;
726 
727 }
#define GDI_HANDLE_GET_INDEX(h)
Definition: gdi.h:28
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define GDI_ENTRY_BASETYPE_MASK
Definition: ntgdihdl.h:34
PGDI_TABLE_ENTRY GdiHandleTable
Definition: misc.c:33
smooth NULL
Definition: ftsmooth.c:416
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
HANDLE CurrentProcessId
Definition: misc.c:35
PVOID HANDLE
Definition: typedefs.h:71
Definition: gdi.h:1
#define GDI_ENTRY_UPPER_SHIFT
Definition: ntgdihdl.h:35
#define GDI_HANDLE_TYPE_MASK
Definition: gdi.h:17
base of all file and directory entries
Definition: entries.h:82

Referenced by DeleteObject(), GetDIBits(), GetMenuItemInfo_common(), GetObjectType(), GetObjectW(), GetPixel(), GetStockObject(), InsertMenuItemA(), InsertMenuItemW(), MirrorRgnDC(), PolyPatBlt(), SelectObject(), SetMenuItemInfoA(), and SetMenuItemInfoW().

◆ GetBoundsRectAlt()

BOOL WINAPI GetBoundsRectAlt ( HDC  hdc,
LPRECT  prc,
UINT  flags 
)

Definition at line 1063 of file misc.c.

1064 {
1065  return NtGdiGetBoundsRect(hdc, prc, flags);
1066 }
GLbitfield flags
Definition: glext.h:7161
HDC hdc
Definition: main.c:9
DWORD APIENTRY NtGdiGetBoundsRect(IN HDC hdc, OUT LPRECT prc, IN DWORD flags)
Definition: dcutil.c:703
_Out_ LPRECT prc
Definition: ntgdi.h:1658

◆ hGetPEBHandle()

HGDIOBJ FASTCALL hGetPEBHandle ( HANDLECACHETYPE  Type,
COLORREF  cr 
)

Definition at line 880 of file misc.c.

881 {
882  int Number, Offset, MaxNum, GdiType;
883  HANDLE Lock;
884  HGDIOBJ Handle = NULL;
885 
887  NtCurrentTeb(),
888  NULL );
889 
890  if (Lock) return Handle;
891 
893 
894  if (Type == hctBrushHandle)
895  {
896  Offset = 0;
897  MaxNum = CACHE_BRUSH_ENTRIES;
898  GdiType = GDILoObjType_LO_BRUSH_TYPE;
899  }
900  else if (Type == hctPenHandle)
901  {
903  MaxNum = CACHE_PEN_ENTRIES;
904  GdiType = GDILoObjType_LO_PEN_TYPE;
905  }
906  else if (Type == hctRegionHandle)
907  {
909  MaxNum = CACHE_REGION_ENTRIES;
910  GdiType = GDILoObjType_LO_REGION_TYPE;
911  }
912  else // Font is not supported here.
913  {
914  return Handle;
915  }
916 
917  if ( Number && Number <= MaxNum )
918  {
919  PBRUSH_ATTR pBrush_Attr;
920  HGDIOBJ *hPtr;
921  hPtr = GdiHandleCache->Handle + Offset;
922  Handle = hPtr[Number - 1];
923 
924  if (GdiGetHandleUserData( Handle, GdiType, (PVOID) &pBrush_Attr))
925  {
926  if (pBrush_Attr->AttrFlags & ATTR_CACHED)
927  {
928  DPRINT("Get Handle! Type %d Count %lu PEB 0x%p\n", Type, GdiHandleCache->ulNumHandles[Type], NtCurrentTeb()->ProcessEnvironmentBlock);
929  pBrush_Attr->AttrFlags &= ~ATTR_CACHED;
930  hPtr[Number - 1] = NULL;
932  if ( Type == hctBrushHandle ) // Handle only brush.
933  {
934  if ( pBrush_Attr->lbColor != cr )
935  {
936  pBrush_Attr->lbColor = cr ;
937  pBrush_Attr->AttrFlags |= ATTR_NEW_COLOR;
938  }
939  }
940  }
941  }
942  else
943  {
944  Handle = NULL;
945  }
946  }
948  return Handle;
949 }
#define CACHE_PEN_ENTRIES
Definition: ntgdityp.h:338
Type
Definition: Type.h:6
#define CACHE_REGION_ENTRIES
Definition: ntgdityp.h:339
BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, DWORD ObjectType, PVOID *UserData)
Definition: misc.c:761
PGDIHANDLECACHE GdiHandleCache
Definition: dllmain.c:10
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_In_ HANDLE Handle
Definition: extypes.h:390
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define CACHE_BRUSH_ENTRIES
Definition: ntgdityp.h:337
ULONG ulNumHandles[GDI_CACHED_HANDLE_TYPES]
Definition: ntgdityp.h:353
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define ATTR_NEW_COLOR
Definition: ntgdihdl.h:208
static void(__cdecl *p__invalid_parameter)(const wchar_t *
HANDLE Handle[CACHE_BRUSH_ENTRIES+CACHE_PEN_ENTRIES+CACHE_REGION_ENTRIES+CACHE_LFONT_ENTRIES]
Definition: ntgdityp.h:354
#define ATTR_CACHED
Definition: ntgdihdl.h:206

Referenced by CreatePen(), and CreateRectRgn().

◆ NamedEscape()

INT WINAPI NamedEscape ( HDC  hdc,
PWCHAR  pDriver,
INT  iEsc,
INT  cjIn,
LPSTR  pjIn,
INT  cjOut,
LPSTR  pjOut 
)

Definition at line 229 of file misc.c.

236 {
237  /* FIXME metadc, metadc are done most in user mode, and we do not support it
238  * Windows 2000/XP/Vista ignore the current hdc, that are being pass and always set hdc to NULL
239  * when it calls to NtGdiExtEscape from NamedEscape
240  */
241  return NtGdiExtEscape(NULL,pDriver,wcslen(pDriver),iEsc,cjIn,pjIn,cjOut,pjOut);
242 }
_In_ ULONG _In_ ULONG _In_ ULONG cjOut
Definition: winddi.h:3583
smooth NULL
Definition: ftsmooth.c:416
__kernel_entry W32KAPI INT APIENTRY NtGdiExtEscape(_In_opt_ HDC hdc, _In_reads_opt_(cwcDriver) PWCHAR pDriver, _In_ INT cwcDriver, _In_ INT iEsc, _In_ INT cjIn, _In_reads_bytes_opt_(cjIn) LPSTR pjIn, _In_ INT cjOut, _Out_writes_bytes_opt_(cjOut) LPSTR pjOut)
_In_ ULONG iEsc
Definition: winddi.h:3529
_In_ ULONG _In_ CLIPOBJ _In_ RECTL _In_ ULONG cjIn
Definition: winddi.h:3529
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ SetBoundsRectAlt()

BOOL WINAPI SetBoundsRectAlt ( HDC  hdc,
LPRECT  prc,
UINT  flags 
)

Definition at line 1070 of file misc.c.

1071 {
1072  return NtGdiSetBoundsRect(hdc, prc, flags );
1073 }
__kernel_entry W32KAPI DWORD APIENTRY NtGdiSetBoundsRect(_In_ HDC hdc, _In_ LPRECT prc, _In_ DWORD f)
GLbitfield flags
Definition: glext.h:7161
HDC hdc
Definition: main.c:9
_Out_ LPRECT prc
Definition: ntgdi.h:1658

◆ UXTHEME_Blt()

static BOOL UXTHEME_Blt ( HDC  hdcDest,
int  nXOriginDest,
int  nYOriginDest,
int  nWidthDest,
int  nHeightDest,
HDC  hdcSrc,
int  nXOriginSrc,
int  nYOriginSrc,
INT  transparent,
COLORREF  transcolor 
)
inlinestatic

Definition at line 345 of file misc.c.

348 {
349  return UXTHEME_StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
350  hdcSrc, nXOriginSrc, nYOriginSrc, nWidthDest, nHeightDest,
351  transparent, transcolor);
352 }
static HDC hdcSrc
Definition: xlate.c:32
static 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)
Definition: misc.c:300

Referenced by UXTHEME_DrawImageBackground(), and UXTHEME_SizedBlt().

◆ UXTHEME_DrawImageBackground()

static HRESULT UXTHEME_DrawImageBackground ( HDC  hdc,
HBITMAP  bmpSrc,
RECT prcSrc,
INT  transparent,
COLORREF  transparentcolor,
BOOL  borderonly,
int  sizingtype,
MARGINS psm,
RECT pRect 
)
static

Definition at line 457 of file misc.c.

459 {
460  HRESULT hr = S_OK;
461  HBITMAP bmpSrcResized = NULL;
462  HGDIOBJ oldSrc;
463  HDC hdcSrc, hdcOrigSrc = NULL;
464  RECT rcDst;
465  POINT dstSize;
466  POINT srcSize;
467  RECT rcSrc;
468  MARGINS sm;
469 
470  rcDst = *pRect;
471  rcSrc = *prcSrc;
472  sm = *psm;
473 
475  if(!hdcSrc) {
477  return hr;
478  }
479  oldSrc = SelectObject(hdcSrc, bmpSrc);
480 
481  dstSize.x = rcDst.right-rcDst.left;
482  dstSize.y = rcDst.bottom-rcDst.top;
483  srcSize.x = rcSrc.right-rcSrc.left;
484  srcSize.y = rcSrc.bottom-rcSrc.top;
485 
486  if(sizingtype == ST_TRUESIZE) {
487  if(!UXTHEME_StretchBlt(hdc, rcDst.left, rcDst.top, dstSize.x, dstSize.y,
488  hdcSrc, rcSrc.left, rcSrc.top, srcSize.x, srcSize.y,
489  transparent, transparentcolor))
491  }
492  else {
493  HDC hdcDst = NULL;
494  POINT org;
495 
496  dstSize.x = abs(dstSize.x);
497  dstSize.y = abs(dstSize.y);
498 
499  /* Resize source image if destination smaller than margins */
500 #ifndef __REACTOS__
501  /* Revert Wine Commit 2b650fa as it breaks themed Explorer Toolbar Separators
502  FIXME: Revisit this when the bug is fixed. CORE-9636 and Wine Bug #38538 */
503  if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y || sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
504  if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y) {
505  sm.cyTopHeight = MulDiv(sm.cyTopHeight, dstSize.y, srcSize.y);
506  sm.cyBottomHeight = dstSize.y - sm.cyTopHeight;
507  srcSize.y = dstSize.y;
508  }
509 
510  if (sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
511  sm.cxLeftWidth = MulDiv(sm.cxLeftWidth, dstSize.x, srcSize.x);
512  sm.cxRightWidth = dstSize.x - sm.cxLeftWidth;
513  srcSize.x = dstSize.x;
514  }
515 
516  hdcOrigSrc = hdcSrc;
518  bmpSrcResized = CreateBitmap(srcSize.x, srcSize.y, 1, 32, NULL);
519  SelectObject(hdcSrc, bmpSrcResized);
520 
521  UXTHEME_StretchBlt(hdcSrc, 0, 0, srcSize.x, srcSize.y, hdcOrigSrc, rcSrc.left, rcSrc.top,
522  rcSrc.right - rcSrc.left, rcSrc.bottom - rcSrc.top, transparent, transparentcolor);
523 
524  rcSrc.left = 0;
525  rcSrc.top = 0;
526  rcSrc.right = srcSize.x;
527  rcSrc.bottom = srcSize.y;
528  }
529 #endif /* __REACTOS__ */
530 
531  hdcDst = hdc;
532  OffsetViewportOrgEx(hdcDst, rcDst.left, rcDst.top, &org);
533 
534  /* Upper left corner */
535  if(!UXTHEME_Blt(hdcDst, 0, 0, sm.cxLeftWidth, sm.cyTopHeight,
536  hdcSrc, rcSrc.left, rcSrc.top,
537  transparent, transparentcolor)) {
539  goto draw_error;
540  }
541  /* Upper right corner */
542  if(!UXTHEME_Blt (hdcDst, dstSize.x-sm.cxRightWidth, 0,
543  sm.cxRightWidth, sm.cyTopHeight,
544  hdcSrc, rcSrc.right-sm.cxRightWidth, rcSrc.top,
545  transparent, transparentcolor)) {
547  goto draw_error;
548  }
549  /* Lower left corner */
550  if(!UXTHEME_Blt (hdcDst, 0, dstSize.y-sm.cyBottomHeight,
552  hdcSrc, rcSrc.left, rcSrc.bottom-sm.cyBottomHeight,
553  transparent, transparentcolor)) {
555  goto draw_error;
556  }
557  /* Lower right corner */
558  if(!UXTHEME_Blt (hdcDst, dstSize.x-sm.cxRightWidth, dstSize.y-sm.cyBottomHeight,
560  hdcSrc, rcSrc.right-sm.cxRightWidth, rcSrc.bottom-sm.cyBottomHeight,
561  transparent, transparentcolor)) {
563  goto draw_error;
564  }
565 
566  if ((sizingtype == ST_STRETCH) || (sizingtype == ST_TILE)) {
567  int destCenterWidth = dstSize.x - (sm.cxLeftWidth + sm.cxRightWidth);
568  int srcCenterWidth = srcSize.x - (sm.cxLeftWidth + sm.cxRightWidth);
569  int destCenterHeight = dstSize.y - (sm.cyTopHeight + sm.cyBottomHeight);
570  int srcCenterHeight = srcSize.y - (sm.cyTopHeight + sm.cyBottomHeight);
571 
572  if(destCenterWidth > 0) {
573  /* Center top */
574  if(!UXTHEME_SizedBlt (hdcDst, sm.cxLeftWidth, 0,
575  destCenterWidth, sm.cyTopHeight,
576  hdcSrc, rcSrc.left+sm.cxLeftWidth, rcSrc.top,
577  srcCenterWidth, sm.cyTopHeight,
578  sizingtype, transparent, transparentcolor)) {
580  goto draw_error;
581  }
582  /* Center bottom */
583  if(!UXTHEME_SizedBlt (hdcDst, sm.cxLeftWidth, dstSize.y-sm.cyBottomHeight,
584  destCenterWidth, sm.cyBottomHeight,
585  hdcSrc, rcSrc.left+sm.cxLeftWidth, rcSrc.bottom-sm.cyBottomHeight,
586  srcCenterWidth, sm.cyBottomHeight,
587  sizingtype, transparent, transparentcolor)) {
589  goto draw_error;
590  }
591  }
592  if(destCenterHeight > 0) {
593  /* Left center */
594  if(!UXTHEME_SizedBlt (hdcDst, 0, sm.cyTopHeight,
595  sm.cxLeftWidth, destCenterHeight,
596  hdcSrc, rcSrc.left, rcSrc.top+sm.cyTopHeight,
597  sm.cxLeftWidth, srcCenterHeight,
598  sizingtype,
599  transparent, transparentcolor)) {
601  goto draw_error;
602  }
603  /* Right center */
604  if(!UXTHEME_SizedBlt (hdcDst, dstSize.x-sm.cxRightWidth, sm.cyTopHeight,
605  sm.cxRightWidth, destCenterHeight,
606  hdcSrc, rcSrc.right-sm.cxRightWidth, rcSrc.top+sm.cyTopHeight,
607  sm.cxRightWidth, srcCenterHeight,
608  sizingtype, transparent, transparentcolor)) {
610  goto draw_error;
611  }
612  }
613  if(destCenterHeight > 0 && destCenterWidth > 0) {
614  if(!borderonly) {
615  /* Center */
617  destCenterWidth, destCenterHeight,
618  hdcSrc, rcSrc.left+sm.cxLeftWidth, rcSrc.top+sm.cyTopHeight,
619  srcCenterWidth, srcCenterHeight,
620  sizingtype, transparent, transparentcolor)) {
622  goto draw_error;
623  }
624  }
625  }
626  }
627 
628 draw_error:
630  }
631  SelectObject(hdcSrc, oldSrc);
632  DeleteDC(hdcSrc);
633  if (bmpSrcResized) DeleteObject(bmpSrcResized);
634  if (hdcOrigSrc) DeleteDC(hdcOrigSrc);
635  *pRect = rcDst;
636  return hr;
637 }
#define abs(i)
Definition: fconv.c:206
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
long y
Definition: polytest.cpp:48
HRESULT hr
Definition: shlfolder.c:183
long x
Definition: polytest.cpp:48
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:292
BOOL WINAPI OffsetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:849
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
LONG left
Definition: windef.h:291
static HDC hdcSrc
Definition: xlate.c:32
LONG right
Definition: windef.h:293
Definition: misc.c:279
static char org[]
Definition: encode.c:7456
int cyBottomHeight
Definition: misc.c:283
static 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)
Definition: misc.c:300
smooth NULL
Definition: ftsmooth.c:416
int cyTopHeight
Definition: misc.c:282
LONG HRESULT
Definition: typedefs.h:77
int cxLeftWidth
Definition: misc.c:280
HDC hdc
Definition: main.c:9
#define S_OK
Definition: intsafe.h:59
static HDC hdcDst
Definition: xlate.c:32
BOOL WINAPI DeleteDC(_In_ HDC)
static BOOL UXTHEME_Blt(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, INT transparent, COLORREF transcolor)
Definition: misc.c:345
Definition: misc.c:289
LONG bottom
Definition: windef.h:294
int cxRightWidth
Definition: misc.c:281
static HBITMAP
Definition: button.c:44
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
static 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)
Definition: misc.c:359
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by GdiDrawStream().

◆ UXTHEME_SizedBlt()

static 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 
)
inlinestatic

Definition at line 359 of file misc.c.

365 {
366  if (sizingtype == ST_TILE)
367  {
368  HDC hdcTemp;
369  BOOL result = FALSE;
370 
371  if (!nWidthSrc || !nHeightSrc) return TRUE;
372 
373  /* For destination width/height less than or equal to source
374  width/height, do not bother with memory bitmap optimization */
375  if (nWidthSrc >= nWidthDst && nHeightSrc >= nHeightDst)
376  {
377  int bltWidth = min (nWidthDst, nWidthSrc);
378  int bltHeight = min (nHeightDst, nHeightSrc);
379 
380  return UXTHEME_Blt (hdcDst, nXOriginDst, nYOriginDst, bltWidth, bltHeight,
381  hdcSrc, nXOriginSrc, nYOriginSrc,
382  transparent, transcolor);
383  }
384 
385  /* Create a DC with a bitmap consisting of a tiling of the source
386  bitmap, with standard GDI functions. This is faster than an
387  iteration with UXTHEME_Blt(). */
388  hdcTemp = CreateCompatibleDC(hdcSrc);
389  if (hdcTemp != 0)
390  {
391  HBITMAP bitmapTemp;
392  HBITMAP bitmapOrig;
393  int nWidthTemp, nHeightTemp;
394  int xOfs, xRemaining;
395  int yOfs, yRemaining;
396  int growSize;
397 
398  /* Calculate temp dimensions of integer multiples of source dimensions */
399  nWidthTemp = ((nWidthDst + nWidthSrc - 1) / nWidthSrc) * nWidthSrc;
400  nHeightTemp = ((nHeightDst + nHeightSrc - 1) / nHeightSrc) * nHeightSrc;
401  bitmapTemp = CreateCompatibleBitmap(hdcSrc, nWidthTemp, nHeightTemp);
402  bitmapOrig = SelectObject(hdcTemp, bitmapTemp);
403 
404  /* Initial copy of bitmap */
405  BitBlt(hdcTemp, 0, 0, nWidthSrc, nHeightSrc, hdcSrc, nXOriginSrc, nYOriginSrc, SRCCOPY);
406 
407  /* Extend bitmap in the X direction. Growth of width is exponential */
408  xOfs = nWidthSrc;
409  xRemaining = nWidthTemp - nWidthSrc;
410  growSize = nWidthSrc;
411  while (xRemaining > 0)
412  {
413  growSize = min(growSize, xRemaining);
414  BitBlt(hdcTemp, xOfs, 0, growSize, nHeightSrc, hdcTemp, 0, 0, SRCCOPY);
415  xOfs += growSize;
416  xRemaining -= growSize;
417  growSize *= 2;
418  }
419 
420  /* Extend bitmap in the Y direction. Growth of height is exponential */
421  yOfs = nHeightSrc;
422  yRemaining = nHeightTemp - nHeightSrc;
423  growSize = nHeightSrc;
424  while (yRemaining > 0)
425  {
426  growSize = min(growSize, yRemaining);
427  BitBlt(hdcTemp, 0, yOfs, nWidthTemp, growSize, hdcTemp, 0, 0, SRCCOPY);
428  yOfs += growSize;
429  yRemaining -= growSize;
430  growSize *= 2;
431  }
432 
433  /* Use temporary hdc for source */
434  result = UXTHEME_Blt (hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
435  hdcTemp, 0, 0,
436  transparent, transcolor);
437 
438  SelectObject(hdcTemp, bitmapOrig);
439  DeleteObject(bitmapTemp);
440  }
441  DeleteDC(hdcTemp);
442  return result;
443  }
444  else
445  {
446  return UXTHEME_StretchBlt (hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
447  hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
448  transparent, transcolor);
449  }
450 }
#define TRUE
Definition: types.h:120
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HDC hdcSrc
Definition: xlate.c:32
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:410
unsigned int BOOL
Definition: ntddk_ex.h:94
static 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)
Definition: misc.c:300
static HDC hdcDst
Definition: xlate.c:32
BOOL WINAPI DeleteDC(_In_ HDC)
static BOOL UXTHEME_Blt(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, INT transparent, COLORREF transcolor)
Definition: misc.c:345
#define min(a, b)
Definition: monoChain.cc:55
Definition: misc.c:289
static HBITMAP
Definition: button.c:44
GLuint64EXT * result
Definition: glext.h:11304
#define SRCCOPY
Definition: wingdi.h:332

Referenced by UXTHEME_DrawImageBackground().

◆ UXTHEME_StretchBlt()

static 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 
)
inlinestatic

Definition at line 300 of file misc.c.

303 {
304  static const BLENDFUNCTION blendFunc =
305  {
306  AC_SRC_OVER, /* BlendOp */
307  0, /* BlendFlag */
308  255, /* SourceConstantAlpha */
309  AC_SRC_ALPHA /* AlphaFormat */
310  };
311 
312  BOOL ret = TRUE;
313  int old_stretch_mode;
314  POINT old_brush_org;
315 
316  old_stretch_mode = SetStretchBltMode(hdcDst, HALFTONE);
317  SetBrushOrgEx(hdcDst, nXOriginDst, nYOriginDst, &old_brush_org);
318 
319  if (transparent == ALPHABLEND_BINARY) {
320  /* Ensure we don't pass any negative values to TransparentBlt */
321  ret = TransparentBlt(hdcDst, nXOriginDst, nYOriginDst, abs(nWidthDst), abs(nHeightDst),
322  hdcSrc, nXOriginSrc, nYOriginSrc, abs(nWidthSrc), abs(nHeightSrc),
323  transcolor);
324  } else if ((transparent == ALPHABLEND_NONE) ||
325  !AlphaBlend(hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
326  hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
327  blendFunc))
328  {
329  ret = StretchBlt(hdcDst, nXOriginDst, nYOriginDst, nWidthDst, nHeightDst,
330  hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
331  SRCCOPY);
332  }
333 
334  SetBrushOrgEx(hdcDst, old_brush_org.x, old_brush_org.y, NULL);
335  SetStretchBltMode(hdcDst, old_stretch_mode);
336 
337  return ret;
338 }
#define abs(i)
Definition: fconv.c:206
#define TransparentBlt
Definition: misc.c:292
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define ALPHABLEND_BINARY
Definition: misc.c:276
#define HALFTONE
Definition: wingdi.h:954
static HDC hdcSrc
Definition: xlate.c:32
#define AC_SRC_ALPHA
Definition: alphablend.c:9
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetBrushOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define ALPHABLEND_NONE
Definition: misc.c:275
int ret
#define AC_SRC_OVER
Definition: wingdi.h:1358
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1324
static HDC hdcDst
Definition: xlate.c:32
#define AlphaBlend
Definition: misc.c:293
#define SRCCOPY
Definition: wingdi.h:332

Referenced by UXTHEME_Blt(), UXTHEME_DrawImageBackground(), and UXTHEME_SizedBlt().

Variable Documentation

◆ CurrentProcessId

HANDLE CurrentProcessId = NULL

Definition at line 35 of file misc.c.

Referenced by GdiGetHandleUserData(), GdiProcessSetup(), and GdiValidateHandle().

◆ GDI_BatchLimit

DWORD GDI_BatchLimit = 1

Definition at line 36 of file misc.c.

Referenced by GdiAllocBatchCommand(), GdiGetBatchLimit(), GdiProcessSetup(), and GdiSetBatchLimit().

◆ GdiHandleCache

PGDIHANDLECACHE GdiHandleCache

Definition at line 10 of file dllmain.c.

Referenced by GdiProcessSetup(), and hGetPEBHandle().

◆ GdiHandleTable

PGDI_TABLE_ENTRY GdiHandleTable = NULL

Definition at line 33 of file misc.c.

Referenced by GdiFixUpHandle(), GdiGetHandleUserData(), GdiQueryTable(), and GdiValidateHandle().

◆ GdiSharedHandleTable

PGDI_SHARED_HANDLE_TABLE GdiSharedHandleTable = NULL

Definition at line 34 of file misc.c.

Referenced by DdQueryDisplaySettingsUniqueness(), GdiProcessSetup(), and STRUCT().