PageRenderTime 75ms CodeModel.GetById 34ms app.highlight 7ms RepoModel.GetById 32ms app.codeStats 1ms

/indra/newview/lltextureatlasmanager.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 106 lines | 52 code | 20 blank | 34 comment | 0 complexity | ed57934df5e2daea2a2916f0c31ec77f MD5 | raw file
  1/** 
  2 * @file lltextureatlasmanager.h
  3 * @brief LLTextureAtlasManager 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_TEXTUREATLASMANAGER_H
 29#define LL_TEXTUREATLASMANAGER_H
 30
 31#include "llmemory.h"
 32
 33class LLSpatialGroup ;
 34class LLViewerTexture ;
 35
 36//just use it as a structure.
 37class LLTextureAtlasSlot : public LLRefCount
 38{
 39public:
 40	LLTextureAtlasSlot(LLTextureAtlas* atlasp, LLSpatialGroup* groupp, S16 col, S16 row, F32 xoffset, F32 yoffset, S8 slot_width) ;
 41
 42protected:
 43	virtual ~LLTextureAtlasSlot();
 44	
 45public:
 46
 47	//
 48	//do not allow to change those values
 49	//
 50	//void setAtlas(LLTextureAtlas* atlasp) ;	
 51	//void setSlotPos(S16 col, S16 row) ;
 52	//void setSlotWidth(S8 width) ;
 53	//void setTexCoordOffset(F32 xoffser, F32 yoffset) ;
 54	//
 55
 56	void setSpatialGroup(LLSpatialGroup* groupp) ;
 57	void setTexCoordScale(F32 xscale, F32 yscale) ;
 58	void setValid() {mValid = TRUE ;}
 59
 60	LLTextureAtlas* getAtlas()const {return mAtlasp;}
 61	LLSpatialGroup* getSpatialGroup() const {return mGroupp ;} 
 62	S16             getSlotCol()const {return mCol;}
 63	S16             getSlotRow()const {return mRow;}
 64	S8              getSlotWidth()const{return mReservedSlotWidth;}
 65	BOOL            isValid()const { return mValid;}
 66	const LLVector2*      getTexCoordOffset()const {return &mTexCoordOffset;}
 67	const LLVector2*      getTexCoordScale() const {return &mTexCoordScale;}
 68
 69	void setUpdatedTime(U32 t) {mUpdatedTime = t;}
 70	U32  getUpdatedTime()const {return mUpdatedTime;}
 71
 72private:
 73	LLTextureAtlas* mAtlasp;
 74	S16             mCol ;//col of the slot
 75	S16             mRow ;//row of the slot
 76	S8              mReservedSlotWidth ; //slot is a square with each edge length a power-of-two number	
 77	LLSpatialGroup* mGroupp ;
 78	BOOL            mValid ;
 79
 80	LLVector2       mTexCoordOffset ;
 81	LLVector2       mTexCoordScale ;
 82
 83	U32             mUpdatedTime ;	
 84} ;
 85
 86class LLTextureAtlasManager : public LLSingleton<LLTextureAtlasManager>
 87{
 88private:
 89	typedef std::list<LLPointer<LLTextureAtlas> > ll_texture_atlas_list_t ;
 90
 91public:
 92	LLTextureAtlasManager();
 93	~LLTextureAtlasManager();
 94
 95	LLPointer<LLTextureAtlasSlot> reserveAtlasSlot(S32 sub_texture_size, S8 ncomponents, 
 96		LLSpatialGroup* groupp, LLViewerTexture* imagep) ;
 97	void releaseAtlas(LLTextureAtlas* atlasp);
 98
 99	BOOL canAddToAtlas(S32 w, S32 h, S8 ncomponents, LLGLenum target) ;
100
101private:	
102	std::vector<ll_texture_atlas_list_t> mAtlasMap ;
103	std::vector<ll_texture_atlas_list_t> mEmptyAtlasMap ; //delay some empty atlases deletion to avoid possible creation of new atlas immediately.
104};
105
106#endif