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.

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