diff options
author | Merov Linden <merov@lindenlab.com> | 2010-11-11 09:33:29 -0800 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2010-11-11 09:33:29 -0800 |
commit | 94f44437d7e7ccb54f227e35523fa8a4e027d7d2 (patch) | |
tree | dd899aa6e98b2c10b22fa0db58cfca866a0322de /indra/llkdu/llblockdata.cpp | |
parent | ee8df375449e97476408417ec6dea0d6a8853d73 (diff) | |
parent | 0e07758b540374aa421d2938ce5ed13e2b9eefe4 (diff) |
STORM-151 : merge kdu static linking, add indra/llkdu implementation. Doesn't build yet.
Diffstat (limited to 'indra/llkdu/llblockdata.cpp')
-rw-r--r-- | indra/llkdu/llblockdata.cpp | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/indra/llkdu/llblockdata.cpp b/indra/llkdu/llblockdata.cpp new file mode 100644 index 0000000000..6a7bc3e6c4 --- /dev/null +++ b/indra/llkdu/llblockdata.cpp @@ -0,0 +1,162 @@ +/** + * @file llblockdata.cpp + * @brief Image block structure + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llblockdata.h" +#include "llmath.h" + +LLBlockData::LLBlockData(const U32 type) +{ + mType = type; + mWidth = 0; + mHeight = 0; + mRowStride = 0; + mData = NULL; +} + +void LLBlockData::setData(U8 *data, const U32 width, const U32 height, const U32 row_stride) +{ + mData = data; + mWidth = width; + mHeight = height; + if (row_stride) + { + mRowStride = row_stride; + } + else + { + mRowStride = width * 4; + } +} + +U32 LLBlockData::getType() const +{ + return mType; +} + + +U8 *LLBlockData::getData() const +{ + return mData; +} + +U32 LLBlockData::getSize() const +{ + return mWidth*mHeight; +} + +U32 LLBlockData::getWidth() const +{ + return mWidth; +} +U32 LLBlockData::getHeight() const +{ + return mHeight; +} + +U32 LLBlockData::getRowStride() const +{ + return mRowStride; +} + +LLBlockDataU32::LLBlockDataU32() : LLBlockData(BLOCK_TYPE_U32) +{ + mPrecision = 32; +} + +void LLBlockDataU32::setData(U32 *data, const U32 width, const U32 height, const U32 row_stride) +{ + LLBlockData::setData((U8 *)data, width, height, row_stride); +} + +U32 LLBlockDataU32::getSize() const +{ + return mWidth*mHeight*4; +} + +void LLBlockDataU32::setPrecision(const U32 bits) +{ + mPrecision = bits; +} + +U32 LLBlockDataU32::getPrecision() const +{ + return mPrecision; +} + +void LLBlockDataF32::setPrecision(const U32 bits) +{ + mPrecision = bits; +} + +U32 LLBlockDataF32::getPrecision() const +{ + return mPrecision; +} + +void LLBlockDataF32::setData(F32 *data, const U32 width, const U32 height, const U32 row_stride) +{ + LLBlockData::setData((U8 *)data, width, height, row_stride); +} + +void LLBlockDataF32::setMin(const F32 min) +{ + mMin = min; +} + +void LLBlockDataF32::setMax(const F32 max) +{ + mMax = max; +} + +void LLBlockDataF32::calcMinMax() +{ + U32 x, y; + + mMin = *(F32*)mData; + mMax = mMin; + + for (y = 0; y < mHeight; y++) + { + for (x = 0; x < mWidth; x++) + { + F32 data = *(F32*)(mData + y*mRowStride + x*4); + mMin = llmin(data, mMin); + mMax = llmax(data, mMax); + } + } +} + +F32 LLBlockDataF32::getMin() const +{ + return mMin; +} + +F32 LLBlockDataF32::getMax() const +{ + return mMax; +} |