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.

125 lines
3.6 KiB

  1. /****************************************************************************/
  2. // abacom.h
  3. //
  4. // BA inline functions and prototypes common to both DD and WD.
  5. //
  6. // Copyright (C) 1997-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #ifndef _H_BACOM
  9. #define _H_BACOM
  10. #ifdef DLL_DISP
  11. #define _pShm pddShm
  12. #else
  13. #define _pShm m_pShm
  14. #endif
  15. #ifdef DC_DEBUG
  16. void RDPCALL BACheckList(void);
  17. #endif
  18. /****************************************************************************/
  19. // BACopyBounds
  20. //
  21. // Copies the current (exclusive) SDA rects.
  22. /****************************************************************************/
  23. __inline void RDPCALL BACopyBounds(PRECTL pRects, unsigned *pNumRects)
  24. {
  25. unsigned iSrc, iDst;
  26. PBA_RECT_INFO pRectInfo;
  27. *pNumRects = _pShm->ba.rectsUsed;
  28. // Return the bounds that have been accumulated by traversing the
  29. // in-use list.
  30. iSrc = _pShm->ba.firstRect;
  31. iDst = 0;
  32. while (iSrc != BA_INVALID_RECT_INDEX) {
  33. pRectInfo = &(_pShm->ba.bounds[iSrc]);
  34. pRects[iDst] = pRectInfo->coord;
  35. iDst++;
  36. iSrc = pRectInfo->iNext;
  37. }
  38. }
  39. /****************************************************************************/
  40. // BAResetBounds
  41. //
  42. // Clears the bounds list.
  43. /****************************************************************************/
  44. __inline void RDPCALL BAResetBounds(void)
  45. {
  46. unsigned iRect, iHold;
  47. BA_RECT_INFO *pRect;
  48. // Restore all rects in used list to the free list.
  49. iRect = _pShm->ba.firstRect;
  50. while (iRect != BA_INVALID_RECT_INDEX) {
  51. pRect = &_pShm->ba.bounds[iRect];
  52. pRect->inUse = FALSE;
  53. iHold = iRect;
  54. iRect = pRect->iNext;
  55. pRect->iNext = _pShm->ba.firstFreeRect;
  56. _pShm->ba.firstFreeRect = iHold;
  57. }
  58. _pShm->ba.firstRect = BA_INVALID_RECT_INDEX;
  59. _pShm->ba.rectsUsed = 0;
  60. _pShm->ba.totalArea = 0;
  61. }
  62. /****************************************************************************/
  63. // BAAddRectList
  64. //
  65. // Adds a rect into the Screen Data Area.
  66. /****************************************************************************/
  67. __inline void RDPCALL BAAddRectList(PRECTL pRect)
  68. {
  69. unsigned iNewRect;
  70. BA_RECT_INFO *pNewRect;
  71. // Note it is responsibility of caller to make sure that there is
  72. // enough space in the bounds array and that the rectangle is valid
  73. // (the left is not greater than the right, top is less than bottom).
  74. // The extra rect at the end of the list is extra space that will be
  75. // used only temporarily by the rect merge code.
  76. // Add the rect to the bounds. This is essentially a doubly-linked list
  77. // insertion using the rect at the head of the free list. Order does
  78. // not matter, so we also insert at the beginning of the in-use list.
  79. iNewRect = _pShm->ba.firstFreeRect;
  80. pNewRect = &(_pShm->ba.bounds[iNewRect]);
  81. // Remove from free list.
  82. _pShm->ba.firstFreeRect = pNewRect->iNext;
  83. // Add to beginning of used list.
  84. pNewRect->iNext = _pShm->ba.firstRect;
  85. pNewRect->iPrev = BA_INVALID_RECT_INDEX;
  86. if (pNewRect->iNext != BA_INVALID_RECT_INDEX)
  87. _pShm->ba.bounds[pNewRect->iNext].iPrev = iNewRect;
  88. _pShm->ba.firstRect = iNewRect;
  89. _pShm->ba.rectsUsed++;
  90. // Fill in data.
  91. pNewRect->inUse = TRUE;
  92. pNewRect->coord = *pRect;
  93. pNewRect->area = COM_SIZEOF_RECT(pNewRect->coord);
  94. _pShm->ba.totalArea += pNewRect->area;
  95. #ifdef DC_DEBUG
  96. // Check the list integrity.
  97. BACheckList();
  98. #endif
  99. }
  100. #endif // !defined(_H_BACOM)