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.

679 lines
13 KiB

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