OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_GPU_BLACKLIST_H_ | |
6 #define CHROME_BROWSER_GPU_BLACKLIST_H_ | |
7 #pragma once | |
8 | |
9 // Determines whether certain gpu-related features are blacklisted or not. | |
10 | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 #include "base/basictypes.h" | |
15 #include "base/scoped_ptr.h" | |
16 #include "base/values.h" | |
brettw
2010/12/03 00:11:38
I think you can forward declare DictionaryValue in
Zhenyao Mo
2010/12/03 18:29:57
Done.
| |
17 #include "base/version.h" | |
18 #include "chrome/common/gpu_feature_flags.h" | |
19 #include "chrome/common/gpu_info.h" | |
brettw
2010/12/03 00:11:38
This can be forward declared.
Zhenyao Mo
2010/12/03 18:29:57
Done.
| |
20 | |
21 class GpuBlacklist { | |
22 public: | |
23 enum OsType { | |
24 kOsLinux, | |
25 kOsMacosx, | |
26 kOsWin, | |
27 kOsAny, | |
28 kOsUnknown | |
29 }; | |
30 | |
31 GpuBlacklist(); | |
32 ~GpuBlacklist(); | |
33 | |
34 // Loads blacklist information from a json file. | |
35 // If failed, the current GpuBlacklist is un-touched. | |
36 bool LoadGpuBlacklist(const std::string& json_context); | |
37 | |
38 // Collects system information and combines them with gpu_info and blacklist | |
39 // information to determine gpu feature flags. | |
40 // If os is kOsAny, use the current OS; if os_version is null, use the | |
41 // current OS version. | |
42 GpuFeatureFlags DetermineGpuFeatureFlags(OsType os, | |
43 Version* os_version, | |
44 const GPUInfo& gpu_info) const; | |
45 | |
46 private: | |
47 class VersionInfo { | |
48 public: | |
49 VersionInfo(const std::string& version_op, | |
50 const std::string& version_string, | |
51 const std::string& version_string2); | |
52 | |
53 // Determines if a given version is included in the VersionInfo range. | |
54 bool Contains(const Version& version) const; | |
55 | |
56 // Determines if the VersionInfo contains valid information. | |
57 bool IsValid() const; | |
58 | |
59 private: | |
60 enum Op { | |
61 kBetween, // <= * <= | |
62 kEQ, // = | |
63 kLT, // < | |
64 kLE, // <= | |
65 kGT, // > | |
66 kGE, // >= | |
67 kAny, | |
68 kUnknown // Indicates VersionInfo data is invalid. | |
69 }; | |
70 | |
71 // Maps string to Op; returns kUnknown if it's not a valid Op. | |
72 static Op StringToOp(const std::string& version_op); | |
73 | |
74 Op op_; | |
75 scoped_ptr<Version> version_; | |
brettw
2010/12/03 00:11:38
You can forward declare Version if you add a non-i
Zhenyao Mo
2010/12/03 18:29:57
Done.
| |
76 scoped_ptr<Version> version2_; | |
77 }; | |
78 | |
79 class OsInfo { | |
80 public: | |
81 OsInfo(const std::string& os, | |
82 const std::string& version_op, | |
83 const std::string& version_string, | |
84 const std::string& version_string2); | |
85 | |
86 // Determines if a given os/version is included in the OsInfo set. | |
87 bool Contains(OsType type, const Version& version) const; | |
88 | |
89 // Determines if the VersionInfo contains valid information. | |
90 bool IsValid() const; | |
91 | |
92 OsType type() const; | |
93 | |
94 private: | |
95 OsType type_; | |
96 scoped_ptr<VersionInfo> version_info_; | |
97 }; | |
98 | |
99 class GpuBlacklistEntry { | |
100 public: | |
101 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json. | |
102 static GpuBlacklistEntry* GetGpuBlacklistEntryFromValue( | |
103 DictionaryValue* value); | |
104 | |
105 // Determines if a given os/gc/driver is included in the Entry set. | |
106 bool Contains(OsType os_type, const Version& os_version, | |
107 uint32 vendor_id, uint32 device_id, | |
108 const Version& driver_version) const; | |
109 | |
110 // Returns the OsType. | |
111 OsType GetOsType() const; | |
112 | |
113 // Returns the GpuFeatureFlags. | |
114 GpuFeatureFlags GetGpuFeatureFlags() const; | |
115 | |
116 private: | |
117 GpuBlacklistEntry(); | |
118 | |
119 bool SetOsInfo(const std::string& os, | |
120 const std::string& version_op, | |
121 const std::string& version_string, | |
122 const std::string& version_string2); | |
123 | |
124 bool SetVendorId(const std::string& vendor_id_string); | |
125 | |
126 bool SetDeviceId(const std::string& device_id_string); | |
127 | |
128 bool SetDriverVersionInfo(const std::string& version_op, | |
129 const std::string& version_string, | |
130 const std::string& version_string2); | |
131 | |
132 bool SetBlacklistedFeatures( | |
133 const std::vector<std::string>& blacklisted_features); | |
134 | |
135 scoped_ptr<OsInfo> os_info_; | |
136 uint32 vendor_id_; | |
137 uint32 device_id_; | |
138 scoped_ptr<VersionInfo> driver_version_info_; | |
139 scoped_ptr<GpuFeatureFlags> feature_flags_; | |
140 }; | |
141 | |
142 // Maps string to OsType; returns kOsUnknown if it's not a valid os. | |
143 static OsType StringToOsType(const std::string& os); | |
144 | |
145 // Gets the current OS type. | |
146 static OsType GetOsType(); | |
147 | |
148 void Clear(); | |
149 | |
150 std::vector<GpuBlacklistEntry*> blacklist_; | |
151 | |
152 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); | |
153 }; | |
154 | |
155 #endif // CHROME_BROWSER_GPU_BLACKLIST_H_ | |
OLD | NEW |