| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/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_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 if (pieces.size() != 3) | 27 if (pieces.size() != 3) |
| 28 return NULL; | 28 return NULL; |
| 29 std::string date_as_version_string = pieces[2]; | 29 std::string date_as_version_string = pieces[2]; |
| 30 for (size_t i = 0; i < 2; ++i) { | 30 for (size_t i = 0; i < 2; ++i) { |
| 31 date_as_version_string += "."; | 31 date_as_version_string += "."; |
| 32 date_as_version_string += pieces[i]; | 32 date_as_version_string += pieces[i]; |
| 33 } | 33 } |
| 34 return Version::GetVersionFromString(date_as_version_string); | 34 return Version::GetVersionFromString(date_as_version_string); |
| 35 } | 35 } |
| 36 | 36 |
| 37 Value* NewStatusValue(const char* name, const char* status) | |
| 38 { | |
| 39 DictionaryValue* value = new DictionaryValue(); | |
| 40 value->SetString("name", name); | |
| 41 value->SetString("status", status); | |
| 42 return value; | |
| 43 } | |
| 44 | |
| 45 } // namespace anonymous | 37 } // namespace anonymous |
| 46 | 38 |
| 47 GpuBlacklist::VersionInfo::VersionInfo(const std::string& version_op, | 39 GpuBlacklist::VersionInfo::VersionInfo(const std::string& version_op, |
| 48 const std::string& version_string, | 40 const std::string& version_string, |
| 49 const std::string& version_string2) { | 41 const std::string& version_string2) { |
| 50 op_ = StringToOp(version_op); | 42 op_ = StringToOp(version_op); |
| 51 if (op_ == kUnknown || op_ == kAny) | 43 if (op_ == kUnknown || op_ == kAny) |
| 52 return; | 44 return; |
| 53 version_.reset(Version::GetVersionFromString(version_string)); | 45 version_.reset(Version::GetVersionFromString(version_string)); |
| 54 if (version_.get() == NULL) { | 46 if (version_.get() == NULL) { |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 std::vector<uint32>& entry_ids, | 772 std::vector<uint32>& entry_ids, |
| 781 bool disabled) const { | 773 bool disabled) const { |
| 782 entry_ids.clear(); | 774 entry_ids.clear(); |
| 783 for (size_t i = 0; i < active_entries_.size(); ++i) { | 775 for (size_t i = 0; i < active_entries_.size(); ++i) { |
| 784 if (((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) && | 776 if (((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) && |
| 785 disabled == active_entries_[i]->disabled()) | 777 disabled == active_entries_[i]->disabled()) |
| 786 entry_ids.push_back(active_entries_[i]->id()); | 778 entry_ids.push_back(active_entries_[i]->id()); |
| 787 } | 779 } |
| 788 } | 780 } |
| 789 | 781 |
| 790 bool GpuBlacklist::IsFeatureBlacklisted( | 782 void GpuBlacklist::GetBlacklistReasons(ListValue* problem_list) const { |
| 791 GpuFeatureFlags::GpuFeatureType feature) const | 783 DCHECK(problem_list); |
| 792 { | |
| 793 for (size_t i = 0; i < active_entries_.size(); ++i) { | 784 for (size_t i = 0; i < active_entries_.size(); ++i) { |
| 794 if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature) | 785 GpuBlacklistEntry* entry = active_entries_[i]; |
| 795 return true; | 786 if (entry->disabled()) |
| 787 continue; |
| 788 DictionaryValue* problem = new DictionaryValue(); |
| 789 |
| 790 problem->SetString("description", entry->description()); |
| 791 |
| 792 ListValue* cr_bugs = new ListValue(); |
| 793 for (size_t j = 0; j < entry->cr_bugs().size(); ++j) |
| 794 cr_bugs->Append(Value::CreateIntegerValue(entry->cr_bugs()[j])); |
| 795 problem->Set("crBugs", cr_bugs); |
| 796 |
| 797 ListValue* webkit_bugs = new ListValue(); |
| 798 for (size_t j = 0; j < entry->webkit_bugs().size(); ++j) { |
| 799 webkit_bugs->Append(Value::CreateIntegerValue( |
| 800 entry->webkit_bugs()[j])); |
| 801 } |
| 802 problem->Set("webkitBugs", webkit_bugs); |
| 803 |
| 804 problem_list->Append(problem); |
| 796 } | 805 } |
| 797 return false; | |
| 798 } | |
| 799 | |
| 800 Value* GpuBlacklist::GetFeatureStatus(bool gpu_access_allowed, | |
| 801 bool disable_accelerated_compositing, | |
| 802 bool disable_accelerated_2D_canvas, | |
| 803 bool disable_experimental_webgl, | |
| 804 bool disable_multisampling) const { | |
| 805 DictionaryValue* status = new DictionaryValue(); | |
| 806 | |
| 807 // Build the feature_status field. | |
| 808 { | |
| 809 ListValue* feature_status_list = new ListValue(); | |
| 810 | |
| 811 // 2d_canvas. | |
| 812 if (!gpu_access_allowed) { | |
| 813 if (disable_accelerated_2D_canvas) | |
| 814 feature_status_list->Append(NewStatusValue("2d_canvas", | |
| 815 "software")); | |
| 816 else | |
| 817 feature_status_list->Append(NewStatusValue("2d_canvas", | |
| 818 "unavailable_software")); | |
| 819 } else if (!disable_accelerated_2D_canvas) { | |
| 820 if (IsFeatureBlacklisted( | |
| 821 GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)) | |
| 822 feature_status_list->Append(NewStatusValue("2d_canvas", | |
| 823 "unavailable_software")); | |
| 824 else if (disable_accelerated_compositing) | |
| 825 feature_status_list->Append(NewStatusValue("2d_canvas", | |
| 826 "disabled_software")); | |
| 827 else | |
| 828 feature_status_list->Append(NewStatusValue("2d_canvas", | |
| 829 "enabled")); | |
| 830 } else { | |
| 831 feature_status_list->Append(NewStatusValue("2d_canvas", | |
| 832 "software")); | |
| 833 } | |
| 834 | |
| 835 // 3d css and compositing. | |
| 836 if (!gpu_access_allowed) { | |
| 837 feature_status_list->Append(NewStatusValue("3d_css", | |
| 838 "unavailable_off")); | |
| 839 feature_status_list->Append(NewStatusValue("compositing", | |
| 840 "unavailable_software")); | |
| 841 } else if (disable_accelerated_compositing) { | |
| 842 feature_status_list->Append(NewStatusValue("3d_css", | |
| 843 "unavailable_off")); | |
| 844 feature_status_list->Append(NewStatusValue("compositing", | |
| 845 "disabled_software")); | |
| 846 } else if (IsFeatureBlacklisted( | |
| 847 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)) { | |
| 848 feature_status_list->Append(NewStatusValue("3d_css", | |
| 849 "unavailable_off")); | |
| 850 feature_status_list->Append(NewStatusValue("compositing", | |
| 851 "disabled_software")); | |
| 852 } else { | |
| 853 feature_status_list->Append(NewStatusValue("3d_css", | |
| 854 "enabled")); | |
| 855 feature_status_list->Append(NewStatusValue("compositing", | |
| 856 "enabled")); | |
| 857 } | |
| 858 | |
| 859 // webgl | |
| 860 if (!gpu_access_allowed) | |
| 861 feature_status_list->Append(NewStatusValue("webgl", | |
| 862 "unavailable_off")); | |
| 863 else if (disable_experimental_webgl) | |
| 864 feature_status_list->Append(NewStatusValue("webgl", | |
| 865 "disabled_off")); | |
| 866 else if (IsFeatureBlacklisted( | |
| 867 GpuFeatureFlags::kGpuFeatureWebgl)) | |
| 868 feature_status_list->Append(NewStatusValue("webgl", | |
| 869 "unavailable_off")); | |
| 870 else if (disable_accelerated_compositing) | |
| 871 feature_status_list->Append(NewStatusValue("webgl", | |
| 872 "enabled_readback")); | |
| 873 else | |
| 874 feature_status_list->Append(NewStatusValue("webgl", | |
| 875 "enabled")); | |
| 876 | |
| 877 // multisampling | |
| 878 if (!gpu_access_allowed) | |
| 879 feature_status_list->Append(NewStatusValue("multisampling", | |
| 880 "unavailable_off")); | |
| 881 else if (disable_multisampling) | |
| 882 feature_status_list->Append(NewStatusValue("multisampling", | |
| 883 "disabled_off")); | |
| 884 else if (IsFeatureBlacklisted( | |
| 885 GpuFeatureFlags::kGpuFeatureMultisampling)) | |
| 886 feature_status_list->Append(NewStatusValue("multisampling", | |
| 887 "disabled_off")); | |
| 888 else | |
| 889 feature_status_list->Append(NewStatusValue("multisampling", | |
| 890 "enabled")); | |
| 891 | |
| 892 status->Set("featureStatus", feature_status_list); | |
| 893 } | |
| 894 | |
| 895 // Build the problems list. | |
| 896 { | |
| 897 ListValue* problem_list = new ListValue(); | |
| 898 if (!gpu_access_allowed) { | |
| 899 DictionaryValue* problem = new DictionaryValue(); | |
| 900 problem->SetString("description", | |
| 901 "GPU process was unable to boot. Access to GPU disallowed."); | |
| 902 problem->Set("crBugs", new ListValue()); | |
| 903 problem->Set("webkitBugs", new ListValue()); | |
| 904 problem_list->Append(problem); | |
| 905 } | |
| 906 if (disable_accelerated_2D_canvas) { | |
| 907 DictionaryValue* problem = new DictionaryValue(); | |
| 908 problem->SetString("description", | |
| 909 "Accelerated 2D canvas has been disabled at the command line"); | |
| 910 problem->Set("crBugs", new ListValue()); | |
| 911 problem->Set("webkitBugs", new ListValue()); | |
| 912 problem_list->Append(problem); | |
| 913 } | |
| 914 if (disable_accelerated_compositing) { | |
| 915 DictionaryValue* problem = new DictionaryValue(); | |
| 916 problem->SetString("description", | |
| 917 "Accelerated compositing has been disabled, either via about:flags " | |
| 918 "or command line. This adversely affects performance of all hardware " | |
| 919 " accelerated features."); | |
| 920 problem->Set("crBugs", new ListValue()); | |
| 921 problem->Set("webkitBugs", new ListValue()); | |
| 922 problem_list->Append(problem); | |
| 923 } | |
| 924 if (disable_experimental_webgl) { | |
| 925 DictionaryValue* problem = new DictionaryValue(); | |
| 926 problem->SetString("description", | |
| 927 "WebGL has been disabled, either via about:flags " | |
| 928 "or command line"); | |
| 929 problem->Set("crBugs", new ListValue()); | |
| 930 problem->Set("webkitBugs", new ListValue()); | |
| 931 problem_list->Append(problem); | |
| 932 } | |
| 933 if (disable_multisampling) { | |
| 934 DictionaryValue* problem = new DictionaryValue(); | |
| 935 problem->SetString("description", | |
| 936 "Multisampling has been disabled, either via about:flags " | |
| 937 "or command line"); | |
| 938 problem->Set("crBugs", new ListValue()); | |
| 939 problem->Set("webkitBugs", new ListValue()); | |
| 940 problem_list->Append(problem); | |
| 941 } | |
| 942 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
| 943 ScopedGpuBlacklistEntry entry = active_entries_[i]; | |
| 944 DictionaryValue* problem = new DictionaryValue(); | |
| 945 | |
| 946 problem->SetString("description", entry->description()); | |
| 947 | |
| 948 ListValue* cr_bugs = new ListValue(); | |
| 949 for (size_t j = 0; j < entry->cr_bugs().size(); ++j) | |
| 950 cr_bugs->Append(Value::CreateIntegerValue( | |
| 951 entry->cr_bugs()[j])); | |
| 952 problem->Set("crBugs", cr_bugs); | |
| 953 | |
| 954 ListValue* webkit_bugs = new ListValue(); | |
| 955 for (size_t j = 0; j < entry->webkit_bugs().size(); ++j) | |
| 956 webkit_bugs->Append(Value::CreateIntegerValue( | |
| 957 entry->webkit_bugs()[j])); | |
| 958 problem->Set("webkitBugs", webkit_bugs); | |
| 959 | |
| 960 problem_list->Append(problem); | |
| 961 } | |
| 962 status->Set("problems", problem_list); | |
| 963 } | |
| 964 return status; | |
| 965 } | 806 } |
| 966 | 807 |
| 967 size_t GpuBlacklist::num_entries() const { | 808 size_t GpuBlacklist::num_entries() const { |
| 968 return blacklist_.size(); | 809 return blacklist_.size(); |
| 969 } | 810 } |
| 970 | 811 |
| 971 uint32 GpuBlacklist::max_entry_id() const { | 812 uint32 GpuBlacklist::max_entry_id() const { |
| 972 return max_entry_id_; | 813 return max_entry_id_; |
| 973 } | 814 } |
| 974 | 815 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 return kStable; | 913 return kStable; |
| 1073 if (value == "beta") | 914 if (value == "beta") |
| 1074 return kBeta; | 915 return kBeta; |
| 1075 if (value == "dev") | 916 if (value == "dev") |
| 1076 return kDev; | 917 return kDev; |
| 1077 if (value == "canary") | 918 if (value == "canary") |
| 1078 return kCanary; | 919 return kCanary; |
| 1079 return kUnknown; | 920 return kUnknown; |
| 1080 } | 921 } |
| 1081 | 922 |
| OLD | NEW |