lllocaltextureobject.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @file lllocaltextureobject.h
  3. * @brief LLLocalTextureObject class header file
  4. *
  5. * $LicenseInfo:firstyear=2009&license=viewergpl$
  6. *
  7. * Copyright (c) 2010, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LOCALTEXTUREOBJECT_H
  33. #define LL_LOCALTEXTUREOBJECT_H
  34. #include "llpointer.h"
  35. #include "llgltexture.h"
  36. #include "lluuid.h"
  37. class LLTexLayer;
  38. class LLTexLayerTemplate;
  39. class LLWearable;
  40. // Stores all relevant information for a single texture assumed to have
  41. // ownership of all objects referred to - will delete objects when being
  42. // replaced or if object is destroyed.
  43. class LLLocalTextureObject
  44. {
  45. public:
  46. LLLocalTextureObject();
  47. LLLocalTextureObject(LLGLTexture* texp, const LLUUID& id);
  48. LLLocalTextureObject(const LLLocalTextureObject& lto);
  49. ~LLLocalTextureObject();
  50. LL_INLINE const LLUUID& getID() const { return mID; }
  51. LL_INLINE void setID(const LLUUID& id) { mID = id; }
  52. LL_INLINE LLGLTexture* getImage() const { return mImage.get(); }
  53. void setImage(LLGLTexture* texp);
  54. LL_INLINE S32 getDiscard() const { return mDiscard; }
  55. LL_INLINE void setDiscard(S32 discard) { mDiscard = discard; }
  56. LL_INLINE bool getBakedReady() const { return mIsBakedReady; }
  57. LL_INLINE void setBakedReady(bool ready) { mIsBakedReady = ready; }
  58. LLTexLayer* getTexLayerByIdx(U32 index) const;
  59. LLTexLayer* getTexLayer(const std::string& name) const;
  60. bool setTexLayer(LLTexLayer* layerp, U32 index);
  61. bool addTexLayer(LLTexLayer* layerp, LLWearable* wearablep);
  62. bool addTexLayer(LLTexLayerTemplate* layerp, LLWearable* wearablep);
  63. bool removeTexLayer(U32 index);
  64. LL_INLINE U32 getNumTexLayers() const { return mTexLayers.size(); }
  65. private:
  66. LLPointer<LLGLTexture> mImage;
  67. LLUUID mID;
  68. // NOTE: LLLocalTextureObject should be the exclusive owner of mTexEntry
  69. // and mTexLayer; using shared pointers here only for smart assignment &
  70. // cleanup. Do NOT create new shared pointers to these objects, or keep
  71. // pointers to them around
  72. typedef std::vector<LLTexLayer*> tex_layer_vec_t;
  73. tex_layer_vec_t mTexLayers;
  74. S32 mDiscard;
  75. bool mIsBakedReady;
  76. public:
  77. // *HACK: in OpenSim, we need to make sure textures used for viewer-side
  78. // baking do not get deleted before the bake happens. It means we cannot
  79. // remove those textures when not rendered. This flag is set to true when
  80. // logged on an OpenSim grid for this purpose... HB
  81. static bool sMarkNoDelete;
  82. };
  83. #endif // LL_LOCALTEXTUREOBJECT_H