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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 void GpuBlacklist::GetGpuFeatureFlagEntries( | 672 void GpuBlacklist::GetGpuFeatureFlagEntries( |
673 GpuFeatureFlags::GpuFeatureType feature, | 673 GpuFeatureFlags::GpuFeatureType feature, |
674 std::vector<uint32>& entry_ids) const { | 674 std::vector<uint32>& entry_ids) const { |
675 entry_ids.clear(); | 675 entry_ids.clear(); |
676 for (size_t i = 0; i < active_entries_.size(); ++i) { | 676 for (size_t i = 0; i < active_entries_.size(); ++i) { |
677 if ((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) | 677 if ((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) |
678 entry_ids.push_back(active_entries_[i]->id()); | 678 entry_ids.push_back(active_entries_[i]->id()); |
679 } | 679 } |
680 } | 680 } |
681 | 681 |
682 Value* GpuBlacklist::GetBlacklistingReasons() const { | 682 Value* GpuBlacklist::GetStatus() const { |
683 ListValue* reasons = new ListValue(); | 683 DictionaryValue* status = new DictionaryValue(); |
684 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
685 DictionaryValue* reason = new DictionaryValue(); | |
686 reason->SetString("description", active_entries_[i]->description()); | |
687 | 684 |
688 ListValue* cr_bugs = new ListValue(); | 685 // build the feature_status field |
689 for (size_t j = 0; j < active_entries_[i]->cr_bugs().size(); ++j) | 686 { |
690 cr_bugs->Append(Value::CreateIntegerValue( | 687 ListValue* feature_status_list = new ListValue(); |
691 active_entries_[i]->cr_bugs()[j])); | 688 // Iterate over all feature bits in kGpuFeatureAll and set feature status |
692 reason->Set("cr_bugs", cr_bugs); | 689 // for each one. |
690 for (size_t i = 0; i < sizeof(GpuFeatureFlags::GpuFeatureType) * 8; ++i) { | |
691 GpuFeatureFlags::GpuFeatureType feature = | |
692 static_cast<GpuFeatureFlags::GpuFeatureType>(1 << i); | |
693 if (!(feature & GpuFeatureFlags::kGpuFeatureAll)) | |
694 continue; | |
693 | 695 |
694 ListValue* webkit_bugs = new ListValue(); | 696 DictionaryValue* feature_status = new DictionaryValue(); |
695 for (size_t j = 0; j < active_entries_[i]->webkit_bugs().size(); ++j) | |
696 webkit_bugs->Append(Value::CreateIntegerValue( | |
697 active_entries_[i]->webkit_bugs()[j])); | |
698 reason->Set("webkit_bugs", webkit_bugs); | |
699 | 697 |
700 reasons->Append(reason); | 698 std::string feature_name( |
699 GpuFeatureFlags::GpuFeatureTypeToUserFriendlyString(feature)); | |
700 feature_status->SetString("name", feature_name); | |
701 | |
702 // figure out if the feature is on or off | |
703 bool flagged = false; | |
704 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
705 if (active_entries_[i]->GetGpuFeatureFlags().flags() & feature) | |
706 flagged |= true; | |
zmo
2011/04/07 20:46:06
should this be flagged = (flagged || true)? | and
| |
707 } | |
708 | |
709 feature_status->SetBoolean("enabled", !flagged); | |
710 | |
711 feature_status_list->Append(feature_status); | |
712 } | |
713 status->Set("featureStatus", feature_status_list); | |
701 } | 714 } |
702 return reasons; | 715 |
716 // build the problems list | |
717 { | |
718 ListValue* problem_list = new ListValue(); | |
719 for (size_t i = 0; i < active_entries_.size(); ++i) { | |
720 GpuBlacklistEntry* entry = active_entries_[i]; | |
721 DictionaryValue* problem = new DictionaryValue(); | |
722 | |
723 problem->SetString("description", entry->description()); | |
724 | |
725 ListValue* cr_bugs = new ListValue(); | |
726 for (size_t j = 0; j < entry->cr_bugs().size(); ++j) | |
727 cr_bugs->Append(Value::CreateIntegerValue( | |
728 entry->cr_bugs()[j])); | |
729 problem->Set("crBugs", cr_bugs); | |
730 | |
731 ListValue* webkit_bugs = new ListValue(); | |
732 for (size_t j = 0; j < entry->webkit_bugs().size(); ++j) | |
733 webkit_bugs->Append(Value::CreateIntegerValue( | |
734 entry->webkit_bugs()[j])); | |
735 problem->Set("webkitBugs", webkit_bugs); | |
736 | |
737 problem_list->Append(problem); | |
738 } | |
739 status->Set("problems", problem_list); | |
740 } | |
741 return status; | |
703 } | 742 } |
704 | 743 |
705 uint32 GpuBlacklist::max_entry_id() const { | 744 uint32 GpuBlacklist::max_entry_id() const { |
706 return max_entry_id_; | 745 return max_entry_id_; |
707 } | 746 } |
708 | 747 |
709 bool GpuBlacklist::GetVersion(uint16* major, uint16* minor) const { | 748 bool GpuBlacklist::GetVersion(uint16* major, uint16* minor) const { |
710 DCHECK(major && minor); | 749 DCHECK(major && minor); |
711 *major = 0; | 750 *major = 0; |
712 *minor = 0; | 751 *minor = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 return kOsUnknown; | 791 return kOsUnknown; |
753 #endif | 792 #endif |
754 } | 793 } |
755 | 794 |
756 void GpuBlacklist::Clear() { | 795 void GpuBlacklist::Clear() { |
757 for (size_t i = 0; i < blacklist_.size(); ++i) | 796 for (size_t i = 0; i < blacklist_.size(); ++i) |
758 delete blacklist_[i]; | 797 delete blacklist_[i]; |
759 blacklist_.clear(); | 798 blacklist_.clear(); |
760 active_entries_.clear(); | 799 active_entries_.clear(); |
761 } | 800 } |
OLD | NEW |