| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/gpu/gpu_blacklist.h" | 5 #include "content/browser/gpu/gpu_blacklist.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 } | 787 } |
| 788 } | 788 } |
| 789 decision_.blacklisted_features = static_cast<GpuFeatureType>(feature_type); | 789 decision_.blacklisted_features = static_cast<GpuFeatureType>(feature_type); |
| 790 return true; | 790 return true; |
| 791 } | 791 } |
| 792 | 792 |
| 793 bool GpuBlacklist::GpuBlacklistEntry::SetGpuSwitchingOption( | 793 bool GpuBlacklist::GpuBlacklistEntry::SetGpuSwitchingOption( |
| 794 const std::string& switching_string) { | 794 const std::string& switching_string) { |
| 795 GpuSwitchingOption switching = gpu_util::StringToGpuSwitchingOption( | 795 GpuSwitchingOption switching = gpu_util::StringToGpuSwitchingOption( |
| 796 switching_string); | 796 switching_string); |
| 797 if (switching == content::GPU_SWITCHING_OPTION_UNKNOWN) | 797 if (switching == content::GPU_SWITCHING_UNKNOWN) |
| 798 return false; | 798 return false; |
| 799 decision_.gpu_switching = switching; | 799 decision_.gpu_switching = switching; |
| 800 return true; | 800 return true; |
| 801 } | 801 } |
| 802 | 802 |
| 803 void GpuBlacklist::GpuBlacklistEntry::AddException( | 803 void GpuBlacklist::GpuBlacklistEntry::AddException( |
| 804 ScopedGpuBlacklistEntry exception) { | 804 ScopedGpuBlacklistEntry exception) { |
| 805 exceptions_.push_back(exception); | 805 exceptions_.push_back(exception); |
| 806 } | 806 } |
| 807 | 807 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 contains_unknown_fields_ = contains_unknown_fields; | 1029 contains_unknown_fields_ = contains_unknown_fields; |
| 1030 return true; | 1030 return true; |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 GpuBlacklist::Decision GpuBlacklist::MakeBlacklistDecision( | 1033 GpuBlacklist::Decision GpuBlacklist::MakeBlacklistDecision( |
| 1034 GpuBlacklist::OsType os, | 1034 GpuBlacklist::OsType os, |
| 1035 Version* os_version, | 1035 Version* os_version, |
| 1036 const content::GPUInfo& gpu_info) { | 1036 const content::GPUInfo& gpu_info) { |
| 1037 active_entries_.clear(); | 1037 active_entries_.clear(); |
| 1038 int type = 0; | 1038 int type = 0; |
| 1039 GpuSwitchingOption switching = content::GPU_SWITCHING_OPTION_AUTOMATIC; | 1039 GpuSwitchingOption switching = content::GPU_SWITCHING_AUTOMATIC; |
| 1040 | 1040 |
| 1041 if (os == kOsAny) | 1041 if (os == kOsAny) |
| 1042 os = GetOsType(); | 1042 os = GetOsType(); |
| 1043 scoped_ptr<Version> my_os_version; | 1043 scoped_ptr<Version> my_os_version; |
| 1044 if (os_version == NULL) { | 1044 if (os_version == NULL) { |
| 1045 std::string version_string = base::SysInfo::OperatingSystemVersion(); | 1045 std::string version_string = base::SysInfo::OperatingSystemVersion(); |
| 1046 size_t pos = version_string.find_first_not_of("0123456789."); | 1046 size_t pos = version_string.find_first_not_of("0123456789."); |
| 1047 if (pos != std::string::npos) | 1047 if (pos != std::string::npos) |
| 1048 version_string = version_string.substr(0, pos); | 1048 version_string = version_string.substr(0, pos); |
| 1049 my_os_version.reset(new Version(version_string)); | 1049 my_os_version.reset(new Version(version_string)); |
| 1050 os_version = my_os_version.get(); | 1050 os_version = my_os_version.get(); |
| 1051 } | 1051 } |
| 1052 DCHECK(os_version != NULL); | 1052 DCHECK(os_version != NULL); |
| 1053 | 1053 |
| 1054 for (size_t i = 0; i < blacklist_.size(); ++i) { | 1054 for (size_t i = 0; i < blacklist_.size(); ++i) { |
| 1055 if (blacklist_[i]->Contains(os, *os_version, gpu_info)) { | 1055 if (blacklist_[i]->Contains(os, *os_version, gpu_info)) { |
| 1056 if (!blacklist_[i]->disabled()) { | 1056 if (!blacklist_[i]->disabled()) { |
| 1057 type |= blacklist_[i]->GetGpuFeatureType(); | 1057 type |= blacklist_[i]->GetGpuFeatureType(); |
| 1058 if (blacklist_[i]->GetGpuSwitchingOption() != | 1058 if (blacklist_[i]->GetGpuSwitchingOption() != |
| 1059 content::GPU_SWITCHING_OPTION_AUTOMATIC) | 1059 content::GPU_SWITCHING_AUTOMATIC) |
| 1060 switching = blacklist_[i]->GetGpuSwitchingOption(); | 1060 switching = blacklist_[i]->GetGpuSwitchingOption(); |
| 1061 } | 1061 } |
| 1062 active_entries_.push_back(blacklist_[i]); | 1062 active_entries_.push_back(blacklist_[i]); |
| 1063 } | 1063 } |
| 1064 } | 1064 } |
| 1065 Decision decision; | 1065 Decision decision; |
| 1066 decision.blacklisted_features = static_cast<GpuFeatureType>(type); | 1066 decision.blacklisted_features = static_cast<GpuFeatureType>(type); |
| 1067 decision.gpu_switching = switching; | 1067 decision.gpu_switching = switching; |
| 1068 return decision; | 1068 return decision; |
| 1069 } | 1069 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 if (op == ">") | 1182 if (op == ">") |
| 1183 return kGT; | 1183 return kGT; |
| 1184 if (op == ">=") | 1184 if (op == ">=") |
| 1185 return kGE; | 1185 return kGE; |
| 1186 if (op == "any") | 1186 if (op == "any") |
| 1187 return kAny; | 1187 return kAny; |
| 1188 if (op == "between") | 1188 if (op == "between") |
| 1189 return kBetween; | 1189 return kBetween; |
| 1190 return kUnknown; | 1190 return kUnknown; |
| 1191 } | 1191 } |
| OLD | NEW |