PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llfeaturemanager.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 163 lines | 93 code | 37 blank | 33 comment | 0 complexity | 70784b4f671d2ebb48c7bfae3ad11dd9 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfeaturemanager.h
  3. * @brief The feature manager is responsible for determining what features are turned on/off in the app.
  4. *
  5. * $LicenseInfo:firstyear=2003&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_LLFEATUREMANAGER_H
  27. #define LL_LLFEATUREMANAGER_H
  28. #include "stdtypes.h"
  29. #include "llsingleton.h"
  30. #include "llstring.h"
  31. #include <map>
  32. typedef enum EGPUClass
  33. {
  34. GPU_CLASS_UNKNOWN = -1,
  35. GPU_CLASS_0 = 0,
  36. GPU_CLASS_1 = 1,
  37. GPU_CLASS_2 = 2,
  38. GPU_CLASS_3 = 3
  39. } EGPUClass;
  40. class LLFeatureInfo
  41. {
  42. public:
  43. LLFeatureInfo() : mValid(FALSE), mAvailable(FALSE), mRecommendedLevel(-1) {}
  44. LLFeatureInfo(const std::string& name, const BOOL available, const F32 level);
  45. BOOL isValid() const { return mValid; };
  46. public:
  47. BOOL mValid;
  48. std::string mName;
  49. BOOL mAvailable;
  50. F32 mRecommendedLevel;
  51. };
  52. class LLFeatureList
  53. {
  54. public:
  55. typedef std::map<std::string, LLFeatureInfo> feature_map_t;
  56. LLFeatureList(const std::string& name);
  57. virtual ~LLFeatureList();
  58. BOOL isFeatureAvailable(const std::string& name);
  59. F32 getRecommendedValue(const std::string& name);
  60. void setFeatureAvailable(const std::string& name, const BOOL available);
  61. void setRecommendedLevel(const std::string& name, const F32 level);
  62. BOOL loadFeatureList(LLFILE *fp);
  63. BOOL maskList(LLFeatureList &mask);
  64. void addFeature(const std::string& name, const BOOL available, const F32 level);
  65. feature_map_t& getFeatures()
  66. {
  67. return mFeatures;
  68. }
  69. void dump();
  70. protected:
  71. std::string mName;
  72. feature_map_t mFeatures;
  73. };
  74. class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManager>
  75. {
  76. public:
  77. LLFeatureManager()
  78. : LLFeatureList("default"),
  79. mInited(FALSE),
  80. mTableVersion(0),
  81. mSafe(FALSE),
  82. mGPUClass(GPU_CLASS_UNKNOWN),
  83. mGPUSupported(FALSE)
  84. {
  85. }
  86. ~LLFeatureManager() {cleanupFeatureTables();}
  87. // initialize this by loading feature table and gpu table
  88. void init();
  89. void maskCurrentList(const std::string& name); // Mask the current feature list with the named list
  90. BOOL loadFeatureTables();
  91. EGPUClass getGPUClass() { return mGPUClass; }
  92. std::string& getGPUString() { return mGPUString; }
  93. BOOL isGPUSupported() { return mGPUSupported; }
  94. void cleanupFeatureTables();
  95. S32 getVersion() const { return mTableVersion; }
  96. void setSafe(const BOOL safe) { mSafe = safe; }
  97. BOOL isSafe() const { return mSafe; }
  98. LLFeatureList *findMask(const std::string& name);
  99. BOOL maskFeatures(const std::string& name);
  100. // set the graphics to low, medium, high, or ultra.
  101. // skipFeatures forces skipping of mostly hardware settings
  102. // that we don't want to change when we change graphics
  103. // settings
  104. void setGraphicsLevel(S32 level, bool skipFeatures);
  105. void applyBaseMasks();
  106. void applyRecommendedSettings();
  107. // apply the basic masks. Also, skip one saved
  108. // in the skip list if true
  109. void applyFeatures(bool skipFeatures);
  110. // load the dynamic GPU/feature table from a website
  111. void fetchHTTPTables();
  112. protected:
  113. void loadGPUClass();
  114. BOOL parseFeatureTable(std::string filename);
  115. void parseGPUTable(std::string filename);
  116. void initBaseMask();
  117. std::map<std::string, LLFeatureList *> mMaskList;
  118. std::set<std::string> mSkippedFeatures;
  119. BOOL mInited;
  120. S32 mTableVersion;
  121. BOOL mSafe; // Reinitialize everything to the "safe" mask
  122. EGPUClass mGPUClass;
  123. std::string mGPUString;
  124. BOOL mGPUSupported;
  125. };
  126. #endif // LL_LLFEATUREMANAGER_H