Source code of Windows XP (NT5)
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.

651 lines
12 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: thunk.c
  3. *
  4. * This module exists solely for testing, to make it is easy to instrument
  5. * all the driver's Drv calls.
  6. *
  7. * Note that most of this stuff will only be compiled in a checked (debug)
  8. * build.
  9. *
  10. * Copyright (c) 1993-1995 Microsoft Corporation
  11. \**************************************************************************/
  12. #include "precomp.h"
  13. ////////////////////////////////////////////////////////////////////////////
  14. #if DBG
  15. // This entire module is only enabled for Checked builds
  16. #define SYNCH_ENTER() 0 // do nothing
  17. #define SYNCH_LEAVE() 0 // do nothing
  18. ////////////////////////////////////////////////////////////////////////////
  19. BOOL gbNull = FALSE; // Set to TRUE with the debugger to test the speed
  20. // of NT with an inifinitely fast display driver
  21. // (actually, almost infinitely fast since we're
  22. // not hooking all the calls we could be)
  23. DHPDEV DbgEnablePDEV(
  24. DEVMODEW* pDevmode,
  25. PWSTR pwszLogAddress,
  26. ULONG cPatterns,
  27. HSURF* ahsurfPatterns,
  28. ULONG cjGdiInfo,
  29. ULONG* pGdiInfo,
  30. ULONG cjDevInfo,
  31. DEVINFO* pDevInfo,
  32. HDEV hdev,
  33. PWSTR pwszDeviceName,
  34. HANDLE hDriver)
  35. {
  36. DHPDEV bRet;
  37. SYNCH_ENTER();
  38. DISPDBG((5, "DrvEnablePDEV"));
  39. bRet = DrvEnablePDEV(
  40. pDevmode,
  41. pwszLogAddress,
  42. cPatterns,
  43. ahsurfPatterns,
  44. cjGdiInfo,
  45. pGdiInfo,
  46. cjDevInfo,
  47. pDevInfo,
  48. hdev,
  49. pwszDeviceName,
  50. hDriver);
  51. DISPDBG((6, "DrvEnablePDEV done"));
  52. SYNCH_LEAVE();
  53. return(bRet);
  54. }
  55. VOID DbgCompletePDEV(
  56. DHPDEV dhpdev,
  57. HDEV hdev)
  58. {
  59. SYNCH_ENTER();
  60. DISPDBG((5, "DrvCompletePDEV"));
  61. DrvCompletePDEV(
  62. dhpdev,
  63. hdev);
  64. DISPDBG((6, "DrvCompletePDEV done"));
  65. SYNCH_LEAVE();
  66. }
  67. VOID DbgDisablePDEV(DHPDEV dhpdev)
  68. {
  69. PDEV* ppdev;
  70. BOOL bNeedSync;
  71. ppdev = (PDEV*) dhpdev;
  72. bNeedSync = ppdev->bEnabled;
  73. //
  74. // If a PDEV has not been disabled by DrvAssertMode
  75. // then this call is synchronized as access to the
  76. // hardware may occur. If the PDEV has been disabled
  77. // by DrvAssertMode then access to the hardware is not
  78. // allowed (all hardware access needs to be done in the
  79. // DrvAssertMode handling) and synchronization is not done
  80. // as drawing may be occurring in a different PDEV.
  81. //
  82. if (bNeedSync)
  83. {
  84. SYNCH_ENTER();
  85. }
  86. DISPDBG((5, "DrvDisable"));
  87. DrvDisablePDEV(dhpdev);
  88. DISPDBG((6, "DrvDisable done"));
  89. if (bNeedSync)
  90. {
  91. SYNCH_LEAVE();
  92. }
  93. }
  94. HSURF DbgEnableSurface(DHPDEV dhpdev)
  95. {
  96. HSURF h;
  97. SYNCH_ENTER();
  98. DISPDBG((5, "DrvEnableSurface"));
  99. h = DrvEnableSurface(dhpdev);
  100. DISPDBG((6, "DrvEnableSurface done"));
  101. SYNCH_LEAVE();
  102. return(h);
  103. }
  104. VOID DbgDisableSurface(DHPDEV dhpdev)
  105. {
  106. PDEV* ppdev;
  107. BOOL bNeedSync;
  108. ppdev = (PDEV*) dhpdev;
  109. bNeedSync = ppdev->bEnabled;
  110. //
  111. // If a PDEV has not been disabled by DrvAssertMode
  112. // then this call is synchronized as access to the
  113. // hardware may occur. If the PDEV has been disabled
  114. // by DrvAssertMode then access to the hardware is not
  115. // allowed (all hardware access needs to be done in the
  116. // DrvAssertMode handling) and synchronization is not done
  117. // as drawing may be occurring in a different PDEV.
  118. //
  119. if (bNeedSync)
  120. {
  121. SYNCH_ENTER();
  122. }
  123. DISPDBG((5, "DrvDisableSurface"));
  124. DrvDisableSurface(dhpdev);
  125. DISPDBG((6, "DrvDisableSurface done"));
  126. if (bNeedSync)
  127. {
  128. SYNCH_LEAVE();
  129. }
  130. }
  131. BOOL DbgAssertMode(
  132. DHPDEV dhpdev,
  133. BOOL bEnable)
  134. {
  135. BOOL b;
  136. SYNCH_ENTER();
  137. DISPDBG((5, "DrvAssertMode"));
  138. b = DrvAssertMode(dhpdev,bEnable);
  139. DISPDBG((6, "DrvAssertMode done"));
  140. SYNCH_LEAVE();
  141. return (b);
  142. }
  143. //
  144. // We do not SYNCH_ENTER since we have not initalized the driver.
  145. // We just want to get the list of modes from the miniport.
  146. //
  147. ULONG DbgGetModes(
  148. HANDLE hDriver,
  149. ULONG cjSize,
  150. DEVMODEW* pdm)
  151. {
  152. ULONG u;
  153. DISPDBG((5, "DrvGetModes"));
  154. u = DrvGetModes(
  155. hDriver,
  156. cjSize,
  157. pdm);
  158. DISPDBG((6, "DrvGetModes done"));
  159. return(u);
  160. }
  161. VOID DbgMovePointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl)
  162. {
  163. if (gbNull)
  164. return;
  165. // Note: Because we set GCAPS_ASYNCMOVE, we don't want to do a
  166. // SYNCH_ENTER/LEAVE here.
  167. DISPDBG((5, "DrvMovePointer"));
  168. DrvMovePointer(pso,x,y,prcl);
  169. DISPDBG((6, "DrvMovePointer done"));
  170. }
  171. ULONG DbgSetPointerShape(
  172. SURFOBJ* pso,
  173. SURFOBJ* psoMask,
  174. SURFOBJ* psoColor,
  175. XLATEOBJ* pxlo,
  176. LONG xHot,
  177. LONG yHot,
  178. LONG x,
  179. LONG y,
  180. RECTL* prcl,
  181. FLONG fl)
  182. {
  183. ULONG u;
  184. if (gbNull)
  185. return(SPS_ACCEPT_NOEXCLUDE);
  186. SYNCH_ENTER();
  187. DISPDBG((5, "DrvSetPointerShape"));
  188. u = DrvSetPointerShape(
  189. pso,
  190. psoMask,
  191. psoColor,
  192. pxlo,
  193. xHot,
  194. yHot,
  195. x,
  196. y,
  197. prcl,
  198. fl);
  199. DISPDBG((6, "DrvSetPointerShape done"));
  200. SYNCH_LEAVE();
  201. return(u);
  202. }
  203. ULONG DbgDitherColor(
  204. DHPDEV dhpdev,
  205. ULONG iMode,
  206. ULONG rgb,
  207. ULONG* pul)
  208. {
  209. ULONG u;
  210. if (gbNull)
  211. return(DCR_DRIVER);
  212. //
  213. // No need to Synchronize Dither color.
  214. //
  215. DISPDBG((5, "DrvDitherColor"));
  216. u = DrvDitherColor(
  217. dhpdev,
  218. iMode,
  219. rgb,
  220. pul);
  221. DISPDBG((6, "DrvDitherColor done"));
  222. return(u);
  223. }
  224. BOOL DbgSetPalette(
  225. DHPDEV dhpdev,
  226. PALOBJ* ppalo,
  227. FLONG fl,
  228. ULONG iStart,
  229. ULONG cColors)
  230. {
  231. BOOL u;
  232. if (gbNull)
  233. return(TRUE);
  234. SYNCH_ENTER();
  235. DISPDBG((5, "DrvSetPalette"));
  236. u = DrvSetPalette(
  237. dhpdev,
  238. ppalo,
  239. fl,
  240. iStart,
  241. cColors);
  242. DISPDBG((6, "DrvSetPalette done"));
  243. SYNCH_LEAVE();
  244. return(u);
  245. }
  246. BOOL DbgCopyBits(
  247. SURFOBJ* psoDst,
  248. SURFOBJ* psoSrc,
  249. CLIPOBJ* pco,
  250. XLATEOBJ* pxlo,
  251. RECTL* prclDst,
  252. POINTL* pptlSrc)
  253. {
  254. BOOL u;
  255. if (gbNull)
  256. return(TRUE);
  257. SYNCH_ENTER();
  258. DISPDBG((5, "DrvCopyBits"));
  259. u = DrvCopyBits(
  260. psoDst,
  261. psoSrc,
  262. pco,
  263. pxlo,
  264. prclDst,
  265. pptlSrc);
  266. DISPDBG((6, "DrvCopyBits done"));
  267. SYNCH_LEAVE();
  268. return(u);
  269. }
  270. BOOL DbgBitBlt(
  271. SURFOBJ* psoDst,
  272. SURFOBJ* psoSrc,
  273. SURFOBJ* psoMask,
  274. CLIPOBJ* pco,
  275. XLATEOBJ* pxlo,
  276. RECTL* prclDst,
  277. POINTL* pptlSrc,
  278. POINTL* pptlMask,
  279. BRUSHOBJ* pbo,
  280. POINTL* pptlBrush,
  281. ROP4 rop4)
  282. {
  283. BOOL u;
  284. if (gbNull)
  285. return(TRUE);
  286. SYNCH_ENTER();
  287. DISPDBG((5, "DrvBitBlt"));
  288. u = DrvBitBlt(
  289. psoDst,
  290. psoSrc,
  291. psoMask,
  292. pco,
  293. pxlo,
  294. prclDst,
  295. pptlSrc,
  296. pptlMask,
  297. pbo,
  298. pptlBrush,
  299. rop4);
  300. DISPDBG((6, "DrvBitBlt done"));
  301. SYNCH_LEAVE();
  302. return(u);
  303. }
  304. BOOL DbgTextOut(
  305. SURFOBJ* pso,
  306. STROBJ* pstro,
  307. FONTOBJ* pfo,
  308. CLIPOBJ* pco,
  309. RECTL* prclExtra,
  310. RECTL* prclOpaque,
  311. BRUSHOBJ* pboFore,
  312. BRUSHOBJ* pboOpaque,
  313. POINTL* pptlOrg,
  314. MIX mix)
  315. {
  316. BOOL u;
  317. if (gbNull)
  318. return(TRUE);
  319. SYNCH_ENTER();
  320. DISPDBG((5, "DrvTextOut"));
  321. u = DrvTextOut(
  322. pso,
  323. pstro,
  324. pfo,
  325. pco,
  326. prclExtra,
  327. prclOpaque,
  328. pboFore,
  329. pboOpaque,
  330. pptlOrg,
  331. mix);
  332. DISPDBG((6, "DrvTextOut done"));
  333. SYNCH_LEAVE();
  334. return(u);
  335. }
  336. BOOL DbgStrokePath(
  337. SURFOBJ* pso,
  338. PATHOBJ* ppo,
  339. CLIPOBJ* pco,
  340. XFORMOBJ* pxo,
  341. BRUSHOBJ* pbo,
  342. POINTL* pptlBrushOrg,
  343. LINEATTRS* plineattrs,
  344. MIX mix)
  345. {
  346. BOOL u;
  347. if (gbNull)
  348. return(TRUE);
  349. SYNCH_ENTER();
  350. DISPDBG((5, "DrvStrokePath"));
  351. u = DrvStrokePath(
  352. pso,
  353. ppo,
  354. pco,
  355. pxo,
  356. pbo,
  357. pptlBrushOrg,
  358. plineattrs,
  359. mix);
  360. DISPDBG((6, "DrvStrokePath done"));
  361. SYNCH_LEAVE();
  362. return(u);
  363. }
  364. BOOL DbgFillPath(
  365. SURFOBJ* pso,
  366. PATHOBJ* ppo,
  367. CLIPOBJ* pco,
  368. BRUSHOBJ* pbo,
  369. POINTL* pptlBrushOrg,
  370. MIX mix,
  371. FLONG flOptions)
  372. {
  373. BOOL u;
  374. if (gbNull)
  375. return(TRUE);
  376. SYNCH_ENTER();
  377. DISPDBG((5, "DrvFillPath"));
  378. u = DrvFillPath(pso,
  379. ppo,
  380. pco,
  381. pbo,
  382. pptlBrushOrg,
  383. mix,
  384. flOptions);
  385. DISPDBG((6, "DrvFillPath done"));
  386. SYNCH_LEAVE();
  387. return(u);
  388. }
  389. BOOL DbgPaint(
  390. SURFOBJ* pso,
  391. CLIPOBJ* pco,
  392. BRUSHOBJ* pbo,
  393. POINTL* pptlBrushOrg,
  394. MIX mix)
  395. {
  396. BOOL u;
  397. if (gbNull)
  398. return(TRUE);
  399. SYNCH_ENTER();
  400. DISPDBG((5, "DrvPaint"));
  401. u = DrvPaint(
  402. pso,
  403. pco,
  404. pbo,
  405. pptlBrushOrg,
  406. mix);
  407. DISPDBG((6, "DrvPaint done"));
  408. SYNCH_LEAVE();
  409. return(u);
  410. }
  411. BOOL DbgRealizeBrush(
  412. BRUSHOBJ* pbo,
  413. SURFOBJ* psoTarget,
  414. SURFOBJ* psoPattern,
  415. SURFOBJ* psoMask,
  416. XLATEOBJ* pxlo,
  417. ULONG iHatch)
  418. {
  419. BOOL u;
  420. // Note: The only time DrvRealizeBrush is called by GDI is when we've
  421. // called BRUSHOBJ_pvGetRbrush in the middle of a DrvBitBlt
  422. // call, and GDI had to call us back. Since we're still in the
  423. // middle of DrvBitBlt, synchronization has already taken care of.
  424. // For the same reason, this will never be called when 'gbNull'
  425. // is TRUE, so it doesn't even make sense to check gbNull...
  426. DISPDBG((5, "DrvRealizeBrush"));
  427. u = DrvRealizeBrush(
  428. pbo,
  429. psoTarget,
  430. psoPattern,
  431. psoMask,
  432. pxlo,
  433. iHatch);
  434. DISPDBG((6, "DrvRealizeBrush done"));
  435. return(u);
  436. }
  437. HBITMAP DbgCreateDeviceBitmap(DHPDEV dhpdev, SIZEL sizl, ULONG iFormat)
  438. {
  439. HBITMAP hbm;
  440. if (gbNull) // I would pretend to have created a
  441. return(FALSE); // bitmap when gbNull is set, by we
  442. // would need some code to back this
  443. // up so that the system wouldn't
  444. // crash...
  445. SYNCH_ENTER();
  446. DISPDBG((5, "DrvCreateDeviceBitmap"));
  447. hbm = DrvCreateDeviceBitmap(dhpdev, sizl, iFormat);
  448. DISPDBG((6, "DrvCreateDeviceBitmap done"));
  449. SYNCH_LEAVE();
  450. return(hbm);
  451. }
  452. VOID DbgDeleteDeviceBitmap(DHSURF dhsurf)
  453. {
  454. SYNCH_ENTER();
  455. DISPDBG((5, "DrvDeleteDeviceBitmap"));
  456. DrvDeleteDeviceBitmap(dhsurf);
  457. DISPDBG((6, "DrvDeleteDeviceBitmap done"));
  458. SYNCH_LEAVE();
  459. }
  460. VOID DbgDestroyFont(FONTOBJ* pfo)
  461. {
  462. SYNCH_ENTER();
  463. DISPDBG((5, "DrvDestroyFont"));
  464. DrvDestroyFont(pfo);
  465. DISPDBG((6, "DrvDestroyFont done"));
  466. SYNCH_LEAVE();
  467. }
  468. BOOL DbgStretchBlt(
  469. SURFOBJ* psoDst,
  470. SURFOBJ* psoSrc,
  471. SURFOBJ* psoMask,
  472. CLIPOBJ* pco,
  473. XLATEOBJ* pxlo,
  474. COLORADJUSTMENT* pca,
  475. POINTL* pptlHTOrg,
  476. RECTL* prclDst,
  477. RECTL* prclSrc,
  478. POINTL* pptlMask,
  479. ULONG iMode)
  480. {
  481. BOOL u;
  482. if (gbNull)
  483. return(TRUE);
  484. SYNCH_ENTER();
  485. DISPDBG((5, "DrvStretchBlt"));
  486. {
  487. // Our DrvStretchBlt routine calls back to EngStretchBlt, which
  488. // calls back to our DrvCopyBits routine -- so we have to be
  489. // re-entrant for synchronization...
  490. SYNCH_LEAVE();
  491. }
  492. u = DrvStretchBlt(psoDst, psoSrc, psoMask, pco, pxlo, pca, pptlHTOrg,
  493. prclDst, prclSrc, pptlMask, iMode);
  494. {
  495. SYNCH_ENTER();
  496. }
  497. DISPDBG((6, "DrvStretchBlt done"));
  498. SYNCH_LEAVE();
  499. return(u);
  500. }
  501. VOID DbgSynchronize(
  502. DHPDEV dhpdev,
  503. RECTL* prcl)
  504. {
  505. SYNCH_ENTER();
  506. DISPDBG((5, "DrvSynchronize"));
  507. DrvSynchronize(dhpdev, prcl);
  508. DISPDBG((6, "DrvSynchronize done"));
  509. SYNCH_LEAVE();
  510. }
  511. #endif