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 bool GpuBlacklist::IsFeatureBlacklisted( | |
697 GpuFeatureFlags::GpuFeatureType feature) const | |
698 { | |
699 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
700 if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature) | |
701 return true; | |
702 } | |
703 return false; | |
704 } | |
705 | |
706 namespace | |
707 { | |
708 | |
709 Value* NewStatusValue(const char* name, const char* status) | |
710 { | |
711 DictionaryValue* value = new DictionaryValue(); | |
712 value->SetString("name", name); | |
713 value->SetString("status", status); | |
714 return value; | |
715 } | |
716 | |
717 } | |
zmo
2011/04/15 17:06:35
Please move this into the anonymous namespace at t
| |
718 | |
696 Value* GpuBlacklist::GetFeatureStatus(bool gpu_access_allowed, | 719 Value* GpuBlacklist::GetFeatureStatus(bool gpu_access_allowed, |
697 bool disable_accelerated_compositing, | 720 bool disable_accelerated_compositing, |
698 bool enable_accelerated_2D_canvas, | 721 bool enable_accelerated_2D_canvas, |
699 bool disable_experimental_webgl, | 722 bool disable_experimental_webgl, |
700 bool disable_multisampling) const { | 723 bool disable_multisampling) const { |
701 DictionaryValue* status = new DictionaryValue(); | 724 DictionaryValue* status = new DictionaryValue(); |
702 | 725 |
703 // build the feature_status field | 726 // Build the feature_status field. |
704 { | 727 { |
705 ListValue* feature_status_list = new ListValue(); | 728 ListValue* feature_status_list = new ListValue(); |
706 // Iterate over all feature bits in kGpuFeatureAll and set feature status | |
707 // for each one. | |
708 for (size_t i = 0; i < sizeof(GpuFeatureFlags::GpuFeatureType) * 8; ++i) { | |
709 GpuFeatureFlags::GpuFeatureType feature = | |
710 static_cast<GpuFeatureFlags::GpuFeatureType>(1 << i); | |
711 if (!(feature & GpuFeatureFlags::kGpuFeatureAll)) | |
712 continue; | |
713 | 729 |
714 DictionaryValue* feature_status = new DictionaryValue(); | 730 // 2d_canvas. |
731 if (!gpu_access_allowed) { | |
732 if(enable_accelerated_2D_canvas) | |
733 feature_status_list->Append(NewStatusValue("2d_canvas", | |
734 "unavailable_software")); | |
735 else | |
736 feature_status_list->Append(NewStatusValue("2d_canvas", | |
737 "software")); | |
738 } else if (enable_accelerated_2D_canvas) { | |
739 if (IsFeatureBlacklisted( | |
740 GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)) | |
741 feature_status_list->Append(NewStatusValue("2d_canvas", | |
742 "unavailable_software")); | |
743 else | |
744 feature_status_list->Append(NewStatusValue("2d_canvas", | |
745 "enabled")); | |
746 } else { | |
747 feature_status_list->Append(NewStatusValue("2d_canvas", | |
748 "software")); | |
749 } | |
715 | 750 |
716 std::string feature_name( | 751 // 3d css and compositing. |
717 GpuFeatureFlags::GpuFeatureTypeToString(feature)); | 752 if (!gpu_access_allowed) { |
718 feature_status->SetString("name", feature_name); | 753 feature_status_list->Append(NewStatusValue("3d_css", |
754 "unavailable_off")); | |
755 feature_status_list->Append(NewStatusValue("compositing", | |
756 "unavailable_software")); | |
757 } else if (disable_accelerated_compositing) { | |
758 feature_status_list->Append(NewStatusValue("3d_css", | |
759 "unavailable_off")); | |
760 feature_status_list->Append(NewStatusValue("compositing", | |
761 "disabled_software")); | |
762 } else if (IsFeatureBlacklisted( | |
763 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)) { | |
764 feature_status_list->Append(NewStatusValue("3d_css", | |
765 "unavailable_off")); | |
766 feature_status_list->Append(NewStatusValue("compositing", | |
767 "disabled_software")); | |
768 } else { | |
769 feature_status_list->Append(NewStatusValue("3d_css", | |
770 "enabled")); | |
771 feature_status_list->Append(NewStatusValue("compositing", | |
772 "enabled")); | |
773 } | |
719 | 774 |
720 // figure out if the feature is on or off | 775 // webgl |
721 bool blacklisted = false; | 776 if (!gpu_access_allowed) |
722 for (size_t i = 0; i < active_entries_.size(); ++i) { | 777 feature_status_list->Append(NewStatusValue("webgl", |
723 if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature) | 778 "unavailable_off")); |
724 blacklisted |= true; | 779 else if (disable_experimental_webgl) |
725 } | 780 feature_status_list->Append(NewStatusValue("webgl", |
781 "disabled_off")); | |
782 else if (IsFeatureBlacklisted( | |
783 GpuFeatureFlags::kGpuFeatureWebgl)) | |
784 feature_status_list->Append(NewStatusValue("webgl", | |
785 "unavailable_off")); | |
786 else | |
787 feature_status_list->Append(NewStatusValue("webgl", | |
788 "enabled")); | |
726 | 789 |
727 // status is actually a function of blacklisting + enable/disable flags + | 790 // multisampling |
728 // global GPU state | 791 if (!gpu_access_allowed) |
729 const char* status; | 792 feature_status_list->Append(NewStatusValue("multisampling", |
730 if (!gpu_access_allowed) { | 793 "unavailable_off")); |
731 status = "unavailable"; | 794 else if(disable_multisampling) |
732 } else { | 795 feature_status_list->Append(NewStatusValue("multisampling", |
733 switch(feature) { | 796 "disabled_off")); |
734 case GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas: { | 797 else if (IsFeatureBlacklisted( |
735 if (enable_accelerated_2D_canvas) { | 798 GpuFeatureFlags::kGpuFeatureMultisampling)) |
736 if (blacklisted) | 799 feature_status_list->Append(NewStatusValue("multisampling", |
737 status = "unavailable"; | 800 "disabled_off")); |
738 else | 801 else |
739 status = "enabled"; | 802 feature_status_list->Append(NewStatusValue("multisampling", |
zmo
2011/04/15 17:06:35
remove two extra white space
| |
740 } else { | 803 "enabled")); |
741 status = "software"; | |
742 } | |
743 break; | |
744 } | |
745 case GpuFeatureFlags::kGpuFeatureAcceleratedCompositing: { | |
746 if (disable_accelerated_compositing) { | |
747 status = "disabled"; | |
748 } else { | |
749 if (blacklisted) | |
750 status = "unavailable"; | |
751 else | |
752 status = "enabled"; | |
753 } | |
754 break; | |
755 } | |
756 case GpuFeatureFlags::kGpuFeatureWebgl: { | |
757 if (disable_experimental_webgl) { | |
758 status = "disabled"; | |
759 } else { | |
760 if (blacklisted) | |
761 status = "unavailable"; | |
762 else | |
763 status = "enabled"; | |
764 } | |
765 break; | |
766 } | |
767 case GpuFeatureFlags::kGpuFeatureMultisampling: { | |
768 if(disable_multisampling) { | |
769 status = "disabled"; | |
770 } else { | |
771 if(blacklisted) | |
772 status = "unavailable"; | |
773 else | |
774 status = "enabled"; | |
775 } | |
776 break; | |
777 } | |
778 default: { | |
779 NOTREACHED(); | |
780 status = "unavailable"; | |
781 break; | |
782 } | |
783 } | |
784 } | |
785 feature_status->SetString("status", status); | |
786 | 804 |
787 feature_status_list->Append(feature_status); | 805 |
788 } | |
789 status->Set("featureStatus", feature_status_list); | 806 status->Set("featureStatus", feature_status_list); |
790 } | 807 } |
791 | 808 |
792 // build the problems list | 809 // Build the problems list. |
793 { | 810 { |
794 ListValue* problem_list = new ListValue(); | 811 ListValue* problem_list = new ListValue(); |
795 if(!gpu_access_allowed) { | 812 if(!gpu_access_allowed) { |
796 DictionaryValue* problem = new DictionaryValue(); | 813 DictionaryValue* problem = new DictionaryValue(); |
797 problem->SetString("description", | 814 problem->SetString("description", |
798 "GPU process was unable to boot. Access to GPU disallowed."); | 815 "GPU process was unable to boot. Access to GPU disallowed."); |
799 problem->Set("crBugs", new ListValue()); | 816 problem->Set("crBugs", new ListValue()); |
800 problem->Set("webkitBugs", new ListValue()); | 817 problem->Set("webkitBugs", new ListValue()); |
801 problem_list->Append(problem); | 818 problem_list->Append(problem); |
802 } | 819 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 browser_version_info.reset( | 952 browser_version_info.reset( |
936 new VersionInfo(version_op, version_string, version_string2)); | 953 new VersionInfo(version_op, version_string, version_string2)); |
937 if (!browser_version_info->IsValid()) | 954 if (!browser_version_info->IsValid()) |
938 return kMalformed; | 955 return kMalformed; |
939 if (browser_version_info->Contains(*browser_version_)) | 956 if (browser_version_info->Contains(*browser_version_)) |
940 return kSupported; | 957 return kSupported; |
941 return kUnsupported; | 958 return kUnsupported; |
942 } | 959 } |
943 return kSupported; | 960 return kSupported; |
944 } | 961 } |
OLD | NEW |