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.

204 lines
4.1 KiB

  1. #include "precomp.h"
  2. //
  3. // BA.CPP
  4. // Bounds Accumulator
  5. //
  6. // Copyright(c) Microsoft 1997-
  7. //
  8. #define MLZ_FILE_ZONE ZONE_CORE
  9. //
  10. // BA_SyncOutgoing()
  11. // Reset rect count
  12. //
  13. void ASHost::BA_SyncOutgoing(void)
  14. {
  15. DebugEntry(ASHost::BA_SyncOutgoing);
  16. m_baNumRects = 0;
  17. DebugExitVOID(ASHost::BA_SyncOutgoing);
  18. }
  19. //
  20. // BA_AddRect()
  21. //
  22. void ASHost::BA_AddRect(LPRECT pRect)
  23. {
  24. DebugEntry(ASHost::BA_AddRect);
  25. //
  26. // Make sure that we don't have too many rects
  27. //
  28. if (m_baNumRects >= BA_NUM_RECTS)
  29. {
  30. ERROR_OUT(( "Too many rectangles"));
  31. DC_QUIT;
  32. }
  33. if(pRect == NULL)
  34. {
  35. DC_QUIT;
  36. }
  37. //
  38. // Check that the caller has passed a valid rectangle. If not, do a
  39. // trace alert, and then return immediately (as an invalid rectangle
  40. // shouldn't contribute to the accumulated bounds) - but report an OK
  41. // return code, so we keep running.
  42. //
  43. if ((pRect->right < pRect->left) ||
  44. (pRect->bottom < pRect->top))
  45. {
  46. WARNING_OUT(("BA_AddRect: empty rect {%04d, %04d, %04d, %04d}",
  47. pRect->left,
  48. pRect->top,
  49. pRect->right,
  50. pRect->bottom ));
  51. DC_QUIT;
  52. }
  53. //
  54. // Add the rect to the bounds.
  55. //
  56. m_abaRects[m_baNumRects++] = *pRect;
  57. DC_EXIT_POINT:
  58. DebugExitVOID(ASHost::BA_AddRect);
  59. }
  60. //
  61. // BA_QueryAccumulation()
  62. //
  63. UINT ASHost::BA_QueryAccumulation(void)
  64. {
  65. UINT totalSDA;
  66. LPBA_FAST_DATA lpbaFast;
  67. DebugEntry(ASHost::BA_QueryAccumulation);
  68. lpbaFast = BA_FST_START_WRITING;
  69. //
  70. // Get the current setting and clear the previous one.
  71. //
  72. totalSDA = lpbaFast->totalSDA;
  73. lpbaFast->totalSDA = 0;
  74. BA_FST_STOP_WRITING;
  75. DebugExitDWORD(ASHost::BA_QueryAccumulation, totalSDA);
  76. return(totalSDA);
  77. }
  78. //
  79. //
  80. // BA_FetchBounds()
  81. //
  82. //
  83. void ASHost::BA_FetchBounds(void)
  84. {
  85. BA_BOUNDS_INFO boundsInfo;
  86. UINT i;
  87. DebugEntry(ASHost::BA_FetchBounds);
  88. //
  89. // Clear our copy of the bounds
  90. //
  91. m_baNumRects = 0;
  92. //
  93. // Get the driver's latest bounds rects
  94. //
  95. OSI_FunctionRequest(BA_ESC_GET_BOUNDS,
  96. (LPOSI_ESCAPE_HEADER)&boundsInfo,
  97. sizeof(boundsInfo));
  98. //
  99. // Add the driver's bounds into our array
  100. //
  101. TRACE_OUT(( "Retreived %d rects from driver", boundsInfo.numRects));
  102. for (i = 0; i < boundsInfo.numRects; i++)
  103. {
  104. TRACE_OUT(( "Rect %d, (%d, %d) (%d, %d)",
  105. i,
  106. boundsInfo.rects[i].left,
  107. boundsInfo.rects[i].top,
  108. boundsInfo.rects[i].right,
  109. boundsInfo.rects[i].bottom));
  110. BA_AddRect((LPRECT)&boundsInfo.rects[i]);
  111. }
  112. DebugExitVOID(ASHost::BA_FetchBounds);
  113. }
  114. //
  115. // BA_ReturnBounds()
  116. //
  117. void ASHost::BA_ReturnBounds(void)
  118. {
  119. BA_BOUNDS_INFO boundsInfo;
  120. DebugEntry(ASHost::BA_ReturnBounds);
  121. //
  122. // Copy the share core's bounds into the structure which we pass to the
  123. // driver. This will also clear the share core's copy of the bounds.
  124. //
  125. BA_CopyBounds((LPRECT)boundsInfo.rects, (LPUINT)&boundsInfo.numRects, TRUE);
  126. //
  127. // Now set up for, and then call into the driver to fetch the driver's
  128. // bounds.
  129. //
  130. TRACE_OUT(( "Passing %d rects to driver", boundsInfo.numRects));
  131. OSI_FunctionRequest(BA_ESC_RETURN_BOUNDS,
  132. (LPOSI_ESCAPE_HEADER)&boundsInfo,
  133. sizeof(boundsInfo));
  134. DebugExitVOID(ASHost::BA_ReturnBounds);
  135. }
  136. //
  137. // BA_CopyBounds()
  138. //
  139. void ASHost::BA_CopyBounds(LPRECT pRects, LPUINT pNumRects, BOOL fReset)
  140. {
  141. DebugEntry(ASHost::BA_CopyBounds);
  142. if (*pNumRects = m_baNumRects)
  143. {
  144. TRACE_OUT(( "num rects : %d", m_baNumRects));
  145. memcpy(pRects, m_abaRects, m_baNumRects * sizeof(RECT));
  146. if (fReset)
  147. {
  148. m_baNumRects = 0;
  149. }
  150. }
  151. DebugExitVOID(ASHost::BA_CopyBounds);
  152. }