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.

309 lines
6.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: fontmath.cxx
  3. *
  4. * math stuff needed by ttfd which uses efloat routines
  5. *
  6. * Created: 04-Apr-1992 10:31:49
  7. * Author: Bodin Dresevic [BodinD]
  8. *
  9. * Copyright (c) 1990 Microsoft Corporation
  10. *
  11. *
  12. \**************************************************************************/
  13. extern "C"
  14. {
  15. #define __CPLUSPLUS
  16. #include <engine.h>
  17. };
  18. #include "engine.hxx"
  19. #include "equad.hxx"
  20. /******************************Public*Routine******************************\
  21. *
  22. * bFDXform, transform an array of points, output in POINTFIX
  23. *
  24. * Effects:
  25. *
  26. * Warnings:
  27. *
  28. * History:
  29. * 05-Apr-1992 -by- Bodin Dresevic [BodinD]
  30. * Wrote it.
  31. \**************************************************************************/
  32. extern "C" BOOL bFDXform(
  33. XFORML *pxf
  34. , POINTFIX *pptfxDst
  35. , POINTL *pptlSrc
  36. , SIZE_T c
  37. )
  38. {
  39. BOOL bRet;
  40. EFLOAT ef11;
  41. EFLOAT ef12;
  42. EFLOAT ef21;
  43. EFLOAT ef22;
  44. ef11 = pxf->eM11;
  45. ef12 = pxf->eM12;
  46. ef21 = pxf->eM21;
  47. ef22 = pxf->eM22;
  48. bRet = FALSE;
  49. if ( ef12.bIsZero() && ef21.bIsZero()) {
  50. for ( ; c ; pptfxDst++, pptlSrc++, c--) {
  51. EFLOAT ef;
  52. ef = pptlSrc->x;
  53. ef *= ef11;
  54. if ( !ef.bEfToFx( pptfxDst->x )) {
  55. break;
  56. }
  57. ef = pptlSrc->y;
  58. ef *= ef22;
  59. if ( !ef.bEfToFx( pptfxDst->y )) {
  60. break;
  61. }
  62. }
  63. bRet = TRUE;
  64. } else {
  65. for ( ; c ; pptfxDst++, pptlSrc++, c--) {
  66. EFLOAT efX;
  67. EFLOAT efY;
  68. EFLOAT ef1;
  69. EFLOAT ef2;
  70. efX = pptlSrc->x;
  71. efY = pptlSrc->y;
  72. ef1 = efX;
  73. ef1 *= ef11;
  74. ef2 = efY;
  75. ef2 *= ef21;
  76. ef2 += ef1;
  77. if ( !ef2.bEfToFx( pptfxDst->x )) {
  78. break;
  79. }
  80. ef1 = efX;
  81. ef1 *= ef12;
  82. ef2 = efY;
  83. ef2 *= ef22;
  84. ef2 += ef1;
  85. if ( !ef2.bEfToFx( pptfxDst->y )) {
  86. break;
  87. }
  88. }
  89. bRet = TRUE;
  90. }
  91. return( bRet );
  92. }
  93. /******************************Public*Routine******************************\
  94. *
  95. * bXformUnitVector
  96. *
  97. * xform vector by pfdxo, compute the unit vector of the transformed
  98. * vector and the norm of the transformed vector. Norm and the transformed
  99. * vector are multiplied by 16 so that when converting to long the result
  100. * will acutally be a 28.4 fix
  101. *
  102. * Effects:
  103. *
  104. * Warnings:
  105. *
  106. * History:
  107. * 01-Apr-1992 -by- Bodin Dresevic [BodinD]
  108. * Wrote it.
  109. \**************************************************************************/
  110. extern "C" BOOL bXformUnitVector(
  111. POINTL *pptl // IN incoming unit vector
  112. , XFORML *pxf // IN xform to use
  113. , PVECTORFL pvtflXformed // OUT xform of the incoming unit vector
  114. , POINTE *ppteUnit // OUT *pptqXormed/|*pptqXormed|, POINTE
  115. , EPOINTQF *pptqUnit // OUT the same as pteUnit, diff format
  116. , EFLOAT *pefNorm // OUT |*pptqXormed|
  117. )
  118. {
  119. EFLOAT efX_;
  120. EFLOAT efY_;
  121. BOOL b = TRUE;
  122. EFLOAT ef11;
  123. EFLOAT ef12;
  124. EFLOAT ef21;
  125. EFLOAT ef22;
  126. EFLOAT efX;
  127. EFLOAT efY;
  128. //
  129. // Convert longs to FIX point
  130. //
  131. efX = 16 * pptl->x;
  132. efY = 16 * pptl->y;
  133. //
  134. // Convert the matrix elements from FLOAT to EFLOAT
  135. //
  136. ef11 = pxf->eM11;
  137. ef12 = pxf->eM12;
  138. ef21 = pxf->eM21;
  139. ef22 = pxf->eM22;
  140. //
  141. // Transform the vector and put the result in efX_ and efY_
  142. //
  143. if ( ef12.bIsZero() && ef21.bIsZero() ) {
  144. efX_ = efX;
  145. efX_ *= ef11;
  146. efY_ = efY;
  147. efY_ *= ef22;
  148. } else {
  149. EFLOAT ef;
  150. efX_ = efX;
  151. efX_ *= ef11;
  152. ef = efY;
  153. ef *= ef21;
  154. efX_ += ef;
  155. ef = efX;
  156. ef *= ef12;
  157. efY_ = efY;
  158. efY_ *= ef22;
  159. efY_ += ef;
  160. }
  161. //
  162. // Record the results
  163. //
  164. pvtflXformed->x = efX_;
  165. pvtflXformed->y = efY_;
  166. // get the norm
  167. efX_ *= efX_;
  168. efY_ *= efY_;
  169. efX_ += efY_;
  170. efX_.vSqrt();
  171. *pefNorm = efX_;
  172. // make a unit vector out of eptfl
  173. EVECTORFL vtfl;
  174. vtfl.x.eqDiv(pvtflXformed->x,*pefNorm);
  175. vtfl.y.eqDiv(pvtflXformed->y,*pefNorm);
  176. vtfl.x.vEfToF(ppteUnit->x);
  177. vtfl.y.vEfToF(ppteUnit->y);
  178. // compute this same quantity in POINTQF format if requasted to do so:
  179. if (pptqUnit != (EPOINTQF *)NULL) {
  180. vtfl.x.vTimes16();
  181. vtfl.y.vTimes16();
  182. // convert to 28.36 format. The incoming vector is already
  183. // multliplied by 16 to ensure that the result is in the 28.36
  184. *pptqUnit = vtfl;
  185. }
  186. return b;
  187. }
  188. /******************************Public*Routine******************************\
  189. *
  190. * vLTimesVtfl
  191. *
  192. * Effects:
  193. *
  194. * Warnings:
  195. *
  196. * History:
  197. * 05-Apr-1992 -by- Bodin Dresevic [BodinD]
  198. * Wrote it.
  199. \**************************************************************************/
  200. extern "C" VOID vLTimesVtfl // *pptq = l * pvtfl, *pptq is in 28.36 format
  201. (
  202. LONG l,
  203. VECTORFL *pvtfl,
  204. EPOINTQF *pptq
  205. )
  206. {
  207. EVECTORFL vtfl;
  208. EFLOAT ef; ef = l;
  209. vtfl.x.eqMul(pvtfl->x,ef);
  210. vtfl.y.eqMul(pvtfl->y,ef);
  211. // convert to 28.36 format. The incoming vector will already have been
  212. // multliplied by 16 to ensure that the result is in the 28.36
  213. *pptq = vtfl;
  214. }
  215. /******************************Public*Routine******************************\
  216. *
  217. * fxLTimesEf
  218. *
  219. * Effects:
  220. *
  221. * Warnings:
  222. *
  223. * History:
  224. * 05-Apr-1992 -by- Bodin Dresevic [BodinD]
  225. * Wrote it.
  226. \**************************************************************************/
  227. extern "C" FIX fxLTimesEf
  228. (
  229. EFLOAT *pef,
  230. LONG l
  231. )
  232. {
  233. // *pef is a norm, already multiplied by 16 to ensure that the result
  234. // is in 28.4 format
  235. l = lCvt((*pef), l);
  236. return (FIX)l;
  237. }
  238. /******************************Public*Routine******************************\
  239. *
  240. * Routine Name:
  241. *
  242. * vLToE
  243. *
  244. * Routine Description:
  245. *
  246. * Arguments:
  247. *
  248. * Called by:
  249. *
  250. * Return Value:
  251. *
  252. \**************************************************************************/
  253. extern "C" VOID vLToE(FLOATL *pe, LONG l)
  254. {
  255. EFLOAT ef;
  256. ef = l;
  257. ef.vEfToF(*pe);
  258. }