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.

145 lines
3.9 KiB

  1. //
  2. // BMC.H
  3. // Bitmap Cache
  4. //
  5. // Copyright (c) Microsoft 1997-
  6. //
  7. #ifndef _H_BMC
  8. #define _H_BMC
  9. //
  10. // Bitmap caching order header
  11. //
  12. typedef struct tagBMC_ORDER_HDR
  13. {
  14. TSHR_UINT8 bmcPacketType;
  15. }
  16. BMC_ORDER_HDR;
  17. typedef BMC_ORDER_HDR FAR * PBMC_ORDER_HDR;
  18. //
  19. // Structure of data stored in DIB cache.
  20. // The first few fields are variable and therefore not included in the
  21. // cache hash.
  22. //
  23. #define BMC_DIB_NOT_HASHED (FIELD_OFFSET(BMC_DIB_ENTRY, cx))
  24. typedef struct tagBMC_DIB_ENTRY
  25. {
  26. BYTE inUse;
  27. BYTE bCompressed;
  28. TSHR_UINT16 iCacheIndex;
  29. TSHR_UINT16 cx;
  30. TSHR_UINT16 cxFixed;
  31. TSHR_UINT16 cy;
  32. TSHR_UINT16 bpp;
  33. UINT cCompressed;
  34. UINT cBits;
  35. BYTE bits[1];
  36. }
  37. BMC_DIB_ENTRY;
  38. typedef BMC_DIB_ENTRY FAR * PBMC_DIB_ENTRY;
  39. //
  40. // DIB cache header
  41. //
  42. typedef struct tagBMC_DIB_CACHE
  43. {
  44. PCHCACHE handle;
  45. PBMC_DIB_ENTRY freeEntry;
  46. LPBYTE data;
  47. UINT cEntries;
  48. UINT cCellSize;
  49. UINT cSize;
  50. }
  51. BMC_DIB_CACHE;
  52. typedef BMC_DIB_CACHE * PBMC_DIB_CACHE;
  53. //
  54. // WE HAVE NO SMALL TILES ANYMORE
  55. // Medium sized tiles must fit into a medium cell for the sending depth.
  56. // Large sized tiles must fit into a large cell for the sending depth.
  57. //
  58. // Since true color sending can change dynamically, the easiest thing to do
  59. // to cut down on memory usage is to check the capture depth. If it's
  60. // <= 8, then we can never send true color, so allocate for 8bpp. Else
  61. // allocate for 24bpp.
  62. //
  63. #define BYTES_IN_SCANLINE(width, bpp) ((((width)*(bpp))+31)/32)*4
  64. #define BYTES_IN_BITMAP(width, height, bpp) (BYTES_IN_SCANLINE(width, bpp)*height)
  65. __inline UINT MaxBitmapHeight(UINT width, UINT bpp)
  66. {
  67. UINT bytesPerRow;
  68. //
  69. // If bpp is 4, there are width/2 bytes per Row
  70. // If bpp is 8, there are width bytes per Row
  71. // If bpp is 24, there are 3*width bytes per Row
  72. //
  73. bytesPerRow = BYTES_IN_SCANLINE(width, bpp);
  74. return((TSHR_MAX_SEND_PKT - sizeof(S20DATAPACKET) + sizeof(DATAPACKETHEADER)) / bytesPerRow);
  75. }
  76. //
  77. // Define the cache identifiers which are transmitted in the hBitmap field
  78. // of Memory->Screen blt orders.
  79. //
  80. // These are replaced by the receiver with their local (real) bitmap
  81. // handle of the specified cache.
  82. //
  83. // Note that they are assumed to be contiguous with the smallest as 0
  84. //
  85. //
  86. #define ID_SMALL_BMP_CACHE 0
  87. #define ID_MEDIUM_BMP_CACHE 1
  88. #define ID_LARGE_BMP_CACHE 2
  89. #define NUM_BMP_CACHES 3
  90. //
  91. // WHEN 2.X COMPAT IS GONE, WE CAN PLAY WITH THESE SIZES AT WILL. But
  92. // since the cell size (width * height * bpp) is negotiated when a 2.x
  93. // node is in the share, we can not. Back level nodes assume a certain
  94. // cell size. So do new level nodes for now!
  95. //
  96. #define MP_SMALL_TILE_WIDTH 16
  97. #define MP_SMALL_TILE_WIDTH 16
  98. #define MP_MEDIUM_TILE_WIDTH 32
  99. #define MP_MEDIUM_TILE_HEIGHT 32
  100. #define MP_LARGE_TILE_WIDTH 64
  101. #define MP_LARGE_TILE_HEIGHT 63
  102. #define MP_CACHE_CELLSIZE(width, height, bpp) \
  103. (BYTES_IN_BITMAP(width, height, bpp) + sizeof(BMC_DIB_ENTRY) - 1)
  104. //
  105. // Upper bound on the total cache memory we'll use (2 MB)
  106. //
  107. #define MP_MEMORY_MAX 0x200000
  108. #define COLORCACHEINDEX_NONE 0xFF
  109. #define MEMBLT_CACHETABLE(pMemBlt) ((TSHR_UINT16)LOBYTE(pMemBlt->cacheId))
  110. #define MEMBLT_COLORINDEX(pMemBlt) ((TSHR_UINT16)HIBYTE(pMemBlt->cacheId))
  111. #define MEMBLT_COMBINEHANDLES(colort, bitmap) ((TSHR_UINT16)MAKEWORD(bitmap, colort))
  112. BOOL BMCAllocateCacheData(UINT numEntries, UINT cellSize, UINT cacheID,
  113. PBMC_DIB_CACHE pCache);
  114. void BMCFreeCacheData(PBMC_DIB_CACHE pCache);
  115. #endif // H_BMC