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_blacklist.h" | 5 #include "content/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_piece.h" | 10 #include "base/string_piece.h" |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 void GpuBlacklist::GetGpuFeatureFlagEntries( | 686 void GpuBlacklist::GetGpuFeatureFlagEntries( |
687 GpuFeatureFlags::GpuFeatureType feature, | 687 GpuFeatureFlags::GpuFeatureType feature, |
688 std::vector<uint32>& entry_ids) const { | 688 std::vector<uint32>& entry_ids) const { |
689 entry_ids.clear(); | 689 entry_ids.clear(); |
690 for (size_t i = 0; i < active_entries_.size(); ++i) { | 690 for (size_t i = 0; i < active_entries_.size(); ++i) { |
691 if ((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) | 691 if ((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) |
692 entry_ids.push_back(active_entries_[i]->id()); | 692 entry_ids.push_back(active_entries_[i]->id()); |
693 } | 693 } |
694 } | 694 } |
695 | 695 |
696 Value* GpuBlacklist::GetBlacklistingReasons() const { | 696 Value* GpuBlacklist::GetFeatureStatus(bool gpuAccessAllowed) const { |
697 ListValue* reasons = new ListValue(); | 697 DictionaryValue* status = new DictionaryValue(); |
698 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
699 DictionaryValue* reason = new DictionaryValue(); | |
700 reason->SetString("description", active_entries_[i]->description()); | |
701 | 698 |
702 ListValue* cr_bugs = new ListValue(); | 699 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
703 for (size_t j = 0; j < active_entries_[i]->cr_bugs().size(); ++j) | 700 bool disableAcceleratedCompositing = |
zmo
2011/04/11 23:10:25
disable_accelerated_compositing
same for the othe
| |
704 cr_bugs->Append(Value::CreateIntegerValue( | 701 browser_command_line.HasSwitch(switches::kDisableAcceleratedCompositing); |
705 active_entries_[i]->cr_bugs()[j])); | 702 bool enableAccelerated2DCanvas = |
706 reason->Set("cr_bugs", cr_bugs); | 703 browser_command_line.HasSwitch(switches::kEnableAccelerated2dCanvas); |
704 bool disableExperimentalWebGL = | |
705 browser_command_line.HasSwitch(switches::kDisableExperimentalWebGL); | |
706 bool disableMultisampling = | |
707 browser_command_line.HasSwitch(switches::kDisableGLMultisampling)); | |
707 | 708 |
708 ListValue* webkit_bugs = new ListValue(); | 709 // build the feature_status field |
709 for (size_t j = 0; j < active_entries_[i]->webkit_bugs().size(); ++j) | 710 { |
710 webkit_bugs->Append(Value::CreateIntegerValue( | 711 ListValue* feature_status_list = new ListValue(); |
711 active_entries_[i]->webkit_bugs()[j])); | 712 // Iterate over all feature bits in kGpuFeatureAll and set feature status |
712 reason->Set("webkit_bugs", webkit_bugs); | 713 // for each one. |
714 for (size_t i = 0; i < sizeof(GpuFeatureFlags::GpuFeatureType) * 8; ++i) { | |
715 GpuFeatureFlags::GpuFeatureType feature = | |
716 static_cast<GpuFeatureFlags::GpuFeatureType>(1 << i); | |
717 if (!(feature & GpuFeatureFlags::kGpuFeatureAll)) | |
718 continue; | |
713 | 719 |
714 reasons->Append(reason); | 720 DictionaryValue* feature_status = new DictionaryValue(); |
721 | |
722 std::string feature_name( | |
723 GpuFeatureFlags::GpuFeatureTypeToString(feature)); | |
724 feature_status->SetString("name", feature_name); | |
725 | |
726 // figure out if the feature is on or off | |
727 bool blacklisted = false; | |
728 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
729 if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature) | |
730 blacklisted = true; | |
731 } | |
732 | |
733 // status is actually a function of blacklisting + enable/disable flags + global GPU state | |
zmo
2011/04/11 23:10:25
80 per line
| |
734 const char* status; | |
735 if (!gpuAccessAllowed) { | |
736 status = "unavailable"; | |
737 } else { | |
738 switch(feature) { | |
739 case GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas: | |
zmo
2011/04/11 23:10:25
switch style is incorrect. two whitespaces before
| |
740 if (enableAccelerated2DCanvas) { | |
741 if (blacklisted) | |
742 status = "unavailable"; | |
743 else | |
744 status = "enabled"; | |
745 } else { | |
746 status = "software"; | |
747 } | |
748 break; | |
749 case GpuFeatureFlags::kGpuFeatureAcceleratedCompositing: | |
750 if (disableAcceleratedCompositing) { | |
751 status = "software"; | |
752 } else { | |
753 if (blacklisted) | |
754 status = "unavailable"; | |
755 else | |
756 status = "enabled"; | |
757 } | |
758 break; | |
759 | |
760 case GpuFeatureFlags::kGpuFeatureWebgl: | |
761 if (disableExperimentalWebGL) { | |
762 status = "software"; | |
zmo
2011/04/11 23:10:25
Since we don't have a software renderer for WebGL
| |
763 } else { | |
764 if (blacklisted) | |
765 status = "unavailable"; | |
766 else | |
767 status = "enabled"; | |
768 } | |
769 break; | |
770 | |
771 case GpuFeatureFlags::kGpuFeatureMultisampling: | |
772 if(disableMultisampling) { | |
773 status = "unavailable"; | |
774 } else { | |
775 if(blacklisted) | |
776 status = "unavailable"; | |
777 else | |
778 status = "enabled"; | |
779 } | |
780 break; | |
781 default: | |
782 status = blacklisted ? "unavailable" : "enabled"; | |
zmo
2011/04/11 23:10:25
shouldn't here be UNREACHABLE() or something like
| |
783 break; | |
784 } | |
785 } | |
786 feature_status->SetString("status", status); | |
787 | |
788 feature_status_list->Append(feature_status); | |
789 } | |
790 status->Set("featureStatus", feature_status_list); | |
715 } | 791 } |
716 return reasons; | 792 |
793 // build the problems list | |
794 { | |
795 ListValue* problem_list = new ListValue(); | |
796 if(!gpuAccessAllowed) { | |
797 DictionaryValue* problem = new DictionaryValue(); | |
798 problem->SetString("description", "GPU process was unable to boot. Access to GPU disallowed."); | |
zmo
2011/04/11 23:10:25
80 per line
| |
799 problem->Set("crBugs", new ListValue()); | |
800 problem->Set("webkitBugs", new ListValue()); | |
801 problem_list->Append(problem); | |
802 } | |
803 if(!enableAccelerated2DCanvas) { | |
804 DictionaryValue* problem = new DictionaryValue(); | |
805 problem->SetString("description", | |
806 "Accelerated 2D canvas has not been enabled " | |
807 "(in about:flags or command line)"); | |
808 problem->Set("crBugs", new ListValue()); | |
809 problem->Set("webkitBugs", new ListValue()); | |
810 problem_list->Append(problem); | |
811 } | |
812 if(disableAcceleratedCompositing) { | |
813 DictionaryValue* problem = new DictionaryValue(); | |
814 problem->SetString("description", | |
815 "Accelerated compositing has been disabled, either via about:flags " | |
816 "or command line"); | |
817 problem->Set("crBugs", new ListValue()); | |
818 problem->Set("webkitBugs", new ListValue()); | |
819 problem_list->Append(problem); | |
820 } | |
821 if(disableExperimentalWebGL) { | |
822 DictionaryValue* problem = new DictionaryValue(); | |
823 problem->SetString("description", | |
824 "WebGL has been disabled, either via about:flags " | |
825 "or command line"); | |
826 problem->Set("crBugs", new ListValue()); | |
827 problem->Set("webkitBugs", new ListValue()); | |
828 problem_list->Append(problem); | |
829 } | |
830 if(disableMultisampling) { | |
831 DictionaryValue* problem = new DictionaryValue(); | |
832 problem->SetString("description", | |
833 "Multisampling has been disabled, either via about:flags " | |
834 "or command line"); | |
835 problem->Set("crBugs", new ListValue()); | |
836 problem->Set("webkitBugs", new ListValue()); | |
837 problem_list->Append(problem); | |
838 } | |
839 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
840 GpuBlacklistEntry* entry = active_entries_[i]; | |
841 DictionaryValue* problem = new DictionaryValue(); | |
842 | |
843 problem->SetString("description", entry->description()); | |
844 | |
845 ListValue* cr_bugs = new ListValue(); | |
846 for (size_t j = 0; j < entry->cr_bugs().size(); ++j) | |
847 cr_bugs->Append(Value::CreateIntegerValue( | |
848 entry->cr_bugs()[j])); | |
849 problem->Set("crBugs", cr_bugs); | |
850 | |
851 ListValue* webkit_bugs = new ListValue(); | |
852 for (size_t j = 0; j < entry->webkit_bugs().size(); ++j) | |
853 webkit_bugs->Append(Value::CreateIntegerValue( | |
854 entry->webkit_bugs()[j])); | |
855 problem->Set("webkitBugs", webkit_bugs); | |
856 | |
857 problem_list->Append(problem); | |
858 } | |
859 status->Set("problems", problem_list); | |
860 } | |
861 return status; | |
717 } | 862 } |
718 | 863 |
719 uint32 GpuBlacklist::max_entry_id() const { | 864 uint32 GpuBlacklist::max_entry_id() const { |
720 return max_entry_id_; | 865 return max_entry_id_; |
721 } | 866 } |
722 | 867 |
723 bool GpuBlacklist::GetVersion(uint16* major, uint16* minor) const { | 868 bool GpuBlacklist::GetVersion(uint16* major, uint16* minor) const { |
724 DCHECK(major && minor); | 869 DCHECK(major && minor); |
725 *major = 0; | 870 *major = 0; |
726 *minor = 0; | 871 *minor = 0; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 browser_version_info.reset( | 935 browser_version_info.reset( |
791 new VersionInfo(version_op, version_string, version_string2)); | 936 new VersionInfo(version_op, version_string, version_string2)); |
792 if (!browser_version_info->IsValid()) | 937 if (!browser_version_info->IsValid()) |
793 return kMalformed; | 938 return kMalformed; |
794 if (browser_version_info->Contains(*browser_version_)) | 939 if (browser_version_info->Contains(*browser_version_)) |
795 return kSupported; | 940 return kSupported; |
796 return kUnsupported; | 941 return kUnsupported; |
797 } | 942 } |
798 return kSupported; | 943 return kSupported; |
799 } | 944 } |
800 | |
OLD | NEW |