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