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.

114 lines
3.8 KiB

  1. /****************************************************************************/
  2. // asdgapi.cpp
  3. //
  4. // RDP Screen Data Grabber API functions
  5. //
  6. // Copyright (C) 1996-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #include <precomp.h>
  9. #pragma hdrstop
  10. #define TRC_FILE "asdgapi"
  11. #include <as_conf.hpp>
  12. #include <nprcount.h>
  13. /****************************************************************************/
  14. // SDG_Init
  15. /****************************************************************************/
  16. void RDPCALL SHCLASS SDG_Init(void)
  17. {
  18. DC_BEGIN_FN("SDG_Init");
  19. #define DC_INIT_DATA
  20. #include <asdgdata.c>
  21. #undef DC_INIT_DATA
  22. #ifdef DC_HICOLOR
  23. #else
  24. TRC_ASSERT((m_desktopBpp == 8), (TB, "Unexpected bpp: %u", m_desktopBpp));
  25. #endif
  26. DC_END_FN();
  27. }
  28. /****************************************************************************/
  29. // SDG_SendScreenDataArea
  30. //
  31. // Sends the accumulated Screen Data Area.
  32. /****************************************************************************/
  33. void RDPCALL SHCLASS SDG_SendScreenDataArea(
  34. BYTE *pFrameBuf,
  35. UINT32 frameBufWidth,
  36. PPDU_PACKAGE_INFO pPkgInfo)
  37. {
  38. unsigned i;
  39. RECTL sdaRect[BA_MAX_ACCUMULATED_RECTS];
  40. unsigned cRects;
  41. BOOLEAN mustSendPDU;
  42. BOOL fBltOK = TRUE;
  43. SDG_ENCODE_CONTEXT Context;
  44. DC_BEGIN_FN("SDG_SendScreenDataArea");
  45. INC_INCOUNTER(IN_SND_SDA_ALL);
  46. ADD_INCOUNTER(IN_SND_SDA_AREA, m_pShm->ba.totalArea);
  47. // Get the bounds of the screen data area. At entry this is always
  48. // our primary transmission area. Even if we had already flushed
  49. // the primary region and were in the middle of the secondary region
  50. // we will switch back to the primary region if any more SD
  51. // accumulates. In this way we keep our spoiling of the secondary
  52. // screendata maximized.
  53. BA_GetBounds(sdaRect, &cRects);
  54. // Initialize the context.
  55. Context.BitmapPDUSize = 0;
  56. Context.pPackageSpace = NULL;
  57. Context.pBitmapPDU = NULL;
  58. Context.pSDARect = NULL;
  59. // Process each of the accumulated rectangles in turn.
  60. TRC_DBG((TB, "%d SDA rectangles", cRects));
  61. for (i = 0; i < cRects; i++) {
  62. TRC_DBG((TB, "(%d): (%d,%d)(%d,%d)", i, sdaRect[i].left,
  63. sdaRect[i].top, sdaRect[i].right, sdaRect[i].bottom ));
  64. // If all of the previous rectangles have been successfully sent
  65. // then try to send this rectangle.
  66. // If a previous rectangle failed to be sent then we don't bother
  67. // trying to send the rest of the rectangles in the same batch -
  68. // they are added back into the SDA so that they will be sent later.
  69. if (fBltOK) {
  70. // Set the 'last' flag to force sending of the PDU for the last
  71. // rectangle.
  72. mustSendPDU = (i + 1 == cRects) ? TRUE : FALSE;
  73. fBltOK = SDGSendSDARect(pFrameBuf, frameBufWidth, &(sdaRect[i]),
  74. mustSendPDU, pPkgInfo, &Context);
  75. }
  76. if (!fBltOK) {
  77. // The blt to network failed - probably because a network
  78. // packet could not be allocated.
  79. // We add the rectangle back into the SDA so that we will try
  80. // to retransmit the area later.
  81. if (m_pTSWd->shadowState == SHADOW_NONE) {
  82. TRC_ALT((TB, "Blt failed - add back rect (%d,%d)(%d,%d)",
  83. sdaRect[i].left, sdaRect[i].top,
  84. sdaRect[i].right, sdaRect[i].bottom));
  85. }
  86. // Add the rectangle into the bounds.
  87. BA_AddRect(&(sdaRect[i]));
  88. }
  89. }
  90. // We counted all the data available as sent, decrement by any still
  91. // unsent!
  92. SUB_INCOUNTER(IN_SND_SDA_AREA, m_pShm->ba.totalArea);
  93. DC_END_FN();
  94. }