1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS System Libraries 4 * FILE: win32ss/gdi/gdi32/include/gdi32p.h 5 * PURPOSE: User-Mode Win32 GDI Library Private Header 6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net) 7 */ 8 9 #pragma once 10 11 /* DATA **********************************************************************/ 12 13 extern PGDI_TABLE_ENTRY GdiHandleTable; 14 extern PGDI_SHARED_HANDLE_TABLE GdiSharedHandleTable; 15 extern HANDLE hProcessHeap; 16 extern HANDLE CurrentProcessId; 17 extern DWORD GDI_BatchLimit; 18 extern PDEVCAPS GdiDevCaps; 19 extern BOOL gbLpk; // Global bool LanguagePack 20 extern HANDLE ghSpooler; 21 extern RTL_CRITICAL_SECTION semLocal; 22 23 typedef INT 24 (CALLBACK* EMFPLAYPROC)( 25 HDC hdc, 26 INT iFunction, 27 HANDLE hPageQuery 28 ); 29 30 typedef BOOL 31 (WINAPI* LPKETO)( 32 HDC hdc, 33 int x, 34 int y, 35 UINT fuOptions, 36 const RECT *lprc, 37 LPCWSTR lpString, 38 UINT uCount, 39 const INT *lpDx, 40 INT unknown 41 ); 42 43 typedef DWORD 44 (WINAPI* LPKGCP)( 45 HDC hdc, 46 LPCWSTR lpString, 47 INT uCount, 48 INT nMaxExtent, 49 LPGCP_RESULTSW lpResults, 50 DWORD dwFlags, 51 DWORD dwUnused 52 ); 53 54 typedef BOOL 55 (WINAPI* LPKGTEP)( 56 HDC hdc, 57 LPCWSTR lpString, 58 INT cString, 59 INT nMaxExtent, 60 LPINT lpnFit, 61 LPINT lpnDx, 62 LPSIZE lpSize, 63 DWORD dwUnused, 64 int unknown 65 ); 66 67 extern HINSTANCE hLpk; 68 extern LPKETO LpkExtTextOut; 69 extern LPKGCP LpkGetCharacterPlacement; 70 extern LPKGTEP LpkGetTextExtentExPoint; 71 72 /* DEFINES *******************************************************************/ 73 74 #define HANDLE_LIST_INC 20 75 76 #define METAFILE_MEMORY 1 77 #define METAFILE_DISK 2 78 79 #define SAPCALLBACKDELAY 244 80 81 #define LPK_INIT 1 82 #define LPK_ETO 2 83 #define LPK_GCP 3 84 #define LPK_GTEP 4 85 86 /* MACRO ********************************************************************/ 87 88 #define ROP_USES_SOURCE(Rop) (((Rop) << 2 ^ Rop) & 0xCC0000) 89 #define RCAST(_Type, _Value) (*((_Type*)&_Value)) 90 91 92 /* TYPES *********************************************************************/ 93 94 // Based on wmfapi.h and Wine. 95 typedef struct tagMETAFILEDC 96 { 97 PVOID pvMetaBuffer; 98 HANDLE hFile; 99 DWORD Size; 100 DWORD dwWritten; 101 METAHEADER mh; 102 WORD reserved; 103 HLOCAL MFObjList; 104 HPEN hPen; 105 HBRUSH hBrush; 106 HDC hDc; 107 HGDIOBJ hMetaDc; 108 HPALETTE hPalette; 109 HFONT hFont; 110 HBITMAP hBitmap; 111 HRGN hRegion; 112 HGDIOBJ hMetafile; 113 HGDIOBJ hMemDc; 114 HPEN hExtPen; 115 HGDIOBJ hEnhMetaDc; 116 HGDIOBJ hEnhMetaFile; 117 HCOLORSPACE hColorSpace; 118 WCHAR Filename[MAX_PATH+2]; 119 } METAFILEDC,*PMETAFILEDC; 120 121 // Metafile Entry handle 122 typedef struct tagMF_ENTRY 123 { 124 LIST_ENTRY List; 125 HGDIOBJ hmDC; // Handle return from NtGdiCreateClientObj. 126 PMETAFILEDC pmfDC; 127 } MF_ENTRY, *PMF_ENTRY; 128 129 typedef struct tagENHMETAFILE 130 { 131 PVOID pvMetaBuffer; 132 HANDLE hFile; /* Handle for disk based MetaFile */ 133 DWORD Size; 134 INT iType; 135 PENHMETAHEADER emf; 136 UINT handles_size, cur_handles; 137 HGDIOBJ *handles; 138 INT horzres, vertres; 139 INT horzsize, vertsize; 140 INT logpixelsx, logpixelsy; 141 INT bitspixel; 142 INT textcaps; 143 INT rastercaps; 144 INT technology; 145 INT planes; 146 } ENHMETAFILE,*PENHMETAFILE; 147 148 149 #define PDEV_UMPD_ID 0xFEDCBA98 150 // UMPDEV flags 151 #define UMPDEV_NO_ESCAPE 0x0002 152 #define UMPDEV_SUPPORT_ESCAPE 0x0004 153 typedef struct _UMPDEV 154 { 155 DWORD_PTR Sig; // Init with PDEV_UMPD_ID 156 struct _UMPDEV *pumpdNext; 157 PDRIVER_INFO_5W pdi5Info; 158 HMODULE hModule; 159 DWORD dwFlags; 160 DWORD dwDriverAttributes; 161 DWORD dwConfigVersion; // Number of times the configuration 162 // file for this driver has been upgraded 163 // or downgraded since the last spooler restart. 164 DWORD dwDriverCount; // After init should be 2 165 DWORD WOW64_UMPDev; 166 DWORD WOW64_hMod; 167 DWORD Unknown; 168 PVOID apfn[INDEX_LAST]; // Print Driver pfn 169 } UMPDEV, *PUMPDEV; 170 171 #define LOCALFONT_COUNT 10 172 typedef struct _LOCALFONT 173 { 174 FONT_ATTR lfa[LOCALFONT_COUNT]; 175 } LOCALFONT, *PLOCALFONT; 176 177 // sdk/winspool.h 178 typedef BOOL (WINAPI *ABORTPRINTER) (HANDLE); 179 typedef BOOL (WINAPI *CLOSEPRINTER) (HANDLE); 180 typedef BOOL (WINAPI *CLOSESPOOLFILEHANDLE) (HANDLE, HANDLE); // W2k8 181 typedef HANDLE (WINAPI *COMMITSPOOLDATA) (HANDLE,HANDLE,DWORD); // W2k8 182 typedef LONG (WINAPI *DOCUMENTPROPERTIESW) (HWND,HANDLE,LPWSTR,PDEVMODEW,PDEVMODEW,DWORD); 183 typedef BOOL (WINAPI *ENDDOCPRINTER) (HANDLE); 184 typedef BOOL (WINAPI *ENDPAGEPRINTER) (HANDLE); 185 typedef BOOL (WINAPI *GETPRINTERW) (HANDLE,DWORD,LPBYTE,DWORD,LPDWORD); 186 typedef BOOL (WINAPI *GETPRINTERDRIVERW) (HANDLE,LPWSTR,DWORD,LPBYTE,DWORD,LPDWORD); 187 typedef HANDLE (WINAPI *GETSPOOLFILEHANDLE) (HANDLE); // W2k8 188 typedef BOOL (WINAPI *ISVALIDDEVMODEW) (PDEVMODEW,size_t); 189 typedef BOOL (WINAPI *OPENPRINTERW) (LPWSTR,PHANDLE,LPPRINTER_DEFAULTSW); 190 typedef BOOL (WINAPI *READPRINTER) (HANDLE,PVOID,DWORD,PDWORD); 191 typedef BOOL (WINAPI *RESETPRINTERW) (HANDLE,LPPRINTER_DEFAULTSW); 192 typedef LPWSTR (WINAPI *STARTDOCDLGW) (HANDLE,DOCINFOW *); 193 typedef DWORD (WINAPI *STARTDOCPRINTERW) (HANDLE,DWORD,PBYTE); 194 typedef BOOL (WINAPI *STARTPAGEPRINTER) (HANDLE); 195 // ddk/winsplp.h 196 typedef BOOL (WINAPI *SEEKPRINTER) (HANDLE,LARGE_INTEGER,PLARGE_INTEGER,DWORD,BOOL); 197 typedef BOOL (WINAPI *SPLREADPRINTER) (HANDLE,LPBYTE *,DWORD); 198 // Same as ddk/winsplp.h DriverUnloadComplete? 199 typedef BOOL (WINAPI *SPLDRIVERUNLOADCOMPLETE) (LPWSTR); 200 // Driver support: 201 // DrvDocumentEvent api/winddiui.h not W2k8 DocumentEventAW 202 typedef INT (WINAPI *DOCUMENTEVENT) (HANDLE,HDC,INT,ULONG,PVOID,ULONG,PVOID); 203 // DrvQueryColorProfile 204 typedef BOOL (WINAPI *QUERYCOLORPROFILE) (HANDLE,PDEVMODEW,ULONG,VOID*,ULONG,FLONG); 205 // Unknown: 206 typedef DWORD (WINAPI *QUERYSPOOLMODE) (HANDLE,DWORD,DWORD); 207 typedef DWORD (WINAPI *QUERYREMOTEFONTS) (DWORD,DWORD,DWORD); 208 209 extern CLOSEPRINTER fpClosePrinter; 210 extern OPENPRINTERW fpOpenPrinterW; 211 212 /* FUNCTIONS *****************************************************************/ 213 214 PVOID 215 HEAP_alloc(DWORD len); 216 217 NTSTATUS 218 HEAP_strdupA2W( 219 LPWSTR* ppszW, 220 LPCSTR lpszA 221 ); 222 223 VOID 224 HEAP_free(LPVOID memory); 225 226 VOID 227 FASTCALL 228 FONT_TextMetricWToA( 229 const TEXTMETRICW *ptmW, 230 LPTEXTMETRICA ptmA 231 ); 232 233 VOID 234 FASTCALL 235 NewTextMetricW2A( 236 NEWTEXTMETRICA *tma, 237 NEWTEXTMETRICW *tmw 238 ); 239 240 VOID 241 FASTCALL 242 NewTextMetricExW2A( 243 NEWTEXTMETRICEXA *tma, 244 NEWTEXTMETRICEXW *tmw 245 ); 246 247 BOOL 248 FASTCALL 249 DeleteRegion( HRGN ); 250 251 BOOL 252 WINAPI 253 GdiValidateHandle(HGDIOBJ); 254 255 BOOL 256 GdiGetHandleUserData( 257 HGDIOBJ hGdiObj, 258 DWORD ObjectType, 259 PVOID *UserData 260 ); 261 262 PLDC 263 FASTCALL 264 GdiGetLDC(HDC hDC); 265 266 BOOL 267 FASTCALL 268 GdiSetLDC(HDC hdc, PVOID pvLDC); 269 270 HGDIOBJ 271 WINAPI 272 GdiFixUpHandle(HGDIOBJ hGO); 273 274 BOOL 275 WINAPI 276 CalculateColorTableSize( 277 CONST BITMAPINFOHEADER *BitmapInfoHeader, 278 UINT *ColorSpec, 279 UINT *ColorTableSize 280 ); 281 282 LPBITMAPINFO 283 WINAPI 284 ConvertBitmapInfo( 285 CONST BITMAPINFO *BitmapInfo, 286 UINT ColorSpec, 287 UINT *BitmapInfoSize, 288 BOOL FollowedByData 289 ); 290 291 DWORD 292 WINAPI 293 GetAndSetDCDWord( 294 _In_ HDC hdc, 295 _In_ UINT u, 296 _In_ DWORD dwIn, 297 _In_ ULONG ulMFId, 298 _In_ USHORT usMF16Id, 299 _In_ DWORD dwError); 300 301 DWORD 302 WINAPI 303 GetDCDWord( 304 _In_ HDC hdc, 305 _In_ UINT u, 306 _In_ DWORD dwError); 307 308 HGDIOBJ 309 WINAPI 310 GetDCObject( HDC, INT); 311 312 VOID 313 NTAPI 314 LogFontA2W( 315 LPLOGFONTW pW, 316 CONST LOGFONTA *pA 317 ); 318 319 VOID 320 NTAPI 321 LogFontW2A( 322 LPLOGFONTA pA, 323 CONST LOGFONTW *pW 324 ); 325 326 VOID 327 WINAPI 328 EnumLogFontExW2A( 329 LPENUMLOGFONTEXA fontA, 330 CONST ENUMLOGFONTEXW *fontW ); 331 332 BOOL 333 WINAPI 334 LoadLPK( 335 INT LpkFunctionID 336 ); 337 338 VOID 339 WINAPI 340 GdiInitializeLanguagePack( 341 _In_ DWORD InitParam); 342 343 VOID 344 WINAPI 345 InitializeLpkHooks( 346 _In_ FARPROC *hookfuncs); 347 348 BOOL 349 WINAPI 350 GetETM(HDC hdc, 351 EXTTEXTMETRIC *petm); 352 353 /* FIXME: Put in some public header */ 354 UINT 355 WINAPI 356 UserRealizePalette(HDC hDC); 357 358 int 359 WINAPI 360 GdiAddFontResourceW(LPCWSTR lpszFilename,FLONG fl,DESIGNVECTOR *pdv); 361 362 VOID 363 WINAPI 364 GdiSetLastError( DWORD dwErrCode ); 365 366 DWORD WINAPI GdiGetCodePage(HDC); 367 368 int 369 WINAPI 370 GdiGetBitmapBitsSize(BITMAPINFO *lpbmi); 371 372 VOID GdiSAPCallback(PLDC pldc); 373 HGDIOBJ FASTCALL hGetPEBHandle(HANDLECACHETYPE,COLORREF); 374 375 int FASTCALL DocumentEventEx(PVOID,HANDLE,HDC,int,ULONG,PVOID,ULONG,PVOID); 376 BOOL FASTCALL EndPagePrinterEx(PVOID,HANDLE); 377 BOOL FASTCALL LoadTheSpoolerDrv(VOID); 378 379 FORCEINLINE 380 PVOID 381 GdiAllocBatchCommand( 382 HDC hdc, 383 USHORT Cmd) 384 { 385 PTEB pTeb; 386 USHORT cjSize; 387 PGDIBATCHHDR pHdr; 388 389 /* Get a pointer to the TEB */ 390 pTeb = NtCurrentTeb(); 391 392 /* Check if we have a valid environment */ 393 if (!pTeb || !pTeb->Win32ThreadInfo) return NULL; 394 395 /* Get the size of the entry */ 396 if (Cmd == GdiBCPatBlt) cjSize = sizeof(GDIBSPATBLT); 397 else if (Cmd == GdiBCPolyPatBlt) cjSize = sizeof(GDIBSPPATBLT); 398 else if (Cmd == GdiBCTextOut) cjSize = sizeof(GDIBSTEXTOUT); 399 else if (Cmd == GdiBCExtTextOut) cjSize = sizeof(GDIBSEXTTEXTOUT); 400 else if (Cmd == GdiBCSetBrushOrg) cjSize = sizeof(GDIBSSETBRHORG); 401 else if (Cmd == GdiBCExtSelClipRgn) cjSize = sizeof(GDIBSEXTSELCLPRGN); 402 else if (Cmd == GdiBCSelObj) cjSize = sizeof(GDIBSOBJECT); 403 else if (Cmd == GdiBCDelRgn) cjSize = sizeof(GDIBSOBJECT); 404 else if (Cmd == GdiBCDelObj) cjSize = sizeof(GDIBSOBJECT); 405 else cjSize = 0; 406 407 /* Unsupported operation */ 408 if (cjSize == 0) return NULL; 409 410 /* Do we use a DC? */ 411 if (hdc) 412 { 413 /* If the batch DC is NULL, we set this one as the new one */ 414 if (!pTeb->GdiTebBatch.HDC) pTeb->GdiTebBatch.HDC = hdc; 415 416 /* If not, check if the batch DC equal to our DC */ 417 else if (pTeb->GdiTebBatch.HDC != hdc) return NULL; 418 } 419 420 /* Check if the buffer is full */ 421 if ((pTeb->GdiBatchCount >= GDI_BatchLimit) || 422 ((pTeb->GdiTebBatch.Offset + cjSize) > GDIBATCHBUFSIZE)) 423 { 424 /* Call win32k, the kernel will call NtGdiFlushUserBatch to flush 425 the current batch */ 426 NtGdiFlush(); 427 428 // If Flushed, lose the hDC for this batch job! See CORE-15839. 429 if (hdc) 430 { 431 if (!pTeb->GdiTebBatch.HDC) pTeb->GdiTebBatch.HDC = hdc; 432 } 433 } 434 435 /* Get the head of the entry */ 436 pHdr = (PVOID)((PUCHAR)pTeb->GdiTebBatch.Buffer + pTeb->GdiTebBatch.Offset); 437 438 /* Update Offset and batch count */ 439 pTeb->GdiTebBatch.Offset += cjSize; 440 pTeb->GdiBatchCount++; 441 442 /* Fill in the core fields */ 443 pHdr->Cmd = Cmd; 444 pHdr->Size = cjSize; 445 446 return pHdr; 447 } 448 449 FORCEINLINE 450 PDC_ATTR 451 GdiGetDcAttr(HDC hdc) 452 { 453 GDILOOBJTYPE eDcObjType; 454 PDC_ATTR pdcattr; 455 456 /* Check DC object type */ 457 eDcObjType = GDI_HANDLE_GET_TYPE(hdc); 458 if ((eDcObjType != GDILoObjType_LO_DC_TYPE) && 459 (eDcObjType != GDILoObjType_LO_ALTDC_TYPE)) 460 { 461 return NULL; 462 } 463 464 /* Get the DC attribute */ 465 if (!GdiGetHandleUserData((HGDIOBJ)hdc, eDcObjType, (PVOID*)&pdcattr)) 466 { 467 return NULL; 468 } 469 470 return pdcattr; 471 } 472 473 FORCEINLINE 474 PRGN_ATTR 475 GdiGetRgnAttr(HRGN hrgn) 476 { 477 PRGN_ATTR prgnattr; 478 479 /* Get the region attribute */ 480 if (!GdiGetHandleUserData(hrgn, GDILoObjType_LO_REGION_TYPE, (PVOID*)&prgnattr)) 481 { 482 return NULL; 483 } 484 485 return prgnattr; 486 } 487 488 #ifdef _M_IX86 489 FLOATL FASTCALL EFtoF(EFLOAT_S * efp); 490 #define FOtoF(pfo) EFtoF((EFLOAT_S*)pfo) 491 #else 492 #define FOtoF(pfo) (*(pfo)) 493 #endif 494 495 /* This is an inlined version of lrintf. */ 496 FORCEINLINE 497 int 498 _lrintf(float f) 499 { 500 #if defined(_M_IX86) && defined(__GNUC__) 501 int result; 502 __asm__ __volatile__ ("fistpl %0" : "=m" (result) : "t" (f) : "st"); 503 return result; 504 #elif defined(_M_IX86) && defined(_MSC_VER) 505 int result; 506 __asm 507 { 508 fld f; 509 fistp result; 510 } 511 #else 512 /* slow, but portable */ 513 return (int)(f >= 0 ? f+0.5 : f-0.5); 514 #endif 515 } 516 517 HBRUSH 518 WINAPI 519 GdiSelectBrush( 520 _In_ HDC hdc, 521 _In_ HBRUSH hbr); 522 523 HPEN 524 WINAPI 525 GdiSelectPen( 526 _In_ HDC hdc, 527 _In_ HPEN hpen); 528 529 HFONT 530 WINAPI 531 GdiSelectFont( 532 _In_ HDC hdc, 533 _In_ HFONT hfont); 534 535 HGDIOBJ 536 WINAPI 537 GdiCreateClientObj( 538 _In_ PVOID pvObject, 539 _In_ GDILOOBJTYPE eObjType); 540 541 PVOID 542 WINAPI 543 GdiDeleteClientObj( 544 _In_ HGDIOBJ hobj); 545 546 BOOL 547 WINAPI 548 GdiCreateClientObjLink( 549 _In_ HGDIOBJ hobj, 550 _In_ PVOID pvObject); 551 552 PVOID 553 WINAPI 554 GdiGetClientObjLink( 555 _In_ HGDIOBJ hobj); 556 557 PVOID 558 WINAPI 559 GdiRemoveClientObjLink( 560 _In_ HGDIOBJ hobj); 561 562 extern ULONG gcClientObj; 563 564 VOID 565 WINAPI 566 METADC_RosGlueDeleteObject(HGDIOBJ hobj); 567 568 BOOL 569 WINAPI 570 METADC_RosGlueDeleteDC( 571 _In_ HDC hdc); 572 573 BOOL METADC_DeleteDC( HDC hdc ); 574 575 BOOL 576 WINAPI 577 METADC_ExtTextOutW( 578 HDC hdc, 579 INT x, 580 INT y, 581 UINT fuOptions, 582 const RECT *lprc, 583 LPCWSTR lpString, 584 UINT cchString, 585 const INT *lpDx); 586 587 588 /* The following METADC_* functions follow this pattern: */ 589 #define HANDLE_METADC(_RetType, _Func, dwError, hdc, ...) \ 590 if (GDI_HANDLE_GET_TYPE(hdc) != GDILoObjType_LO_DC_TYPE) \ 591 { \ 592 if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE) \ 593 { \ 594 return (_RetType)METADC_##_Func(hdc, __VA_ARGS__); \ 595 } \ 596 else \ 597 { \ 598 PLDC pLDC = GdiGetLDC(hdc); \ 599 _RetType _Ret = dwError; \ 600 if ( !pLDC ) \ 601 { \ 602 SetLastError(ERROR_INVALID_HANDLE); \ 603 return (_RetType)_Ret; \ 604 } \ 605 if ( pLDC->iType == LDC_EMFLDC && !(EMFDC_##_Func(pLDC, __VA_ARGS__)) ) \ 606 { \ 607 return (_RetType)_Ret; \ 608 } \ 609 /* Fall through to support information DC's.*/ \ 610 } \ 611 } 612 613 #define HANDLE_METADC16(_RetType, _Func, dwError, hdc, ...) \ 614 if (GDI_HANDLE_GET_TYPE(hdc) != GDILoObjType_LO_DC_TYPE) \ 615 { \ 616 if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE) \ 617 { \ 618 return METADC_##_Func(hdc, __VA_ARGS__); \ 619 } \ 620 } 621 622 #define HANDLE_METADC0P(_RetType, _Func, dwError, hdc, ...) \ 623 if (GDI_HANDLE_GET_TYPE(hdc) != GDILoObjType_LO_DC_TYPE) \ 624 { \ 625 PLDC pLDC = NULL; \ 626 _RetType _Ret = dwError; \ 627 if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE) \ 628 { \ 629 return (_RetType)_Ret; \ 630 } \ 631 pLDC = GdiGetLDC(hdc); \ 632 if ( !pLDC ) \ 633 { \ 634 SetLastError(ERROR_INVALID_HANDLE); \ 635 return (_RetType)_Ret; \ 636 } \ 637 if ( pLDC->iType == LDC_EMFLDC && !(EMFDC_##_Func(pLDC)) ) \ 638 { \ 639 return (_RetType)_Ret; \ 640 } \ 641 /* Fall through to support information DC's.*/ \ 642 } 643 644 #define HANDLE_EMETAFDC(_RetType, _Func, dwError, hdc, ...) \ 645 if (GDI_HANDLE_GET_TYPE(hdc) != GDILoObjType_LO_DC_TYPE) \ 646 { \ 647 PLDC pLDC = NULL; \ 648 _RetType _Ret = dwError; \ 649 if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE) \ 650 { \ 651 return (_RetType)_Ret; \ 652 } \ 653 pLDC = GdiGetLDC(hdc); \ 654 if ( !pLDC ) \ 655 { \ 656 SetLastError(ERROR_INVALID_HANDLE); \ 657 return (_RetType)_Ret; \ 658 } \ 659 if ( pLDC->iType == LDC_EMFLDC && !(EMFDC_##_Func(pLDC, __VA_ARGS__)) ) \ 660 { \ 661 return (_RetType)_Ret; \ 662 } \ 663 /* Fall through to support information DC's.*/ \ 664 } 665 666 #define HANDLE_METADC1P(_RetType, _Func, dwError, hdc, ...) \ 667 if (GDI_HANDLE_GET_TYPE(hdc) != GDILoObjType_LO_DC_TYPE) \ 668 { \ 669 if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE) \ 670 { \ 671 return (_RetType)METADC_##_Func(hdc); \ 672 } \ 673 else \ 674 { \ 675 PLDC pLDC = GdiGetLDC(hdc); \ 676 _RetType _Ret = dwError; \ 677 if ( !pLDC ) \ 678 { \ 679 SetLastError(ERROR_INVALID_HANDLE); \ 680 return (_RetType)_Ret; \ 681 } \ 682 if ( pLDC->iType == LDC_EMFLDC && !(EMFDC_##_Func(pLDC)) ) \ 683 { \ 684 return (_RetType)_Ret; \ 685 } \ 686 /* Fall through to support information DC's.*/ \ 687 } \ 688 } 689 690 691 BOOL WINAPI METADC_SetD(_In_ HDC hdc,_In_ DWORD dwIn,_In_ USHORT usMF16Id); 692 BOOL WINAPI EMFDC_SetD(_In_ PLDC pldc,_In_ DWORD dwIn,_In_ ULONG ulMFId); 693 694 HDC WINAPI GdiConvertAndCheckDC(HDC hdc); 695 696 HENHMETAFILE WINAPI SetEnhMetaFileBitsAlt( PDWORD pdw, LPWSTR FilePart, HANDLE hFile, LARGE_INTEGER li); 697 698 /* meta dc files */ 699 extern BOOL METADC_Arc( HDC hdc, INT left, INT top, INT right, INT bottom, 700 INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN; 701 extern BOOL METADC_BitBlt( HDC hdc_dst, INT x_dst, INT y_dst, INT width, INT height, 702 HDC hdc_src, INT x_src, INT y_src, DWORD rop ); 703 extern BOOL METADC_Chord( HDC hdc, INT left, INT top, INT right, INT bottom, INT xstart, 704 INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN; 705 extern BOOL METADC_Ellipse( HDC hdc, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN; 706 extern BOOL METADC_ExcludeClipRect( HDC hdc, INT left, INT top, INT right, 707 INT bottom ) DECLSPEC_HIDDEN; 708 extern BOOL METADC_ExtEscape( HDC hdc, INT escape, INT input_size, LPCSTR input, INT output_size, LPVOID output ) DECLSPEC_HIDDEN; 709 extern BOOL METADC_ExtFloodFill( HDC hdc, INT x, INT y, COLORREF color, 710 UINT fill_type ) DECLSPEC_HIDDEN; 711 extern BOOL METADC_ExtSelectClipRgn( HDC hdc, HRGN hrgn, INT mode ) DECLSPEC_HIDDEN; 712 extern BOOL METADC_ExtTextOut( HDC hdc, INT x, INT y, UINT flags, const RECT *rect, 713 const WCHAR *str, UINT count, const INT *dx ) DECLSPEC_HIDDEN; 714 extern BOOL METADC_FillRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush ) DECLSPEC_HIDDEN; 715 extern BOOL METADC_FrameRgn( HDC hdc, HRGN hrgn, HBRUSH hbrush, INT x, INT y ) DECLSPEC_HIDDEN; 716 extern INT METADC_GetDeviceCaps( HDC hdc, INT cap ); 717 extern BOOL METADC_IntersectClipRect( HDC hdc, INT left, INT top, INT right, 718 INT bottom ) DECLSPEC_HIDDEN; 719 extern BOOL METADC_InvertRgn( HDC hdc, HRGN hrgn ) DECLSPEC_HIDDEN; 720 extern BOOL METADC_LineTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 721 extern BOOL METADC_MoveTo( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 722 extern BOOL METADC_OffsetClipRgn( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 723 extern BOOL METADC_OffsetViewportOrgEx( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 724 extern BOOL METADC_OffsetWindowOrgEx( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 725 extern BOOL METADC_PaintRgn( HDC hdc, HRGN hrgn ) DECLSPEC_HIDDEN; 726 extern BOOL METADC_PatBlt( HDC hdc, INT left, INT top, INT width, INT height, DWORD rop ); 727 extern BOOL METADC_Pie( HDC hdc, INT left, INT top, INT right, INT bottom, 728 INT xstart, INT ystart, INT xend, INT yend ) DECLSPEC_HIDDEN; 729 extern BOOL METADC_PolyPolygon( HDC hdc, const POINT *points, const INT *counts, 730 UINT polygons ) DECLSPEC_HIDDEN; 731 extern BOOL METADC_Polygon( HDC hdc, const POINT *points, INT count ) DECLSPEC_HIDDEN; 732 extern BOOL METADC_Polyline( HDC hdc, const POINT *points,INT count) DECLSPEC_HIDDEN; 733 extern BOOL METADC_RealizePalette( HDC hdc ) DECLSPEC_HIDDEN; 734 extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN; 735 extern BOOL METADC_RestoreDC( HDC hdc, INT level ) DECLSPEC_HIDDEN; 736 extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom, 737 INT ell_width, INT ell_height ) DECLSPEC_HIDDEN; 738 extern BOOL METADC_SaveDC( HDC hdc ) DECLSPEC_HIDDEN; 739 extern BOOL METADC_ScaleViewportExtEx( HDC hdc, INT x_num, INT x_denom, INT y_num, 740 INT y_denom ) DECLSPEC_HIDDEN; 741 extern BOOL METADC_ScaleWindowExtEx( HDC hdc, INT x_num, INT x_denom, INT y_num, 742 INT y_denom ) DECLSPEC_HIDDEN; 743 extern HGDIOBJ METADC_SelectObject( HDC hdc, HGDIOBJ obj ) DECLSPEC_HIDDEN; 744 extern BOOL METADC_SelectPalette( HDC hdc, HPALETTE palette ) DECLSPEC_HIDDEN; 745 extern BOOL METADC_SetBkColor( HDC hdc, COLORREF color ) DECLSPEC_HIDDEN; 746 extern BOOL METADC_SetBkMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN; 747 extern INT METADC_SetDIBitsToDevice( HDC hdc, INT x_dest, INT y_dest, DWORD width, DWORD height, 748 INT x_src, INT y_src, UINT startscan, UINT lines, 749 const void *bits, const BITMAPINFO *info, 750 UINT coloruse ) DECLSPEC_HIDDEN; 751 extern BOOL METADC_SetLayout( HDC hdc, DWORD layout ) DECLSPEC_HIDDEN; 752 extern BOOL METADC_SetTextCharacterExtra( HDC hdc, INT extra ) DECLSPEC_HIDDEN; 753 extern BOOL METADC_SetMapMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN; 754 extern BOOL METADC_SetMapperFlags( HDC hdc, DWORD flags ) DECLSPEC_HIDDEN; 755 extern BOOL METADC_SetPixel( HDC hdc, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN; 756 extern BOOL METADC_SetPolyFillMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN; 757 extern BOOL METADC_SetRelAbs( HDC hdc, INT mode ) DECLSPEC_HIDDEN; 758 extern BOOL METADC_SetROP2( HDC hdc, INT rop ) DECLSPEC_HIDDEN; 759 extern BOOL METADC_SetStretchBltMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN; 760 extern BOOL METADC_SetTextAlign( HDC hdc, UINT align ) DECLSPEC_HIDDEN; 761 extern BOOL METADC_SetTextColor( HDC hdc, COLORREF color ) DECLSPEC_HIDDEN; 762 extern BOOL METADC_SetTextJustification( HDC hdc, INT extra, INT breaks ) DECLSPEC_HIDDEN; 763 extern BOOL METADC_SetViewportExtEx( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 764 extern BOOL METADC_SetViewportOrgEx( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 765 extern BOOL METADC_SetWindowExtEx( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN; 766 extern BOOL METADC_SetWindowOrgEx( HDC, INT x, INT y ) DECLSPEC_HIDDEN; 767 extern BOOL METADC_StretchBlt( HDC hdc_dst, INT x_dst, INT y_dst, INT width_dst, INT height_dst, 768 HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src, 769 DWORD rop ); 770 extern BOOL METADC_StretchDIBits( HDC hdc, INT x_dst, INT y_dst, INT width_dst, INT height_dst, 771 INT x_src, INT y_src, INT width_src, INT height_src, 772 const void *bits, const BITMAPINFO *info, UINT coloruse, 773 DWORD rop ) DECLSPEC_HIDDEN; 774 /* enhanced metafiles */ 775 extern BOOL EMFDC_AbortPath( LDC *dc_attr ) DECLSPEC_HIDDEN; 776 extern BOOL EMFDC_AlphaBlend( LDC *dc_attr, INT x_dst, INT y_dst, INT width_dst, INT height_dst, 777 HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src, 778 BLENDFUNCTION blend_function ); 779 extern BOOL EMFDC_AngleArc( LDC *dc_attr, INT x, INT y, DWORD radius, FLOAT start, 780 FLOAT sweep ) DECLSPEC_HIDDEN; 781 extern BOOL EMFDC_ArcChordPie( LDC *dc_attr, INT left, INT top, INT right, 782 INT bottom, INT xstart, INT ystart, INT xend, 783 INT yend, DWORD type ) DECLSPEC_HIDDEN; 784 extern BOOL EMFDC_BeginPath( LDC *dc_attr ) DECLSPEC_HIDDEN; 785 extern BOOL EMFDC_BitBlt( LDC *dc_attr, INT x_dst, INT y_dst, INT width, INT height, 786 HDC hdc_src, INT x_src, INT y_src, DWORD rop ); 787 extern BOOL EMFDC_CloseFigure( LDC *dc_attr ) DECLSPEC_HIDDEN; 788 extern BOOL EMFDC_DeleteDC( LDC *dc_attr ) DECLSPEC_HIDDEN; 789 extern BOOL EMFDC_Ellipse( LDC *dc_attr, INT left, INT top, INT right, 790 INT bottom ) DECLSPEC_HIDDEN; 791 extern BOOL EMFDC_EndPath( LDC *dc_attr ) DECLSPEC_HIDDEN; 792 extern BOOL EMFDC_ExcludeClipRect( LDC *dc_attr, INT left, INT top, INT right, 793 INT bottom ) DECLSPEC_HIDDEN; 794 extern BOOL EMFDC_ExtFloodFill( LDC *dc_attr, INT x, INT y, COLORREF color, 795 UINT fill_type ) DECLSPEC_HIDDEN; 796 extern BOOL EMFDC_ExtSelectClipRgn( LDC *dc_attr, HRGN hrgn, INT mode ) DECLSPEC_HIDDEN; 797 extern BOOL EMFDC_ExtTextOut( LDC *dc_attr, INT x, INT y, UINT flags, const RECT *rect, 798 const WCHAR *str, UINT count, const INT *dx ) DECLSPEC_HIDDEN; 799 extern BOOL EMFDC_FillPath( LDC *dc_attr ) DECLSPEC_HIDDEN; 800 extern BOOL EMFDC_FillRgn( LDC *dc_attr, HRGN hrgn, HBRUSH hbrush ) DECLSPEC_HIDDEN; 801 extern BOOL EMFDC_FlattenPath( LDC *dc_attr ) DECLSPEC_HIDDEN; 802 extern BOOL EMFDC_FrameRgn( LDC *dc_attr, HRGN hrgn, HBRUSH hbrush, INT width, 803 INT height ) DECLSPEC_HIDDEN; 804 extern BOOL EMFDC_GradientFill( LDC *dc_attr, TRIVERTEX *vert_array, ULONG nvert, 805 void *grad_array, ULONG ngrad, ULONG mode ) DECLSPEC_HIDDEN; 806 extern BOOL EMFDC_IntersectClipRect( LDC *dc_attr, INT left, INT top, INT right, 807 INT bottom ) DECLSPEC_HIDDEN; 808 extern BOOL EMFDC_InvertRgn( LDC *dc_attr, HRGN hrgn ) DECLSPEC_HIDDEN; 809 extern BOOL EMFDC_LineTo( LDC *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN; 810 extern BOOL EMFDC_ModifyWorldTransform( LDC *dc_attr, const XFORM *xform, 811 DWORD mode ) DECLSPEC_HIDDEN; 812 extern BOOL EMFDC_MoveTo( LDC *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN; 813 extern BOOL EMFDC_OffsetClipRgn( LDC *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN; 814 extern BOOL EMFDC_PaintRgn( LDC *dc_attr, HRGN hrgn ) DECLSPEC_HIDDEN; 815 extern BOOL EMFDC_PatBlt( LDC *dc_attr, INT left, INT top, INT width, INT height, DWORD rop ); 816 extern BOOL EMFDC_PolyBezier( LDC *dc_attr, const POINT *points, DWORD count ) DECLSPEC_HIDDEN; 817 extern BOOL EMFDC_PolyBezierTo( LDC *dc_attr, const POINT *points, DWORD count ) DECLSPEC_HIDDEN; 818 extern BOOL EMFDC_PolyDraw( LDC *dc_attr, const POINT *points, const BYTE *types, 819 DWORD count ) DECLSPEC_HIDDEN; 820 extern BOOL EMFDC_PolyPolyline( LDC *dc_attr, const POINT *points, const DWORD *counts, 821 DWORD polys ) DECLSPEC_HIDDEN; 822 extern BOOL EMFDC_PolyPolygon( LDC *dc_attr, const POINT *points, const INT *counts, 823 UINT polys ) DECLSPEC_HIDDEN; 824 extern BOOL EMFDC_Polygon( LDC *dc_attr, const POINT *points, INT count ) DECLSPEC_HIDDEN; 825 extern BOOL EMFDC_Polyline( LDC *dc_attr, const POINT *points, INT count) DECLSPEC_HIDDEN; 826 extern BOOL EMFDC_PolylineTo( LDC *dc_attr, const POINT *points, INT count ) DECLSPEC_HIDDEN; 827 extern BOOL EMFDC_Rectangle( LDC *dc_attr, INT left, INT top, INT right, 828 INT bottom) DECLSPEC_HIDDEN; 829 extern BOOL EMFDC_RestoreDC( LDC *dc_attr, INT level ) DECLSPEC_HIDDEN; 830 extern BOOL EMFDC_RoundRect( LDC *dc_attr, INT left, INT top, INT right, INT bottom, 831 INT ell_width, INT ell_height ) DECLSPEC_HIDDEN; 832 extern BOOL EMFDC_SaveDC( LDC *dc_attr ) DECLSPEC_HIDDEN; 833 extern BOOL EMFDC_ScaleViewportExtEx( LDC *dc_attr, INT x_num, INT x_denom, INT y_num, 834 INT y_denom ) DECLSPEC_HIDDEN; 835 extern BOOL EMFDC_ScaleWindowExtEx( LDC *dc_attr, INT x_num, INT x_denom, INT y_num, 836 INT y_denom ) DECLSPEC_HIDDEN; 837 extern BOOL EMFDC_SelectClipPath( LDC *dc_attr, INT mode ) DECLSPEC_HIDDEN; 838 extern BOOL EMFDC_SelectObject( LDC *dc_attr, HGDIOBJ obj ) DECLSPEC_HIDDEN; 839 extern BOOL EMFDC_SelectPalette( LDC *dc_attr, HPALETTE palette ) DECLSPEC_HIDDEN; 840 extern BOOL EMFDC_SetArcDirection( LDC *dc_attr, INT dir ) DECLSPEC_HIDDEN; 841 extern BOOL EMFDC_SetBkColor( LDC *dc_attr, COLORREF color ) DECLSPEC_HIDDEN; 842 extern BOOL EMFDC_SetBkMode( LDC *dc_attr, INT mode ) DECLSPEC_HIDDEN; 843 extern BOOL EMFDC_SetDCBrushColor( LDC *dc_attr, COLORREF color ) DECLSPEC_HIDDEN; 844 extern BOOL EMFDC_SetDCPenColor( LDC *dc_attr, COLORREF color ) DECLSPEC_HIDDEN; 845 extern BOOL EMFDC_SetDIBitsToDevice( LDC *dc_attr, INT x_dest, INT y_dest, DWORD width, 846 DWORD height, INT x_src, INT y_src, UINT startscan, 847 UINT lines, const void *bits, const BITMAPINFO *info, 848 UINT coloruse ) DECLSPEC_HIDDEN; 849 extern BOOL EMFDC_SetLayout( LDC *dc_attr, DWORD layout ) DECLSPEC_HIDDEN; 850 extern BOOL EMFDC_SetMapMode( LDC *dc_attr, INT mode ) DECLSPEC_HIDDEN; 851 extern BOOL EMFDC_SetMapperFlags( LDC *dc_attr, DWORD flags ) DECLSPEC_HIDDEN; 852 extern BOOL EMFDC_SetPixel( LDC *dc_attr, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN; 853 extern BOOL EMFDC_SetPolyFillMode( LDC *dc_attr, INT mode ) DECLSPEC_HIDDEN; 854 extern BOOL EMFDC_SetROP2( LDC *dc_attr, INT rop ) DECLSPEC_HIDDEN; 855 extern BOOL EMFDC_SetStretchBltMode( LDC *dc_attr, INT mode ) DECLSPEC_HIDDEN; 856 extern BOOL EMFDC_SetTextAlign( LDC *dc_attr, UINT align ) DECLSPEC_HIDDEN; 857 extern BOOL EMFDC_SetTextColor( LDC *dc_attr, COLORREF color ) DECLSPEC_HIDDEN; 858 extern BOOL EMFDC_SetTextJustification( LDC *dc_attr, INT extra, INT breaks ) DECLSPEC_HIDDEN; 859 extern BOOL EMFDC_SetViewportExtEx( LDC *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN; 860 extern BOOL EMFDC_SetViewportOrgEx( LDC *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN; 861 extern BOOL EMFDC_SetWindowExtEx( LDC *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN; 862 extern BOOL EMFDC_SetWindowOrgEx( LDC *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN; 863 extern BOOL EMFDC_SetWorldTransform( LDC *dc_attr, const XFORM *xform ) DECLSPEC_HIDDEN; 864 extern BOOL EMFDC_StretchBlt( LDC *dc_attr, INT x_dst, INT y_dst, INT width_dst, INT height_dst, 865 HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src, 866 DWORD rop ); 867 extern BOOL EMFDC_StretchDIBits( LDC *dc_attr, INT x_dst, INT y_dst, INT width_dst, 868 INT height_dst, INT x_src, INT y_src, INT width_src, 869 INT height_src, const void *bits, const BITMAPINFO *info, 870 UINT coloruse, DWORD rop ) DECLSPEC_HIDDEN; 871 extern BOOL EMFDC_StrokeAndFillPath( LDC *dc_attr ) DECLSPEC_HIDDEN; 872 extern BOOL EMFDC_StrokePath( LDC *dc_attr ) DECLSPEC_HIDDEN; 873 extern BOOL EMFDC_WidenPath( LDC *dc_attr ) DECLSPEC_HIDDEN; 874 875 876 BOOL EMFDC_MaskBlt( LDC *dc_attr, INT xDest, INT yDest, INT cx, INT cy, HDC hdcSrc, INT xSrc, INT ySrc, HBITMAP hbmMask, INT xMask, INT yMask, DWORD dwRop); 877 BOOL EMFDC_PlgBlt( LDC *dc_attr, const POINT * ppt, HDC hdcSrc, INT xSrc, INT ySrc, INT cx, INT cy, HBITMAP hbmMask, INT xMask, INT yMask); 878 BOOL EMFDC_TransparentBlt( LDC *dc_attr, INT xDst, INT yDst, INT cxDst, INT cyDst, HDC hdcSrc, INT xSrc, INT ySrc, INT cxSrc, INT cySrc, UINT crTransparent); 879 BOOL EMFDC_SetBrushOrg( LDC *dc_attr, INT x, INT y); 880 BOOL EMFDC_SetMetaRgn( LDC *dc_attr ); 881 BOOL EMFDC_WriteNamedEscape( LDC *dc_attr, PWCHAR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData); 882 BOOL EMFDC_WriteEscape( LDC *dc_attr, INT nEscape, INT cbInput, LPSTR lpszInData, DWORD emrType); 883 884 885 FORCEINLINE BOOL EMFDC_Arc( PLDC dc_attr, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) 886 { 887 return EMFDC_ArcChordPie( dc_attr, left, top, right, bottom, xstart, ystart, xend, yend, EMR_ARC ); 888 } 889 890 FORCEINLINE BOOL EMFDC_ArcTo( PLDC dc_attr, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) 891 { 892 return EMFDC_ArcChordPie( dc_attr, left, top, right, bottom, xstart, ystart, xend, yend, EMR_ARCTO ); 893 } 894 FORCEINLINE BOOL EMFDC_Chord( PLDC dc_attr, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) 895 { 896 return EMFDC_ArcChordPie( dc_attr, left, top, right, bottom, xstart, ystart, xend, yend, EMR_CHORD ); 897 } 898 899 FORCEINLINE BOOL EMFDC_Pie( PLDC dc_attr, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend ) 900 { 901 return EMFDC_ArcChordPie( dc_attr, left, top, right, bottom, xstart, ystart, xend, yend, EMR_PIE ); 902 } 903 904 BOOL WINAPI EMFDC_GdiComment( HDC hdc, UINT bytes, const BYTE *buffer ); 905 906 /* EOF */ 907