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.

2240 lines
61 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. graphics.c
  5. Abstract:
  6. Implementation of graphics related DDI entry points:
  7. DrvCopyBits
  8. DrvBitBlt
  9. DrvStretchBlt
  10. DrvStretchBltROP
  11. DrvDitherColor
  12. DrvPlgBlt
  13. DrvPaint
  14. DrvLineTo
  15. DrvStrokePath
  16. DrvFillPath
  17. DrvStrokeAndFillPath
  18. DrvRealizeBrush
  19. DrvAlphaBlend
  20. DrvGradientFill
  21. DrvTransparentBlt
  22. Environment:
  23. Windows NT Unidrv driver
  24. Revision History:
  25. 10/14/96 -amandan-
  26. Initial framework.
  27. 03/31/97 -zhanw-
  28. Added OEM customization support
  29. --*/
  30. //#define DBGNEWRULES 1
  31. #include "unidrv.h"
  32. VOID CheckBitmapSurface(
  33. SURFOBJ *pso,
  34. RECTL *pRect
  35. )
  36. /*++
  37. Routine Description:
  38. This function checks whether the bitmap surface has
  39. been erased and if not it erases it. It needs to be
  40. called before every Drv draw function.
  41. Arguments:
  42. pso Points to surface
  43. --*/
  44. {
  45. PDEV * pPDev = (PDEV *)pso->dhpdev;
  46. int iWhiteIndex;
  47. //
  48. // This function should only be called from a bitmap
  49. // surface driver. If the driver is device managed
  50. // just return
  51. if (DRIVER_DEVICEMANAGED (pPDev)) // a device surface
  52. {
  53. WARNING(("CheckBitmapSurface is being called from a device surface driver"));
  54. return;
  55. }
  56. //
  57. // If it hasn't already been done, erase the
  58. // bitmap surface.
  59. //
  60. if (!(pPDev->fMode & PF_SURFACE_USED))
  61. {
  62. pPDev->fMode |= PF_SURFACE_USED;
  63. if (pPDev->pbRasterScanBuf == NULL)
  64. {
  65. RECTL rcPage;
  66. iWhiteIndex = ((PAL_DATA*)(pPDev->pPalData))->iWhiteIndex;
  67. rcPage.left = 0;
  68. rcPage.top = 0;
  69. rcPage.right = pPDev->szBand.cx;
  70. rcPage.bottom = pPDev->szBand.cy;
  71. EngEraseSurface( pso, &rcPage, iWhiteIndex );
  72. pPDev->fMode |= PF_SURFACE_ERASED;
  73. }
  74. }
  75. #ifndef DISABLE_NEWRULES
  76. //
  77. // determine whether there are any rules that have previously been
  78. // detected but now need to be drawn because they overlap with this object
  79. //
  80. if (pPDev->pbRulesArray && pPDev->dwRulesCount)
  81. {
  82. DWORD i = 0;
  83. RECTL SrcRect;
  84. DWORD dwRulesCount = pPDev->dwRulesCount;
  85. PRECTL pRules = pPDev->pbRulesArray;
  86. pPDev->pbRulesArray = NULL;
  87. if (pRect == NULL)
  88. {
  89. SrcRect.left = SrcRect.top = 0;
  90. SrcRect.right = pPDev->szBand.cx;
  91. SrcRect.bottom = pPDev->szBand.cy;
  92. }
  93. else
  94. {
  95. SrcRect = *pRect;
  96. if (SrcRect.top > SrcRect.bottom)
  97. {
  98. int tmp = SrcRect.top;
  99. SrcRect.top = SrcRect.bottom;
  100. SrcRect.bottom = tmp;
  101. }
  102. if (SrcRect.top < 0)
  103. SrcRect.top = 0;
  104. if (SrcRect.bottom > pPDev->szBand.cy)
  105. SrcRect.bottom = pPDev->szBand.cy;
  106. if (SrcRect.left > SrcRect.right)
  107. {
  108. int tmp = SrcRect.left;
  109. SrcRect.left = SrcRect.right;
  110. SrcRect.right = tmp;
  111. }
  112. if (SrcRect.left < 0)
  113. SrcRect.left = 0;
  114. if (SrcRect.right > pPDev->szBand.cx)
  115. SrcRect.right = pPDev->szBand.cx;
  116. }
  117. // Now we loop once for every potential rule to see if the current object
  118. // overlaps any of them. If so we need to bitblt black into that area but we
  119. // try to save any of the rule that extends outside the current object.
  120. //
  121. while (i < dwRulesCount)
  122. {
  123. PRECTL pTmp = &pRules[i];
  124. POINTL BrushOrg = {0,0};
  125. if (pTmp->right > SrcRect.left &&
  126. pTmp->left < SrcRect.right &&
  127. pTmp->bottom > SrcRect.top &&
  128. pTmp->top < SrcRect.bottom)
  129. {
  130. if (pTmp->top < SrcRect.top && dwRulesCount < MAX_NUM_RULES)
  131. {
  132. PRECTL pTmp2 = &pRules[dwRulesCount++];
  133. *pTmp2 = *pTmp;
  134. pTmp2->bottom = SrcRect.top;
  135. pTmp->top = SrcRect.top;
  136. }
  137. if (pTmp->bottom > SrcRect.bottom && dwRulesCount < MAX_NUM_RULES)
  138. {
  139. PRECTL pTmp2 = &pRules[dwRulesCount++];
  140. *pTmp2 = *pTmp;
  141. pTmp2->top = SrcRect.bottom;
  142. pTmp->bottom = SrcRect.bottom;
  143. }
  144. if (pTmp->right > SrcRect.right && dwRulesCount < MAX_NUM_RULES)
  145. {
  146. PRECTL pTmp2 = &pRules[dwRulesCount++];
  147. *pTmp2 = *pTmp;
  148. pTmp2->left = SrcRect.right;
  149. pTmp->right = SrcRect.right;
  150. }
  151. if (pTmp->left < SrcRect.left && dwRulesCount < MAX_NUM_RULES)
  152. {
  153. PRECTL pTmp2 = &pRules[dwRulesCount++];
  154. *pTmp2 = *pTmp;
  155. pTmp2->right = SrcRect.left;
  156. pTmp->left = SrcRect.left;
  157. }
  158. #ifdef DBGNEWRULES
  159. DbgPrint("Removed rule %u: L%u,R%u,T%u,B%u; L%u,R%u,T%u,B%u\n",
  160. dwRulesCount,pTmp->left,pTmp->right,pTmp->top,pTmp->bottom,
  161. SrcRect.left,SrcRect.right,SrcRect.top,SrcRect.bottom);
  162. #endif
  163. CheckBitmapSurface(pPDev->pso,pTmp);
  164. EngBitBlt(pPDev->pso,
  165. NULL,
  166. NULL,
  167. NULL,
  168. NULL,
  169. pTmp,
  170. NULL,
  171. NULL,
  172. NULL,
  173. NULL,
  174. 0x0000); // rop4 = BLACKNESS = 0
  175. //
  176. // if we draw this in the bitmap instead of downloading we may need
  177. // to download a white rectangle to erase anything else already drawn
  178. //
  179. if ((COMMANDPTR(pPDev->pDriverInfo,CMD_RECTWHITEFILL)) &&
  180. (pPDev->fMode & PF_DOWNLOADED_TEXT))
  181. {
  182. INT j;
  183. BYTE bMask = BGetMask(pPDev, pTmp);
  184. BOOL bSendRectFill = FALSE;
  185. for (j = pTmp->top; j < pTmp->bottom ; j++)
  186. {
  187. if (pPDev->pbScanBuf[j] & bMask)
  188. {
  189. bSendRectFill = TRUE;
  190. break;
  191. }
  192. }
  193. //
  194. // check if we overlap with downloaded text
  195. //
  196. if (bSendRectFill)
  197. {
  198. DRAWPATRECT PatRect;
  199. PatRect.wStyle = 1; // white rectangle
  200. PatRect.wPattern = 0; // pattern not used
  201. PatRect.ptPosition.x = pTmp->left;
  202. PatRect.ptPosition.y = pTmp->top;
  203. PatRect.ptSize.x = pTmp->right - pTmp->left;
  204. PatRect.ptSize.y = pTmp->bottom - pTmp->top;
  205. DrawPatternRect(pPDev,&PatRect);
  206. }
  207. }
  208. dwRulesCount--;
  209. *pTmp = pRules[dwRulesCount];
  210. }
  211. else
  212. i++;
  213. }
  214. pPDev->dwRulesCount = dwRulesCount;
  215. pPDev->pbRulesArray = pRules;
  216. }
  217. #endif
  218. //
  219. // if entire surface hasn't been erased then
  220. // we need to erase the require section
  221. //
  222. if (!(pPDev->fMode & PF_SURFACE_ERASED))
  223. {
  224. int y1,y2;
  225. long iScan;
  226. long dwWidth = pso->lDelta;
  227. PBYTE pBits = (PBYTE)pso->pvBits;
  228. if (pRect == NULL)
  229. {
  230. pPDev->fMode |= PF_SURFACE_ERASED;
  231. y1 = 0;
  232. y2 = pPDev->szBand.cy - 1;
  233. }
  234. else
  235. {
  236. if (pRect->top > pRect->bottom)
  237. {
  238. y1 = max(0,pRect->bottom);
  239. y2 = min (pPDev->szBand.cy-1,pRect->top);
  240. }
  241. else
  242. {
  243. y1 = max(0,pRect->top);
  244. y2 = min(pPDev->szBand.cy-1,pRect->bottom);
  245. }
  246. }
  247. y1 = y1 / LINESPERBLOCK;
  248. y2 = y2 / LINESPERBLOCK;
  249. while ( y1 <= y2)
  250. {
  251. // test whether this block has already been erased
  252. //
  253. if (pPDev->pbRasterScanBuf[y1] == 0)
  254. {
  255. // specify block as erased
  256. pPDev->pbRasterScanBuf[y1] = 1;
  257. //
  258. // determined erase byte
  259. //
  260. if (pPDev->sBitsPixel == 4)
  261. iWhiteIndex = 0x77;
  262. else if (pPDev->sBitsPixel == 8)
  263. iWhiteIndex = ((PAL_DATA*)(pPDev->pPalData))->iWhiteIndex;
  264. else
  265. iWhiteIndex = 0xff;
  266. //
  267. // determine block size and erase block
  268. //
  269. iScan = pPDev->szBand.cy - (y1 * LINESPERBLOCK);
  270. if (iScan > LINESPERBLOCK)
  271. iScan = LINESPERBLOCK;
  272. #ifndef WINNT_40
  273. FillMemory (&pBits[(ULONG_PTR )dwWidth*y1*LINESPERBLOCK],
  274. (SIZE_T)dwWidth*iScan,(BYTE)iWhiteIndex);
  275. #else
  276. FillMemory (&pBits[(ULONG_PTR )dwWidth*y1*LINESPERBLOCK],
  277. dwWidth*iScan,(BYTE)iWhiteIndex);
  278. #endif
  279. }
  280. y1++;
  281. }
  282. }
  283. }
  284. #ifndef DISABLE_NEWRULES
  285. VOID AddRuleToList(
  286. PDEV *pPDev,
  287. PRECTL pRect,
  288. CLIPOBJ *pco
  289. )
  290. /*++
  291. Routine Description:
  292. This function checks whether a potential black rule needs to be clipped.
  293. Arguments:
  294. pPDev
  295. pRect black rule
  296. pco clip object
  297. --*/
  298. {
  299. //
  300. // if clip rectangle then clip the rule
  301. //
  302. if (pco && pco->iDComplexity == DC_RECT)
  303. {
  304. if (pRect->left < pco->rclBounds.left)
  305. pRect->left = pco->rclBounds.left;
  306. if (pRect->top < pco->rclBounds.top)
  307. pRect->top = pco->rclBounds.top;
  308. if (pRect->right > pco->rclBounds.right)
  309. pRect->right = pco->rclBounds.right;
  310. if (pRect->bottom > pco->rclBounds.bottom)
  311. pRect->bottom = pco->rclBounds.bottom;
  312. }
  313. #ifdef DBGNEWRULES
  314. DbgPrint("New Rule %3d, L%d,R%d,T%d,B%d\n",pPDev->dwRulesCount,
  315. pRect->left,pRect->right,pRect->top,pRect->bottom);
  316. #endif
  317. if (pRect->left < pRect->right && pRect->top < pRect->bottom)
  318. {
  319. pPDev->dwRulesCount++;
  320. }
  321. }
  322. BOOL TestStrokeRectangle(
  323. PDEV *pPDev,
  324. PATHOBJ *ppo,
  325. CLIPOBJ *pco,
  326. LONG width
  327. )
  328. /*++
  329. Routine Description:
  330. This function determines whether a StrokeFillPath is actually defining
  331. a rectangle that can be drawn with black rules instead.
  332. Arguments:
  333. pPDev
  334. ppo path object that might be rectangle
  335. pco clip object
  336. width line width
  337. --*/
  338. {
  339. POINTFIX* pptfx;
  340. PATHDATA PathData;
  341. DWORD dwPoints = 0;
  342. POINTL pPoints[5];
  343. PATHOBJ_vEnumStart(ppo);
  344. // if there is more than one subpath then its not a rectangle
  345. //
  346. if (PATHOBJ_bEnum(ppo, &PathData))
  347. {
  348. #ifdef DBGNEWRULES
  349. DbgPrint ("Unable to convert Rectangle3\n");
  350. #endif
  351. return FALSE;
  352. }
  353. //
  354. // Begin new sub path
  355. //
  356. if ((PathData.count != 4 && (PathData.flags & PD_CLOSEFIGURE)) ||
  357. (PathData.count != 5 && !(PathData.flags & PD_CLOSEFIGURE)) ||
  358. !(PathData.flags & PD_BEGINSUBPATH) ||
  359. PathData.flags & PD_BEZIERS)
  360. {
  361. #ifdef DBGNEWRULES
  362. DbgPrint("Unable to convert Rectangle4: flags=%x,Count=%d\n",
  363. PathData.flags,PathData.count);
  364. #endif
  365. return FALSE;
  366. }
  367. // Verify these are all vertical or horizontal lines only
  368. //
  369. pptfx = PathData.pptfx;
  370. while (dwPoints <= 4)
  371. {
  372. if (dwPoints != 4 || PathData.count == 5)
  373. {
  374. pPoints[dwPoints].x = FXTOL(pptfx->x);
  375. pPoints[dwPoints].y = FXTOL(pptfx->y);
  376. pptfx++;
  377. }
  378. else
  379. {
  380. pPoints[dwPoints].x = pPoints[0].x;
  381. pPoints[dwPoints].y = pPoints[0].y;
  382. }
  383. //
  384. // check for diagonal lines
  385. //
  386. if (dwPoints != 0)
  387. {
  388. if (pPoints[dwPoints].x != pPoints[dwPoints-1].x &&
  389. pPoints[dwPoints].y != pPoints[dwPoints-1].y)
  390. {
  391. #ifdef DBGNEWRULES
  392. DbgPrint ("Unable to convert Rectangle5\n");
  393. #endif
  394. return FALSE;
  395. }
  396. }
  397. dwPoints++;
  398. }
  399. //
  400. // make sure width is at least 1 pixel
  401. //
  402. if (width <= 0)
  403. width = 1;
  404. //
  405. // convert rectangle edges to rules
  406. //
  407. for (dwPoints = 0;dwPoints < 4;dwPoints++)
  408. {
  409. PRECTL pRect= &pPDev->pbRulesArray[pPDev->dwRulesCount];
  410. pRect->left = pPoints[dwPoints].x;
  411. pRect->top = pPoints[dwPoints].y;
  412. pRect->right = pPoints[dwPoints+1].x;
  413. pRect->bottom = pPoints[dwPoints+1].y;
  414. if (pRect->left > pRect->right)
  415. {
  416. LONG temp = pRect->left;
  417. pRect->left = pRect->right;
  418. pRect->right = temp;
  419. }
  420. pRect->left -= width >> 1;
  421. pRect->right += width - (width >> 1);
  422. if (pRect->top > pRect->bottom)
  423. {
  424. LONG temp = pRect->top;
  425. pRect->top = pRect->bottom;
  426. pRect->bottom = temp;
  427. }
  428. pRect->top -= width >> 1;
  429. pRect->bottom += width - (width >> 1);
  430. AddRuleToList(pPDev,pRect,pco);
  431. }
  432. return TRUE;
  433. }
  434. #endif
  435. BOOL
  436. DrvCopyBits(
  437. SURFOBJ *psoDst,
  438. SURFOBJ *psoSrc,
  439. CLIPOBJ *pco,
  440. XLATEOBJ *pxlo,
  441. RECTL *prclDst,
  442. POINTL *pptlSrc
  443. )
  444. /*++
  445. Routine Description:
  446. Implementation of DDI entry point DrvCopyBits.
  447. Please refer to DDK documentation for more details.
  448. Arguments:
  449. psoDst - Points to the Dstination surface
  450. psoSrc - Points to the source surface
  451. pxlo - XLATEOBJ provided by the engine
  452. pco - Defines a clipping region on the Dstination surface
  453. pxlo - Defines the translation of color indices
  454. between the source and target surfaces
  455. prclDst - Defines the area to be modified
  456. pptlSrc - Defines the upper-left corner of the source rectangle
  457. Return Value:
  458. TRUE if successful, FALSE if there is an error
  459. --*/
  460. {
  461. PDEV * pPDev = (PDEV *)psoDst->dhpdev;
  462. VERBOSE(("Entering DrvCopyBits...\n"));
  463. //
  464. // Sometimes GDI calls DrvCopyBits with the destination surface
  465. // as STYPE_BITMAP and the source surface as STYPE_DEVICE.
  466. // This means GDI wants the driver to copy whats on the device surface to the
  467. // Bitmap surface. For device managed surfaces, driver does not keep track of
  468. // what has already been drawn on the device. So either the driver can fail
  469. // this call, or assume that nothing was drawn on the device earlier and
  470. // therefore whiten the surface.
  471. // In most cases, the driver fails the call, except when
  472. // 1. It has been told to whiten the surface
  473. // 2. The destination surface is 24bpp (this condition was hit
  474. // for 24bpp and thats how we can test it. We can make the solution more
  475. // general for other color depths, but how do we test it...)
  476. // The drawback of whitening the surface is that
  477. // whatever is actually on the device surface
  478. // is overwritten. To prevent this, driver sets the flag PF2_RENDER_TRANSPARENT
  479. // in pPDev->fMode2. This is an indication to download the bitmap in
  480. // transparent mode, so that the white on the bitmap does not overwrite the
  481. // destination.
  482. // To hit this case, print grdfil06.emf using guiman using HP5si
  483. // (or any model using inbox HPGL driver).
  484. // NOTE: GDI is planning to change the behavior for Windows XP, but if you want to
  485. // see this happening, run this driver on Windows2000 machine.
  486. //
  487. if ( pPDev == NULL &&
  488. psoSrc && psoSrc->iType == STYPE_DEVICE &&
  489. psoDst && psoDst->iType == STYPE_BITMAP )
  490. {
  491. PDEV * pPDevSrc = (PDEV *)psoSrc->dhpdev;
  492. if ( pPDevSrc &&
  493. (pPDevSrc->fMode2 & PF2_WHITEN_SURFACE) &&
  494. (psoSrc->iBitmapFormat == BMF_24BPP) &&
  495. psoDst->pvBits &&
  496. (psoDst->cjBits > 0)
  497. )
  498. {
  499. //
  500. // Change the bits in the destination surface to white
  501. // and return TRUE.
  502. //
  503. memset(psoDst->pvBits, 0xff, psoDst->cjBits);
  504. pPDevSrc->fMode2 |= PF2_SURFACE_WHITENED;
  505. return TRUE;
  506. }
  507. return FALSE;
  508. }
  509. //
  510. // use driver managed surface
  511. //
  512. if (pPDev && pPDev->pso)
  513. psoDst = pPDev->pso;
  514. //
  515. // Unidrv does not allow OEM's to hook out DrvEnableSurface and it creates
  516. // only the bitmap surface itself.
  517. //
  518. if ( ((pPDev == 0) || (pPDev->ulID != PDEV_ID)) ||
  519. ((!DRIVER_DEVICEMANAGED (pPDev)) &&
  520. ((psoSrc->iType != STYPE_BITMAP) ||
  521. (psoDst->iType != STYPE_BITMAP))) ) // compatible bitmap case
  522. {
  523. return (EngCopyBits(psoDst,psoSrc,pco,pxlo,
  524. prclDst,pptlSrc));
  525. }
  526. ASSERT_VALID_PDEV(pPDev);
  527. //
  528. // Handle OEM hooks
  529. //
  530. HANDLE_OEMHOOKS(pPDev,
  531. EP_OEMCopyBits,
  532. PFN_OEMCopyBits,
  533. BOOL,
  534. (psoDst,
  535. psoSrc,
  536. pco,
  537. pxlo,
  538. prclDst,
  539. pptlSrc));
  540. HANDLE_VECTORHOOKS(pPDev,
  541. EP_OEMCopyBits,
  542. VMCopyBits,
  543. BOOL,
  544. (psoDst,
  545. psoSrc,
  546. pco,
  547. pxlo,
  548. prclDst,
  549. pptlSrc));
  550. {
  551. PRMPROCS pRasterProcs = (PRMPROCS)(pPDev->pRasterProcs);
  552. if (!DRIVER_DEVICEMANAGED (pPDev)) // a bitmap surface
  553. {
  554. if (pRasterProcs->RMCopyBits == NULL)
  555. {
  556. CheckBitmapSurface(psoDst,prclDst);
  557. return FALSE;
  558. }
  559. else
  560. return ( pRasterProcs->RMCopyBits(psoDst,
  561. psoSrc, pco, pxlo, prclDst, pptlSrc) );
  562. }
  563. else
  564. {
  565. ERR (("Device Managed Surface cannot call EngCopyBits\n"));
  566. return FALSE;
  567. }
  568. }
  569. }
  570. BOOL
  571. DrvBitBlt(
  572. SURFOBJ *psoDst,
  573. SURFOBJ *psoSrc,
  574. SURFOBJ *psoMask,
  575. CLIPOBJ *pco,
  576. XLATEOBJ *pxlo,
  577. RECTL *prclDst,
  578. POINTL *pptlSrc,
  579. POINTL *pptlMask,
  580. BRUSHOBJ *pbo,
  581. POINTL *pptlBrush,
  582. ROP4 rop4
  583. )
  584. /*++
  585. Routine Description:
  586. Implementation of DDI entry point DrvBitBlt.
  587. Please refer to DDK documentation for more details.
  588. Arguments:
  589. psoDst - Describes the target surface
  590. psoSrc - Describes the source surface
  591. psoMask - Describes the mask for rop4
  592. pco - Limits the area to be modified
  593. pxlo - Specifies how color indices are translated
  594. between the source and target surfaces
  595. prclDst - Defines the area to be modified
  596. pptlSrc - Defines the upper left corner of the source rectangle
  597. pptlMask - Defines which pixel in the mask corresponds to
  598. the upper left corner of the source rectangle
  599. pbo - Defines the pattern for bitblt
  600. pptlBrush - Defines the origin of the brush in the Dstination surface
  601. rop4 - ROP code that defines how the mask, pattern, source, and
  602. Dstination pixels are combined to write to the Dstination surface
  603. Return Value:
  604. TRUE if successful, FALSE if there is an error
  605. --*/
  606. {
  607. PDEV * pPDev = (PDEV *)psoDst->dhpdev;
  608. VERBOSE(("Entering DrvBitBlt...\n"));
  609. ASSERT_VALID_PDEV(pPDev);
  610. //
  611. // use driver managed surface
  612. //
  613. if (pPDev->pso)
  614. psoDst = pPDev->pso;
  615. //
  616. // Handle OEM hooks
  617. //
  618. HANDLE_OEMHOOKS(pPDev,
  619. EP_OEMBitBlt,
  620. PFN_OEMBitBlt,
  621. BOOL,
  622. (psoDst,
  623. psoSrc,
  624. psoMask,
  625. pco,
  626. pxlo,
  627. prclDst,
  628. pptlSrc,
  629. pptlMask,
  630. pbo,
  631. pptlBrush,
  632. rop4));
  633. HANDLE_VECTORHOOKS(pPDev,
  634. EP_OEMBitBlt,
  635. VMBitBlt,
  636. BOOL,
  637. (psoDst,
  638. psoSrc,
  639. psoMask,
  640. pco,
  641. pxlo,
  642. prclDst,
  643. pptlSrc,
  644. pptlMask,
  645. pbo,
  646. pptlBrush,
  647. rop4));
  648. {
  649. PRMPROCS pRasterProcs = (PRMPROCS)(pPDev->pRasterProcs);
  650. if (!DRIVER_DEVICEMANAGED (pPDev)) // a bitmap surface
  651. {
  652. if (pRasterProcs->RMBitBlt == NULL)
  653. {
  654. CheckBitmapSurface(psoDst,prclDst);
  655. return FALSE;
  656. }
  657. else
  658. return ( pRasterProcs->RMBitBlt(psoDst,
  659. psoSrc, psoMask, pco, pxlo, prclDst,
  660. pptlSrc,pptlMask, pbo, pptlBrush, rop4));
  661. }
  662. }
  663. return FALSE;
  664. }
  665. BOOL
  666. DrvStretchBlt(
  667. SURFOBJ *psoDst,
  668. SURFOBJ *psoSrc,
  669. SURFOBJ *psoMask,
  670. CLIPOBJ *pco,
  671. XLATEOBJ *pxlo,
  672. COLORADJUSTMENT *pca,
  673. POINTL *pptlHTOrg,
  674. RECTL *prclDst,
  675. RECTL *prclSrc,
  676. POINTL *pptlMask,
  677. ULONG iMode
  678. )
  679. /*++
  680. Routine Description:
  681. Implementation of DDI entry point DrvStretchBlt.
  682. Please refer to DDK documentation for more details.
  683. Arguments:
  684. psoDst - Defines the surface on which to draw
  685. psoSrc - Defines the source for blt operation
  686. psoMask - Defines a surface that provides a mask for the source
  687. pco - Limits the area to be modified on the Dstination
  688. pxlo - Specifies how color dwIndexes are to be translated
  689. between the source and target surfaces
  690. pca - Defines color adjustment values to be applied to the source bitmap
  691. pptlHTOrg - Specifies the origin of the halftone brush
  692. prclDst - Defines the area to be modified on the Dstination surface
  693. prclSrc - Defines the area to be copied from the source surface
  694. pptlMask - Specifies which pixel in the given mask corresponds to
  695. the upper left pixel in the source rectangle
  696. iMode - Specifies how source pixels are combined to get output pixels
  697. Return Value:
  698. TRUE if successful, FALSE if there is an error
  699. --*/
  700. {
  701. PDEV * pPDev = (PDEV *)psoDst->dhpdev;
  702. VERBOSE(("Entering DrvStretchBlt...\n"));
  703. ASSERT_VALID_PDEV(pPDev);
  704. //
  705. // use driver managed surface
  706. //
  707. if (pPDev->pso)
  708. psoDst = pPDev->pso;
  709. //
  710. // Handle OEM hooks
  711. //
  712. HANDLE_OEMHOOKS(pPDev,
  713. EP_OEMStretchBlt,
  714. PFN_OEMStretchBlt,
  715. BOOL,
  716. (psoDst,
  717. psoSrc,
  718. psoMask,
  719. pco,
  720. pxlo,
  721. pca,
  722. pptlHTOrg,
  723. prclDst,
  724. prclSrc,
  725. pptlMask,
  726. iMode));
  727. HANDLE_VECTORHOOKS(pPDev,
  728. EP_OEMStretchBlt,
  729. VMStretchBlt,
  730. BOOL,
  731. (psoDst,
  732. psoSrc,
  733. psoMask,
  734. pco,
  735. pxlo,
  736. pca,
  737. pptlHTOrg,
  738. prclDst,
  739. prclSrc,
  740. pptlMask,
  741. iMode));
  742. {
  743. PRMPROCS pRasterProcs = (PRMPROCS)(pPDev->pRasterProcs);
  744. if (!DRIVER_DEVICEMANAGED (pPDev)) // a bitmap surface
  745. {
  746. if (pRasterProcs->RMStretchBlt == NULL)
  747. {
  748. CheckBitmapSurface(psoDst,prclDst);
  749. return FALSE;
  750. }
  751. else
  752. return ( pRasterProcs->RMStretchBlt(psoDst, psoSrc,
  753. psoMask, pco, pxlo, pca,
  754. pptlHTOrg, prclDst, prclSrc, pptlMask, iMode) );
  755. }
  756. else
  757. {
  758. //
  759. // ERR (("Device Managed Surface cannot call EngStretchBlt\n"));
  760. // We make an exception for StretchBlt because OEM driver may not
  761. // be able to handle complex clipping. In that case it may wants
  762. // gdi to simply the call by breaking the StretchBlt into several
  763. // CopyBits. So call EngStretchBlt and hope for the best.
  764. //
  765. return ( EngStretchBlt(psoDst,
  766. psoSrc,
  767. psoMask,
  768. pco,
  769. pxlo,
  770. pca,
  771. pptlHTOrg,
  772. prclDst,
  773. prclSrc,
  774. pptlMask,
  775. iMode) );
  776. }
  777. }
  778. }
  779. ULONG
  780. DrvDitherColor(
  781. DHPDEV dhpdev,
  782. ULONG iMode,
  783. ULONG rgbColor,
  784. ULONG *pulDither
  785. )
  786. /*++
  787. Routine Description:
  788. This is the hooked brush creation function, it ask CreateHalftoneBrush()
  789. to do the actual work.
  790. Arguments:
  791. dhpdev - DHPDEV passed, it is our pDEV
  792. iMode - Not used
  793. rgbColor - Solid rgb color to be used
  794. pulDither - buffer to put the halftone brush.
  795. Return Value:
  796. returns halftone method, default is DCR_HALFTONE
  797. --*/
  798. {
  799. PDEV *pPDev = (PDEV *)dhpdev;
  800. VERBOSE(("Entering DrvDitherColor...\n"));
  801. ASSERT_VALID_PDEV(pPDev);
  802. //
  803. // Handle OEM hooks
  804. //
  805. HANDLE_OEMHOOKS(pPDev,
  806. EP_OEMDitherColor,
  807. PFN_OEMDitherColor,
  808. ULONG,
  809. (dhpdev,
  810. iMode,
  811. rgbColor,
  812. pulDither));
  813. HANDLE_VECTORHOOKS(pPDev,
  814. EP_OEMDitherColor,
  815. VMDitherColor,
  816. ULONG,
  817. (dhpdev,
  818. iMode,
  819. rgbColor,
  820. pulDither));
  821. {
  822. PRMPROCS pRasterProcs = (PRMPROCS)(pPDev->pRasterProcs);
  823. if (pRasterProcs->RMDitherColor == NULL)
  824. return DCR_HALFTONE;
  825. else
  826. return ( pRasterProcs->RMDitherColor(pPDev,
  827. iMode,
  828. rgbColor,
  829. pulDither) );
  830. }
  831. }
  832. #ifndef WINNT_40
  833. BOOL APIENTRY
  834. DrvStretchBltROP(
  835. SURFOBJ *psoDst,
  836. SURFOBJ *psoSrc,
  837. SURFOBJ *psoMask,
  838. CLIPOBJ *pco,
  839. XLATEOBJ *pxlo,
  840. COLORADJUSTMENT *pca,
  841. POINTL *pptlHTOrg,
  842. RECTL *prclDst,
  843. RECTL *prclSrc,
  844. POINTL *pptlMask,
  845. ULONG iMode,
  846. BRUSHOBJ *pbo,
  847. ROP4 rop4
  848. )
  849. /*++
  850. Routine Description:
  851. Implementation of DDI entry point DrvStretchBltROP.
  852. Please refer to DDK documentation for more details.
  853. Arguments:
  854. psoDst - Specifies the target surface
  855. psoSrc - Specifies the source surface
  856. psoMask - Specifies the mask surface
  857. pco - Limits the area to be modified
  858. pxlo - Specifies how color indices are translated
  859. between the source and target surfaces
  860. pca - Defines color adjustment values to be applied to the source bitmap
  861. prclHTOrg - Specifies the halftone origin
  862. prclDst - Area to be modified on the destination surface
  863. prclSrc - Rectangle area on the source surface
  864. prclMask - Rectangle area on the mask surface
  865. pptlMask - Defines which pixel in the mask corresponds to
  866. the upper left corner of the source rectangle
  867. iMode - Specifies how source pixels are combined to get output pixels
  868. pbo - Defines the pattern for bitblt
  869. rop4 - ROP code that defines how the mask, pattern, source, and
  870. destination pixels are combined on the destination surface
  871. Return Value:
  872. TRUE if successful, FALSE if there is an error
  873. --*/
  874. {
  875. PDEV *pPDev = (PDEV *)psoDst->dhpdev;
  876. PRMPROCS pRasterProcs;
  877. VERBOSE(("Entering DrvStretchBltROP...\n"));
  878. ASSERT_VALID_PDEV(pPDev);
  879. //
  880. // use driver managed surface
  881. //
  882. if (pPDev->pso)
  883. psoDst = pPDev->pso;
  884. //
  885. // Handle OEM hooks
  886. //
  887. HANDLE_OEMHOOKS(pPDev,
  888. EP_OEMStretchBltROP,
  889. PFN_OEMStretchBltROP,
  890. BOOL,
  891. (psoDst,
  892. psoSrc,
  893. psoMask,
  894. pco,
  895. pxlo,
  896. pca,
  897. pptlHTOrg,
  898. prclDst,
  899. prclSrc,
  900. pptlMask,
  901. iMode,
  902. pbo,
  903. rop4));
  904. HANDLE_VECTORHOOKS(pPDev,
  905. EP_OEMStretchBltROP,
  906. VMStretchBltROP,
  907. BOOL,
  908. (psoDst,
  909. psoSrc,
  910. psoMask,
  911. pco,
  912. pxlo,
  913. pca,
  914. pptlHTOrg,
  915. prclDst,
  916. prclSrc,
  917. pptlMask,
  918. iMode,
  919. pbo,
  920. rop4));
  921. pRasterProcs = (PRMPROCS)(pPDev->pRasterProcs);
  922. if (!DRIVER_DEVICEMANAGED (pPDev)) // a bitmap surface
  923. {
  924. if (pRasterProcs->RMStretchBltROP == NULL)
  925. {
  926. CheckBitmapSurface(psoDst,prclDst);
  927. return FALSE;
  928. }
  929. else
  930. return ( pRasterProcs->RMStretchBltROP(psoDst, psoSrc,
  931. psoMask, pco, pxlo, pca,
  932. pptlHTOrg, prclDst, prclSrc, pptlMask, iMode,
  933. pbo, rop4) );
  934. }
  935. else
  936. {
  937. ERR (("Device Managed Surface cannot call EngStretchBltROP\n"));
  938. return FALSE;
  939. }
  940. }
  941. #endif
  942. #ifndef WINNT_40
  943. BOOL APIENTRY
  944. DrvPlgBlt(
  945. SURFOBJ *psoDst,
  946. SURFOBJ *psoSrc,
  947. SURFOBJ *psoMask,
  948. CLIPOBJ *pco,
  949. XLATEOBJ *pxlo,
  950. COLORADJUSTMENT *pca,
  951. POINTL *pptlBrushOrg,
  952. POINTFIX *pptfixDest,
  953. RECTL *prclSrc,
  954. POINTL *pptlMask,
  955. ULONG iMode)
  956. /*++
  957. Routine Description:
  958. Implementation of DDI entry point DrvPlgBlt.
  959. Please refer to DDK documentation for more details.
  960. Arguments:
  961. psoDst - Defines the surface on which to draw
  962. psoSrc - Defines the source for blt operation
  963. psoMask - Defines a surface that provides a mask for the source
  964. pco - Limits the area to be modified on the Dstination
  965. pxlo - Specifies how color dwIndexes are to be translated
  966. between the source and target surfaces
  967. pca - Defines color adjustment values to be applied to the source bitmap
  968. pptlBrushOrg - Specifies the origin of the halftone brush
  969. ppfxDest - Defines the area to be modified on the Dstination surface
  970. prclSrc - Defines the area to be copied from the source surface
  971. pptlMask - Specifies which pixel in the given mask corresponds to
  972. the upper left pixel in the source rectangle
  973. iMode - Specifies how source pixels are combined to get output pixels
  974. Return Value:
  975. TRUE if successful, FALSE if there is an error
  976. --*/
  977. {
  978. PDEV *pPDev;
  979. VERBOSE(("Entering DrvPlgBlt...\n"));
  980. ASSERT(psoDst != NULL);
  981. pPDev = (PDEV *)psoDst->dhpdev;
  982. ASSERT_VALID_PDEV(pPDev);
  983. //
  984. // use driver managed surface
  985. //
  986. if (pPDev->pso)
  987. psoDst = pPDev->pso;
  988. //
  989. // Handle OEM hooks
  990. //
  991. HANDLE_OEMHOOKS(pPDev,
  992. EP_OEMPlgBlt,
  993. PFN_OEMPlgBlt,
  994. BOOL,
  995. (psoDst,
  996. psoSrc,
  997. psoMask,
  998. pco,
  999. pxlo,
  1000. pca,
  1001. pptlBrushOrg,
  1002. pptfixDest,
  1003. prclSrc,
  1004. pptlMask,
  1005. iMode));
  1006. HANDLE_VECTORHOOKS(pPDev,
  1007. EP_OEMPlgBlt,
  1008. VMPlgBlt,
  1009. BOOL,
  1010. (psoDst,
  1011. psoSrc,
  1012. psoMask,
  1013. pco,
  1014. pxlo,
  1015. pca,
  1016. pptlBrushOrg,
  1017. pptfixDest,
  1018. prclSrc,
  1019. pptlMask,
  1020. iMode));
  1021. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1022. {
  1023. PRMPROCS pRasterProcs;
  1024. pRasterProcs = (PRMPROCS)(pPDev->pRasterProcs);
  1025. if (pRasterProcs->RMPlgBlt != NULL)
  1026. {
  1027. return ( pRasterProcs->RMPlgBlt(psoDst, psoSrc, psoMask, pco, pxlo, pca, pptlBrushOrg,
  1028. pptfixDest, prclSrc, pptlMask, iMode));
  1029. }
  1030. else
  1031. {
  1032. //
  1033. // Check whether to erase surface
  1034. //
  1035. CheckBitmapSurface(psoDst,NULL);
  1036. //
  1037. // Unidrv does not handle this call itself.
  1038. //
  1039. return EngPlgBlt(psoDst, psoSrc, psoMask, pco, pxlo, pca, pptlBrushOrg,
  1040. pptfixDest, prclSrc, pptlMask, iMode);
  1041. }
  1042. }
  1043. else
  1044. {
  1045. ERR (("Device Managed Surface cannot call EngPlgBlt\n"));
  1046. return FALSE;
  1047. }
  1048. }
  1049. #endif
  1050. BOOL APIENTRY
  1051. DrvPaint(
  1052. SURFOBJ *pso,
  1053. CLIPOBJ *pco,
  1054. BRUSHOBJ *pbo,
  1055. POINTL *pptlBrushOrg,
  1056. MIX mix)
  1057. /*++
  1058. Routine Description:
  1059. Implementation of DDI entry point DrvPaint.
  1060. Please refer to DDK documentation for more details.
  1061. Arguments:
  1062. pso - Defines the surface on which to draw
  1063. pco - Limits the area to be modified on the Dstination
  1064. pbo - Points to a BRUSHOBJ which defined the pattern and colors to fill with
  1065. pptlBrushOrg - Specifies the origin of the halftone brush
  1066. mix - Defines the foreground and background raster operations to use for
  1067. the brush
  1068. Return Value:
  1069. TRUE if successful, FALSE if there is an error
  1070. --*/
  1071. {
  1072. PDEV *pPDev = (PDEV *)pso->dhpdev;
  1073. PRMPROCS pRasterProcs;
  1074. VERBOSE(("Entering DrvPaint...\n"));
  1075. ASSERT_VALID_PDEV(pPDev);
  1076. //
  1077. // use driver managed surface
  1078. //
  1079. if (pPDev->pso)
  1080. pso = pPDev->pso;
  1081. //
  1082. // Handle OEM hooks
  1083. //
  1084. HANDLE_OEMHOOKS(pPDev,
  1085. EP_OEMPaint,
  1086. PFN_OEMPaint,
  1087. BOOL,
  1088. (pso,
  1089. pco,
  1090. pbo,
  1091. pptlBrushOrg,
  1092. mix));
  1093. HANDLE_VECTORHOOKS(pPDev,
  1094. EP_OEMPaint,
  1095. VMPaint,
  1096. BOOL,
  1097. (pso,
  1098. pco,
  1099. pbo,
  1100. pptlBrushOrg,
  1101. mix));
  1102. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1103. {
  1104. pRasterProcs = (PRMPROCS)(pPDev->pRasterProcs);
  1105. if (pRasterProcs->RMPaint != NULL)
  1106. {
  1107. return ( pRasterProcs->RMPaint(pso, pco, pbo, pptlBrushOrg, mix));
  1108. }
  1109. else
  1110. {
  1111. //
  1112. // Check whether to erase surface
  1113. //
  1114. CheckBitmapSurface(pso,&pco->rclBounds);
  1115. //
  1116. // Unidrv does not handle this call itself.
  1117. //
  1118. return EngPaint(pso, pco, pbo, pptlBrushOrg, mix);
  1119. }
  1120. }
  1121. else
  1122. {
  1123. ERR (("Device Managed Surface cannot call EngPaint"));
  1124. return FALSE;
  1125. }
  1126. }
  1127. BOOL APIENTRY
  1128. DrvRealizeBrush(
  1129. BRUSHOBJ *pbo,
  1130. SURFOBJ *psoTarget,
  1131. SURFOBJ *psoPattern,
  1132. SURFOBJ *psoMask,
  1133. XLATEOBJ *pxlo,
  1134. ULONG iHatch
  1135. )
  1136. /*++
  1137. Routine Description:
  1138. Implementation of DDI entry point DrvRealizeBrush.
  1139. Please refer to DDK documentation for more details.
  1140. Arguments:
  1141. pbo - BRUSHOBJ to be realized
  1142. psoTarget - Defines the surface for which the brush is to be realized
  1143. psoPattern - Defines the pattern for the brush
  1144. psoMask - Transparency mask for the brush
  1145. pxlo - Defines the interpretration of colors in the pattern
  1146. iHatch - Specifies whether psoPattern is one of the hatch brushes
  1147. Return Value:
  1148. TRUE if successful, FALSE if there is an error
  1149. --*/
  1150. {
  1151. PDEV *pPDev;
  1152. PDEVBRUSH pDB;
  1153. VERBOSE(("Entering DrvRealizeBrush...\n"));
  1154. ASSERT(psoTarget && pbo && pxlo);
  1155. pPDev = (PDEV *) psoTarget->dhpdev;
  1156. ASSERT_VALID_PDEV(pPDev);
  1157. //
  1158. // use driver managed surface
  1159. //
  1160. if (pPDev->pso)
  1161. psoTarget = pPDev->pso;
  1162. //
  1163. // Handle OEM hooks
  1164. //
  1165. HANDLE_OEMHOOKS(pPDev,
  1166. EP_OEMRealizeBrush,
  1167. PFN_OEMRealizeBrush,
  1168. BOOL,
  1169. (pbo,
  1170. psoTarget,
  1171. psoPattern,
  1172. psoMask,
  1173. pxlo,
  1174. iHatch));
  1175. HANDLE_VECTORHOOKS(pPDev,
  1176. EP_OEMRealizeBrush,
  1177. VMRealizeBrush,
  1178. BOOL,
  1179. (pbo,
  1180. psoTarget,
  1181. psoPattern,
  1182. psoMask,
  1183. pxlo,
  1184. iHatch));
  1185. //
  1186. // BUG_BUG, if OEM hook out DrvRealizeBrush, how are we
  1187. // handling dithering of solid color for pattern brush for text?
  1188. // Amanda says if OEM doesn't call this function or provide
  1189. // an equivalent when hooking out this function, dithered text
  1190. // support will not work. So maybe the OEM extensions guide
  1191. // should include such a warning in it.
  1192. //
  1193. // Handle realize brush for user defined pattern, dither solid color.
  1194. //
  1195. if ((iHatch >= HS_DDI_MAX) &&
  1196. (psoPattern) &&
  1197. (psoPattern->iType == STYPE_BITMAP) &&
  1198. (psoTarget->iType == STYPE_BITMAP) &&
  1199. (psoTarget->iBitmapFormat == psoPattern->iBitmapFormat) &&
  1200. (pDB = (PDEVBRUSH)BRUSHOBJ_pvAllocRbrush(pbo, sizeof(DEVBRUSH))))
  1201. {
  1202. WORD wChecksum;
  1203. LONG lPatID;
  1204. RECTW rcw;
  1205. rcw.l =
  1206. rcw.t = 0;
  1207. rcw.r = (WORD)psoPattern->sizlBitmap.cx;
  1208. rcw.b = (WORD)psoPattern->sizlBitmap.cy;
  1209. wChecksum = GetBMPChecksum(psoPattern, &rcw);
  1210. #ifndef WINNT_40
  1211. VERBOSE (("\n\nRaddd:DrvRealizedBrush(%08lx) Checksum=%04lx, %ld x %ld [%ld] ",
  1212. BRUSHOBJ_ulGetBrushColor(pbo) & 0x00FFFFFF,
  1213. wChecksum, psoPattern->sizlBitmap.cx,
  1214. psoPattern->sizlBitmap.cy, psoPattern->iBitmapFormat));
  1215. #endif
  1216. if (lPatID = FindCachedHTPattern(pPDev, wChecksum))
  1217. {
  1218. //
  1219. // Either need to download (<0) or already downloaded (>0)
  1220. //
  1221. if (lPatID < 0)
  1222. {
  1223. //
  1224. // Need to download the ID now
  1225. //
  1226. lPatID = -lPatID;
  1227. if (!Download1BPPHTPattern(pPDev, psoPattern, lPatID))
  1228. {
  1229. return(FALSE);
  1230. }
  1231. }
  1232. else if (lPatID == 0) // Out of memory case
  1233. return FALSE;
  1234. }
  1235. pDB->iColor = lPatID;
  1236. pbo->pvRbrush = (LPVOID)pDB;
  1237. VERBOSE (("\nUnidrv:DrvRealizedBrush(PatID=%d) ", pDB->iColor));
  1238. return(TRUE);
  1239. }
  1240. return ( FALSE );
  1241. }
  1242. BOOL APIENTRY
  1243. DrvStrokePath(
  1244. SURFOBJ *pso,
  1245. PATHOBJ *ppo,
  1246. CLIPOBJ *pco,
  1247. XFORMOBJ *pxo,
  1248. BRUSHOBJ *pbo,
  1249. POINTL *pptlBrushOrg,
  1250. LINEATTRS *plineattrs,
  1251. MIX mix
  1252. )
  1253. /*++
  1254. Routine Description:
  1255. Implementation of DDI entry point DrvStrokePath.
  1256. Please refer to DDK documentation for more details.
  1257. Arguments:
  1258. pso - Identifies the surface on which to draw
  1259. ppo - Defines the path to be stroked
  1260. pco - Defines the clipping path
  1261. pbo - Specifies the brush to be used when drawing the path
  1262. pptlBrushOrg - Defines the brush origin
  1263. plineattrs - Defines the line attributes
  1264. mix - Specifies how to combine the brush with the destination
  1265. Return Value:
  1266. TRUE if successful
  1267. FALSE if driver cannot handle the path
  1268. DDI_ERROR if there is an error
  1269. --*/
  1270. {
  1271. PDEV *pPDev;
  1272. VERBOSE(("Entering DrvStrokePath...\n"));
  1273. ASSERT(pso);
  1274. pPDev = (PDEV *)pso->dhpdev;
  1275. ASSERT_VALID_PDEV(pPDev);
  1276. //
  1277. // use driver managed surface
  1278. //
  1279. if (pPDev->pso)
  1280. pso = pPDev->pso;
  1281. //
  1282. // Handle OEM hooks
  1283. //
  1284. HANDLE_OEMHOOKS(pPDev,
  1285. EP_OEMStrokePath,
  1286. PFN_OEMStrokePath,
  1287. BOOL,
  1288. (pso,
  1289. ppo,
  1290. pco,
  1291. pxo,
  1292. pbo,
  1293. pptlBrushOrg,
  1294. plineattrs,
  1295. mix));
  1296. HANDLE_VECTORHOOKS(pPDev,
  1297. EP_OEMStrokePath,
  1298. VMStrokePath,
  1299. BOOL,
  1300. (pso,
  1301. ppo,
  1302. pco,
  1303. pxo,
  1304. pbo,
  1305. pptlBrushOrg,
  1306. plineattrs,
  1307. mix));
  1308. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1309. {
  1310. #ifndef DISABLE_NEWRULES
  1311. //
  1312. // check for black rectangle replacement
  1313. //
  1314. if (ppo->cCurves == 4 && ppo->fl == 0 &&
  1315. pPDev->pbRulesArray && pPDev->dwRulesCount < (MAX_NUM_RULES-4) &&
  1316. mix == (R2_COPYPEN | (R2_COPYPEN << 8)) && pbo &&
  1317. (pco == NULL || pco->iDComplexity != DC_COMPLEX) &&
  1318. ((pso->iBitmapFormat != BMF_24BPP &&
  1319. pbo->iSolidColor == (ULONG)((PAL_DATA*)(pPDev->pPalData))->iBlackIndex) ||
  1320. (pso->iBitmapFormat == BMF_24BPP &&
  1321. pbo->iSolidColor == 0)))
  1322. {
  1323. // Make sure outline doesn't use line style
  1324. //
  1325. if (!(plineattrs->fl & (LA_GEOMETRIC | LA_STYLED | LA_ALTERNATE)))
  1326. {
  1327. if (TestStrokeRectangle(pPDev,ppo,pco,plineattrs->elWidth.l))
  1328. {
  1329. return TRUE;
  1330. }
  1331. }
  1332. }
  1333. #endif
  1334. //
  1335. // Check whether to erase surface
  1336. //
  1337. CheckBitmapSurface(pso,pco? &pco->rclBounds : NULL);
  1338. //
  1339. // Unidrv does not handle this call itself.
  1340. //
  1341. return EngStrokePath(pso, ppo, pco, pxo, pbo, pptlBrushOrg, plineattrs,mix);
  1342. }
  1343. else
  1344. {
  1345. ERR (("Device Managed Surface cannot call EngStrokePath"));
  1346. return FALSE;
  1347. }
  1348. }
  1349. BOOL APIENTRY
  1350. DrvFillPath(
  1351. SURFOBJ *pso,
  1352. PATHOBJ *ppo,
  1353. CLIPOBJ *pco,
  1354. BRUSHOBJ *pbo,
  1355. POINTL *pptlBrushOrg,
  1356. MIX mix,
  1357. FLONG flOptions
  1358. )
  1359. /*++
  1360. Routine Description:
  1361. Implementation of DDI entry point DrvFillPath.
  1362. Please refer to DDK documentation for more details.
  1363. Arguments:
  1364. pso - Defines the surface on which to draw.
  1365. ppo - Defines the path to be filled
  1366. pco - Defines the clipping path
  1367. pbo - Defines the pattern and colors to fill with
  1368. pptlBrushOrg - Defines the brush origin
  1369. mix - Defines the foreground and background ROPs to use for the brush
  1370. flOptions - Whether to use zero-winding or odd-even rule
  1371. Return Value:
  1372. TRUE if successful
  1373. FALSE if driver cannot handle the path
  1374. DDI_ERROR if there is an error
  1375. --*/
  1376. {
  1377. PDEV *pPDev;
  1378. VERBOSE(("Entering DrvFillPath...\n"));
  1379. ASSERT(pso);
  1380. pPDev = (PDEV *) pso->dhpdev;
  1381. ASSERT_VALID_PDEV(pPDev);
  1382. //
  1383. // use driver managed surface
  1384. //
  1385. if (pPDev->pso)
  1386. pso = pPDev->pso;
  1387. //
  1388. // Handle OEM hooks
  1389. //
  1390. HANDLE_OEMHOOKS(pPDev,
  1391. EP_OEMFillPath,
  1392. PFN_OEMFillPath,
  1393. BOOL,
  1394. (pso,
  1395. ppo,
  1396. pco,
  1397. pbo,
  1398. pptlBrushOrg,
  1399. mix,
  1400. flOptions));
  1401. HANDLE_VECTORHOOKS(pPDev,
  1402. EP_OEMFillPath,
  1403. VMFillPath,
  1404. BOOL,
  1405. (pso,
  1406. ppo,
  1407. pco,
  1408. pbo,
  1409. pptlBrushOrg,
  1410. mix,
  1411. flOptions));
  1412. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1413. {
  1414. //
  1415. // Check whether to erase surface
  1416. //
  1417. CheckBitmapSurface(pso,&pco->rclBounds);
  1418. //
  1419. // Unidrv does not handle this call itself.
  1420. //
  1421. return EngFillPath(pso, ppo, pco, pbo, pptlBrushOrg, mix, flOptions);
  1422. }
  1423. else
  1424. {
  1425. ERR (("Device Managed Surface cannot call EngFillPath"));
  1426. return FALSE;
  1427. }
  1428. }
  1429. BOOL APIENTRY
  1430. DrvStrokeAndFillPath(
  1431. SURFOBJ *pso,
  1432. PATHOBJ *ppo,
  1433. CLIPOBJ *pco,
  1434. XFORMOBJ *pxo,
  1435. BRUSHOBJ *pboStroke,
  1436. LINEATTRS *plineattrs,
  1437. BRUSHOBJ *pboFill,
  1438. POINTL *pptlBrushOrg,
  1439. MIX mixFill,
  1440. FLONG flOptions
  1441. )
  1442. /*++
  1443. Routine Description:
  1444. Implementation of DDI entry point DrvStrokeAndFillPath.
  1445. Please refer to DDK documentation for more details.
  1446. Arguments:
  1447. pso - Describes the surface on which to draw
  1448. ppo - Describes the path to be filled
  1449. pco - Defines the clipping path
  1450. pxo - Specifies the world to device coordinate transformation
  1451. pboStroke - Specifies the brush to use when stroking the path
  1452. plineattrs - Specifies the line attributes
  1453. pboFill - Specifies the brush to use when filling the path
  1454. pptlBrushOrg - Specifies the brush origin for both brushes
  1455. mixFill - Specifies the foreground and background ROPs to use
  1456. for the fill brush
  1457. Return Value:
  1458. TRUE if successful
  1459. FALSE if driver cannot handle the path
  1460. DDI_ERROR if there is an error
  1461. --*/
  1462. {
  1463. PDEV *pPDev;
  1464. VERBOSE(("Entering DrvFillAndStrokePath...\n"));
  1465. ASSERT(pso);
  1466. pPDev = (PDEV *) pso->dhpdev;
  1467. ASSERT_VALID_PDEV(pPDev);
  1468. //
  1469. // use driver managed surface
  1470. //
  1471. if (pPDev->pso)
  1472. pso = pPDev->pso;
  1473. //
  1474. // Handle OEM hooks
  1475. //
  1476. HANDLE_OEMHOOKS(pPDev,
  1477. EP_OEMStrokeAndFillPath,
  1478. PFN_OEMStrokeAndFillPath,
  1479. BOOL,
  1480. (pso,
  1481. ppo,
  1482. pco,
  1483. pxo,
  1484. pboStroke,
  1485. plineattrs,
  1486. pboFill,
  1487. pptlBrushOrg,
  1488. mixFill,
  1489. flOptions));
  1490. HANDLE_VECTORHOOKS(pPDev,
  1491. EP_OEMStrokeAndFillPath,
  1492. VMStrokeAndFillPath,
  1493. BOOL,
  1494. (pso,
  1495. ppo,
  1496. pco,
  1497. pxo,
  1498. pboStroke,
  1499. plineattrs,
  1500. pboFill,
  1501. pptlBrushOrg,
  1502. mixFill,
  1503. flOptions));
  1504. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1505. {
  1506. //
  1507. // Check whether to erase surface
  1508. //
  1509. CheckBitmapSurface(pso,&pco->rclBounds);
  1510. //
  1511. // Unidrv does not handle this call itself.
  1512. //
  1513. return EngStrokeAndFillPath(pso, ppo, pco, pxo, pboStroke, plineattrs,
  1514. pboFill, pptlBrushOrg, mixFill, flOptions);
  1515. }
  1516. else
  1517. {
  1518. ERR (("Device Managed Surface cannot call EngStrokeAndFillPath"));
  1519. return FALSE;
  1520. }
  1521. }
  1522. BOOL APIENTRY
  1523. DrvLineTo(
  1524. SURFOBJ *pso,
  1525. CLIPOBJ *pco,
  1526. BRUSHOBJ *pbo,
  1527. LONG x1,
  1528. LONG y1,
  1529. LONG x2,
  1530. LONG y2,
  1531. RECTL *prclBounds,
  1532. MIX mix
  1533. )
  1534. /*++
  1535. Routine Description:
  1536. Implementation of DDI entry point DrvLineTo.
  1537. Please refer to DDK documentation for more details.
  1538. Arguments:
  1539. pso - Describes the surface on which to draw
  1540. pco - Defines the clipping path
  1541. pbo - Defines the brush used to draw the line
  1542. x1,y1 - Specifies the line's starting point
  1543. x2,y2 - Specifies the line's ending point
  1544. prclBounds - Defines a rectangle that bounds the unclipped line.
  1545. mix - Specifies the foreground and background ROP
  1546. Return Value:
  1547. TRUE if successful
  1548. FALSE if driver cannot handle the path
  1549. DDI_ERROR if there is an error
  1550. --*/
  1551. {
  1552. PDEV *pPDev;
  1553. RECTL DstRect;
  1554. VERBOSE(("Entering DrvLineTo...\n"));
  1555. ASSERT(pso);
  1556. pPDev = (PDEV *) pso->dhpdev;
  1557. ASSERT_VALID_PDEV(pPDev);
  1558. //
  1559. // use driver managed surface
  1560. //
  1561. if (pPDev->pso)
  1562. pso = pPDev->pso;
  1563. //
  1564. // Handle OEM hooks
  1565. //
  1566. HANDLE_OEMHOOKS(pPDev,
  1567. EP_OEMLineTo,
  1568. PFN_OEMLineTo,
  1569. BOOL,
  1570. (pso,
  1571. pco,
  1572. pbo,
  1573. x1,
  1574. y1,
  1575. x2,
  1576. y2,
  1577. prclBounds,
  1578. mix));
  1579. HANDLE_VECTORHOOKS(pPDev,
  1580. EP_OEMLineTo,
  1581. VMLineTo,
  1582. BOOL,
  1583. (pso,
  1584. pco,
  1585. pbo,
  1586. x1,
  1587. y1,
  1588. x2,
  1589. y2,
  1590. prclBounds,
  1591. mix));
  1592. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1593. {
  1594. DstRect.top = min(y1,y2);
  1595. DstRect.bottom = max(y1,y2);
  1596. DstRect.left = min(x1,x2);
  1597. DstRect.right = max(x1,x2);
  1598. #ifndef DISABLE_NEWRULES
  1599. //
  1600. // check for black rectangle replacement
  1601. //
  1602. if (pPDev->pbRulesArray && (pPDev->dwRulesCount < MAX_NUM_RULES) &&
  1603. (x1 == x2 || y1 == y2) &&
  1604. mix == (R2_COPYPEN | (R2_COPYPEN << 8)) && pbo &&
  1605. (pco == NULL || pco->iDComplexity != DC_COMPLEX) &&
  1606. ((pso->iBitmapFormat != BMF_24BPP &&
  1607. pbo->iSolidColor == (ULONG)((PAL_DATA*)(pPDev->pPalData))->iBlackIndex) ||
  1608. (pso->iBitmapFormat == BMF_24BPP &&
  1609. pbo->iSolidColor == 0)))
  1610. {
  1611. PRECTL pRect = &pPDev->pbRulesArray[pPDev->dwRulesCount];
  1612. *pRect = DstRect;
  1613. if (x1 == x2)
  1614. pRect->right++;
  1615. else if (y1 == y2)
  1616. pRect->bottom++;
  1617. AddRuleToList(pPDev,pRect,pco);
  1618. return TRUE;
  1619. }
  1620. #endif
  1621. //
  1622. // Check whether to erase surface
  1623. //
  1624. CheckBitmapSurface(pso,&DstRect);
  1625. //
  1626. // Unidrv does not handle this call itself.
  1627. //
  1628. return EngLineTo(pso, pco, pbo, x1, y1, x2, y2, prclBounds, mix);
  1629. }
  1630. else
  1631. {
  1632. ERR (("Device Managed Surface cannot call EngLineTo"));
  1633. return FALSE;
  1634. }
  1635. }
  1636. #ifndef WINNT_40
  1637. BOOL APIENTRY
  1638. DrvAlphaBlend(
  1639. SURFOBJ *psoDest,
  1640. SURFOBJ *psoSrc,
  1641. CLIPOBJ *pco,
  1642. XLATEOBJ *pxlo,
  1643. RECTL *prclDest,
  1644. RECTL *prclSrc,
  1645. BLENDOBJ *pBlendObj
  1646. )
  1647. /*++
  1648. Routine Description:
  1649. Implementation of DDI entry point DrvAlphaBlend.
  1650. Please refer to DDK documentation for more details.
  1651. Arguments:
  1652. psoDest - Defines the surface on which to draw
  1653. psoSrc - Defines the source
  1654. pco - Limits the area to be modified on the Destination
  1655. pxlo - Specifies how color dwIndexes are to be translated
  1656. between the source and target surfaces
  1657. prclDest - Defines the area to be modified on the Destination surface
  1658. prclSrc - Defines the area to be copied from the source surface
  1659. BlendFunction - Specifies the blend function to be used
  1660. Return Value:
  1661. TRUE if successful, FALSE if there is an error
  1662. --*/
  1663. {
  1664. PDEV *pPDev;
  1665. VERBOSE(("Entering DrvAlphaBlend...\n"));
  1666. pPDev = (PDEV *) psoDest->dhpdev;
  1667. ASSERT_VALID_PDEV(pPDev);
  1668. //
  1669. // use driver managed surface
  1670. //
  1671. if (pPDev->pso)
  1672. psoDest = pPDev->pso;
  1673. //
  1674. // Handle OEM hooks
  1675. //
  1676. HANDLE_OEMHOOKS(pPDev,
  1677. EP_OEMAlphaBlend,
  1678. PFN_OEMAlphaBlend,
  1679. BOOL,
  1680. (psoDest,
  1681. psoSrc,
  1682. pco,
  1683. pxlo,
  1684. prclDest,
  1685. prclSrc,
  1686. pBlendObj));
  1687. HANDLE_VECTORHOOKS(pPDev,
  1688. EP_OEMAlphaBlend,
  1689. VMAlphaBlend,
  1690. BOOL,
  1691. (psoDest,
  1692. psoSrc,
  1693. pco,
  1694. pxlo,
  1695. prclDest,
  1696. prclSrc,
  1697. pBlendObj));
  1698. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1699. {
  1700. //
  1701. // Check whether to erase surface
  1702. //
  1703. CheckBitmapSurface(psoDest,prclDest);
  1704. //
  1705. // Unidrv does not handle this call itself.
  1706. //
  1707. return EngAlphaBlend(psoDest,
  1708. psoSrc,
  1709. pco,
  1710. pxlo,
  1711. prclDest,
  1712. prclSrc,
  1713. pBlendObj);
  1714. }
  1715. else
  1716. {
  1717. ERR (("Device Managed Surface cannot call EngAlphaBlend"));
  1718. return FALSE;
  1719. }
  1720. }
  1721. BOOL APIENTRY
  1722. DrvGradientFill(
  1723. SURFOBJ *psoDest,
  1724. CLIPOBJ *pco,
  1725. XLATEOBJ *pxlo,
  1726. TRIVERTEX *pVertex,
  1727. ULONG nVertex,
  1728. PVOID pMesh,
  1729. ULONG nMesh,
  1730. RECTL *prclExtents,
  1731. POINTL *pptlDitherOrg,
  1732. ULONG ulMode
  1733. )
  1734. /*++
  1735. Routine Description:
  1736. Implementation of DDI entry point DrvGradientFill.
  1737. Please refer to DDK documentation for more details.
  1738. Return Value:
  1739. TRUE if successful, FALSE if there is an error
  1740. --*/
  1741. {
  1742. PDEV *pPDev;
  1743. VERBOSE(("Entering DrvGradientFill...\n"));
  1744. pPDev = (PDEV *) psoDest->dhpdev;
  1745. ASSERT_VALID_PDEV(pPDev);
  1746. //
  1747. // use driver managed surface
  1748. //
  1749. if (pPDev->pso)
  1750. psoDest = pPDev->pso;
  1751. //
  1752. // Handle OEM hooks
  1753. //
  1754. HANDLE_OEMHOOKS(pPDev,
  1755. EP_OEMGradientFill,
  1756. PFN_OEMGradientFill,
  1757. BOOL,
  1758. (psoDest,
  1759. pco,
  1760. pxlo,
  1761. pVertex,
  1762. nVertex,
  1763. pMesh,
  1764. nMesh,
  1765. prclExtents,
  1766. pptlDitherOrg,
  1767. ulMode));
  1768. HANDLE_VECTORHOOKS(pPDev,
  1769. EP_OEMGradientFill,
  1770. VMGradientFill,
  1771. BOOL,
  1772. (psoDest,
  1773. pco,
  1774. pxlo,
  1775. pVertex,
  1776. nVertex,
  1777. pMesh,
  1778. nMesh,
  1779. prclExtents,
  1780. pptlDitherOrg,
  1781. ulMode));
  1782. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1783. {
  1784. //
  1785. // Check whether to erase surface
  1786. //
  1787. CheckBitmapSurface(psoDest,prclExtents);
  1788. //
  1789. // Unidrv does not handle this call itself.
  1790. //
  1791. return EngGradientFill(psoDest,
  1792. pco,
  1793. pxlo,
  1794. pVertex,
  1795. nVertex,
  1796. pMesh,
  1797. nMesh,
  1798. prclExtents,
  1799. pptlDitherOrg,
  1800. ulMode);
  1801. }
  1802. else
  1803. {
  1804. ERR (("Device Managed Surface cannot call EngGradientFill"));
  1805. return FALSE;
  1806. }
  1807. }
  1808. BOOL APIENTRY
  1809. DrvTransparentBlt(
  1810. SURFOBJ *psoDst,
  1811. SURFOBJ *psoSrc,
  1812. CLIPOBJ *pco,
  1813. XLATEOBJ *pxlo,
  1814. RECTL *prclDst,
  1815. RECTL *prclSrc,
  1816. ULONG iTransColor,
  1817. ULONG ulReserved
  1818. )
  1819. /*++
  1820. Routine Description:
  1821. Implementation of DDI entry point DrvTransparentBlt.
  1822. Please refer to DDK documentation for more details.
  1823. Arguments:
  1824. psoDst - Defines the surface on which to draw
  1825. psoSrc - Defines the source
  1826. pco - Limits the area to be modified on the Destination
  1827. pxlo - Specifies how color dwIndexes are to be translated
  1828. between the source and target surfaces
  1829. prclDst - Defines the area to be modified on the Destination surface
  1830. prclSrc - Defines the area to be copied from the source surface
  1831. iTransColor - Specifies the transparent color
  1832. Return Value:
  1833. TRUE if successful, FALSE if there is an error
  1834. --*/
  1835. {
  1836. PDEV *pPDev;
  1837. VERBOSE(("Entering DrvTransparentBlt...\n"));
  1838. pPDev = (PDEV *) psoDst->dhpdev;
  1839. ASSERT_VALID_PDEV(pPDev);
  1840. //
  1841. // use driver managed surface
  1842. //
  1843. if (pPDev->pso)
  1844. psoDst = pPDev->pso;
  1845. //
  1846. // Handle OEM hooks
  1847. //
  1848. HANDLE_OEMHOOKS(pPDev,
  1849. EP_OEMTransparentBlt,
  1850. PFN_OEMTransparentBlt,
  1851. BOOL,
  1852. (psoDst,
  1853. psoSrc,
  1854. pco,
  1855. pxlo,
  1856. prclDst,
  1857. prclSrc,
  1858. iTransColor,
  1859. ulReserved));
  1860. HANDLE_VECTORHOOKS(pPDev,
  1861. EP_OEMTransparentBlt,
  1862. VMTransparentBlt,
  1863. BOOL,
  1864. (psoDst,
  1865. psoSrc,
  1866. pco,
  1867. pxlo,
  1868. prclDst,
  1869. prclSrc,
  1870. iTransColor,
  1871. ulReserved));
  1872. if (!DRIVER_DEVICEMANAGED (pPDev)) // not a device surface
  1873. {
  1874. //
  1875. // Check whether to erase surface
  1876. //
  1877. CheckBitmapSurface(psoDst,prclDst);
  1878. //
  1879. // Unidrv does not handle this call itself.
  1880. //
  1881. return EngTransparentBlt(psoDst,
  1882. psoSrc,
  1883. pco,
  1884. pxlo,
  1885. prclDst,
  1886. prclSrc,
  1887. iTransColor,
  1888. ulReserved);
  1889. }
  1890. else
  1891. {
  1892. ERR (("Device Managed Surface cannot call EngTransparentBlt"));
  1893. return FALSE;
  1894. }
  1895. }
  1896. #endif