lltexlayerparams.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /**
  2. * @file lltexlayerparams.h
  3. * @brief Texture layer parameters, used by lltexlayer.
  4. *
  5. * $LicenseInfo:firstyear=2002&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_LLTEXLAYERPARAMS_H
  33. #define LL_LLTEXLAYERPARAMS_H
  34. #include "llpointer.h"
  35. #include "llviewervisualparam.h"
  36. #include "llcolor4.h"
  37. class LLAvatarAppearance;
  38. class LLGLTexture;
  39. class LLImageRaw;
  40. class LLImageTGA;
  41. class LLTexLayer;
  42. class LLTexLayerInterface;
  43. class LLWearable;
  44. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. // LLTexLayerParam
  46. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. class alignas(16) LLTexLayerParam : public LLViewerVisualParam
  48. {
  49. protected:
  50. LOG_CLASS(LLTexLayerParam);
  51. LLTexLayerParam(const LLTexLayerParam& other);
  52. public:
  53. LLTexLayerParam(LLTexLayerInterface* layer);
  54. LLTexLayerParam(LLAvatarAppearance* appearance);
  55. bool setInfo(LLViewerVisualParamInfo* info, bool add_to_app);
  56. LLViewerVisualParam* cloneParam(LLWearable* wearable) const override = 0;
  57. protected:
  58. LLTexLayerInterface* mTexLayer;
  59. LLAvatarAppearance* mAvatarAppearance;
  60. };
  61. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62. // LLTexLayerParamAlpha
  63. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. class alignas(16) LLTexLayerParamAlpha final : public LLTexLayerParam
  65. {
  66. protected:
  67. LOG_CLASS(LLTexLayerParamAlpha);
  68. LLTexLayerParamAlpha(const LLTexLayerParamAlpha& other);
  69. public:
  70. LLTexLayerParamAlpha(LLTexLayerInterface* layer);
  71. LLTexLayerParamAlpha(LLAvatarAppearance* appearance);
  72. ~LLTexLayerParamAlpha() override;
  73. LLViewerVisualParam* cloneParam(LLWearable* wearp = NULL) const override;
  74. // LLVisualParam Virtual functions
  75. void apply(ESex avatar_sex) override {}
  76. void setWeight(F32 weight, bool upload_bake) override;
  77. void setAnimationTarget(F32 target_value, bool upload_bake) override;
  78. void animate(F32 delta, bool upload_bake) override;
  79. #if 0 // Unused methods
  80. // LLViewerVisualParam Virtual functions
  81. LL_INLINE F32 getTotalDistortion() override { return 1.f; }
  82. LL_INLINE const LLVector4a& getAvgDistortion() override { return mAvgDistortionVec; }
  83. LL_INLINE F32 getMaxDistortion() override { return 3.f; }
  84. LL_INLINE LLVector4a getVertexDistortion(S32, LLPolyMesh*) override
  85. {
  86. return LLVector4a(1.f, 1.f, 1.f);
  87. }
  88. LL_INLINE const LLVector4a* getFirstDistortion(U32* index,
  89. LLPolyMesh** pmesh) override
  90. {
  91. index = 0;
  92. pmesh = NULL;
  93. return &mAvgDistortionVec;
  94. }
  95. LL_INLINE const LLVector4a* getNextDistortion(U32* index,
  96. LLPolyMesh** pmesh) override
  97. {
  98. index = 0;
  99. pmesh = NULL;
  100. return NULL;
  101. }
  102. #endif
  103. // New functions
  104. bool render(S32 x, S32 y, S32 width, S32 height);
  105. bool getSkip() const;
  106. void deleteCaches();
  107. bool getMultiplyBlend() const;
  108. private:
  109. LLVector4a mAvgDistortionVec;
  110. LLPointer<LLGLTexture> mCachedProcessedTexture;
  111. LLPointer<LLImageTGA> mStaticImageTGA;
  112. LLPointer<LLImageRaw> mStaticImageRaw;
  113. bool mNeedsCreateTexture;
  114. bool mStaticImageInvalid;
  115. F32 mCachedEffectiveWeight;
  116. public:
  117. // Global list of instances for gathering statistics
  118. static void dumpCacheByteCount();
  119. static void getCacheByteCount(S32* gl_bytes);
  120. typedef std::list< LLTexLayerParamAlpha* > param_alpha_ptr_list_t;
  121. static param_alpha_ptr_list_t sInstances;
  122. };
  123. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124. // LLTexLayerParamAlphaInfo
  125. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  126. class LLTexLayerParamAlphaInfo final : public LLViewerVisualParamInfo
  127. {
  128. friend class LLTexLayerParamAlpha;
  129. public:
  130. LLTexLayerParamAlphaInfo();
  131. bool parseXml(LLXmlTreeNode* node) override;
  132. private:
  133. F32 mDomain;
  134. bool mMultiplyBlend;
  135. bool mSkipIfZeroWeight;
  136. std::string mStaticImageFileName;
  137. };
  138. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. // LLTexLayerParamColor
  140. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  141. class alignas(16) LLTexLayerParamColor : public LLTexLayerParam
  142. {
  143. protected:
  144. LOG_CLASS(LLTexLayerParamColor);
  145. LLTexLayerParamColor(const LLTexLayerParamColor& other);
  146. public:
  147. enum EColorOperation
  148. {
  149. OP_ADD = 0,
  150. OP_MULTIPLY = 1,
  151. OP_BLEND = 2,
  152. OP_COUNT = 3 // Number of operations
  153. };
  154. LLTexLayerParamColor(LLTexLayerInterface* layer);
  155. LLTexLayerParamColor(LLAvatarAppearance* appearance);
  156. LLViewerVisualParam* cloneParam(LLWearable* wearp = NULL) const override;
  157. // LLVisualParam Virtual functions
  158. LL_INLINE void apply(ESex avatar_sex) override {}
  159. void setWeight(F32 weight, bool upload_bake) override;
  160. void setAnimationTarget(F32 target_value, bool upload_bake) override;
  161. void animate(F32 delta, bool upload_bake) override;
  162. #if 0 // Unused methods
  163. // LLViewerVisualParam Virtual functions
  164. LL_INLINE F32 getTotalDistortion() override { return 1.f; }
  165. LL_INLINE const LLVector4a& getAvgDistortion() override { return mAvgDistortionVec; }
  166. LL_INLINE F32 getMaxDistortion() override { return 3.f; }
  167. LL_INLINE LLVector4a getVertexDistortion(S32, LLPolyMesh*) override
  168. {
  169. return LLVector4a(1.f, 1.f, 1.f);
  170. }
  171. LL_INLINE const LLVector4a* getFirstDistortion(U32* index,
  172. LLPolyMesh** pmesh) override
  173. {
  174. index = 0;
  175. pmesh = NULL;
  176. return &mAvgDistortionVec;
  177. }
  178. LL_INLINE const LLVector4a* getNextDistortion(U32* index,
  179. LLPolyMesh** pmesh) override
  180. {
  181. index = 0;
  182. pmesh = NULL;
  183. return NULL;
  184. }
  185. #endif
  186. // New functions
  187. LLColor4 getNetColor() const;
  188. protected:
  189. LL_INLINE virtual void onGlobalColorChanged(bool upload_bake) {}
  190. private:
  191. LLVector4a mAvgDistortionVec;
  192. };
  193. class LLTexLayerParamColorInfo final : public LLViewerVisualParamInfo
  194. {
  195. friend class LLTexLayerParamColor;
  196. protected:
  197. LOG_CLASS(LLTexLayerParamColorInfo);
  198. public:
  199. LLTexLayerParamColorInfo();
  200. bool parseXml(LLXmlTreeNode* node);
  201. LL_INLINE LLTexLayerParamColor::EColorOperation getOperation() const
  202. {
  203. return mOperation;
  204. }
  205. private:
  206. enum { MAX_COLOR_VALUES = 20 };
  207. LLTexLayerParamColor::EColorOperation mOperation;
  208. LLColor4 mColors[MAX_COLOR_VALUES];
  209. S32 mNumColors;
  210. };
  211. typedef std::vector<LLTexLayerParamColor*> param_color_list_t;
  212. typedef std::vector<LLTexLayerParamAlpha*> param_alpha_list_t;
  213. typedef std::vector<LLTexLayerParamColorInfo*> param_color_info_list_t;
  214. typedef std::vector<LLTexLayerParamAlphaInfo*> param_alpha_info_list_t;
  215. #endif