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.

155 lines
4.4 KiB

  1. /*==============================================================================
  2. These routines are wrappers for the display driver BitBlt interface.
  3. 05-30-93 RajeevD Created.
  4. 02-15-94 RajeevD Integrated into unified resource executor.
  5. ==============================================================================*/
  6. #include <windows.h>
  7. #include <windowsx.h>
  8. #include "constant.h"
  9. #include "frame.h" // driver header file, resource block format
  10. #include "jtypes.h" // type definition used in cartridge
  11. #include "jres.h" // cartridge resource data type definition
  12. #include "hretype.h"
  13. #include "hreext.h"
  14. #include "ddbitblt.h"
  15. USHORT usBrushWidth; // just a dummy
  16. //==============================================================================
  17. BOOL OpenBlt (LPRESTATE lpRE, UINT yBrush)
  18. {
  19. LPDD_BITMAP lpbmPat;
  20. LPBITMAP lpbmBand;
  21. // Initialize source.
  22. lpRE->bmSrc.bmPlanes = 1;
  23. lpRE->bmSrc.bmBitsPixel = 1;
  24. // Initialize destination.
  25. lpbmBand = lpRE->lpBandBuffer;
  26. lpRE->bmDst.bmPlanes = 1;
  27. lpRE->bmDst.bmBitsPixel = 1;
  28. lpRE->bmDst.bmWidth = lpbmBand->bmWidth;
  29. lpRE->bmDst.bmHeight = lpbmBand->bmHeight;
  30. lpRE->bmDst.bmWidthBytes = lpbmBand->bmWidthBytes;
  31. lpRE->bmDst.bmWidthPlanes = lpRE->bmDst.bmWidthBytes * lpRE->bmDst.bmHeight;
  32. lpRE->bmDst.bmBits = lpbmBand->bmBits;
  33. // Initialize DRAWMODE.
  34. ddColorInfo (&lpRE->bmDst, 0xFFFFFF, &lpRE->DrawMode.dwbgColor);
  35. ddColorInfo (&lpRE->bmDst, 0x000000, &lpRE->DrawMode.dwfgColor);
  36. lpRE->DrawMode.bkMode = 1; // transparent
  37. // Initialize LOGBRUSH.
  38. lpRE->lb.lbStyle = BS_PATTERN;
  39. lpRE->lb.lbHatch = GlobalAlloc (GMEM_ZEROINIT, sizeof(DD_BITMAP));
  40. if (!lpRE->lb.lbHatch)
  41. return FALSE;
  42. lpbmPat = (LPDD_BITMAP) GlobalLock (lpRE->lb.lbHatch);
  43. // Set brush origin.
  44. lpRE->wPoint[0] = 0;
  45. lpRE->wPoint[1] = yBrush;
  46. // Initialize pattern bitmap.
  47. lpbmPat->bmPlanes = 1;
  48. lpbmPat->bmBitsPixel = 1;
  49. lpbmPat->bmWidth = 32;
  50. lpbmPat->bmHeight = 32;
  51. lpbmPat->bmWidthBytes = 4;
  52. lpbmPat->bmWidthPlanes = 128;
  53. lpbmPat->bmBits = lpRE->TiledPat;
  54. GlobalUnlock (lpRE->lb.lbHatch);
  55. // Set physical brush.
  56. lpRE->lpBrush = NULL;
  57. return TRUE;
  58. }
  59. //==============================================================================
  60. void CloseBlt (LPRESTATE lpRE)
  61. {
  62. GlobalFree (lpRE->lb.lbHatch);
  63. if (lpRE->lpBrush)
  64. GlobalFreePtr (lpRE->lpBrush);
  65. }
  66. //==============================================================================
  67. BOOL SetBrush (LPRESTATE lpRE)
  68. {
  69. LPDD_BITMAP lpbmPat = (LPDD_BITMAP) GlobalLock (lpRE->lb.lbHatch);
  70. UINT cbBrush;
  71. // Delete previous brush, if any.
  72. if (lpRE->lpBrush)
  73. {
  74. ddRealize (&lpRE->bmDst, -OBJ_BRUSH, &lpRE->lb, lpRE->lpBrush, lpRE->wPoint);
  75. GlobalFreePtr (lpRE->lpBrush);
  76. }
  77. // Realize new physical brush.
  78. lpbmPat->bmBits = lpRE->lpCurBrush;
  79. cbBrush = ddRealize (&lpRE->bmDst, OBJ_BRUSH, &lpRE->lb, NULL, lpRE->wPoint);
  80. lpRE->lpBrush = GlobalAllocPtr (GMEM_FIXED, cbBrush);
  81. ddRealize (&lpRE->bmDst, OBJ_BRUSH, &lpRE->lb, lpRE->lpBrush, lpRE->wPoint);
  82. GlobalUnlock (lpRE->lb.lbHatch);
  83. return TRUE;
  84. }
  85. //==============================================================================
  86. // Clipping to top and bottom of band is performed, but
  87. // ideally should be handled by caller as needed.
  88. DWORD FAR PASCAL RP_BITMAP1TO1
  89. (
  90. LPRESTATE lpRE,
  91. WORD xSrc, // Left padding
  92. short yDst, // Top row of destination.
  93. short xDst, // Left column of destination.
  94. WORD clLine, // Longs per scan line
  95. WORD yExt, // Height in pixels
  96. WORD xExt, // Width in pixels
  97. LPDWORD lpSrc, // Far pointer to source
  98. LPDWORD lpPat, // Far pointer to pattern
  99. DWORD dwRop // Raster operation
  100. )
  101. {
  102. LPBITMAP lpbmBand;
  103. WORD ySrc;
  104. // Record parameters.
  105. lpRE->bmSrc.bmWidth = xExt + xSrc;
  106. lpRE->bmSrc.bmHeight = yExt;
  107. lpRE->bmSrc.bmWidthBytes = 4 * clLine;
  108. lpRE->bmSrc.bmWidthPlanes = lpRE->bmSrc.bmWidthBytes * lpRE->bmSrc.bmHeight;
  109. lpRE->bmSrc.bmBits = lpSrc;
  110. // Clip to top of band.
  111. if (yDst >= 0)
  112. ySrc = 0;
  113. else
  114. {
  115. ySrc = -yDst;
  116. yExt -= ySrc;
  117. yDst = 0;
  118. }
  119. // Clip to bottom of band.
  120. lpbmBand = lpRE->lpBandBuffer;
  121. if (yExt > (WORD) lpbmBand->bmHeight - yDst)
  122. yExt = lpbmBand->bmHeight - yDst;
  123. ddBitBlt
  124. (
  125. &lpRE->bmDst, xDst, yDst, &lpRE->bmSrc, xSrc, ySrc,
  126. xExt, yExt, lpRE->dwRop, lpRE->lpBrush, &lpRE->DrawMode
  127. );
  128. return 0;
  129. }