PageRenderTime 39ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llvlmanager.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 164 lines | 116 code | 23 blank | 25 comment | 22 complexity | 8404eac0903dc6da5a58efdd31427a0c MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llvlmanager.cpp
  3. * @brief LLVLManager class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llvlmanager.h"
  28. #include "indra_constants.h"
  29. #include "bitpack.h"
  30. #include "patch_code.h"
  31. #include "patch_dct.h"
  32. #include "llviewerregion.h"
  33. #include "llframetimer.h"
  34. #include "llsurface.h"
  35. LLVLManager gVLManager;
  36. LLVLManager::~LLVLManager()
  37. {
  38. S32 i;
  39. for (i = 0; i < mPacketData.count(); i++)
  40. {
  41. delete mPacketData[i];
  42. }
  43. mPacketData.reset();
  44. }
  45. void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size)
  46. {
  47. if (LAND_LAYER_CODE == vl_datap->mType)
  48. {
  49. mLandBits += mesg_size * 8;
  50. }
  51. else if (WIND_LAYER_CODE == vl_datap->mType)
  52. {
  53. mWindBits += mesg_size * 8;
  54. }
  55. else if (CLOUD_LAYER_CODE == vl_datap->mType)
  56. {
  57. mCloudBits += mesg_size * 8;
  58. }
  59. else
  60. {
  61. llerrs << "Unknown layer type!" << (S32)vl_datap->mType << llendl;
  62. }
  63. mPacketData.put(vl_datap);
  64. }
  65. void LLVLManager::unpackData(const S32 num_packets)
  66. {
  67. static LLFrameTimer decode_timer;
  68. S32 i;
  69. for (i = 0; i < mPacketData.count(); i++)
  70. {
  71. LLVLData *datap = mPacketData[i];
  72. LLBitPack bit_pack(datap->mData, datap->mSize);
  73. LLGroupHeader goph;
  74. decode_patch_group_header(bit_pack, &goph);
  75. if (LAND_LAYER_CODE == datap->mType)
  76. {
  77. datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph, FALSE);
  78. }
  79. else if (WIND_LAYER_CODE == datap->mType)
  80. {
  81. datap->mRegionp->mWind.decompress(bit_pack, &goph);
  82. }
  83. else if (CLOUD_LAYER_CODE == datap->mType)
  84. {
  85. }
  86. }
  87. for (i = 0; i < mPacketData.count(); i++)
  88. {
  89. delete mPacketData[i];
  90. }
  91. mPacketData.reset();
  92. }
  93. void LLVLManager::resetBitCounts()
  94. {
  95. mLandBits = mWindBits = mCloudBits = 0;
  96. }
  97. S32 LLVLManager::getLandBits() const
  98. {
  99. return mLandBits;
  100. }
  101. S32 LLVLManager::getWindBits() const
  102. {
  103. return mWindBits;
  104. }
  105. S32 LLVLManager::getCloudBits() const
  106. {
  107. return mCloudBits;
  108. }
  109. S32 LLVLManager::getTotalBytes() const
  110. {
  111. return mLandBits + mWindBits + mCloudBits;
  112. }
  113. void LLVLManager::cleanupData(LLViewerRegion *regionp)
  114. {
  115. S32 cur = 0;
  116. while (cur < mPacketData.count())
  117. {
  118. if (mPacketData[cur]->mRegionp == regionp)
  119. {
  120. delete mPacketData[cur];
  121. mPacketData.remove(cur);
  122. }
  123. else
  124. {
  125. cur++;
  126. }
  127. }
  128. }
  129. LLVLData::LLVLData(LLViewerRegion *regionp, const S8 type, U8 *data, const S32 size)
  130. {
  131. mType = type;
  132. mData = data;
  133. mRegionp = regionp;
  134. mSize = size;
  135. }
  136. LLVLData::~LLVLData()
  137. {
  138. delete [] mData;
  139. mData = NULL;
  140. mRegionp = NULL;
  141. }