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.

1209 lines
26 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: thunk.c
  8. *
  9. * Content:
  10. *
  11. * This module exists solely for testing, to make it is easy to instrument
  12. * all the driver's Drv calls.
  13. *
  14. * Note that most of this stuff will only be compiled in a checked (debug)
  15. * build.
  16. *
  17. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  18. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  19. \*****************************************************************************/
  20. #include "precomp.h"
  21. #include "glint.h"
  22. #if DBG
  23. // default these to FALSE
  24. BOOL bPuntCopyBits = FALSE;
  25. BOOL bPuntBitBlt = FALSE;
  26. BOOL bPuntTextOut = FALSE;
  27. BOOL bPuntStrokePath = FALSE;
  28. BOOL bPuntLineTo = FALSE;
  29. BOOL bPuntFillPath = FALSE;
  30. BOOL bPuntPaint = FALSE;
  31. #endif //DBG
  32. ////////////////////////////////////////////////////////////////////////////
  33. #if DBG || !SYNCHRONIZEACCESS_WORKS
  34. // This entire module is only enabled for Checked builds, or when we
  35. // have to explicitly synchronize bitmap access ourselves.
  36. ////////////////////////////////////////////////////////////////////////////
  37. // By default, GDI does not synchronize drawing to device-bitmaps. Since
  38. // our hardware dictates that only one thread can access the accelerator
  39. // at a time, we have to synchronize bitmap access.
  40. //
  41. // If we're running on Windows NT 3.1, we have to do it ourselves.
  42. //
  43. // If we're running on Windows NT 3.5 or later, we can ask GDI to do it
  44. // by setting HOOK_SYNCHRONIZEACCESS when we associate a device-bitmap
  45. // surface.
  46. extern HSEMAPHORE g_cs;
  47. #define SYNCH_ENTER() EngAcquireSemaphore(g_cs);
  48. #define SYNCH_LEAVE() EngReleaseSemaphore(g_cs);
  49. ////////////////////////////////////////////////////////////////////////////
  50. BOOL gbNull = FALSE; // Set to TRUE with the debugger to test the speed
  51. // of NT with an inifinitely fast display driver
  52. // (actually, almost infinitely fast since we're
  53. // not hooking all the calls we could be)
  54. BOOL inBitBlt = FALSE;
  55. VOID DbgDisableDriver(VOID)
  56. {
  57. SYNCH_ENTER();
  58. DISPDBG((5, "DrvDisableDriver"));
  59. DrvDisableDriver();
  60. DISPDBG((6, "DrvDisableDriver done"));
  61. SYNCH_LEAVE();
  62. }
  63. DHPDEV DbgEnablePDEV(
  64. DEVMODEW* pDevmode,
  65. PWSTR pwszLogAddress,
  66. ULONG cPatterns,
  67. HSURF* ahsurfPatterns,
  68. ULONG cjGdiInfo,
  69. ULONG* pGdiInfo,
  70. ULONG cjDevInfo,
  71. DEVINFO* pDevInfo,
  72. HDEV hdev,
  73. PWSTR pwszDeviceName,
  74. HANDLE hDriver)
  75. {
  76. DHPDEV bRet;
  77. SYNCH_ENTER();
  78. DISPDBG((5, "DrvEnablePDEV"));
  79. bRet = DrvEnablePDEV(
  80. pDevmode,
  81. pwszLogAddress,
  82. cPatterns,
  83. ahsurfPatterns,
  84. cjGdiInfo,
  85. pGdiInfo,
  86. cjDevInfo,
  87. pDevInfo,
  88. hdev,
  89. pwszDeviceName,
  90. hDriver);
  91. DISPDBG((6, "DrvEnablePDEV done"));
  92. SYNCH_LEAVE();
  93. return(bRet);
  94. }
  95. VOID DbgCompletePDEV(
  96. DHPDEV dhpdev,
  97. HDEV hdev)
  98. {
  99. SYNCH_ENTER();
  100. DISPDBG((5, "DrvCompletePDEV"));
  101. DrvCompletePDEV(
  102. dhpdev,
  103. hdev);
  104. DISPDBG((6, "DrvCompletePDEV done"));
  105. SYNCH_LEAVE();
  106. }
  107. VOID DbgDisablePDEV(DHPDEV dhpdev)
  108. {
  109. SYNCH_ENTER();
  110. DISPDBG((5, "DrvDisable"));
  111. DrvDisablePDEV(dhpdev);
  112. DISPDBG((6, "DrvDisable done"));
  113. SYNCH_LEAVE();
  114. }
  115. HSURF DbgEnableSurface(DHPDEV dhpdev)
  116. {
  117. HSURF h;
  118. SYNCH_ENTER();
  119. DISPDBG((5, "DrvEnableSurface"));
  120. h = DrvEnableSurface(dhpdev);
  121. DISPDBG((6, "DrvEnableSurface done"));
  122. SYNCH_LEAVE();
  123. return(h);
  124. }
  125. VOID DbgDisableSurface(DHPDEV dhpdev)
  126. {
  127. SYNCH_ENTER();
  128. DISPDBG((5, "DrvDisableSurface"));
  129. DrvDisableSurface(dhpdev);
  130. DISPDBG((6, "DrvDisableSurface done"));
  131. SYNCH_LEAVE();
  132. }
  133. BOOL DbgAssertMode(
  134. DHPDEV dhpdev,
  135. BOOL bEnable)
  136. {
  137. BOOL bRet;
  138. SYNCH_ENTER();
  139. DISPDBG((5, "DrvAssertMode"));
  140. bRet = DrvAssertMode(dhpdev,bEnable);
  141. DISPDBG((6, "DrvAssertMode done"));
  142. SYNCH_LEAVE();
  143. return(bRet);
  144. }
  145. //
  146. // We do not SYNCH_ENTER since we have not initalized the driver.
  147. // We just want to get the list of modes from the miniport.
  148. //
  149. ULONG DbgGetModes(
  150. HANDLE hDriver,
  151. ULONG cjSize,
  152. DEVMODEW* pdm)
  153. {
  154. ULONG u;
  155. DISPDBG((5, "DrvGetModes"));
  156. u = DrvGetModes(
  157. hDriver,
  158. cjSize,
  159. pdm);
  160. DISPDBG((6, "DrvGetModes done"));
  161. return(u);
  162. }
  163. VOID DbgMovePointer(SURFOBJ *pso,LONG x,LONG y,RECTL *prcl)
  164. {
  165. if (gbNull)
  166. return;
  167. #if DBG
  168. {
  169. PPDEV ppdev = (PPDEV)pso->dhpdev;
  170. CHECK_MEMORY_VIEW(ppdev);
  171. }
  172. #endif
  173. // We don't synchronise access to this routine. If the cursor is hardware
  174. // the move can be done at any time and if it is software GDI locks the
  175. // access for us.
  176. DISPDBG((15, "DrvMovePointer 0x%x 0x%x", x, y));
  177. DrvMovePointer(pso,x,y,prcl);
  178. DISPDBG((16, "DrvMovePointer done"));
  179. }
  180. ULONG DbgSetPointerShape(
  181. SURFOBJ* pso,
  182. SURFOBJ* psoMask,
  183. SURFOBJ* psoColor,
  184. XLATEOBJ* pxlo,
  185. LONG xHot,
  186. LONG yHot,
  187. LONG x,
  188. LONG y,
  189. RECTL* prcl,
  190. FLONG fl)
  191. {
  192. ULONG u;
  193. if (gbNull)
  194. return(SPS_ACCEPT_NOEXCLUDE);
  195. SYNCH_ENTER();
  196. #if DBG
  197. {
  198. PPDEV ppdev = (PPDEV)pso->dhpdev;
  199. CHECK_MEMORY_VIEW(ppdev);
  200. }
  201. #endif
  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 done"));
  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. DISPDBG((5, "DrvDitherColor"));
  228. u = DrvDitherColor(
  229. dhpdev,
  230. iMode,
  231. rgb,
  232. pul);
  233. DISPDBG((6, "DrvDitherColor done"));
  234. return(u);
  235. }
  236. BOOL DbgSetPalette(
  237. DHPDEV dhpdev,
  238. PALOBJ* ppalo,
  239. FLONG fl,
  240. ULONG iStart,
  241. ULONG cColors)
  242. {
  243. BOOL u;
  244. if (gbNull)
  245. return(TRUE);
  246. SYNCH_ENTER();
  247. DISPDBG((5, "DrvSetPalette"));
  248. u = DrvSetPalette(
  249. dhpdev,
  250. ppalo,
  251. fl,
  252. iStart,
  253. cColors);
  254. DISPDBG((6, "DrvSetPalette done"));
  255. SYNCH_LEAVE();
  256. return(u);
  257. }
  258. BOOL DbgCopyBits(
  259. SURFOBJ* psoDst,
  260. SURFOBJ* psoSrc,
  261. CLIPOBJ* pco,
  262. XLATEOBJ* pxlo,
  263. RECTL* prclDst,
  264. POINTL* pptlSrc)
  265. {
  266. BOOL u;
  267. if (gbNull)
  268. return(TRUE);
  269. #if DBG
  270. {
  271. PPDEV ppdev = (psoSrc && psoSrc->iType != STYPE_BITMAP) ? (PPDEV)psoSrc->dhpdev : (PPDEV)psoDst->dhpdev;
  272. CHECK_MEMORY_VIEW(ppdev);
  273. if(bPuntCopyBits)
  274. {
  275. SYNCH_ENTER();
  276. if(psoSrc->iType != STYPE_BITMAP)
  277. {
  278. DSURF *pdsurfSrc = (DSURF *)psoSrc->dhsurf;
  279. psoSrc = pdsurfSrc->pso;
  280. }
  281. if(psoDst->iType != STYPE_BITMAP)
  282. {
  283. DSURF *pdsurfDst = (DSURF *)psoDst->dhsurf;
  284. psoDst = pdsurfDst->pso;
  285. }
  286. u = EngCopyBits(psoDst, psoSrc, pco, pxlo, prclDst, pptlSrc);
  287. SYNCH_LEAVE();
  288. return(u);
  289. }
  290. }
  291. #endif //DBG
  292. SYNCH_ENTER();
  293. DISPDBG((5, "DrvCopyBits"));
  294. u = DrvCopyBits(
  295. psoDst,
  296. psoSrc,
  297. pco,
  298. pxlo,
  299. prclDst,
  300. pptlSrc);
  301. DISPDBG((6, "DrvCopyBits done"));
  302. SYNCH_LEAVE();
  303. return(u);
  304. }
  305. BOOL DbgBitBlt(
  306. SURFOBJ* psoDst,
  307. SURFOBJ* psoSrc,
  308. SURFOBJ* psoMask,
  309. CLIPOBJ* pco,
  310. XLATEOBJ* pxlo,
  311. RECTL* prclDst,
  312. POINTL* pptlSrc,
  313. POINTL* pptlMask,
  314. BRUSHOBJ* pbo,
  315. POINTL* pptlBrush,
  316. ROP4 rop4)
  317. {
  318. BOOL u;
  319. if (gbNull)
  320. return(TRUE);
  321. #if DBG
  322. {
  323. PPDEV ppdev = (psoSrc && psoSrc->iType != STYPE_BITMAP) ? (PPDEV)psoSrc->dhpdev : (PPDEV)psoDst->dhpdev;
  324. CHECK_MEMORY_VIEW(ppdev);
  325. if(bPuntBitBlt)
  326. {
  327. SYNCH_ENTER();
  328. if(psoSrc && psoSrc->iType != STYPE_BITMAP)
  329. {
  330. DSURF *pdsurfSrc = (DSURF *)psoSrc->dhsurf;
  331. psoSrc = pdsurfSrc->pso;
  332. }
  333. if(psoDst && psoDst->iType != STYPE_BITMAP)
  334. {
  335. DSURF *pdsurfDst = (DSURF *)psoDst->dhsurf;
  336. psoDst = pdsurfDst->pso;
  337. }
  338. u = EngBitBlt(psoDst, psoSrc, psoMask, pco, pxlo, prclDst, pptlSrc, pptlMask, pbo, pptlBrush, rop4);
  339. SYNCH_LEAVE();
  340. return(u);
  341. }
  342. }
  343. #endif //DBG
  344. SYNCH_ENTER();
  345. DISPDBG((5, "DrvBitBlt: psoDst(%p) psoSrc(%p) psoMask(%p) pbo(%p) rop(%08x)", psoDst, psoSrc, psoMask, pbo, rop4));
  346. inBitBlt = TRUE;
  347. u = DrvBitBlt(
  348. psoDst,
  349. psoSrc,
  350. psoMask,
  351. pco,
  352. pxlo,
  353. prclDst,
  354. pptlSrc,
  355. pptlMask,
  356. pbo,
  357. pptlBrush,
  358. rop4);
  359. inBitBlt = FALSE;
  360. DISPDBG((6, "DrvBitBlt done"));
  361. SYNCH_LEAVE();
  362. return(u);
  363. }
  364. BOOL DbgTextOut(
  365. SURFOBJ* pso,
  366. STROBJ* pstro,
  367. FONTOBJ* pfo,
  368. CLIPOBJ* pco,
  369. RECTL* prclExtra,
  370. RECTL* prclOpaque,
  371. BRUSHOBJ* pboFore,
  372. BRUSHOBJ* pboOpaque,
  373. POINTL* pptlOrg,
  374. MIX mix)
  375. {
  376. BOOL u;
  377. if (gbNull)
  378. return(TRUE);
  379. #if DBG
  380. {
  381. PPDEV ppdev = (PPDEV)pso->dhpdev;
  382. CHECK_MEMORY_VIEW(ppdev);
  383. if(bPuntTextOut)
  384. {
  385. SYNCH_ENTER();
  386. if(pso->iType != STYPE_BITMAP)
  387. {
  388. DSURF *pdsurf = (DSURF *)pso->dhsurf;
  389. pso = pdsurf->pso;
  390. }
  391. u = EngTextOut(pso, pstro, pfo, pco, prclExtra, prclOpaque, pboFore, pboOpaque, pptlOrg, mix);
  392. SYNCH_LEAVE();
  393. return(u);
  394. }
  395. }
  396. #endif //DBG
  397. SYNCH_ENTER();
  398. DISPDBG((5, "DrvTextOut"));
  399. u = DrvTextOut(
  400. pso,
  401. pstro,
  402. pfo,
  403. pco,
  404. prclExtra,
  405. prclOpaque,
  406. pboFore,
  407. pboOpaque,
  408. pptlOrg,
  409. mix);
  410. DISPDBG((6, "DrvTextOut done"));
  411. SYNCH_LEAVE();
  412. return(u);
  413. }
  414. BOOL DbgStrokePath(
  415. SURFOBJ* pso,
  416. PATHOBJ* ppo,
  417. CLIPOBJ* pco,
  418. XFORMOBJ* pxo,
  419. BRUSHOBJ* pbo,
  420. POINTL* pptlBrushOrg,
  421. LINEATTRS* plineattrs,
  422. MIX mix)
  423. {
  424. BOOL u;
  425. if (gbNull)
  426. return(TRUE);
  427. #if DBG
  428. {
  429. PPDEV ppdev = (PPDEV)pso->dhpdev;
  430. CHECK_MEMORY_VIEW(ppdev);
  431. if(bPuntStrokePath)
  432. {
  433. SYNCH_ENTER();
  434. if(pso && pso->iType != STYPE_BITMAP)
  435. {
  436. DSURF *pdsurf = (DSURF *)pso->dhsurf;
  437. pso = pdsurf->pso;
  438. }
  439. u = EngStrokePath(pso, ppo, pco, pxo, pbo, pptlBrushOrg, plineattrs, mix);
  440. SYNCH_LEAVE();
  441. return(u);
  442. }
  443. }
  444. #endif //DBG
  445. SYNCH_ENTER();
  446. DISPDBG((5, "DrvStrokePath"));
  447. u = DrvStrokePath(
  448. pso,
  449. ppo,
  450. pco,
  451. pxo,
  452. pbo,
  453. pptlBrushOrg,
  454. plineattrs,
  455. mix);
  456. DISPDBG((6, "DrvStrokePath done"));
  457. SYNCH_LEAVE();
  458. return(u);
  459. }
  460. BOOL DbgLineTo(
  461. SURFOBJ* pso,
  462. CLIPOBJ* pco,
  463. BRUSHOBJ* pbo,
  464. LONG x1,
  465. LONG y1,
  466. LONG x2,
  467. LONG y2,
  468. RECTL *prclBounds,
  469. MIX mix)
  470. {
  471. BOOL u;
  472. if (gbNull)
  473. return(TRUE);
  474. #if DBG
  475. {
  476. PPDEV ppdev = (PPDEV)pso->dhpdev;
  477. CHECK_MEMORY_VIEW(ppdev);
  478. if(bPuntLineTo)
  479. {
  480. SYNCH_ENTER();
  481. if(pso && pso->iType != STYPE_BITMAP)
  482. {
  483. DSURF *pdsurf = (DSURF *)pso->dhsurf;
  484. pso = pdsurf->pso;
  485. }
  486. u = EngLineTo(pso, pco, pbo, x1, y1, x2, y2, prclBounds, mix);
  487. SYNCH_LEAVE();
  488. return(u);
  489. }
  490. }
  491. #endif //DBG
  492. SYNCH_ENTER();
  493. DISPDBG((5, "DrvLineTo"));
  494. u = DrvLineTo(
  495. pso,
  496. pco,
  497. pbo,
  498. x1,
  499. y1,
  500. x2,
  501. y2,
  502. prclBounds,
  503. mix);
  504. DISPDBG((6, "DrvLineTo done"));
  505. SYNCH_LEAVE();
  506. return(u);
  507. }
  508. BOOL DbgFillPath(
  509. SURFOBJ* pso,
  510. PATHOBJ* ppo,
  511. CLIPOBJ* pco,
  512. BRUSHOBJ* pbo,
  513. POINTL* pptlBrushOrg,
  514. MIX mix,
  515. FLONG flOptions)
  516. {
  517. BOOL u;
  518. if (gbNull)
  519. return(TRUE);
  520. #if DBG
  521. {
  522. PPDEV ppdev = (PPDEV)pso->dhpdev;
  523. CHECK_MEMORY_VIEW(ppdev);
  524. if(bPuntFillPath)
  525. {
  526. SYNCH_ENTER();
  527. if(pso && pso->iType != STYPE_BITMAP)
  528. {
  529. DSURF *pdsurf = (DSURF *)pso->dhsurf;
  530. pso = pdsurf->pso;
  531. }
  532. u = EngFillPath(pso, ppo, pco, pbo, pptlBrushOrg, mix, flOptions);
  533. SYNCH_LEAVE();
  534. return(u);
  535. }
  536. }
  537. #endif //DBG
  538. SYNCH_ENTER();
  539. DISPDBG((5, "DrvFillPath"));
  540. u = DrvFillPath(pso,
  541. ppo,
  542. pco,
  543. pbo,
  544. pptlBrushOrg,
  545. mix,
  546. flOptions);
  547. DISPDBG((6, "DrvFillPath done"));
  548. SYNCH_LEAVE();
  549. return(u);
  550. }
  551. BOOL DbgPaint(
  552. SURFOBJ* pso,
  553. CLIPOBJ* pco,
  554. BRUSHOBJ* pbo,
  555. POINTL* pptlBrushOrg,
  556. MIX mix)
  557. {
  558. BOOL u;
  559. if (gbNull)
  560. return(TRUE);
  561. #if DBG
  562. {
  563. PPDEV ppdev = (PPDEV)pso->dhpdev;
  564. CHECK_MEMORY_VIEW(ppdev);
  565. if(bPuntPaint)
  566. {
  567. SYNCH_ENTER();
  568. if(pso && pso->iType != STYPE_BITMAP)
  569. {
  570. DSURF *pdsurf = (DSURF *)pso->dhsurf;
  571. pso = pdsurf->pso;
  572. }
  573. u = EngPaint(pso, pco, pbo, pptlBrushOrg, mix);
  574. SYNCH_LEAVE();
  575. return(u);
  576. }
  577. }
  578. #endif //DBG
  579. SYNCH_ENTER();
  580. DISPDBG((5, "DrvPaint"));
  581. u = DrvPaint(
  582. pso,
  583. pco,
  584. pbo,
  585. pptlBrushOrg,
  586. mix);
  587. DISPDBG((6, "DrvPaint done"));
  588. SYNCH_LEAVE();
  589. return(u);
  590. }
  591. BOOL DbgRealizeBrush(
  592. BRUSHOBJ* pbo,
  593. SURFOBJ* psoTarget,
  594. SURFOBJ* psoPattern,
  595. SURFOBJ* psoMask,
  596. XLATEOBJ* pxlo,
  597. ULONG iHatch)
  598. {
  599. BOOL u;
  600. //@@BEGIN_DDKSPLIT
  601. // Note: The only time DrvRealizeBrush is called by GDI is when we've
  602. // called BRUSHOBJ_pvGetRbrush in the middle of a DrvBitBlt
  603. // call, and GDI had to call us back. Since we're still in the
  604. // middle of DrvBitBlt, synchronization has already taken care of.
  605. // For the same reason, this will never be called when 'gbNull'
  606. // is TRUE, so it doesn't even make sense to check gbNull...
  607. // I've seen this to be untrue at least once on a MIPS so ...
  608. //@@END_DDKSPLIT
  609. if (!inBitBlt)
  610. SYNCH_ENTER();
  611. DISPDBG((5, "DrvRealizeBrush"));
  612. u = DrvRealizeBrush(
  613. pbo,
  614. psoTarget,
  615. psoPattern,
  616. psoMask,
  617. pxlo,
  618. iHatch);
  619. DISPDBG((6, "DrvRealizeBrush done"));
  620. if (!inBitBlt)
  621. SYNCH_LEAVE();
  622. return(u);
  623. }
  624. HBITMAP DbgCreateDeviceBitmap(DHPDEV dhpdev, SIZEL sizl, ULONG iFormat)
  625. {
  626. HBITMAP hbm;
  627. //@@BEGIN_DDKSPLIT
  628. #if 0
  629. if (gbNull) // I would pretend to have created a
  630. return(FALSE); // bitmap when gbNull is set, by we
  631. // would need some code to back this
  632. // up so that the system wouldn't
  633. // crash...
  634. #endif
  635. //@@END_DDKSPLIT
  636. SYNCH_ENTER();
  637. #if DBG
  638. {
  639. PPDEV ppdev = (PPDEV)dhpdev;
  640. CHECK_MEMORY_VIEW(ppdev);
  641. }
  642. #endif
  643. DISPDBG((5, "DrvCreateDeviceBitmap"));
  644. hbm = DrvCreateDeviceBitmap(dhpdev, sizl, iFormat);
  645. DISPDBG((6, "DrvCreateDeviceBitmap done"));
  646. SYNCH_LEAVE();
  647. return(hbm);
  648. }
  649. VOID DbgDeleteDeviceBitmap(DHSURF dhsurf)
  650. {
  651. SYNCH_ENTER();
  652. #if DBG
  653. {
  654. PPDEV ppdev = ((DSURF *)dhsurf)->ppdev;
  655. CHECK_MEMORY_VIEW(ppdev);
  656. }
  657. #endif
  658. DISPDBG((5, "DrvDeleteDeviceBitmap"));
  659. DrvDeleteDeviceBitmap(dhsurf);
  660. DISPDBG((6, "DrvDeleteDeviceBitmap done"));
  661. SYNCH_LEAVE();
  662. }
  663. //@@BEGIN_DDKSPLIT
  664. #define DRV_STRETCH_SUPPORTED 0
  665. #if DRV_STRETCH_SUPPORTED
  666. #if DBG
  667. #define STRETCH_COPY 0x00000000
  668. #define STRETCH_DOWNLOAD 0x00000001
  669. #define STRETCH_COLORONCOLOR 0x00000000
  670. #define STRETCH_BLACKONWHITE 0x00000002
  671. #define STRETCH_WHITEONBLACK 0x00000004
  672. #define STRETCH_SOURCE_1BPP 0x00000000
  673. #define STRETCH_SOURCE_4BPP 0x00000008
  674. #define STRETCH_SOURCE_8BPP 0x00000010
  675. #define STRETCH_SOURCE_16BPP 0x00000020
  676. #define STRETCH_SOURCE_24BPP 0x00000040
  677. #define STRETCH_SOURCE_32BPP 0x00000080
  678. #define STRETCH_ONE2ONE_X 0x00000000
  679. #define STRETCH_GROW_X 0x00000100
  680. #define STRETCH_SHRINK_X 0x00000200
  681. #define STRETCH_ONE2ONE_Y 0x00000000
  682. #define STRETCH_GROW_Y 0x00000400
  683. #define STRETCH_SHRINK_Y 0x00000800
  684. ULONG aStretch[0x900];
  685. #endif // DBG
  686. BOOL DbgStretchBlt(
  687. SURFOBJ* psoDst,
  688. SURFOBJ* psoSrc,
  689. SURFOBJ* psoMask,
  690. CLIPOBJ* pco,
  691. XLATEOBJ* pxlo,
  692. COLORADJUSTMENT* pca,
  693. POINTL* pptlHTOrg,
  694. RECTL* prclDst,
  695. RECTL* prclSrc,
  696. POINTL* pptlMask,
  697. ULONG iMode)
  698. {
  699. BOOL u;
  700. if (gbNull)
  701. return(TRUE);
  702. SYNCH_ENTER();
  703. DISPDBG((5, "DrvStretchBlt"));
  704. #if SYNCHRONIZEACCESS_WORKS
  705. {
  706. // Our DrvStretchBlt routine calls back to EngStretchBlt, which
  707. // calls back to our DrvCopyBits routine -- so we have to be
  708. // re-entrant for synchronization...
  709. SYNCH_LEAVE();
  710. }
  711. #endif // SYNCHRONIZEACCESS_WORKS
  712. #if DBG
  713. {
  714. int i;
  715. SIZEL sizlSrc;
  716. SIZEL sizlDst;
  717. i = (psoSrc->iType == STYPE_BITMAP) ? STRETCH_DOWNLOAD :
  718. STRETCH_COPY;
  719. i |= (iMode == COLORONCOLOR) ? STRETCH_COLORONCOLOR :
  720. (iMode == BLACKONWHITE) ? STRETCH_BLACKONWHITE :
  721. STRETCH_WHITEONBLACK;
  722. i |= (psoSrc->iBitmapFormat == BMF_1BPP) ? STRETCH_SOURCE_1BPP :
  723. (psoSrc->iBitmapFormat == BMF_4BPP) ? STRETCH_SOURCE_4BPP :
  724. (psoSrc->iBitmapFormat == BMF_8BPP) ? STRETCH_SOURCE_8BPP :
  725. (psoSrc->iBitmapFormat == BMF_16BPP) ? STRETCH_SOURCE_16BPP :
  726. (psoSrc->iBitmapFormat == BMF_24BPP) ? STRETCH_SOURCE_24BPP :
  727. STRETCH_SOURCE_32BPP;
  728. sizlSrc.cx = prclSrc->right - prclSrc->left;
  729. if((int)sizlSrc.cx < 0)
  730. sizlSrc.cx = (ULONG)-(int)sizlSrc.cx;
  731. sizlSrc.cy = prclSrc->bottom - prclSrc->top;
  732. if((int)sizlSrc.cy < 0)
  733. sizlSrc.cy = (ULONG)-(int)sizlSrc.cy;
  734. sizlDst.cx = prclDst->right - prclDst->left;
  735. if((int)sizlDst.cx < 0)
  736. sizlDst.cx = (ULONG)-(int)sizlDst.cx;
  737. sizlDst.cy = prclDst->bottom - prclDst->top;
  738. if((int)sizlDst.cy < 0)
  739. sizlDst.cy = (ULONG)-(int)sizlDst.cy;
  740. i |= (sizlSrc.cx == sizlDst.cx) ? STRETCH_ONE2ONE_X :
  741. (sizlSrc.cx < sizlDst.cx) ? STRETCH_GROW_X :
  742. STRETCH_SHRINK_X;
  743. i |= (sizlSrc.cy == sizlDst.cy) ? STRETCH_ONE2ONE_Y :
  744. (sizlSrc.cy < sizlDst.cy) ? STRETCH_GROW_Y :
  745. STRETCH_SHRINK_Y;
  746. ++aStretch[i];
  747. }
  748. #endif
  749. u = DrvStretchBlt(psoDst, psoSrc, psoMask, pco, pxlo, pca, pptlHTOrg,
  750. prclDst, prclSrc, pptlMask, iMode);
  751. #if SYNCHRONIZEACCESS_WORKS
  752. {
  753. SYNCH_ENTER();
  754. }
  755. #endif // SYNCHRONIZEACCESS_WORKS
  756. DISPDBG((6, "DrvStretchBlt done"));
  757. SYNCH_LEAVE();
  758. return(u);
  759. }
  760. #endif // DRV_STRETCH_SUPPORTED
  761. //@@END_DDKSPLIT
  762. ULONG
  763. DbgEscape(
  764. SURFOBJ *pso,
  765. ULONG iEsc,
  766. ULONG cjIn,
  767. VOID *pvIn,
  768. ULONG cjOut,
  769. VOID *pvOut)
  770. {
  771. ULONG u;
  772. if (gbNull)
  773. return(TRUE);
  774. SYNCH_ENTER();
  775. #if DBG
  776. {
  777. PPDEV ppdev = (PPDEV)pso->dhpdev;
  778. CHECK_MEMORY_VIEW(ppdev);
  779. }
  780. #endif
  781. DISPDBG((5, "DrvEscape"));
  782. u = DrvEscape(pso, iEsc, cjIn, pvIn, cjOut, pvOut);
  783. DISPDBG((6, "DrvEscape done"));
  784. SYNCH_LEAVE();
  785. return(u);
  786. }
  787. ULONG
  788. DbgDrawEscape(
  789. SURFOBJ *pso,
  790. ULONG iEsc,
  791. CLIPOBJ *pco,
  792. RECTL *prcl,
  793. ULONG cjIn,
  794. VOID *pvIn)
  795. {
  796. ULONG u;
  797. if (gbNull)
  798. return(TRUE);
  799. SYNCH_ENTER();
  800. #if DBG
  801. {
  802. PPDEV ppdev = (PPDEV)pso->dhpdev;
  803. CHECK_MEMORY_VIEW(ppdev);
  804. }
  805. #endif
  806. DISPDBG((5, "DrvDrawEscape"));
  807. // Nothing to do....
  808. u = (ULONG)-1;
  809. DISPDBG((6, "DrvDrawEscape done"));
  810. SYNCH_LEAVE();
  811. return(u);
  812. }
  813. BOOL DbgResetPDEV(
  814. DHPDEV dhpdevOld,
  815. DHPDEV dhpdevNew)
  816. {
  817. BOOL bRet;
  818. SYNCH_ENTER();
  819. DISPDBG((5, ">> DrvResetPDEV"));
  820. bRet = DrvResetPDEV(dhpdevOld, dhpdevNew);
  821. DISPDBG((6, "<< DrvResetPDEV"));
  822. SYNCH_LEAVE();
  823. return(bRet);
  824. }
  825. VOID DbgSynchronize(
  826. DHPDEV dhpdev,
  827. RECTL *prcl)
  828. {
  829. DISPDBG((5, "DbgSynchronize"));
  830. //
  831. // don't do SYNCH_ENTER checks here as we will be called from within
  832. // an Eng routine that is called from within a Drv function.
  833. //
  834. DrvSynchronize(
  835. dhpdev,
  836. prcl);
  837. DISPDBG((6, "DbgSynchronize done"));
  838. }
  839. #if WNT_DDRAW
  840. BOOL DbgGetDirectDrawInfo(
  841. DHPDEV dhpdev,
  842. DD_HALINFO* pHalInfo,
  843. DWORD* lpdwNumHeaps,
  844. VIDEOMEMORY* pvmList,
  845. DWORD* lpdwNumFourCC,
  846. DWORD* lpdwFourCC)
  847. {
  848. BOOL b;
  849. DISPDBG((5, ">> DbgQueryDirectDrawInfo"));
  850. b = DrvGetDirectDrawInfo(dhpdev,
  851. pHalInfo,
  852. lpdwNumHeaps,
  853. pvmList,
  854. lpdwNumFourCC,
  855. lpdwFourCC);
  856. DISPDBG((6, "<< DbgQueryDirectDrawInfo"));
  857. return(b);
  858. }
  859. BOOL DbgEnableDirectDraw(
  860. DHPDEV dhpdev,
  861. DD_CALLBACKS* pCallBacks,
  862. DD_SURFACECALLBACKS* pSurfaceCallBacks,
  863. DD_PALETTECALLBACKS* pPaletteCallBacks)
  864. {
  865. BOOL b;
  866. SYNCH_ENTER();
  867. DISPDBG((5, ">> DbgEnableDirectDraw"));
  868. b = DrvEnableDirectDraw(dhpdev,
  869. pCallBacks,
  870. pSurfaceCallBacks,
  871. pPaletteCallBacks);
  872. DISPDBG((6, "<< DbgEnableDirectDraw"));
  873. SYNCH_LEAVE();
  874. return(b);
  875. }
  876. VOID DbgDisableDirectDraw(
  877. DHPDEV dhpdev)
  878. {
  879. SYNCH_ENTER();
  880. DISPDBG((5, ">> DbgDisableDirectDraw"));
  881. DrvDisableDirectDraw(dhpdev);
  882. DISPDBG((6, "<< DbgDisableDirectDraw"));
  883. SYNCH_LEAVE();
  884. }
  885. #endif // WNT_DDRAW
  886. #if(_WIN32_WINNT >= 0x500)
  887. BOOL DbgIcmSetDeviceGammaRamp(
  888. DHPDEV dhpdev,
  889. ULONG iFormat,
  890. LPVOID lpRamp)
  891. {
  892. BOOL b;
  893. SYNCH_ENTER();
  894. DISPDBG((5, ">> DbgIcmSetDeviceGammaRamp"));
  895. b = DrvIcmSetDeviceGammaRamp(dhpdev, iFormat, lpRamp);
  896. DISPDBG((6, "<< DbgIcmSetDeviceGammaRamp"));
  897. SYNCH_LEAVE();
  898. return(b);
  899. }
  900. BOOL DbgGradientFill(
  901. SURFOBJ *psoDest,
  902. CLIPOBJ *pco,
  903. XLATEOBJ *pxlo,
  904. TRIVERTEX *pVertex,
  905. ULONG nVertex,
  906. PVOID pMesh,
  907. ULONG nMesh,
  908. RECTL *prclExtents,
  909. POINTL *pptlDitherOrg,
  910. ULONG ulMode)
  911. {
  912. BOOL b;
  913. SYNCH_ENTER();
  914. DISPDBG((5, ">> DbgGradientFill"));
  915. b = DrvGradientFill(psoDest, pco, pxlo, pVertex, nVertex, pMesh, nMesh, prclExtents, pptlDitherOrg, ulMode);
  916. DISPDBG((6, "<< DbgGradientFill"));
  917. SYNCH_LEAVE();
  918. return(b);
  919. }
  920. BOOL DbgAlphaBlend(
  921. SURFOBJ *psoDest,
  922. SURFOBJ *psoSrc,
  923. CLIPOBJ *pco,
  924. XLATEOBJ *pxlo,
  925. RECTL *prclDest,
  926. RECTL *prclSrc,
  927. BLENDOBJ *pBlendObj)
  928. {
  929. BOOL b;
  930. SYNCH_ENTER();
  931. DISPDBG((5, ">> DbgAlphaBlend"));
  932. b = DrvAlphaBlend(psoDest, psoSrc, pco, pxlo, prclDest, prclSrc, pBlendObj);
  933. DISPDBG((6, "<< DbgAlphaBlend"));
  934. SYNCH_LEAVE();
  935. return(b);
  936. }
  937. BOOL DbgTransparentBlt(
  938. SURFOBJ *psoDst,
  939. SURFOBJ *psoSrc,
  940. CLIPOBJ *pco,
  941. XLATEOBJ *pxlo,
  942. RECTL *prclDst,
  943. RECTL *prclSrc,
  944. ULONG iTransColor,
  945. ULONG ulReserved)
  946. {
  947. BOOL b;
  948. SYNCH_ENTER();
  949. DISPDBG((5, ">> DbgTransparentBlt"));
  950. b = DrvTransparentBlt(psoDst, psoSrc, pco, pxlo, prclDst, prclSrc, iTransColor, ulReserved);
  951. DISPDBG((6, "<< DbgTransparentBlt"));
  952. SYNCH_LEAVE();
  953. return(b);
  954. }
  955. VOID DbgNotify(
  956. SURFOBJ *pso,
  957. ULONG iType,
  958. PVOID pvData)
  959. {
  960. SYNCH_ENTER();
  961. DISPDBG((5, ">> DbgNotify"));
  962. DrvNotify(pso, iType, pvData);
  963. DISPDBG((6, "<< DbgNotify"));
  964. SYNCH_LEAVE();
  965. }
  966. #endif // (_WIN32_WINNT >= 0x500)
  967. #endif // DBG || !SYNCHRONIZEACCESS_WORKS