Source code of Windows XP (NT5)
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.

198 lines
3.9 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. //
  34. // Check that the caller has passed a valid rectangle. If not, do a
  35. // trace alert, and then return immediately (as an invalid rectangle
  36. // shouldn't contribute to the accumulated bounds) - but report an OK
  37. // return code, so we keep running.
  38. //
  39. if ((pRect->right < pRect->left) ||
  40. (pRect->bottom < pRect->top))
  41. {
  42. WARNING_OUT(("BA_AddRect: empty rect {%04d, %04d, %04d, %04d}",
  43. pRect->left,
  44. pRect->top,
  45. pRect->right,
  46. pRect->bottom ));
  47. DC_QUIT;
  48. }
  49. //
  50. // Add the rect to the bounds.
  51. //
  52. m_abaRects[m_baNumRects++] = *pRect;
  53. DC_EXIT_POINT:
  54. DebugExitVOID(ASHost::BA_AddRect);
  55. }
  56. //
  57. // BA_QueryAccumulation()
  58. //
  59. UINT ASHost::BA_QueryAccumulation(void)
  60. {
  61. UINT totalSDA;
  62. LPBA_FAST_DATA lpbaFast;
  63. DebugEntry(ASHost::BA_QueryAccumulation);
  64. lpbaFast = BA_FST_START_WRITING;
  65. //
  66. // Get the current setting and clear the previous one.
  67. //
  68. totalSDA = lpbaFast->totalSDA;
  69. lpbaFast->totalSDA = 0;
  70. BA_FST_STOP_WRITING;
  71. DebugExitDWORD(ASHost::BA_QueryAccumulation, totalSDA);
  72. return(totalSDA);
  73. }
  74. //
  75. //
  76. // BA_FetchBounds()
  77. //
  78. //
  79. void ASHost::BA_FetchBounds(void)
  80. {
  81. BA_BOUNDS_INFO boundsInfo;
  82. UINT i;
  83. DebugEntry(ASHost::BA_FetchBounds);
  84. //
  85. // Clear our copy of the bounds
  86. //
  87. m_baNumRects = 0;
  88. //
  89. // Get the driver's latest bounds rects
  90. //
  91. OSI_FunctionRequest(BA_ESC_GET_BOUNDS,
  92. (LPOSI_ESCAPE_HEADER)&boundsInfo,
  93. sizeof(boundsInfo));
  94. //
  95. // Add the driver's bounds into our array
  96. //
  97. TRACE_OUT(( "Retreived %d rects from driver", boundsInfo.numRects));
  98. for (i = 0; i < boundsInfo.numRects; i++)
  99. {
  100. TRACE_OUT(( "Rect %d, (%d, %d) (%d, %d)",
  101. i,
  102. boundsInfo.rects[i].left,
  103. boundsInfo.rects[i].top,
  104. boundsInfo.rects[i].right,
  105. boundsInfo.rects[i].bottom));
  106. BA_AddRect((LPRECT)&boundsInfo.rects[i]);
  107. }
  108. DebugExitVOID(ASHost::BA_FetchBounds);
  109. }
  110. //
  111. // BA_ReturnBounds()
  112. //
  113. void ASHost::BA_ReturnBounds(void)
  114. {
  115. BA_BOUNDS_INFO boundsInfo;
  116. DebugEntry(ASHost::BA_ReturnBounds);
  117. //
  118. // Copy the share core's bounds into the structure which we pass to the
  119. // driver. This will also clear the share core's copy of the bounds.
  120. //
  121. BA_CopyBounds((LPRECT)boundsInfo.rects, (LPUINT)&boundsInfo.numRects, TRUE);
  122. //
  123. // Now set up for, and then call into the driver to fetch the driver's
  124. // bounds.
  125. //
  126. TRACE_OUT(( "Passing %d rects to driver", boundsInfo.numRects));
  127. OSI_FunctionRequest(BA_ESC_RETURN_BOUNDS,
  128. (LPOSI_ESCAPE_HEADER)&boundsInfo,
  129. sizeof(boundsInfo));
  130. DebugExitVOID(ASHost::BA_ReturnBounds);
  131. }
  132. //
  133. // BA_CopyBounds()
  134. //
  135. void ASHost::BA_CopyBounds(LPRECT pRects, LPUINT pNumRects, BOOL fReset)
  136. {
  137. DebugEntry(ASHost::BA_CopyBounds);
  138. if (*pNumRects = m_baNumRects)
  139. {
  140. TRACE_OUT(( "num rects : %d", m_baNumRects));
  141. memcpy(pRects, m_abaRects, m_baNumRects * sizeof(RECT));
  142. if (fReset)
  143. {
  144. m_baNumRects = 0;
  145. }
  146. }
  147. DebugExitVOID(ASHost::BA_CopyBounds);
  148. }