PageRenderTime 22ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/newview/lltextureatlas.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 90 lines | 47 code | 17 blank | 26 comment | 0 complexity | d543ed8e9e27bdfd30bdb0aeecd7c11a MD5 | raw file
 1/** 
 2 * @file lltextureatlas.h
 3 * @brief LLTextureAtlas base class.
 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
28#ifndef LL_TEXTUREATLAS_H
29#define LL_TEXTUREATLAS_H
30
31#include "llviewertexture.h"
32class LLSpatialGroup ;
33
34class LLTextureAtlas : public LLViewerTexture
35{
36protected:
37	/*virtual*/ ~LLTextureAtlas() ;
38
39public:
40	LLTextureAtlas(U8 ncomponents, S16 atlas_dim = 16) ;	
41
42	/*virtual*/ S8 getType() const;
43
44	LLGLuint insertSubTexture(LLImageGL* source_gl_tex, S32 discard_level, const LLImageRaw* raw_image, S16 slot_col, S16 slot_row) ;
45	void releaseSlot(S16 slot_col, S16 slot_row, S8 slot_width);
46
47	BOOL getNextAvailableSlot(S8 bits_len, S16& col, S16& row) ;
48	void getTexCoordOffset(S16 col, S16 row, F32& xoffset, F32& yOffset) ;
49	void getTexCoordScale(S32 w, S32 h, F32& xscale, F32& yscale) ;
50
51	BOOL isEmpty() const ;
52	BOOL isFull(S8 to_be_reserved = 1) const ;
53	F32  getFullness() const ;
54
55	void addSpatialGroup(LLSpatialGroup* groupp) ;
56	void removeSpatialGroup(LLSpatialGroup* groupp) ;
57	LLSpatialGroup* getLastSpatialGroup() ;
58	void removeLastSpatialGroup() ;
59	BOOL hasSpatialGroup(LLSpatialGroup* groupp) ;
60	void clearSpatialGroup() ;
61	std::list<LLSpatialGroup*>* getSpatialGroupList() {return &mSpatialGroupList;}
62private:
63	void generateEmptyUsageBits() ;
64	void releaseUsageBits() ;
65
66	void markUsageBits(S8 bits_len, U8 mask, S16 col, S16 row) ;
67	void unmarkUsageBits(S8 bits_len, S16 col, S16 row) ;
68
69	void getPositionFromIndex(S16 index, S16& col, S16& row) ;
70	void getIndexFromPosition(S16 col, S16 row, S16& index) ;
71	BOOL areUsageBitsMarked(S8 bits_len, U8 mask, S16 col, S16 row) ;
72
73private:	
74	S16 mAtlasDim ; //number of slots per edge, i.e, there are "mAtlasDim * mAtlasDim" total slots in the atlas. 
75	S16 mNumSlotsReserved ;
76	S16 mMaxSlotsInAtlas ;
77	U8  **mUsageBits ;	
78	std::list<LLSpatialGroup*> mSpatialGroupList ;
79
80public:
81	//debug use only
82	U8  **mTestBits ;
83
84public:
85	static S16 sMaxSubTextureSize ;
86	static S16 sSlotSize ;
87};
88
89#endif
90