Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
5.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: csxobj.cxx *
  3. * *
  4. * CSXform object non-inline methods. *
  5. * *
  6. * Created: 12-Nov-1990 16:54:37 *
  7. * Author: Wendy Wu [wendywu] *
  8. * *
  9. * Copyright (c) 1990-1999 Microsoft Corporation *
  10. \**************************************************************************/
  11. #define NO_STRICT
  12. #if !defined(_GDIPLUS_)
  13. #define INITGUID // Declare any GUIDs
  14. #endif
  15. extern "C" {
  16. #if defined(_GDIPLUS_)
  17. #include <gpprefix.h>
  18. #endif
  19. #include <string.h>
  20. #include <stdio.h>
  21. #include <nt.h>
  22. #include <ntrtl.h>
  23. #include <nturtl.h>
  24. #include <stddef.h>
  25. #include <windows.h> // GDI function declarations.
  26. #include <winspool.h>
  27. #include "nlsconv.h" // UNICODE helpers
  28. #include "firewall.h"
  29. #define __CPLUSPLUS
  30. #include <winspool.h>
  31. #include <w32gdip.h>
  32. #include "ntgdistr.h"
  33. #include "winddi.h"
  34. #include "hmgshare.h"
  35. #include "icm.h"
  36. #include "local.h" // Local object support.
  37. #include "gdiicm.h"
  38. #include "metadef.h" // Metafile record type constants.
  39. #include "metarec.h"
  40. #include "mf16.h"
  41. #include "ntgdi.h"
  42. #include "glsup.h"
  43. }
  44. #include "xfflags.h"
  45. #include "csxobj.hxx"
  46. #if defined(_AMD64_) || defined(_IA64_) || defined(BUILD_WOW6432)
  47. #define vSetTo1Over16(ef) (ef.e = EFLOAT_1Over16)
  48. #else
  49. #define vSetTo1Over16(ef) (ef.i.lMant = 0x040000000, ef.i.lExp = -2)
  50. #endif
  51. #ifndef _BASETSD_H_
  52. typedef size_t SIZE_T;
  53. #endif
  54. extern "C" {
  55. BOOL bCvtPts1(PMATRIX pmx, PPOINTL pptl, SIZE_T cPts);
  56. BOOL bCvtPts(PMATRIX pmx, PPOINTL pSrc, PPOINTL pDest, SIZE_T cPts);
  57. };
  58. #define bIsIdentity(fl) ((fl & (XFORM_UNITY | XFORM_NO_TRANSLATION)) == \
  59. (XFORM_UNITY | XFORM_NO_TRANSLATION))
  60. /******************************Public*Routine******************************\
  61. * DPtoLP()
  62. *
  63. * History:
  64. *
  65. * 12-Mar-1996 -by- Mark Enstrom [marke]
  66. * Use cached dc transform data
  67. * 01-Dec-1994 -by- Eric Kutter [erick]
  68. * Wrote it.
  69. \**************************************************************************/
  70. BOOL APIENTRY DPtoLP(HDC hdc, LPPOINT pptl, int c)
  71. {
  72. PDC_ATTR pdcattr;
  73. PVOID pvuser;
  74. BOOL bRet = TRUE;
  75. if (c > 0)
  76. {
  77. PSHARED_GET_VALIDATE(pvuser,hdc,DC_TYPE);
  78. pdcattr = (PDC_ATTR)pvuser;
  79. if (pdcattr)
  80. {
  81. if (
  82. pdcattr->flXform &
  83. (
  84. PAGE_XLATE_CHANGED |
  85. PAGE_EXTENTS_CHANGED |
  86. WORLD_XFORM_CHANGED |
  87. DEVICE_TO_WORLD_INVALID
  88. )
  89. )
  90. {
  91. bRet = NtGdiTransformPoints(hdc,pptl,pptl,c,XFP_DPTOLP);
  92. }
  93. else
  94. {
  95. //
  96. // xform is valid, transform in user mode
  97. //
  98. PMATRIX pmx = (PMATRIX)&(pdcattr->mxDtoW);
  99. if (!bIsIdentity(pmx->flAccel))
  100. {
  101. if (!bCvtPts1(pmx, (PPOINTL)pptl, c))
  102. {
  103. GdiSetLastError(ERROR_ARITHMETIC_OVERFLOW);
  104. bRet = FALSE;
  105. }
  106. }
  107. }
  108. }
  109. else
  110. {
  111. GdiSetLastError(ERROR_INVALID_PARAMETER);
  112. bRet = FALSE;
  113. }
  114. }
  115. return(bRet);
  116. }
  117. /******************************Public*Routine******************************\
  118. * LPtoDP()
  119. *
  120. * History:
  121. * 12-Mar-1996 -by- Mark Enstrom [marke]
  122. * Use cached dc transform data
  123. * 01-Dec-1994 -by- Eric Kutter [erick]
  124. * Wrote it.
  125. \**************************************************************************/
  126. BOOL APIENTRY LPtoDP(HDC hdc, LPPOINT pptl, int c)
  127. {
  128. PDC_ATTR pdcattr;
  129. PVOID pvuser;
  130. BOOL bRet = TRUE;
  131. if (c > 0)
  132. {
  133. PSHARED_GET_VALIDATE(pvuser,hdc,DC_TYPE);
  134. pdcattr = (PDC_ATTR)pvuser;
  135. if (pdcattr)
  136. {
  137. if (pdcattr->flXform & (PAGE_XLATE_CHANGED | PAGE_EXTENTS_CHANGED |
  138. WORLD_XFORM_CHANGED))
  139. {
  140. //
  141. // transform needs to be updated, call kernel
  142. //
  143. bRet = NtGdiTransformPoints(hdc,pptl,pptl,c,XFP_LPTODP);
  144. }
  145. else
  146. {
  147. //
  148. // transform is valid, transform points locally
  149. //
  150. PMATRIX pmx = (PMATRIX)&(pdcattr->mxWtoD);
  151. if (!bIsIdentity(pmx->flAccel))
  152. {
  153. #if DBG_XFORM
  154. DbgPrint("LPtoDP: NOT IDENTITY, hdc = %p, flAccel = %lx\n", hdc, pmx->flAccel);
  155. #endif
  156. if (!bCvtPts1(pmx, (PPOINTL)pptl, c))
  157. {
  158. GdiSetLastError(ERROR_ARITHMETIC_OVERFLOW);
  159. bRet = FALSE;
  160. }
  161. }
  162. }
  163. }
  164. else
  165. {
  166. GdiSetLastError(ERROR_INVALID_PARAMETER);
  167. bRet = FALSE;
  168. }
  169. }
  170. return(bRet);
  171. }