OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gpu_blacklist.h" | 5 #include "chrome/browser/gpu_blacklist.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 return kOsWin; | 128 return kOsWin; |
129 else if (os == "macosx") | 129 else if (os == "macosx") |
130 return kOsMacosx; | 130 return kOsMacosx; |
131 else if (os == "linux") | 131 else if (os == "linux") |
132 return kOsLinux; | 132 return kOsLinux; |
133 else if (os == "any") | 133 else if (os == "any") |
134 return kOsAny; | 134 return kOsAny; |
135 return kOsUnknown; | 135 return kOsUnknown; |
136 } | 136 } |
137 | 137 |
138 GpuBlacklist::StringInfo::StringInfo(const std::string& string_op, | |
139 const std::string& string_value) { | |
140 op_ = StringToOp(string_op); | |
141 value_ = StringToLowerASCII(string_value); | |
142 } | |
143 | |
144 GpuBlacklist::StringInfo::~StringInfo() { | |
145 } | |
146 | |
147 bool GpuBlacklist::StringInfo::Contains(const std::string& value) const { | |
148 std::string my_value = StringToLowerASCII(value); | |
149 switch (op_) { | |
150 case kContains: | |
151 return my_value.find_first_of(value_) != std::string::npos; | |
152 case kBeginWith: | |
153 return my_value.find_first_of(value_) == 0; | |
Ken Russell (switch to Gerrit)
2011/01/21 19:57:52
Probably faster to use std::string::compare(0, val
Zhenyao Mo
2011/01/21 21:51:40
Done.
| |
154 case kEndWith: | |
155 { | |
156 size_t pos = my_value.find_last_of(value_); | |
157 if (pos == std::string::npos) | |
158 return false; | |
159 return pos + value_.length() == my_value.length(); | |
Ken Russell (switch to Gerrit)
2011/01/21 19:57:52
Faster to use something like std::string::compare(
Zhenyao Mo
2011/01/21 21:51:40
Done.
| |
160 } | |
161 case kEQ: | |
162 return value_ == my_value; | |
163 default: | |
164 return false; | |
165 } | |
166 } | |
167 | |
168 bool GpuBlacklist::StringInfo::IsValid() const { | |
169 return op_ != kUnknown; | |
170 } | |
171 | |
172 GpuBlacklist::StringInfo::Op GpuBlacklist::StringInfo::StringToOp( | |
173 const std::string& string_op) { | |
174 if (string_op == "=") | |
175 return kEQ; | |
176 else if (string_op == "contains") | |
177 return kContains; | |
178 else if (string_op == "beginwith") | |
179 return kBeginWith; | |
180 else if (string_op == "endwith") | |
181 return kEndWith; | |
182 return kUnknown; | |
183 } | |
184 | |
138 GpuBlacklist::GpuBlacklistEntry* | 185 GpuBlacklist::GpuBlacklistEntry* |
139 GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue( | 186 GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue( |
140 DictionaryValue* value) { | 187 DictionaryValue* value) { |
141 if (value == NULL) | 188 if (value == NULL) |
142 return NULL; | 189 return NULL; |
143 | 190 |
144 GpuBlacklistEntry* entry = new GpuBlacklistEntry(); | 191 GpuBlacklistEntry* entry = new GpuBlacklistEntry(); |
145 | 192 |
193 std::string id; | |
194 if (!value->GetString("id", &id) || !entry->SetId(id)) { | |
195 delete entry; | |
196 return NULL; | |
197 } | |
198 | |
146 DictionaryValue* os_value = NULL; | 199 DictionaryValue* os_value = NULL; |
147 if (value->GetDictionary("os", &os_value)) { | 200 if (value->GetDictionary("os", &os_value)) { |
148 std::string os_type; | 201 std::string os_type; |
149 std::string os_version_op = "any"; | 202 std::string os_version_op = "any"; |
150 std::string os_version_string; | 203 std::string os_version_string; |
151 std::string os_version_string2; | 204 std::string os_version_string2; |
152 os_value->GetString("type", &os_type); | 205 os_value->GetString("type", &os_type); |
153 DictionaryValue* os_version_value = NULL; | 206 DictionaryValue* os_version_value = NULL; |
154 if (os_value->GetDictionary("version", &os_version_value)) { | 207 if (os_value->GetDictionary("version", &os_version_value)) { |
155 os_version_value->GetString("op", &os_version_op); | 208 os_version_value->GetString("op", &os_version_op); |
(...skipping 16 matching lines...) Expand all Loading... | |
172 } | 225 } |
173 | 226 |
174 std::string device_id; | 227 std::string device_id; |
175 if (value->GetString("device_id", &device_id)) { | 228 if (value->GetString("device_id", &device_id)) { |
176 if (!entry->SetDeviceId(device_id)) { | 229 if (!entry->SetDeviceId(device_id)) { |
177 delete entry; | 230 delete entry; |
178 return NULL; | 231 return NULL; |
179 } | 232 } |
180 } | 233 } |
181 | 234 |
235 DictionaryValue* driver_vendor_value = NULL; | |
236 if (value->GetDictionary("driver_vendor", &driver_vendor_value)) { | |
237 std::string vendor_op; | |
238 std::string vendor_value; | |
239 driver_vendor_value->GetString("op", &vendor_op); | |
240 driver_vendor_value->GetString("value", &vendor_value); | |
241 if (!entry->SetDriverVendorInfo(vendor_op, vendor_value)) { | |
242 delete entry; | |
243 return NULL; | |
244 } | |
245 } | |
246 | |
182 DictionaryValue* driver_version_value = NULL; | 247 DictionaryValue* driver_version_value = NULL; |
183 if (value->GetDictionary("driver_version", &driver_version_value)) { | 248 if (value->GetDictionary("driver_version", &driver_version_value)) { |
184 std::string driver_version_op = "any"; | 249 std::string driver_version_op = "any"; |
185 std::string driver_version_string; | 250 std::string driver_version_string; |
186 std::string driver_version_string2; | 251 std::string driver_version_string2; |
187 driver_version_value->GetString("op", &driver_version_op); | 252 driver_version_value->GetString("op", &driver_version_op); |
188 driver_version_value->GetString("number", &driver_version_string); | 253 driver_version_value->GetString("number", &driver_version_string); |
189 driver_version_value->GetString("number2", &driver_version_string2); | 254 driver_version_value->GetString("number2", &driver_version_string2); |
190 if (!entry->SetDriverVersionInfo(driver_version_op, driver_version_string, | 255 if (!entry->SetDriverVersionInfo(driver_version_op, driver_version_string, |
191 driver_version_string2)) { | 256 driver_version_string2)) { |
192 delete entry; | 257 delete entry; |
193 return NULL; | 258 return NULL; |
194 } | 259 } |
195 } | 260 } |
196 | 261 |
262 DictionaryValue* gl_renderer_value = NULL; | |
263 if (value->GetDictionary("gl_renderer", &gl_renderer_value)) { | |
264 std::string renderer_op; | |
265 std::string renderer_value; | |
266 gl_renderer_value->GetString("op", &renderer_op); | |
267 gl_renderer_value->GetString("value", &renderer_value); | |
268 if (!entry->SetGlRendererInfo(renderer_op, renderer_value)) { | |
269 delete entry; | |
270 return NULL; | |
271 } | |
272 } | |
273 | |
197 ListValue* blacklist_value = NULL; | 274 ListValue* blacklist_value = NULL; |
198 if (!value->GetList("blacklist", &blacklist_value)) { | 275 if (!value->GetList("blacklist", &blacklist_value)) { |
199 delete entry; | 276 delete entry; |
200 return NULL; | 277 return NULL; |
201 } | 278 } |
202 std::vector<std::string> blacklist; | 279 std::vector<std::string> blacklist; |
203 for (size_t i = 0; i < blacklist_value->GetSize(); ++i) { | 280 for (size_t i = 0; i < blacklist_value->GetSize(); ++i) { |
204 std::string feature; | 281 std::string feature; |
205 if (blacklist_value->GetString(i, &feature)) { | 282 if (blacklist_value->GetString(i, &feature)) { |
206 blacklist.push_back(feature); | 283 blacklist.push_back(feature); |
(...skipping 10 matching lines...) Expand all Loading... | |
217 return entry; | 294 return entry; |
218 } | 295 } |
219 | 296 |
220 GpuBlacklist::GpuBlacklistEntry::~GpuBlacklistEntry() {} | 297 GpuBlacklist::GpuBlacklistEntry::~GpuBlacklistEntry() {} |
221 | 298 |
222 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry() | 299 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry() |
223 : vendor_id_(0), | 300 : vendor_id_(0), |
224 device_id_(0) { | 301 device_id_(0) { |
225 } | 302 } |
226 | 303 |
304 bool GpuBlacklist::GpuBlacklistEntry::SetId( | |
305 const std::string& id_string) { | |
306 id_ = 0; | |
307 return (base::HexStringToInt(id_string, | |
308 reinterpret_cast<int*>(&id_)) && | |
309 id_ != 0); | |
310 } | |
311 | |
227 bool GpuBlacklist::GpuBlacklistEntry::SetOsInfo( | 312 bool GpuBlacklist::GpuBlacklistEntry::SetOsInfo( |
228 const std::string& os, | 313 const std::string& os, |
229 const std::string& version_op, | 314 const std::string& version_op, |
230 const std::string& version_string, | 315 const std::string& version_string, |
231 const std::string& version_string2) { | 316 const std::string& version_string2) { |
232 os_info_.reset(new OsInfo(os, version_op, version_string, version_string2)); | 317 os_info_.reset(new OsInfo(os, version_op, version_string, version_string2)); |
233 return os_info_->IsValid(); | 318 return os_info_->IsValid(); |
234 } | 319 } |
235 | 320 |
236 bool GpuBlacklist::GpuBlacklistEntry::SetVendorId( | 321 bool GpuBlacklist::GpuBlacklistEntry::SetVendorId( |
237 const std::string& vendor_id_string) { | 322 const std::string& vendor_id_string) { |
238 vendor_id_ = 0; | 323 vendor_id_ = 0; |
239 return base::HexStringToInt(vendor_id_string, | 324 return base::HexStringToInt(vendor_id_string, |
240 reinterpret_cast<int*>(&vendor_id_)); | 325 reinterpret_cast<int*>(&vendor_id_)); |
241 } | 326 } |
242 | 327 |
243 bool GpuBlacklist::GpuBlacklistEntry::SetDeviceId( | 328 bool GpuBlacklist::GpuBlacklistEntry::SetDeviceId( |
244 const std::string& device_id_string) { | 329 const std::string& device_id_string) { |
245 device_id_ = 0; | 330 device_id_ = 0; |
246 return base::HexStringToInt(device_id_string, | 331 return base::HexStringToInt(device_id_string, |
247 reinterpret_cast<int*>(&device_id_)); | 332 reinterpret_cast<int*>(&device_id_)); |
248 } | 333 } |
249 | 334 |
335 bool GpuBlacklist::GpuBlacklistEntry::SetDriverVendorInfo( | |
336 const std::string& vendor_op, | |
337 const std::string& vendor_value) { | |
338 driver_vendor_info_.reset( | |
339 new StringInfo(vendor_op, vendor_value)); | |
340 return driver_vendor_info_->IsValid(); | |
341 } | |
342 | |
250 bool GpuBlacklist::GpuBlacklistEntry::SetDriverVersionInfo( | 343 bool GpuBlacklist::GpuBlacklistEntry::SetDriverVersionInfo( |
251 const std::string& version_op, | 344 const std::string& version_op, |
252 const std::string& version_string, | 345 const std::string& version_string, |
253 const std::string& version_string2) { | 346 const std::string& version_string2) { |
254 driver_version_info_.reset( | 347 driver_version_info_.reset( |
255 new VersionInfo(version_op, version_string, version_string2)); | 348 new VersionInfo(version_op, version_string, version_string2)); |
256 return driver_version_info_->IsValid(); | 349 return driver_version_info_->IsValid(); |
257 } | 350 } |
258 | 351 |
352 bool GpuBlacklist::GpuBlacklistEntry::SetGlRendererInfo( | |
353 const std::string& renderer_op, | |
354 const std::string& renderer_value) { | |
355 gl_renderer_info_.reset( | |
356 new StringInfo(renderer_op, renderer_value)); | |
357 return gl_renderer_info_->IsValid(); | |
358 } | |
359 | |
259 bool GpuBlacklist::GpuBlacklistEntry::SetBlacklistedFeatures( | 360 bool GpuBlacklist::GpuBlacklistEntry::SetBlacklistedFeatures( |
260 const std::vector<std::string>& blacklisted_features) { | 361 const std::vector<std::string>& blacklisted_features) { |
261 size_t size = blacklisted_features.size(); | 362 size_t size = blacklisted_features.size(); |
262 if (size == 0) | 363 if (size == 0) |
263 return false; | 364 return false; |
264 uint32 flags = 0; | 365 uint32 flags = 0; |
265 for (size_t i = 0; i < size; ++i) { | 366 for (size_t i = 0; i < size; ++i) { |
266 GpuFeatureFlags::GpuFeatureType type = | 367 GpuFeatureFlags::GpuFeatureType type = |
267 GpuFeatureFlags::StringToGpuFeatureType(blacklisted_features[i]); | 368 GpuFeatureFlags::StringToGpuFeatureType(blacklisted_features[i]); |
268 switch (type) { | 369 switch (type) { |
269 case GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas: | 370 case GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas: |
270 case GpuFeatureFlags::kGpuFeatureAcceleratedCompositing: | 371 case GpuFeatureFlags::kGpuFeatureAcceleratedCompositing: |
271 case GpuFeatureFlags::kGpuFeatureWebgl: | 372 case GpuFeatureFlags::kGpuFeatureWebgl: |
272 case GpuFeatureFlags::kGpuFeatureAll: | 373 case GpuFeatureFlags::kGpuFeatureAll: |
273 flags |= type; | 374 flags |= type; |
274 break; | 375 break; |
275 case GpuFeatureFlags::kGpuFeatureUnknown: | 376 case GpuFeatureFlags::kGpuFeatureUnknown: |
276 return false; | 377 return false; |
277 } | 378 } |
278 } | 379 } |
279 feature_flags_.reset(new GpuFeatureFlags()); | 380 feature_flags_.reset(new GpuFeatureFlags()); |
280 feature_flags_->set_flags(flags); | 381 feature_flags_->set_flags(flags); |
281 return true; | 382 return true; |
282 } | 383 } |
283 | 384 |
284 bool GpuBlacklist::GpuBlacklistEntry::Contains( | 385 bool GpuBlacklist::GpuBlacklistEntry::Contains( |
285 OsType os_type, const Version& os_version, | 386 OsType os_type, const Version& os_version, |
286 uint32 vendor_id, uint32 device_id, | 387 uint32 vendor_id, uint32 device_id, |
287 const Version& driver_version) const { | 388 const std::string& driver_vendor, |
389 const Version& driver_version, | |
390 const std::string& gl_renderer) const { | |
288 DCHECK(os_type != kOsAny); | 391 DCHECK(os_type != kOsAny); |
289 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) | 392 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) |
290 return false; | 393 return false; |
291 if (vendor_id_ != 0 && vendor_id_ != vendor_id) | 394 if (vendor_id_ != 0 && vendor_id_ != vendor_id) |
292 return false; | 395 return false; |
293 if (device_id_ != 0 && device_id_ != device_id) | 396 if (device_id_ != 0 && device_id_ != device_id) |
294 return false; | 397 return false; |
295 if (driver_version_info_.get() == NULL) | 398 if (driver_vendor_info_.get() != NULL && |
296 return true; | 399 !driver_vendor_info_->Contains(driver_vendor)) |
297 return driver_version_info_->Contains(driver_version); | 400 return false; |
401 if (driver_version_info_.get() != NULL && | |
402 !driver_version_info_->Contains(driver_version)) | |
403 return false; | |
404 if (gl_renderer_info_.get() != NULL && | |
405 !gl_renderer_info_->Contains(gl_renderer)) | |
406 return false; | |
407 return true; | |
298 } | 408 } |
299 | 409 |
300 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { | 410 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { |
301 if (os_info_.get() == NULL) | 411 if (os_info_.get() == NULL) |
302 return kOsUnknown; | 412 return kOsUnknown; |
303 return os_info_->type(); | 413 return os_info_->type(); |
304 } | 414 } |
305 | 415 |
416 uint32 GpuBlacklist::GpuBlacklistEntry::id() const { | |
417 return id_; | |
418 } | |
419 | |
306 GpuFeatureFlags GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureFlags() const { | 420 GpuFeatureFlags GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureFlags() const { |
307 return *feature_flags_; | 421 return *feature_flags_; |
308 } | 422 } |
309 | 423 |
310 GpuBlacklist::GpuBlacklist() { | 424 GpuBlacklist::GpuBlacklist() { |
311 } | 425 } |
312 | 426 |
313 GpuBlacklist::~GpuBlacklist() { | 427 GpuBlacklist::~GpuBlacklist() { |
314 Clear(); | 428 Clear(); |
315 } | 429 } |
316 | 430 |
317 bool GpuBlacklist::LoadGpuBlacklist(const std::string& json_context, | 431 bool GpuBlacklist::LoadGpuBlacklist(const std::string& json_context, |
318 bool current_os_only) { | 432 bool current_os_only) { |
319 std::vector<GpuBlacklistEntry*> entries; | 433 std::vector<GpuBlacklistEntry*> entries; |
320 scoped_ptr<Value> root; | 434 scoped_ptr<Value> root; |
321 root.reset(base::JSONReader::Read(json_context, false)); | 435 root.reset(base::JSONReader::Read(json_context, false)); |
322 if (root.get() == NULL || !root->IsType(Value::TYPE_DICTIONARY)) | 436 if (root.get() == NULL || !root->IsType(Value::TYPE_DICTIONARY)) |
323 return false; | 437 return false; |
324 | 438 |
439 DictionaryValue* root_dictionary = static_cast<DictionaryValue*>(root.get()); | |
440 DCHECK(root_dictionary); | |
441 std::string version_string; | |
442 root_dictionary->GetString("version", &version_string); | |
443 version_.reset(Version::GetVersionFromString(version_string)); | |
444 if (version_.get() == NULL) | |
445 return false; | |
446 | |
325 ListValue* list = NULL; | 447 ListValue* list = NULL; |
326 static_cast<DictionaryValue*>(root.get())->GetList("entries", &list); | 448 root_dictionary->GetList("entries", &list); |
327 if (list == NULL) | 449 if (list == NULL) |
328 return false; | 450 return false; |
329 | 451 |
452 uint32 max_entry_id = 0; | |
330 for (size_t i = 0; i < list->GetSize(); ++i) { | 453 for (size_t i = 0; i < list->GetSize(); ++i) { |
331 DictionaryValue* list_item = NULL; | 454 DictionaryValue* list_item = NULL; |
332 bool valid = list->GetDictionary(i, &list_item); | 455 bool valid = list->GetDictionary(i, &list_item); |
333 if (!valid) | 456 if (!valid) |
334 break; | 457 break; |
335 GpuBlacklistEntry* entry = | 458 GpuBlacklistEntry* entry = |
336 GpuBlacklistEntry::GetGpuBlacklistEntryFromValue(list_item); | 459 GpuBlacklistEntry::GetGpuBlacklistEntryFromValue(list_item); |
337 if (entry == NULL) | 460 if (entry == NULL) |
338 break; | 461 break; |
462 if (entry->id() > max_entry_id) | |
463 max_entry_id = entry->id(); | |
339 entries.push_back(entry); | 464 entries.push_back(entry); |
340 } | 465 } |
341 | 466 |
342 if (entries.size() < list->GetSize()) { | 467 if (entries.size() < list->GetSize()) { |
343 for (size_t i = 0; i < entries.size(); ++i) | 468 for (size_t i = 0; i < entries.size(); ++i) |
344 delete entries[i]; | 469 delete entries[i]; |
345 return false; | 470 return false; |
346 } | 471 } |
347 | 472 |
348 Clear(); | 473 Clear(); |
349 // Don't apply GPU blacklist for a non-registered OS. | 474 // Don't apply GPU blacklist for a non-registered OS. |
350 OsType os_filter = GetOsType(); | 475 OsType os_filter = GetOsType(); |
351 if (os_filter != kOsUnknown) { | 476 if (os_filter != kOsUnknown) { |
352 for (size_t i = 0; i < entries.size(); ++i) { | 477 for (size_t i = 0; i < entries.size(); ++i) { |
353 OsType entry_os = entries[i]->GetOsType(); | 478 OsType entry_os = entries[i]->GetOsType(); |
354 if (!current_os_only || | 479 if (!current_os_only || |
355 entry_os == kOsAny || entry_os == os_filter) | 480 entry_os == kOsAny || entry_os == os_filter) |
356 blacklist_.push_back(entries[i]); | 481 blacklist_.push_back(entries[i]); |
357 else | 482 else |
358 delete entries[i]; | 483 delete entries[i]; |
359 } | 484 } |
360 } | 485 } |
486 max_entry_id_ = max_entry_id; | |
361 return true; | 487 return true; |
362 } | 488 } |
363 | 489 |
364 GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags( | 490 GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags( |
365 GpuBlacklist::OsType os, | 491 GpuBlacklist::OsType os, |
366 Version* os_version, | 492 Version* os_version, |
367 const GPUInfo& gpu_info) const { | 493 const GPUInfo& gpu_info) { |
494 features_.clear(); | |
495 entry_ids_.clear(); | |
368 GpuFeatureFlags flags; | 496 GpuFeatureFlags flags; |
369 // No need to go through blacklist entries if GPUInfo isn't available. | 497 // No need to go through blacklist entries if GPUInfo isn't available. |
370 if (gpu_info.progress() == GPUInfo::kUninitialized) | 498 if (gpu_info.progress() == GPUInfo::kUninitialized) |
371 return flags; | 499 return flags; |
372 scoped_ptr<Version> driver_version( | 500 scoped_ptr<Version> driver_version( |
373 Version::GetVersionFromString(gpu_info.driver_version())); | 501 Version::GetVersionFromString(gpu_info.driver_version())); |
374 if (driver_version.get() == NULL) | 502 if (driver_version.get() == NULL) |
375 return flags; | 503 return flags; |
376 | 504 |
377 if (os == kOsAny) | 505 if (os == kOsAny) |
(...skipping 18 matching lines...) Expand all Loading... | |
396 version_string = version_string.substr(0, pos); | 524 version_string = version_string.substr(0, pos); |
397 #endif | 525 #endif |
398 my_os_version.reset(Version::GetVersionFromString(version_string)); | 526 my_os_version.reset(Version::GetVersionFromString(version_string)); |
399 os_version = my_os_version.get(); | 527 os_version = my_os_version.get(); |
400 } | 528 } |
401 DCHECK(os_version != NULL); | 529 DCHECK(os_version != NULL); |
402 | 530 |
403 for (size_t i = 0; i < blacklist_.size(); ++i) { | 531 for (size_t i = 0; i < blacklist_.size(); ++i) { |
404 if (blacklist_[i]->Contains(os, *os_version, | 532 if (blacklist_[i]->Contains(os, *os_version, |
405 gpu_info.vendor_id(), gpu_info.device_id(), | 533 gpu_info.vendor_id(), gpu_info.device_id(), |
406 *driver_version)) { | 534 "", // gpu_info.driver_vendor(), |
535 *driver_version, | |
536 "")) { // gpu_info.gl_renderer())) { | |
407 flags.Combine(blacklist_[i]->GetGpuFeatureFlags()); | 537 flags.Combine(blacklist_[i]->GetGpuFeatureFlags()); |
538 features_.push_back(blacklist_[i]->GetGpuFeatureFlags().flags()); | |
539 entry_ids_.push_back(blacklist_[i]->id()); | |
408 } | 540 } |
409 } | 541 } |
410 return flags; | 542 return flags; |
411 } | 543 } |
412 | 544 |
545 void GpuBlacklist::GetGpuFeatureFlagEntries( | |
546 GpuFeatureFlags::GpuFeatureType feature, | |
547 std::vector<uint32>& entry_ids) const { | |
548 DCHECK(features_.size() == entry_ids_.size()); | |
549 entry_ids.clear(); | |
550 for (size_t i = 0; i < features_.size(); ++i) { | |
551 if ((feature & features_[i]) != 0) | |
552 entry_ids.push_back(entry_ids_[i]); | |
553 } | |
554 } | |
555 | |
556 uint32 GpuBlacklist::max_entry_id() const { | |
557 return max_entry_id_; | |
558 } | |
559 | |
560 bool GpuBlacklist::GetVersion(uint16* major, uint16* minor) const { | |
561 DCHECK(major && minor); | |
562 *major = 0; | |
563 *minor = 0; | |
564 if (version_.get() == NULL) | |
565 return false; | |
566 const std::vector<uint16>& components_reference = version_->components(); | |
567 if (components_reference.size() != 2) | |
568 return false; | |
569 *major = components_reference[0]; | |
570 *minor = components_reference[1]; | |
571 return true; | |
572 } | |
573 | |
413 GpuBlacklist::OsType GpuBlacklist::GetOsType() { | 574 GpuBlacklist::OsType GpuBlacklist::GetOsType() { |
414 #if defined(OS_WIN) | 575 #if defined(OS_WIN) |
415 return kOsWin; | 576 return kOsWin; |
416 #elif defined(OS_LINUX) | 577 #elif defined(OS_LINUX) |
417 return kOsLinux; | 578 return kOsLinux; |
418 #elif defined(OS_MACOSX) | 579 #elif defined(OS_MACOSX) |
419 return kOsMacosx; | 580 return kOsMacosx; |
420 #else | 581 #else |
421 return kOsUnknown; | 582 return kOsUnknown; |
422 #endif | 583 #endif |
423 } | 584 } |
424 | 585 |
425 void GpuBlacklist::Clear() { | 586 void GpuBlacklist::Clear() { |
426 for (size_t i = 0; i < blacklist_.size(); ++i) | 587 for (size_t i = 0; i < blacklist_.size(); ++i) |
427 delete blacklist_[i]; | 588 delete blacklist_[i]; |
428 blacklist_.clear(); | 589 blacklist_.clear(); |
429 } | 590 } |
430 | 591 |
OLD | NEW |