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.

152 lines
4.5 KiB

  1. #include <windows.h>
  2. #include "constant.h"
  3. #include "frame.h" // driver header file, resource block format
  4. #include "jtypes.h" /* Jumbo type definitions. */
  5. #include "jres.h" // cartridge resource data type definition
  6. #include "hretype.h" /* Slice Descriptor defs. */
  7. #include "hreext.h"
  8. //==============================================================================
  9. BOOL OpenBlt (LPRESTATE lpRE, UINT yBrush)
  10. {
  11. HDC hdcScreen;
  12. HBITMAP hbmDst;
  13. LPBITMAP lpbmBand = lpRE->lpBandBuffer;
  14. UINT cbBand = lpbmBand->bmHeight * lpbmBand->bmWidthBytes;
  15. LPVOID lpBits;
  16. struct
  17. {
  18. BITMAPINFOHEADER bmih;
  19. DWORD dwPal[2];
  20. }
  21. bmiDst;
  22. // Create memory device contexts.
  23. hdcScreen = CreateIC ("DISPLAY", NULL, NULL, NULL);
  24. lpRE->hdcDst = CreateCompatibleDC (hdcScreen);
  25. lpRE->hdcSrc = CreateCompatibleDC (hdcScreen);
  26. DeleteDC (hdcScreen);
  27. // Initialize destination bitmap.
  28. bmiDst.bmih.biSize = sizeof(BITMAPINFOHEADER);
  29. bmiDst.bmih.biWidth = lpbmBand->bmWidth;
  30. bmiDst.bmih.biHeight = -lpbmBand->bmHeight; // top-down
  31. bmiDst.bmih.biPlanes = 1;
  32. bmiDst.bmih.biBitCount = 1;
  33. bmiDst.bmih.biCompression = BI_RGB;
  34. bmiDst.bmih.biSizeImage = 0;
  35. bmiDst.bmih.biClrUsed = 0;
  36. bmiDst.bmih.biClrImportant = 0;
  37. bmiDst.dwPal[0] = RGB ( 0, 0, 0);
  38. bmiDst.dwPal[1] = RGB (255, 255, 255);
  39. // Create DIB section.
  40. hbmDst = CreateDIBSection
  41. (lpRE->hdcDst, (LPBITMAPINFO) &bmiDst, DIB_RGB_COLORS, &lpBits, NULL, 0);
  42. if (!hbmDst)
  43. return FALSE;
  44. lpRE->hbmDef = SelectObject (lpRE->hdcDst, hbmDst);
  45. lpRE->hbrDef = NULL;
  46. // Swap frame buffers.
  47. lpRE->lpBandSave = lpbmBand->bmBits;
  48. lpbmBand->bmBits = lpBits;
  49. // Disable GDI batching.
  50. GdiSetBatchLimit (1);
  51. return TRUE;
  52. }
  53. //==============================================================================
  54. void CloseBlt (LPRESTATE lpRE)
  55. {
  56. // Restore frame buffer.
  57. LPBITMAP lpbmBand = lpRE->lpBandBuffer;
  58. UINT cbBand = lpbmBand->bmHeight * lpbmBand->bmWidthBytes;
  59. memcpy (lpRE->lpBandSave, lpbmBand->bmBits, cbBand);
  60. lpbmBand->bmBits = lpRE->lpBandSave;
  61. // Restore default objects.
  62. DeleteObject (SelectObject (lpRE->hdcDst, lpRE->hbmDef));
  63. DeleteObject (SelectObject (lpRE->hdcDst, lpRE->hbrDef));
  64. // Destroy memory device contexts.
  65. DeleteDC (lpRE->hdcDst);
  66. DeleteDC (lpRE->hdcSrc);
  67. // Restore GDI batching.
  68. GdiSetBatchLimit (0);
  69. }
  70. //==============================================================================
  71. DWORD FAR PASCAL RP_BITMAP1TO1
  72. (
  73. LPRESTATE lpRE,
  74. WORD xSrc, // Left padding
  75. short yDst, // Top row of destination.
  76. short xDst, // Left column of destination.
  77. WORD clLine, // Longs per scan line
  78. WORD yExt, // Height in pixels
  79. WORD xExt, // Width in pixels
  80. LPDWORD lpSrc, // Far pointer to source
  81. LPDWORD lpPat, // Far pointer to pattern
  82. DWORD dwRop // Raster operation
  83. )
  84. {
  85. HBITMAP hbmSrc, hbmOld;
  86. // Create source bitmap.
  87. hbmSrc = CreateCompatibleBitmap (lpRE->hdcSrc, 32*clLine, yExt);
  88. SetBitmapBits (hbmSrc, 4*clLine*yExt, lpSrc);
  89. hbmOld = SelectObject (lpRE->hdcSrc, hbmSrc);
  90. // Call GDI BitBlt.
  91. BitBlt (lpRE->hdcDst, xDst, yDst, xExt, yExt, lpRE->hdcSrc, xSrc, 0, lpRE->dwRop);
  92. // Destroy source bitmap.
  93. SelectObject (lpRE->hdcSrc, hbmOld);
  94. DeleteObject (hbmSrc);
  95. return 0;
  96. }
  97. //==============================================================================
  98. BOOL SetBrush (LPRESTATE lpRE)
  99. {
  100. HBITMAP hbmPat;
  101. HBRUSH hbrPat, hbrOld;
  102. // Create pattern brush.
  103. hbmPat = CreateBitmap (32, 32, 1, 1, lpRE->lpCurBrush);
  104. hbrPat = CreatePatternBrush (hbmPat);
  105. DeleteObject (hbmPat);
  106. // Replace previous brush.
  107. hbrOld = SelectObject (lpRE->hdcDst, hbrPat);
  108. if (lpRE->hbrDef)
  109. DeleteObject (hbrOld); // delete old brush
  110. else
  111. lpRE->hbrDef = hbrOld; // save default brush
  112. return TRUE;
  113. }
  114. //==============================================================================
  115. ULONG FAR PASCAL RP_FILLSCANROW
  116. (
  117. LPRESTATE lpRE, // resource executor context
  118. USHORT xDst, // rectangle left
  119. USHORT yDst, // rectangle right
  120. USHORT xExt, // rectangle width
  121. USHORT yExt, // rectangle height
  122. UBYTE FAR* lpPat, // 32x32 pattern bitmap
  123. DWORD dwRop, // raster operation
  124. LPVOID lpBand, // output band buffer
  125. UINT cbLine, // band width in bytes
  126. WORD yBrush // brush position offset
  127. )
  128. {
  129. return PatBlt (lpRE->hdcDst, xDst, yDst, xExt, yExt, lpRE->dwRop);
  130. }