PageRenderTime 27ms CodeModel.GetById 15ms app.highlight 9ms RepoModel.GetById 2ms 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
  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
 27#include "llviewerprecompiledheaders.h"
 28
 29#include "llvlmanager.h"
 30
 31#include "indra_constants.h"
 32#include "bitpack.h"
 33#include "patch_code.h"
 34#include "patch_dct.h"
 35#include "llviewerregion.h"
 36#include "llframetimer.h"
 37#include "llsurface.h"
 38
 39LLVLManager gVLManager;
 40
 41LLVLManager::~LLVLManager()
 42{
 43	S32 i;
 44	for (i = 0; i < mPacketData.count(); i++)
 45	{
 46		delete mPacketData[i];
 47	}
 48	mPacketData.reset();
 49}
 50
 51void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size)
 52{
 53	if (LAND_LAYER_CODE == vl_datap->mType)
 54	{
 55		mLandBits += mesg_size * 8;
 56	}
 57	else if (WIND_LAYER_CODE == vl_datap->mType)
 58	{
 59		mWindBits += mesg_size * 8;
 60	}
 61	else if (CLOUD_LAYER_CODE == vl_datap->mType)
 62	{
 63		mCloudBits += mesg_size * 8;
 64	}
 65	else
 66	{
 67		llerrs << "Unknown layer type!" << (S32)vl_datap->mType << llendl;
 68	}
 69
 70	mPacketData.put(vl_datap);
 71}
 72
 73void LLVLManager::unpackData(const S32 num_packets)
 74{
 75	static LLFrameTimer decode_timer;
 76	
 77	S32 i;
 78	for (i = 0; i < mPacketData.count(); i++)
 79	{
 80		LLVLData *datap = mPacketData[i];
 81
 82		LLBitPack bit_pack(datap->mData, datap->mSize);
 83		LLGroupHeader goph;
 84
 85		decode_patch_group_header(bit_pack, &goph);
 86		if (LAND_LAYER_CODE == datap->mType)
 87		{
 88			datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph, FALSE);
 89		}
 90		else if (WIND_LAYER_CODE == datap->mType)
 91		{
 92			datap->mRegionp->mWind.decompress(bit_pack, &goph);
 93
 94		}
 95		else if (CLOUD_LAYER_CODE == datap->mType)
 96		{
 97
 98		}
 99	}
100
101	for (i = 0; i < mPacketData.count(); i++)
102	{
103		delete mPacketData[i];
104	}
105	mPacketData.reset();
106
107}
108
109void LLVLManager::resetBitCounts()
110{
111	mLandBits = mWindBits = mCloudBits = 0;
112}
113
114S32 LLVLManager::getLandBits() const
115{
116	return mLandBits;
117}
118
119S32 LLVLManager::getWindBits() const
120{
121	return mWindBits;
122}
123
124S32 LLVLManager::getCloudBits() const
125{
126	return mCloudBits;
127}
128
129S32 LLVLManager::getTotalBytes() const
130{
131	return mLandBits + mWindBits + mCloudBits;
132}
133
134void LLVLManager::cleanupData(LLViewerRegion *regionp)
135{
136	S32 cur = 0;
137	while (cur < mPacketData.count())
138	{
139		if (mPacketData[cur]->mRegionp == regionp)
140		{
141			delete mPacketData[cur];
142			mPacketData.remove(cur);
143		}
144		else
145		{
146			cur++;
147		}
148	}
149}
150
151LLVLData::LLVLData(LLViewerRegion *regionp, const S8 type, U8 *data, const S32 size)
152{
153	mType = type;
154	mData = data;
155	mRegionp = regionp;
156	mSize = size;
157}
158
159LLVLData::~LLVLData()
160{
161	delete [] mData;
162	mData = NULL;
163	mRegionp = NULL;
164}