Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: chrome/browser/gpu_blacklist.h

Issue 5612002: Blacklist bad GPU drivers: currenly we disable all gpu related features if th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/gpu_blacklist.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // A valid gpu_blacklist.json file are in the format of
11 // {
12 // "entries": [
13 // { // entry 1
14 // },
15 // ...
16 // { // entry n
17 // }
18 // ]
19 // }
20 // Each entry contains the following fields:
21 // "os", "vendor_id", "device_id", "driver_version", and "blacklist".
22 // Only "blacklist" is mandatory.
23 // 1. "os" contains "type" and an optional "version". "type" could be "macosx",
24 // "linux", "win", or "any". "any" is the same as not specifying "os".
25 // "version" is a VERSION structure (defined later).
26 // 2. "vendor_id" has the value of a string.
27 // 3. "device_id" has the value of a string.
28 // 4. "driver_version" is a VERSION structure (defined later).
29 // 5. "blacklist" is a list of gpu feature strings, valid values include
30 // "accelerated_2d_canvas", "accelerated_compositing", "webgl", and "all".
31 // Currently whatever feature is selected, the effect is the same as "all",
32 // i.e., it's not supported to turn off one GPU feature and not the others.
33 // VERSION includes "op" "number", and "number2". "op" can be any of the
34 // following value: "=", "<", "<=", ">", ">=", "any", "between". "number2" is
35 // only used if "op" is "between". "number" is used for all "op" values except
36 // "any". "number" and "number2" are in the format of x, x.x, x.x.x, ect.
37 // Check out "gpu_blacklist_unittest.cc" for examples.
38
39 #include <string>
40 #include <vector>
41
42 #include "base/basictypes.h"
43 #include "base/scoped_ptr.h"
44 #include "chrome/common/gpu_feature_flags.h"
45
46 class DictionaryValue;
47 class GPUInfo;
48 class Version;
49
50 class GpuBlacklist {
51 public:
52 enum OsType {
53 kOsLinux,
54 kOsMacosx,
55 kOsWin,
56 kOsAny,
57 kOsUnknown
58 };
59
60 GpuBlacklist();
61 ~GpuBlacklist();
62
63 // Loads blacklist information from a json file.
64 // current_os_only==true indicates all blacklist entries that don't belong to
65 // the current OS are discarded; current_os_only==false should only be used
66 // for testing purpose.
67 // If failed, the current GpuBlacklist is un-touched.
68 bool LoadGpuBlacklist(const std::string& json_context,
69 bool current_os_only);
70
71 // Collects system information and combines them with gpu_info and blacklist
72 // information to determine gpu feature flags.
73 // If os is kOsAny, use the current OS; if os_version is null, use the
74 // current OS version.
75 GpuFeatureFlags DetermineGpuFeatureFlags(OsType os,
76 Version* os_version,
77 const GPUInfo& gpu_info) const;
78
79 private:
80 class VersionInfo {
81 public:
82 VersionInfo(const std::string& version_op,
83 const std::string& version_string,
84 const std::string& version_string2);
85 ~VersionInfo();
86
87 // Determines if a given version is included in the VersionInfo range.
88 bool Contains(const Version& version) const;
89
90 // Determines if the VersionInfo contains valid information.
91 bool IsValid() const;
92
93 private:
94 enum Op {
95 kBetween, // <= * <=
96 kEQ, // =
97 kLT, // <
98 kLE, // <=
99 kGT, // >
100 kGE, // >=
101 kAny,
102 kUnknown // Indicates VersionInfo data is invalid.
103 };
104
105 // Maps string to Op; returns kUnknown if it's not a valid Op.
106 static Op StringToOp(const std::string& version_op);
107
108 Op op_;
109 scoped_ptr<Version> version_;
110 scoped_ptr<Version> version2_;
111 };
112
113 class OsInfo {
114 public:
115 OsInfo(const std::string& os,
116 const std::string& version_op,
117 const std::string& version_string,
118 const std::string& version_string2);
119
120 // Determines if a given os/version is included in the OsInfo set.
121 bool Contains(OsType type, const Version& version) const;
122
123 // Determines if the VersionInfo contains valid information.
124 bool IsValid() const;
125
126 OsType type() const;
127
128 // Maps string to OsType; returns kOsUnknown if it's not a valid os.
129 static OsType StringToOsType(const std::string& os);
130
131 private:
132 OsType type_;
133 scoped_ptr<VersionInfo> version_info_;
134 };
135
136 class GpuBlacklistEntry {
137 public:
138 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json.
139 static GpuBlacklistEntry* GetGpuBlacklistEntryFromValue(
140 DictionaryValue* value);
141
142 // Determines if a given os/gc/driver is included in the Entry set.
143 bool Contains(OsType os_type, const Version& os_version,
144 uint32 vendor_id, uint32 device_id,
145 const Version& driver_version) const;
146
147 // Returns the OsType.
148 OsType GetOsType() const;
149
150 // Returns the GpuFeatureFlags.
151 GpuFeatureFlags GetGpuFeatureFlags() const;
152
153 private:
154 GpuBlacklistEntry();
155
156 bool SetOsInfo(const std::string& os,
157 const std::string& version_op,
158 const std::string& version_string,
159 const std::string& version_string2);
160
161 bool SetVendorId(const std::string& vendor_id_string);
162
163 bool SetDeviceId(const std::string& device_id_string);
164
165 bool SetDriverVersionInfo(const std::string& version_op,
166 const std::string& version_string,
167 const std::string& version_string2);
168
169 bool SetBlacklistedFeatures(
170 const std::vector<std::string>& blacklisted_features);
171
172 scoped_ptr<OsInfo> os_info_;
173 uint32 vendor_id_;
174 uint32 device_id_;
175 scoped_ptr<VersionInfo> driver_version_info_;
176 scoped_ptr<GpuFeatureFlags> feature_flags_;
177 };
178
179 // Gets the current OS type.
180 static OsType GetOsType();
181
182 void Clear();
183
184 std::vector<GpuBlacklistEntry*> blacklist_;
185
186 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist);
187 };
188
189 #endif // CHROME_BROWSER_GPU_BLACKLIST_H_
190
OLDNEW
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/gpu_blacklist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698