00001
00032 #ifndef LL_LLFEATUREMANAGER_H
00033 #define LL_LLFEATUREMANAGER_H
00034
00035 #include "stdtypes.h"
00036
00037 #include "llstring.h"
00038 #include <map>
00039
00040 typedef enum EGPUClass
00041 {
00042 GPU_CLASS_UNKNOWN = -1,
00043 GPU_CLASS_0 = 0,
00044 GPU_CLASS_1 = 1,
00045 GPU_CLASS_2 = 2,
00046 GPU_CLASS_3 = 3
00047 } EGPUClass;
00048
00049 class LLFeatureInfo
00050 {
00051 public:
00052 LLFeatureInfo() : mValid(FALSE), mAvailable(FALSE), mRecommendedLevel(-1) {}
00053 LLFeatureInfo(const char *name, const BOOL available, const F32 level);
00054
00055 BOOL isValid() const { return mValid; };
00056
00057 public:
00058 BOOL mValid;
00059 LLString mName;
00060 BOOL mAvailable;
00061 F32 mRecommendedLevel;
00062 };
00063
00064
00065 class LLFeatureList
00066 {
00067 public:
00068 typedef std::map<LLString, LLFeatureInfo> feature_map_t;
00069
00070 LLFeatureList(const char *name = "default");
00071 virtual ~LLFeatureList();
00072
00073 BOOL isFeatureAvailable(const char *name);
00074 F32 getRecommendedValue(const char *name);
00075
00076 void setFeatureAvailable(const char *name, const BOOL available);
00077 void setRecommendedLevel(const char *name, const F32 level);
00078
00079 BOOL loadFeatureList(LLFILE *fp);
00080
00081 BOOL maskList(LLFeatureList &mask);
00082
00083 void addFeature(const char *name, const BOOL available, const F32 level);
00084
00085 feature_map_t& getFeatures()
00086 {
00087 return mFeatures;
00088 }
00089
00090 void dump();
00091 protected:
00092 LLString mName;
00093 feature_map_t mFeatures;
00094 };
00095
00096
00097 class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManager>
00098 {
00099 public:
00100 LLFeatureManager() : mInited(FALSE), mTableVersion(0), mSafe(FALSE), mGPUClass(GPU_CLASS_UNKNOWN) {}
00101 ~LLFeatureManager() {cleanupFeatureTables();}
00102
00103
00104 void init();
00105
00106 void maskCurrentList(const char *name);
00107
00108 BOOL loadFeatureTables();
00109
00110 EGPUClass getGPUClass() { return mGPUClass; }
00111 std::string& getGPUString() { return mGPUString; }
00112 BOOL isGPUSupported() { return mGPUSupported; }
00113
00114 void cleanupFeatureTables();
00115
00116 S32 getVersion() const { return mTableVersion; }
00117 void setSafe(const BOOL safe) { mSafe = safe; }
00118 BOOL isSafe() const { return mSafe; }
00119
00120 LLFeatureList *findMask(const char *name);
00121 BOOL maskFeatures(const char *name);
00122
00123
00124
00125
00126
00127 void setGraphicsLevel(S32 level, bool skipFeatures);
00128
00129 void applyBaseMasks();
00130 void applyRecommendedSettings();
00131
00132
00133
00134 void applyFeatures(bool skipFeatures);
00135
00136 protected:
00137 void loadGPUClass();
00138 void initBaseMask();
00139
00140
00141 std::map<LLString, LLFeatureList *> mMaskList;
00142 std::set<LLString> mSkippedFeatures;
00143 BOOL mInited;
00144 S32 mTableVersion;
00145 BOOL mSafe;
00146 EGPUClass mGPUClass;
00147 std::string mGPUString;
00148 BOOL mGPUSupported;
00149 };
00150
00151
00152 #endif // LL_LLFEATUREMANAGER_H