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.

816 lines
15 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-1996 Microsoft Corporation
  11. * Copyright (c) 1993-1996 Matrox Electronic Systems, Ltd.
  12. \**************************************************************************/
  13. #include "precomp.h"
  14. ////////////////////////////////////////////////////////////////////////////
  15. #if DBG
  16. // This entire module is only enabled for Checked builds
  17. #define SYNCH_ENTER() 0 // do nothing
  18. #define SYNCH_LEAVE() 0 // do nothing
  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"));
  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"));
  66. SYNCH_LEAVE();
  67. }
  68. VOID DbgDisablePDEV(DHPDEV dhpdev)
  69. {
  70. PDEV* ppdev;
  71. BOOL bNeedSync;
  72. ppdev = (PDEV*) dhpdev;
  73. bNeedSync = ppdev->bEnabled;
  74. //
  75. // If a PDEV has not been disabled by DrvAssertMode
  76. // then this call is synchronized as access to the
  77. // hardware may occur. If the PDEV has been disabled
  78. // by DrvAssertMode then access to the hardware is not
  79. // allowed (all hardware access needs to be done in the
  80. // DrvAssertMode handling) and synchronization is not done
  81. // as drawing may be occurring in a different PDEV.
  82. //
  83. if (bNeedSync)
  84. {
  85. SYNCH_ENTER();
  86. }
  87. DISPDBG((5, ">> DrvDisable"));
  88. DrvDisablePDEV(dhpdev);
  89. DISPDBG((6, "<< DrvDisable"));
  90. if (bNeedSync)
  91. {
  92. SYNCH_LEAVE();
  93. }
  94. }
  95. HSURF DbgEnableSurface(DHPDEV dhpdev)
  96. {
  97. HSURF h;
  98. SYNCH_ENTER();
  99. DISPDBG((5, ">> DrvEnableSurface"));
  100. h = DrvEnableSurface(dhpdev);
  101. DISPDBG((6, "<< DrvEnableSurface"));
  102. SYNCH_LEAVE();
  103. return(h);
  104. }
  105. VOID DbgDisableSurface(DHPDEV dhpdev)
  106. {
  107. PDEV* ppdev;
  108. BOOL bNeedSync;
  109. ppdev = (PDEV*) dhpdev;
  110. bNeedSync = ppdev->bEnabled;
  111. //
  112. // If a PDEV has not been disabled by DrvAssertMode
  113. // then this call is synchronized as access to the
  114. // hardware may occur. If the PDEV has been disabled
  115. // by DrvAssertMode then access to the hardware is not
  116. // allowed (all hardware access needs to be done in the
  117. // DrvAssertMode handling) and synchronization is not done
  118. // as drawing may be occurring in a different PDEV.
  119. //
  120. if (bNeedSync)
  121. {
  122. SYNCH_ENTER();
  123. }
  124. DISPDBG((5, ">> DrvDisableSurface"));
  125. DrvDisableSurface(dhpdev);
  126. DISPDBG((6, "<< DrvDisableSurface"));
  127. if (bNeedSync)
  128. {
  129. SYNCH_LEAVE();
  130. }
  131. }
  132. BOOL DbgAssertMode(
  133. DHPDEV dhpdev,
  134. BOOL bEnable)
  135. {
  136. BOOL b;
  137. SYNCH_ENTER();
  138. DISPDBG((5, ">> DrvAssertMode"));
  139. b = DrvAssertMode(dhpdev,bEnable);
  140. DISPDBG((6, "<< DrvAssertMode"));
  141. SYNCH_LEAVE();
  142. return (b);
  143. }
  144. BOOL DbgOffset(
  145. SURFOBJ* pso,
  146. LONG x,
  147. LONG y,
  148. FLONG fl)
  149. {
  150. BOOL b;
  151. SYNCH_ENTER();
  152. DISPDBG((5, ">> DrvOffset"));
  153. b = DrvOffset(pso,x,y,fl);
  154. DISPDBG((6, "<< DrvOffset"));
  155. SYNCH_LEAVE();
  156. return (b);
  157. }
  158. //
  159. // We do not SYNCH_ENTER since we have not initalized the driver.
  160. // We just want to get the list of modes from the miniport.
  161. //
  162. ULONG DbgGetModes(
  163. HANDLE hDriver,
  164. ULONG cjSize,
  165. DEVMODEW* pdm)
  166. {
  167. ULONG u;
  168. DISPDBG((5, ">> DrvGetModes"));
  169. u = DrvGetModes(
  170. hDriver,
  171. cjSize,
  172. pdm);
  173. DISPDBG((6, "<< DrvGetModes"));
  174. return(u);
  175. }
  176. VOID DbgMovePointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl)
  177. {
  178. if (gbNull)
  179. return;
  180. // Note: Because we set GCAPS_ASYNCMOVE, we don't want to do a
  181. // SYNCH_ENTER/LEAVE here.
  182. DISPDBG((5, ">> DrvMovePointer"));
  183. DrvMovePointer(pso,x,y,prcl);
  184. DISPDBG((6, "<< DrvMovePointer"));
  185. }
  186. ULONG DbgSetPointerShape(
  187. SURFOBJ* pso,
  188. SURFOBJ* psoMask,
  189. SURFOBJ* psoColor,
  190. XLATEOBJ* pxlo,
  191. LONG xHot,
  192. LONG yHot,
  193. LONG x,
  194. LONG y,
  195. RECTL* prcl,
  196. FLONG fl)
  197. {
  198. ULONG u;
  199. if (gbNull)
  200. return(SPS_ACCEPT_NOEXCLUDE);
  201. SYNCH_ENTER();
  202. DISPDBG((5, ">> DrvSetPointerShape"));
  203. u = DrvSetPointerShape(
  204. pso,
  205. psoMask,
  206. psoColor,
  207. pxlo,
  208. xHot,
  209. yHot,
  210. x,
  211. y,
  212. prcl,
  213. fl);
  214. DISPDBG((6, "<< DrvSetPointerShape"));
  215. SYNCH_LEAVE();
  216. return(u);
  217. }
  218. ULONG DbgDitherColor(
  219. DHPDEV dhpdev,
  220. ULONG iMode,
  221. ULONG rgb,
  222. ULONG* pul)
  223. {
  224. ULONG u;
  225. if (gbNull)
  226. return(DCR_DRIVER);
  227. //
  228. // No need to Synchronize Dither color.
  229. //
  230. DISPDBG((5, ">> DrvDitherColor"));
  231. u = DrvDitherColor(
  232. dhpdev,
  233. iMode,
  234. rgb,
  235. pul);
  236. DISPDBG((6, "<< DrvDitherColor"));
  237. return(u);
  238. }
  239. BOOL DbgSetPalette(
  240. DHPDEV dhpdev,
  241. PALOBJ* ppalo,
  242. FLONG fl,
  243. ULONG iStart,
  244. ULONG cColors)
  245. {
  246. BOOL u;
  247. if (gbNull)
  248. return(TRUE);
  249. SYNCH_ENTER();
  250. DISPDBG((5, ">> DrvSetPalette"));
  251. u = DrvSetPalette(
  252. dhpdev,
  253. ppalo,
  254. fl,
  255. iStart,
  256. cColors);
  257. DISPDBG((6, "<< DrvSetPalette"));
  258. SYNCH_LEAVE();
  259. return(u);
  260. }
  261. BOOL DbgCopyBits(
  262. SURFOBJ* psoDst,
  263. SURFOBJ* psoSrc,
  264. CLIPOBJ* pco,
  265. XLATEOBJ* pxlo,
  266. RECTL* prclDst,
  267. POINTL* pptlSrc)
  268. {
  269. BOOL u;
  270. if (gbNull)
  271. return(TRUE);
  272. SYNCH_ENTER();
  273. DISPDBG((5, ">> DrvCopyBits"));
  274. u = DrvCopyBits(
  275. psoDst,
  276. psoSrc,
  277. pco,
  278. pxlo,
  279. prclDst,
  280. pptlSrc);
  281. DISPDBG((6, "<< DrvCopyBits"));
  282. SYNCH_LEAVE();
  283. return(u);
  284. }
  285. BOOL DbgBitBlt(
  286. SURFOBJ* psoDst,
  287. SURFOBJ* psoSrc,
  288. SURFOBJ* psoMask,
  289. CLIPOBJ* pco,
  290. XLATEOBJ* pxlo,
  291. RECTL* prclDst,
  292. POINTL* pptlSrc,
  293. POINTL* pptlMask,
  294. BRUSHOBJ* pbo,
  295. POINTL* pptlBrush,
  296. ROP4 rop4)
  297. {
  298. BOOL u;
  299. if (gbNull)
  300. return(TRUE);
  301. SYNCH_ENTER();
  302. DISPDBG((5, ">> DrvBitBlt"));
  303. u = DrvBitBlt(
  304. psoDst,
  305. psoSrc,
  306. psoMask,
  307. pco,
  308. pxlo,
  309. prclDst,
  310. pptlSrc,
  311. pptlMask,
  312. pbo,
  313. pptlBrush,
  314. rop4);
  315. DISPDBG((6, "<< DrvBitBlt"));
  316. SYNCH_LEAVE();
  317. return(u);
  318. }
  319. BOOL DbgTextOut(
  320. SURFOBJ* pso,
  321. STROBJ* pstro,
  322. FONTOBJ* pfo,
  323. CLIPOBJ* pco,
  324. RECTL* prclExtra,
  325. RECTL* prclOpaque,
  326. BRUSHOBJ* pboFore,
  327. BRUSHOBJ* pboOpaque,
  328. POINTL* pptlOrg,
  329. MIX mix)
  330. {
  331. BOOL u;
  332. if (gbNull)
  333. return(TRUE);
  334. SYNCH_ENTER();
  335. DISPDBG((5, ">> DrvTextOut"));
  336. u = DrvTextOut(
  337. pso,
  338. pstro,
  339. pfo,
  340. pco,
  341. prclExtra,
  342. prclOpaque,
  343. pboFore,
  344. pboOpaque,
  345. pptlOrg,
  346. mix);
  347. DISPDBG((6, "<< DrvTextOut"));
  348. SYNCH_LEAVE();
  349. return(u);
  350. }
  351. BOOL DbgStrokePath(
  352. SURFOBJ* pso,
  353. PATHOBJ* ppo,
  354. CLIPOBJ* pco,
  355. XFORMOBJ* pxo,
  356. BRUSHOBJ* pbo,
  357. POINTL* pptlBrushOrg,
  358. LINEATTRS* plineattrs,
  359. MIX mix)
  360. {
  361. BOOL u;
  362. if (gbNull)
  363. return(TRUE);
  364. SYNCH_ENTER();
  365. DISPDBG((5, ">> DrvStrokePath"));
  366. u = DrvStrokePath(
  367. pso,
  368. ppo,
  369. pco,
  370. pxo,
  371. pbo,
  372. pptlBrushOrg,
  373. plineattrs,
  374. mix);
  375. DISPDBG((6, "<< DrvStrokePath"));
  376. SYNCH_LEAVE();
  377. return(u);
  378. }
  379. BOOL DbgLineTo(
  380. SURFOBJ* pso,
  381. CLIPOBJ* pco,
  382. BRUSHOBJ* pbo,
  383. LONG x1,
  384. LONG y1,
  385. LONG x2,
  386. LONG y2,
  387. RECTL* prclBounds,
  388. MIX mix)
  389. {
  390. BOOL u;
  391. if (gbNull)
  392. return(TRUE);
  393. SYNCH_ENTER();
  394. DISPDBG((5, ">> DrvLineTo"));
  395. u = DrvLineTo(
  396. pso,
  397. pco,
  398. pbo,
  399. x1,
  400. y1,
  401. x2,
  402. y2,
  403. prclBounds,
  404. mix);
  405. DISPDBG((6, "<< DrvLineTo done"));
  406. SYNCH_LEAVE();
  407. return(u);
  408. }
  409. BOOL DbgFillPath(
  410. SURFOBJ* pso,
  411. PATHOBJ* ppo,
  412. CLIPOBJ* pco,
  413. BRUSHOBJ* pbo,
  414. POINTL* pptlBrushOrg,
  415. MIX mix,
  416. FLONG flOptions)
  417. {
  418. BOOL u;
  419. if (gbNull)
  420. return(TRUE);
  421. SYNCH_ENTER();
  422. DISPDBG((5, ">> DrvFillPath"));
  423. u = DrvFillPath(pso,
  424. ppo,
  425. pco,
  426. pbo,
  427. pptlBrushOrg,
  428. mix,
  429. flOptions);
  430. DISPDBG((6, "<< DrvFillPath"));
  431. SYNCH_LEAVE();
  432. return(u);
  433. }
  434. BOOL DbgPaint(
  435. SURFOBJ* pso,
  436. CLIPOBJ* pco,
  437. BRUSHOBJ* pbo,
  438. POINTL* pptlBrushOrg,
  439. MIX mix)
  440. {
  441. BOOL u;
  442. if (gbNull)
  443. return(TRUE);
  444. SYNCH_ENTER();
  445. DISPDBG((5, ">> DrvPaint"));
  446. u = DrvPaint(
  447. pso,
  448. pco,
  449. pbo,
  450. pptlBrushOrg,
  451. mix);
  452. DISPDBG((6, "<< DrvPaint"));
  453. SYNCH_LEAVE();
  454. return(u);
  455. }
  456. BOOL DbgRealizeBrush(
  457. BRUSHOBJ* pbo,
  458. SURFOBJ* psoTarget,
  459. SURFOBJ* psoPattern,
  460. SURFOBJ* psoMask,
  461. XLATEOBJ* pxlo,
  462. ULONG iHatch)
  463. {
  464. BOOL u;
  465. // Note: The only time DrvRealizeBrush is called by GDI is when we've
  466. // called BRUSHOBJ_pvGetRbrush in the middle of a DrvBitBlt
  467. // call, and GDI had to call us back. Since we're still in the
  468. // middle of DrvBitBlt, synchronization has already taken care of.
  469. // For the same reason, this will never be called when 'gbNull'
  470. // is TRUE, so it doesn't even make sense to check gbNull...
  471. DISPDBG((5, ">> DrvRealizeBrush"));
  472. u = DrvRealizeBrush(
  473. pbo,
  474. psoTarget,
  475. psoPattern,
  476. psoMask,
  477. pxlo,
  478. iHatch);
  479. DISPDBG((6, "<< DrvRealizeBrush"));
  480. return(u);
  481. }
  482. HBITMAP DbgCreateDeviceBitmap(DHPDEV dhpdev, SIZEL sizl, ULONG iFormat)
  483. {
  484. HBITMAP hbm;
  485. SYNCH_ENTER();
  486. DISPDBG((5, ">> DrvCreateDeviceBitmap"));
  487. hbm = DrvCreateDeviceBitmap(dhpdev, sizl, iFormat);
  488. DISPDBG((6, "<< DrvCreateDeviceBitmap"));
  489. SYNCH_LEAVE();
  490. return(hbm);
  491. }
  492. VOID DbgDeleteDeviceBitmap(DHSURF dhsurf)
  493. {
  494. SYNCH_ENTER();
  495. DISPDBG((5, ">> DrvDeleteDeviceBitmap"));
  496. DrvDeleteDeviceBitmap(dhsurf);
  497. DISPDBG((6, "<< DrvDeleteDeviceBitmap"));
  498. SYNCH_LEAVE();
  499. }
  500. VOID DbgDestroyFont(FONTOBJ* pfo)
  501. {
  502. SYNCH_ENTER();
  503. DISPDBG((5, ">> DrvDestroyFont"));
  504. DrvDestroyFont(pfo);
  505. DISPDBG((6, "<< DrvDestroyFont"));
  506. SYNCH_LEAVE();
  507. }
  508. BOOL DbgStretchBlt(
  509. SURFOBJ* psoDst,
  510. SURFOBJ* psoSrc,
  511. SURFOBJ* psoMask,
  512. CLIPOBJ* pco,
  513. XLATEOBJ* pxlo,
  514. COLORADJUSTMENT* pca,
  515. POINTL* pptlHTOrg,
  516. RECTL* prclDst,
  517. RECTL* prclSrc,
  518. POINTL* pptlMask,
  519. ULONG iMode)
  520. {
  521. BOOL u;
  522. if (gbNull)
  523. return(TRUE);
  524. SYNCH_ENTER();
  525. DISPDBG((5, "DrvStretchBlt"));
  526. #if SYNCHRONIZEACCESS_WORKS
  527. {
  528. // Our DrvStretchBlt routine calls back to EngStretchBlt, which
  529. // calls back to our DrvCopyBits routine -- so we have to be
  530. // re-entrant for synchronization...
  531. SYNCH_LEAVE();
  532. }
  533. #endif // SYNCHRONIZEACCESS_WORKS
  534. u = DrvStretchBlt(psoDst, psoSrc, psoMask, pco, pxlo, pca, pptlHTOrg,
  535. prclDst, prclSrc, pptlMask, iMode);
  536. #if SYNCHRONIZEACCESS_WORKS
  537. {
  538. SYNCH_ENTER();
  539. }
  540. #endif // SYNCHRONIZEACCESS_WORKS
  541. DISPDBG((6, "DrvStretchBlt done"));
  542. SYNCH_LEAVE();
  543. return(u);
  544. }
  545. ULONG DbgEscape(
  546. SURFOBJ* pso,
  547. ULONG iEsc,
  548. ULONG cjIn,
  549. VOID* pvIn,
  550. ULONG cjOut,
  551. VOID* pvOut)
  552. {
  553. ULONG u;
  554. if (gbNull)
  555. return(TRUE);
  556. // Most escapes are not synchronized by GDI...
  557. DISPDBG((5, "DrvEscape"));
  558. u = DrvEscape(pso,
  559. iEsc,
  560. cjIn,
  561. pvIn,
  562. cjOut,
  563. pvOut);
  564. DISPDBG((6, "DrvEscape done"));
  565. return(u);
  566. }
  567. BOOL DbgResetPDEV(
  568. DHPDEV dhpdevOld,
  569. DHPDEV dhpdevNew)
  570. {
  571. BOOL bRet;
  572. SYNCH_ENTER();
  573. DISPDBG((5, ">> DrvResetPDEV"));
  574. bRet = DrvResetPDEV(dhpdevOld, dhpdevNew);
  575. DISPDBG((6, "<< DrvResetPDEV"));
  576. SYNCH_LEAVE();
  577. return(bRet);
  578. }
  579. BOOL DbgGetDirectDrawInfo(
  580. DHPDEV dhpdev,
  581. DD_HALINFO* pHalInfo,
  582. DWORD* lpdwNumHeaps,
  583. VIDEOMEMORY* pvmList,
  584. DWORD* lpdwNumFourCC,
  585. DWORD* lpdwFourCC)
  586. {
  587. BOOL b;
  588. DISPDBG((5, ">> DbgQueryDirectDrawInfo"));
  589. b = DrvGetDirectDrawInfo(dhpdev,
  590. pHalInfo,
  591. lpdwNumHeaps,
  592. pvmList,
  593. lpdwNumFourCC,
  594. lpdwFourCC);
  595. DISPDBG((6, "<< DbgQueryDirectDrawInfo"));
  596. return(b);
  597. }
  598. BOOL DbgEnableDirectDraw(
  599. DHPDEV dhpdev,
  600. DD_CALLBACKS* pCallBacks,
  601. DD_SURFACECALLBACKS* pSurfaceCallBacks,
  602. DD_PALETTECALLBACKS* pPaletteCallBacks)
  603. {
  604. BOOL b;
  605. SYNCH_ENTER();
  606. DISPDBG((5, ">> DbgEnableDirectDraw"));
  607. b = DrvEnableDirectDraw(dhpdev,
  608. pCallBacks,
  609. pSurfaceCallBacks,
  610. pPaletteCallBacks);
  611. DISPDBG((6, "<< DbgEnableDirectDraw"));
  612. SYNCH_LEAVE();
  613. return(b);
  614. }
  615. VOID DbgDisableDirectDraw(
  616. DHPDEV dhpdev)
  617. {
  618. SYNCH_ENTER();
  619. DISPDBG((5, ">> DbgDisableDirectDraw"));
  620. DrvDisableDirectDraw(dhpdev);
  621. DISPDBG((6, "<< DbgDisableDirectDraw"));
  622. SYNCH_LEAVE();
  623. }
  624. BOOL DbgIcmSetDeviceGammaRamp(
  625. DHPDEV dhpdev,
  626. ULONG iFormat,
  627. LPVOID lpRamp)
  628. {
  629. BOOL b;
  630. SYNCH_ENTER();
  631. DISPDBG((5, ">> DbgIcmSetDeviceGammaRamp"));
  632. b = DrvIcmSetDeviceGammaRamp(dhpdev,iFormat,lpRamp);
  633. DISPDBG((6, "<< DbgIcmSetDeviceGammaRamp"));
  634. SYNCH_LEAVE();
  635. return (b);
  636. }
  637. #endif // DBG