/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. #ifndef LL_TEXTUREATLAS_H
  27. #define LL_TEXTUREATLAS_H
  28. #include "llviewertexture.h"
  29. class LLSpatialGroup ;
  30. class LLTextureAtlas : public LLViewerTexture
  31. {
  32. protected:
  33. /*virtual*/ ~LLTextureAtlas() ;
  34. public:
  35. LLTextureAtlas(U8 ncomponents, S16 atlas_dim = 16) ;
  36. /*virtual*/ S8 getType() const;
  37. LLGLuint insertSubTexture(LLImageGL* source_gl_tex, S32 discard_level, const LLImageRaw* raw_image, S16 slot_col, S16 slot_row) ;
  38. void releaseSlot(S16 slot_col, S16 slot_row, S8 slot_width);
  39. BOOL getNextAvailableSlot(S8 bits_len, S16& col, S16& row) ;
  40. void getTexCoordOffset(S16 col, S16 row, F32& xoffset, F32& yOffset) ;
  41. void getTexCoordScale(S32 w, S32 h, F32& xscale, F32& yscale) ;
  42. BOOL isEmpty() const ;
  43. BOOL isFull(S8 to_be_reserved = 1) const ;
  44. F32 getFullness() const ;
  45. void addSpatialGroup(LLSpatialGroup* groupp) ;
  46. void removeSpatialGroup(LLSpatialGroup* groupp) ;
  47. LLSpatialGroup* getLastSpatialGroup() ;
  48. void removeLastSpatialGroup() ;
  49. BOOL hasSpatialGroup(LLSpatialGroup* groupp) ;
  50. void clearSpatialGroup() ;
  51. std::list<LLSpatialGroup*>* getSpatialGroupList() {return &mSpatialGroupList;}
  52. private:
  53. void generateEmptyUsageBits() ;
  54. void releaseUsageBits() ;
  55. void markUsageBits(S8 bits_len, U8 mask, S16 col, S16 row) ;
  56. void unmarkUsageBits(S8 bits_len, S16 col, S16 row) ;
  57. void getPositionFromIndex(S16 index, S16& col, S16& row) ;
  58. void getIndexFromPosition(S16 col, S16 row, S16& index) ;
  59. BOOL areUsageBitsMarked(S8 bits_len, U8 mask, S16 col, S16 row) ;
  60. private:
  61. S16 mAtlasDim ; //number of slots per edge, i.e, there are "mAtlasDim * mAtlasDim" total slots in the atlas.
  62. S16 mNumSlotsReserved ;
  63. S16 mMaxSlotsInAtlas ;
  64. U8 **mUsageBits ;
  65. std::list<LLSpatialGroup*> mSpatialGroupList ;
  66. public:
  67. //debug use only
  68. U8 **mTestBits ;
  69. public:
  70. static S16 sMaxSubTextureSize ;
  71. static S16 sSlotSize ;
  72. };
  73. #endif