summaryrefslogtreecommitdiff
path: root/indra/llkdu/llblockdata.h
blob: dcc847e7e27029c89e356540c4f05d6be186744b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/** 
 * @file llblockdata.h
 * @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$
 */

#ifndef LL_LLBLOCKDATA_H
#define LL_LLBLOCKDATA_H

#include "stdtypes.h"

//////////////////////////////////////////////////
//
//  This class stores all of the information about
//  a single channel of raw data, either integer
//	or floating point.
//
class LLBlockData
{
protected:
	U32 mType;
	U32 mWidth;
	U32 mHeight;
	U32 mRowStride;
	U8 *mData;
public:
	enum
	{
		BLOCK_TYPE_U32 = 1,
		BLOCK_TYPE_F32 = 2
	};

	LLBlockData(const U32 type);
	virtual ~LLBlockData() {}

	void setData(U8 *data, const U32 width, const U32 height, const U32 row_stride = 0);

	U32 getType() const;
	U8 *getData() const;
	virtual U32 getSize() const;
	U32 getWidth() const;
	U32 getHeight() const;
	U32 getRowStride() const;
};

class LLBlockDataU32 : public LLBlockData
{
protected:
	U32 mPrecision;
public:
	LLBlockDataU32();

	void setData(U32 *data, const U32 width, const U32 height, const U32 row_stride = 0);
	void setPrecision(const U32 bits);

	/*virtual*/ U32 getSize() const;
	U32 getPrecision() const;
};

class LLBlockDataF32 : public LLBlockData
{
protected:
	U32 mPrecision;
	F32 mMin;
	F32 mMax;
public:
	LLBlockDataF32()
		: LLBlockData(LLBlockData::BLOCK_TYPE_F32),
		  mPrecision(0),
		  mMin(0.f),
		  mMax(0.f)
	{};
	
	void setData(F32 *data, const U32 width, const U32 height, const U32 row_stride = 0);

	void setPrecision(const U32 bits);
	void setMin(const F32 min);
	void setMax(const F32 max);

	void calcMinMax();

	U32 getPrecision() const;
	F32 getMin() const;
	F32 getMax() const;
};

#endif // LL_LLBLOCKDATA_H