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.

423 lines
8.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: xformddi.cxx
  3. *
  4. * Transform DDI callback routines.
  5. *
  6. * Created: 13-May-1991 19:08:43
  7. * Author: Wendy Wu [wendywu]
  8. *
  9. * Copyright (c) 1990-1999 Microsoft Corporation
  10. \**************************************************************************/
  11. #include "precomp.hxx"
  12. /******************************Public*Routine******************************\
  13. * BOOL XFORMOBJ_bApplyXform(
  14. * XFORMOBJ *pxo,
  15. * ULONG iMode,
  16. * ULONG cPoints,
  17. * PVOID pvIn,
  18. * PVOID pvOut)
  19. *
  20. * Applies the transform or its inverse to the given array of points.
  21. *
  22. * History:
  23. * 13-May-1991 -by- Wendy Wu [wendywu]
  24. * Wrote it.
  25. \**************************************************************************/
  26. BOOL XFORMOBJ_bApplyXform(
  27. XFORMOBJ *pxo,
  28. ULONG iMode,
  29. ULONG cPoints,
  30. PVOID pvIn,
  31. PVOID pvOut)
  32. {
  33. if (pxo == NULL)
  34. return(FALSE);
  35. if ((pvIn == NULL) || (pvOut == NULL))
  36. return(FALSE);
  37. if (iMode == XF_LTOL)
  38. {
  39. if (pvIn == pvOut)
  40. return(((EXFORMOBJ *)pxo)->bXform((PPOINTL)pvIn,(UINT)cPoints));
  41. if (((EXFORMOBJ *)pxo)->bXform((PPOINTL)pvIn, (PPOINTFIX)pvOut,
  42. (UINT)cPoints))
  43. {
  44. PPOINTL pptl = (PPOINTL)pvOut;
  45. PPOINTL pptlEnd = pptl + cPoints;
  46. while (pptl < pptlEnd)
  47. {
  48. pptl->x = (pptl->x + 8) >> 4; // FXTOLROUND
  49. pptl->y = (pptl->y + 8) >> 4; // FXTOLROUND
  50. pptl++;
  51. }
  52. return(TRUE);
  53. }
  54. return(FALSE);
  55. }
  56. if (iMode == XF_LTOFX)
  57. return(((EXFORMOBJ *)pxo)->bXform((PPOINTL)pvIn, (PPOINTFIX)pvOut,
  58. (UINT)cPoints));
  59. MATRIX mx;
  60. EXFORMOBJ xo(&mx, DONT_COMPUTE_FLAGS);
  61. if (xo.bInverse(*((EXFORMOBJ *)pxo)))
  62. {
  63. if (iMode == XF_INV_LTOL)
  64. {
  65. if (pvIn == pvOut)
  66. return(xo.bXform((PPOINTL)pvIn,(UINT)cPoints));
  67. PPOINTL pptl = (PPOINTL)pvIn;
  68. PPOINTL pptlEnd = pptl + cPoints;
  69. while (pptl < pptlEnd)
  70. {
  71. pptl->x <<= 4;
  72. pptl->y <<= 4;
  73. pptl++;
  74. }
  75. BOOL bRet = xo.bXform((PPOINTFIX)pvIn, (PPOINTL)pvOut, (UINT)cPoints);
  76. pptl = (PPOINTL)pvIn;
  77. while (pptl < pptlEnd)
  78. {
  79. pptl->x >>= 4;
  80. pptl->y >>= 4;
  81. pptl++;
  82. }
  83. return(bRet);
  84. }
  85. if (iMode == XF_INV_FXTOL)
  86. return(xo.bXform((PPOINTFIX)pvIn, (PPOINTL)pvOut, (UINT)cPoints));
  87. }
  88. return(FALSE);
  89. }
  90. /******************************Public*Routine******************************\
  91. * ULONG XFORMOBJ_iGetXform(XFORMOBJ *pxo,XFORM *pxform)
  92. *
  93. * Get the coefficients of the given transform.
  94. *
  95. * History:
  96. * 13-May-1991 -by- Wendy Wu [wendywu]
  97. * Wrote it.
  98. \**************************************************************************/
  99. ULONG XFORMOBJ_iGetXform(XFORMOBJ *pxo, XFORML *pxform)
  100. {
  101. if (pxo == NULL)
  102. return(DDI_ERROR);
  103. if (pxform != NULL)
  104. ((EXFORMOBJ *)pxo)->vGetCoefficient((XFORML *)pxform);
  105. switch(((EXFORMOBJ *)pxo)->flAccel() &
  106. (XFORM_SCALE|XFORM_UNITY|XFORM_NO_TRANSLATION))
  107. {
  108. case (XFORM_SCALE|XFORM_UNITY|XFORM_NO_TRANSLATION):
  109. return(GX_IDENTITY);
  110. case (XFORM_SCALE|XFORM_UNITY):
  111. return(GX_OFFSET);
  112. case (XFORM_SCALE):
  113. return(GX_SCALE);
  114. default:
  115. return(GX_GENERAL);
  116. }
  117. }
  118. /******************************Public*Routine******************************\
  119. * ULONG XFORMOBJ_iGetXform(XFORMOBJ *pxo,XFORM *pxform)
  120. *
  121. * Get the coefficients of the given transform.
  122. *
  123. * History:
  124. * 13-May-1991 -by- Wendy Wu [wendywu]
  125. * Wrote it.
  126. \**************************************************************************/
  127. ULONG XFORMOBJ_iGetFloatObjXform(XFORMOBJ *pxo, FLOATOBJ_XFORM *pxform)
  128. {
  129. if (pxo == NULL)
  130. return(DDI_ERROR);
  131. if (pxform != NULL)
  132. ((EXFORMOBJ *)pxo)->vGetCoefficient(pxform);
  133. switch(((EXFORMOBJ *)pxo)->flAccel() &
  134. (XFORM_SCALE|XFORM_UNITY|XFORM_NO_TRANSLATION))
  135. {
  136. case (XFORM_SCALE|XFORM_UNITY|XFORM_NO_TRANSLATION):
  137. return(GX_IDENTITY);
  138. case (XFORM_SCALE|XFORM_UNITY):
  139. return(GX_OFFSET);
  140. case (XFORM_SCALE):
  141. return(GX_SCALE);
  142. default:
  143. return(GX_GENERAL);
  144. }
  145. }
  146. /******************************Public*Routine******************************\
  147. *
  148. * a few wrapper functions for EFLOATS. See winddi for the list.
  149. *
  150. * Note that currently these are only defined for x86 since we allow floating
  151. * point operations in the kernel for MIPS, ALPHA, and PPC where these are macros.
  152. *
  153. * History:
  154. * 16-Mar-1995 -by- Eric Kutter [erick]
  155. * Wrote it.
  156. \**************************************************************************/
  157. #if defined(_X86_) && !defined(BUILD_WOW6432)
  158. VOID FLOATOBJ_SetFloat(
  159. PFLOATOBJ pf,
  160. FLOATL f)
  161. {
  162. *(EFLOAT*)pf = f;
  163. }
  164. VOID FLOATOBJ_SetLong(
  165. PFLOATOBJ pf,
  166. LONG l)
  167. {
  168. *(EFLOAT*)pf = l;
  169. }
  170. LONG FLOATOBJ_GetFloat(
  171. PFLOATOBJ pf)
  172. {
  173. return(((EFLOAT*)pf)->lEfToF());
  174. }
  175. LONG FLOATOBJ_GetLong(
  176. PFLOATOBJ pf)
  177. {
  178. LONG l;
  179. ((EFLOAT*)pf)->bEfToLTruncate(l);
  180. return(l);
  181. }
  182. VOID FLOATOBJ_AddFloat(
  183. PFLOATOBJ pf,
  184. FLOATL f)
  185. {
  186. EFLOAT ef;
  187. ef = f;
  188. *(EFLOAT*)pf += ef;
  189. }
  190. VOID FLOATOBJ_AddLong(
  191. PFLOATOBJ pf,
  192. LONG l)
  193. {
  194. EFLOAT ef;
  195. ef = l;
  196. *(EFLOAT*)pf += ef;
  197. }
  198. VOID FLOATOBJ_Add(
  199. PFLOATOBJ pf,
  200. PFLOATOBJ pf1)
  201. {
  202. *(EFLOAT*)pf += *(EFLOAT*)pf1;
  203. }
  204. VOID FLOATOBJ_AddFloatObj(
  205. PFLOATOBJ pf,
  206. PFLOATOBJ pf1)
  207. {
  208. *(EFLOAT*)pf += *(EFLOAT*)pf1;
  209. }
  210. VOID FLOATOBJ_SubFloat(
  211. PFLOATOBJ pf,
  212. FLOATL f)
  213. {
  214. EFLOAT ef;
  215. ef = f;
  216. *(EFLOAT*)pf -= ef;
  217. }
  218. VOID FLOATOBJ_SubLong(
  219. PFLOATOBJ pf,
  220. LONG l)
  221. {
  222. EFLOAT ef;
  223. ef = l;
  224. *(EFLOAT*)pf -= ef;
  225. }
  226. VOID FLOATOBJ_Sub(
  227. PFLOATOBJ pf,
  228. PFLOATOBJ pf1)
  229. {
  230. *(EFLOAT*)pf -= *(EFLOAT*)pf1;
  231. }
  232. VOID FLOATOBJ_SubFloatObj(
  233. PFLOATOBJ pf,
  234. PFLOATOBJ pf1)
  235. {
  236. *(EFLOAT*)pf -= *(EFLOAT*)pf1;
  237. }
  238. VOID FLOATOBJ_MulFloat(
  239. PFLOATOBJ pf,
  240. FLOATL f)
  241. {
  242. EFLOAT ef;
  243. ef = f;
  244. *(EFLOAT*)pf *= ef;
  245. }
  246. VOID FLOATOBJ_MulLong(
  247. PFLOATOBJ pf,
  248. LONG l)
  249. {
  250. EFLOAT ef;
  251. ef = l;
  252. *(EFLOAT*)pf *= ef;
  253. }
  254. VOID FLOATOBJ_MulFloatObj(
  255. PFLOATOBJ pf,
  256. PFLOATOBJ pf1)
  257. {
  258. *(EFLOAT*)pf *= *(EFLOAT*)pf1;
  259. }
  260. VOID FLOATOBJ_Mul(
  261. PFLOATOBJ pf,
  262. PFLOATOBJ pf1)
  263. {
  264. *(EFLOAT*)pf *= *(EFLOAT*)pf1;
  265. }
  266. VOID FLOATOBJ_DivFloat(
  267. PFLOATOBJ pf,
  268. FLOATL f)
  269. {
  270. EFLOAT ef;
  271. ef = f;
  272. *(EFLOAT*)pf /= ef;
  273. }
  274. VOID FLOATOBJ_DivLong(
  275. PFLOATOBJ pf,
  276. LONG l)
  277. {
  278. EFLOAT ef;
  279. ef = l;
  280. *(EFLOAT*)pf /= ef;
  281. }
  282. VOID FLOATOBJ_Div(
  283. PFLOATOBJ pf,
  284. PFLOATOBJ pf1)
  285. {
  286. *(EFLOAT*)pf /= *(EFLOAT*)pf1;
  287. }
  288. VOID FLOATOBJ_DivFloatObj(
  289. PFLOATOBJ pf,
  290. PFLOATOBJ pf1)
  291. {
  292. *(EFLOAT*)pf /= *(EFLOAT*)pf1;
  293. }
  294. VOID FLOATOBJ_Neg(PFLOATOBJ pf)
  295. {
  296. ((EFLOAT*)pf)->vNegate();
  297. }
  298. BOOL FLOATOBJ_EqualLong(
  299. PFLOATOBJ pf,
  300. LONG l)
  301. {
  302. if (l == 0)
  303. {
  304. return(((EFLOAT*)pf)->bIsZero());
  305. }
  306. else
  307. {
  308. EFLOAT ef;
  309. ef = l;
  310. return(*(EFLOAT*)pf == ef);
  311. }
  312. }
  313. BOOL FLOATOBJ_GreaterThanLong(
  314. PFLOATOBJ pf,
  315. LONG l)
  316. {
  317. if (l == 0)
  318. {
  319. return(!((EFLOAT*)pf)->bIsNegative() && !((EFLOAT*)pf)->bIsZero());
  320. }
  321. else
  322. {
  323. EFLOAT ef;
  324. ef = l;
  325. return(*(EFLOAT*)pf > ef);
  326. }
  327. }
  328. BOOL FLOATOBJ_LessThanLong(
  329. PFLOATOBJ pf,
  330. LONG l)
  331. {
  332. if (l == 0)
  333. {
  334. return(((EFLOAT*)pf)->bIsNegative());
  335. }
  336. else
  337. {
  338. EFLOAT ef;
  339. ef = l;
  340. return(*(EFLOAT*)pf < ef);
  341. }
  342. }
  343. BOOL FLOATOBJ_Equal(
  344. PFLOATOBJ pf,
  345. PFLOATOBJ pf1)
  346. {
  347. return(*(EFLOAT*)pf == *(EFLOAT*)pf1);
  348. }
  349. BOOL FLOATOBJ_GreaterThan(
  350. PFLOATOBJ pf,
  351. PFLOATOBJ pf1)
  352. {
  353. return(*(EFLOAT*)pf > *(EFLOAT*)pf1);
  354. }
  355. BOOL FLOATOBJ_LessThan(
  356. PFLOATOBJ pf,
  357. PFLOATOBJ pf1)
  358. {
  359. return(*(EFLOAT*)pf < *(EFLOAT*)pf1);
  360. }
  361. #endif _x86_