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.

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