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.

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