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.

130 lines
4.2 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: stretch.c
  3. *
  4. * Copyright (c) 1993-1994 Microsoft Corporation
  5. \**************************************************************************/
  6. #include "precomp.h"
  7. /******************************Public*Routine******************************\
  8. * BOOL DrvStretchBlt
  9. *
  10. \**************************************************************************/
  11. BOOL DrvStretchBlt(
  12. SURFOBJ* psoDst,
  13. SURFOBJ* psoSrc,
  14. SURFOBJ* psoMsk,
  15. CLIPOBJ* pco,
  16. XLATEOBJ* pxlo,
  17. COLORADJUSTMENT* pca,
  18. POINTL* pptlHTOrg,
  19. RECTL* prclDst,
  20. RECTL* prclSrc,
  21. POINTL* pptlMsk,
  22. ULONG iMode)
  23. {
  24. DSURF* pdsurfSrc;
  25. DSURF* pdsurfDst;
  26. PDEV* ppdev;
  27. ppdev = (PDEV*) psoDst->dhpdev;
  28. // It's quicker for GDI to do a StretchBlt when the source surface
  29. // is not a device-managed surface, because then it can directly
  30. // read the source bits without having to allocate a temporary
  31. // buffer and call DrvCopyBits to get a copy that it can use.
  32. //
  33. // So if the source is one of our off-screen DFBs, we'll immediately
  34. // and permanently convert it to a DIB:
  35. if (psoSrc->iType == STYPE_DEVBITMAP)
  36. {
  37. pdsurfSrc = (DSURF*) psoSrc->dhsurf;
  38. if (pdsurfSrc->dt == DT_SCREEN)
  39. {
  40. if (!pohMoveOffscreenDfbToDib(ppdev, pdsurfSrc->poh))
  41. return(FALSE);
  42. }
  43. ASSERTDD(pdsurfSrc->dt == DT_DIB, "Can only handle DIB DFBs here");
  44. psoSrc = pdsurfSrc->pso;
  45. }
  46. // Pass the call off to GDI if the destination surface is a device
  47. // bitmap that we converted to a DIB:
  48. pdsurfDst = (DSURF*) psoDst->dhsurf;
  49. if (pdsurfDst->dt == DT_DIB)
  50. {
  51. psoDst = pdsurfDst->pso;
  52. goto Punt_It;
  53. }
  54. #if 0 // I would enable this chunk of code, except for the fact that
  55. { // GDI does byte writes to the screen, which kills us on ISA
  56. // buses (it's faster to have GDI write to a temporary DIB,
  57. // paying the cost of the DIB allocation, and then doing an
  58. // aligned copy of the final result).
  59. #if defined(i386)
  60. {
  61. OH* poh;
  62. BANK bnk;
  63. BOOL b;
  64. RECTL rclDraw;
  65. // Make sure we're not doing a screen-to-screen StretchBlt,
  66. // because we can't map two banks in at the same time:
  67. if (psoSrc->iType == STYPE_BITMAP)
  68. {
  69. // We'll be drawing to the screen or an off-screen DFB;
  70. // copy the surface's offset now so that we won't need
  71. // to refer to the DSURF again:
  72. poh = pdsurfDst->poh;
  73. ppdev->xOffset = poh->x;
  74. ppdev->yOffset = poh->y;
  75. // The bank manager requires that the 'draw' rectangle be
  76. // well-ordered:
  77. rclDraw = *prclDst;
  78. if (rclDraw.left > rclDraw.right)
  79. {
  80. rclDraw.left = prclDst->right;
  81. rclDraw.right = prclDst->left;
  82. }
  83. if (rclDraw.top > rclDraw.bottom)
  84. {
  85. rclDraw.top = prclDst->bottom;
  86. rclDraw.bottom = prclDst->top;
  87. }
  88. vBankStart(ppdev, &rclDraw, pco, &bnk);
  89. b = TRUE;
  90. do {
  91. b &= EngStretchBlt(bnk.pso, psoSrc, psoMsk, bnk.pco,
  92. pxlo, pca, pptlHTOrg, prclDst,
  93. prclSrc, pptlMsk, iMode);
  94. } while (bBankEnum(&bnk));
  95. return(b);
  96. }
  97. }
  98. #endif // i386
  99. }
  100. #endif // 0
  101. Punt_It:
  102. // GDI is nice enough to handle the cases where 'psoDst' and/or 'psoSrc'
  103. // are device-managed surfaces, but it ain't gonna be fast...
  104. return(EngStretchBlt(psoDst, psoSrc, psoMsk, pco, pxlo, pca, pptlHTOrg,
  105. prclDst, prclSrc, pptlMsk, iMode));
  106. }