lllocalbitmaps.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /**
  2. * @file lllocalbitmaps.h
  3. * @author Vaalith Jinn, code cleanup by Henri Beauchamp
  4. * @brief Local Bitmaps header
  5. *
  6. * $LicenseInfo:firstyear=2011&license=viewergpl$
  7. *
  8. * Copyright (c) 2011, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LL_LOCALBITMAPS_H
  34. #define LL_LOCALBITMAPS_H
  35. #include <list>
  36. #include <time.h> // For time_t
  37. #include "boost/signals2.hpp"
  38. #include "llavatarappearancedefines.h"
  39. #include "lleventtimer.h"
  40. #include "hbfileselector.h"
  41. #include "llimage.h"
  42. #include "llpointer.h"
  43. #include "llwearabletype.h"
  44. class LLGLTFMaterial;
  45. class LLGTTexture;
  46. class LLViewerObject;
  47. class LLLocalBitmapTimer final : public LLEventTimer
  48. {
  49. public:
  50. LLLocalBitmapTimer();
  51. bool tick() override;
  52. void startTimer();
  53. void stopTimer();
  54. bool isRunning();
  55. };
  56. class LLLocalBitmap
  57. {
  58. protected:
  59. LOG_CLASS(LLLocalBitmap);
  60. public:
  61. LLLocalBitmap(std::string filename);
  62. ~LLLocalBitmap();
  63. LL_INLINE const std::string& getFilename() const { return mFilename; }
  64. LL_INLINE const std::string& getShortName() const { return mShortName; }
  65. LL_INLINE const LLUUID& getTrackingID() const { return mTrackingID; }
  66. LL_INLINE const LLUUID& getWorldID() const { return mWorldID; }
  67. LL_INLINE bool getValid() const { return mValid; }
  68. enum EUpdateType
  69. {
  70. UT_FIRSTUSE,
  71. UT_REGUPDATE
  72. };
  73. bool updateSelf(EUpdateType = UT_REGUPDATE);
  74. typedef boost::signals2::signal<void(const LLUUID& tracking_id,
  75. const LLUUID& old_id,
  76. const LLUUID& new_id)> changed_sig_t;
  77. typedef changed_sig_t::slot_type changed_cb_t;
  78. boost::signals2::connection setChangedCallback(const changed_cb_t& cb);
  79. void addGLTFMaterial(LLGLTFMaterial* matp);
  80. typedef std::list<LLLocalBitmap*> list_t;
  81. LL_INLINE static const list_t& getBitmapList() { return sBitmapList; }
  82. LL_INLINE static S32 getBitmapListVersion() { return sBitmapsListVersion; }
  83. static void addUnits();
  84. static void delUnit(const LLUUID& tracking_id);
  85. static const LLUUID& getWorldID(const LLUUID& tracking_id);
  86. static bool isLocal(const LLUUID& world_id);
  87. static const std::string& getFilename(const LLUUID& tracking_id);
  88. static void doUpdates();
  89. static void setNeedsRebake();
  90. static void doRebake();
  91. static boost::signals2::connection setOnChangedCallback(const LLUUID& trac_id,
  92. const changed_cb_t& cb);
  93. static void associateGLTFMaterial(const LLUUID& tracking_id,
  94. LLGLTFMaterial* matp);
  95. // To be called on viewer shutdown in LLAppViewer::cleanup(). HB
  96. static void cleanupClass();
  97. // Only used for llgltf (new implementation, WIP) for now. HB
  98. static LLLocalBitmap* addUnit(const std::string& filename);
  99. private:
  100. bool decodeBitmap(LLPointer<LLImageRaw> raw);
  101. void replaceIDs(const LLUUID& old_id, LLUUID new_id);
  102. void prepUpdateObjects(const LLUUID& old_id, U32 channel,
  103. std::vector<LLViewerObject*>& obj_list);
  104. void updateUserPrims(const LLUUID& old_id, const LLUUID& new_id,
  105. U32 channel);
  106. void updateUserVolumes(const LLUUID& old_id, const LLUUID& new_id,
  107. U32 channel);
  108. void updateUserLayers(const LLUUID& old_id, const LLUUID& new_id,
  109. LLWearableType::EType type);
  110. void updateGLTFMaterials(const LLUUID& old_id, const LLUUID& new_id);
  111. LLAvatarAppearanceDefines::ETextureIndex
  112. getTexIndex(LLWearableType::EType type,
  113. LLAvatarAppearanceDefines::EBakedTextureIndex index);
  114. enum ELinkStatus
  115. {
  116. LS_ON,
  117. LS_BROKEN
  118. };
  119. enum EExtension
  120. {
  121. ET_IMG_BMP,
  122. ET_IMG_TGA,
  123. ET_IMG_JPG,
  124. ET_IMG_PNG
  125. };
  126. static void addUnitsCallback(HBFileSelector::ELoadFilter type,
  127. std::deque<std::string>& files, void*);
  128. private:
  129. S32 mUpdateRetries;
  130. EExtension mExtension;
  131. ELinkStatus mLinkStatus;
  132. LLUUID mTrackingID;
  133. LLUUID mWorldID;
  134. std::string mFilename;
  135. std::string mShortName;
  136. changed_sig_t mChangedSignal;
  137. typedef std::vector<LLPointer<LLGLTFMaterial> > mat_list_t;
  138. mat_list_t mGLTFMaterialWithLocalTextures;
  139. time_t mLastModified;
  140. bool mValid;
  141. static LLLocalBitmapTimer sTimer;
  142. static list_t sBitmapList;
  143. static S32 sBitmapsListVersion;
  144. static bool sNeedsRebake;
  145. };
  146. #endif