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