Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: cc/base/math_util.cc

Issue 853393002: cc: refactor of MathUtil::AddToTracedValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/base/math_util.h ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/base/math_util.h" 5 #include "cc/base/math_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 return true; 726 return true;
727 } 727 }
728 728
729 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::PointF& pt) { 729 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::PointF& pt) {
730 scoped_ptr<base::ListValue> res(new base::ListValue()); 730 scoped_ptr<base::ListValue> res(new base::ListValue());
731 res->AppendDouble(pt.x()); 731 res->AppendDouble(pt.x());
732 res->AppendDouble(pt.y()); 732 res->AppendDouble(pt.y());
733 return res.Pass(); 733 return res.Pass();
734 } 734 }
735 735
736 void MathUtil::AddToTracedValue(const gfx::Size& s, 736 void MathUtil::AddToTracedValue(const char* name,
737 const gfx::Size& s,
737 base::debug::TracedValue* res) { 738 base::debug::TracedValue* res) {
739 res->BeginDictionary(name);
738 res->SetDouble("width", s.width()); 740 res->SetDouble("width", s.width());
739 res->SetDouble("height", s.height()); 741 res->SetDouble("height", s.height());
742 res->EndDictionary();
740 } 743 }
741 744
742 void MathUtil::AddToTracedValue(const gfx::SizeF& s, 745 void MathUtil::AddToTracedValue(const char* name,
746 const gfx::SizeF& s,
743 base::debug::TracedValue* res) { 747 base::debug::TracedValue* res) {
748 res->BeginDictionary(name);
744 res->SetDouble("width", s.width()); 749 res->SetDouble("width", s.width());
745 res->SetDouble("height", s.height()); 750 res->SetDouble("height", s.height());
751 res->EndDictionary();
746 } 752 }
747 753
748 void MathUtil::AddToTracedValue(const gfx::Rect& r, 754 void MathUtil::AddToTracedValue(const char* name,
755 const gfx::Rect& r,
749 base::debug::TracedValue* res) { 756 base::debug::TracedValue* res) {
757 res->BeginArray(name);
750 res->AppendInteger(r.x()); 758 res->AppendInteger(r.x());
751 res->AppendInteger(r.y()); 759 res->AppendInteger(r.y());
752 res->AppendInteger(r.width()); 760 res->AppendInteger(r.width());
753 res->AppendInteger(r.height()); 761 res->AppendInteger(r.height());
762 res->EndArray();
754 } 763 }
755 764
756 void MathUtil::AddToTracedValue(const gfx::PointF& pt, 765 void MathUtil::AddToTracedValue(const char* name,
766 const gfx::PointF& pt,
757 base::debug::TracedValue* res) { 767 base::debug::TracedValue* res) {
768 res->BeginArray(name);
758 res->AppendDouble(pt.x()); 769 res->AppendDouble(pt.x());
759 res->AppendDouble(pt.y()); 770 res->AppendDouble(pt.y());
771 res->EndArray();
760 } 772 }
761 773
762 void MathUtil::AddToTracedValue(const gfx::Point3F& pt, 774 void MathUtil::AddToTracedValue(const char* name,
775 const gfx::Point3F& pt,
763 base::debug::TracedValue* res) { 776 base::debug::TracedValue* res) {
777 res->BeginArray(name);
764 res->AppendDouble(pt.x()); 778 res->AppendDouble(pt.x());
765 res->AppendDouble(pt.y()); 779 res->AppendDouble(pt.y());
766 res->AppendDouble(pt.z()); 780 res->AppendDouble(pt.z());
781 res->EndArray();
767 } 782 }
768 783
769 void MathUtil::AddToTracedValue(const gfx::Vector2d& v, 784 void MathUtil::AddToTracedValue(const char* name,
785 const gfx::Vector2d& v,
770 base::debug::TracedValue* res) { 786 base::debug::TracedValue* res) {
787 res->BeginArray(name);
771 res->AppendInteger(v.x()); 788 res->AppendInteger(v.x());
772 res->AppendInteger(v.y()); 789 res->AppendInteger(v.y());
790 res->EndArray();
773 } 791 }
774 792
775 void MathUtil::AddToTracedValue(const gfx::Vector2dF& v, 793 void MathUtil::AddToTracedValue(const char* name,
794 const gfx::Vector2dF& v,
776 base::debug::TracedValue* res) { 795 base::debug::TracedValue* res) {
796 res->BeginArray(name);
777 res->AppendDouble(v.x()); 797 res->AppendDouble(v.x());
778 res->AppendDouble(v.y()); 798 res->AppendDouble(v.y());
799 res->EndArray();
779 } 800 }
780 801
781 void MathUtil::AddToTracedValue(const gfx::ScrollOffset& v, 802 void MathUtil::AddToTracedValue(const char* name,
803 const gfx::ScrollOffset& v,
782 base::debug::TracedValue* res) { 804 base::debug::TracedValue* res) {
805 res->BeginArray(name);
783 res->AppendDouble(v.x()); 806 res->AppendDouble(v.x());
784 res->AppendDouble(v.y()); 807 res->AppendDouble(v.y());
808 res->EndArray();
785 } 809 }
786 810
787 void MathUtil::AddToTracedValue(const gfx::QuadF& q, 811 void MathUtil::AddToTracedValue(const char* name,
812 const gfx::QuadF& q,
788 base::debug::TracedValue* res) { 813 base::debug::TracedValue* res) {
814 res->BeginArray(name);
789 res->AppendDouble(q.p1().x()); 815 res->AppendDouble(q.p1().x());
790 res->AppendDouble(q.p1().y()); 816 res->AppendDouble(q.p1().y());
791 res->AppendDouble(q.p2().x()); 817 res->AppendDouble(q.p2().x());
792 res->AppendDouble(q.p2().y()); 818 res->AppendDouble(q.p2().y());
793 res->AppendDouble(q.p3().x()); 819 res->AppendDouble(q.p3().x());
794 res->AppendDouble(q.p3().y()); 820 res->AppendDouble(q.p3().y());
795 res->AppendDouble(q.p4().x()); 821 res->AppendDouble(q.p4().x());
796 res->AppendDouble(q.p4().y()); 822 res->AppendDouble(q.p4().y());
823 res->EndArray();
797 } 824 }
798 825
799 void MathUtil::AddToTracedValue(const gfx::RectF& rect, 826 void MathUtil::AddToTracedValue(const char* name,
827 const gfx::RectF& rect,
800 base::debug::TracedValue* res) { 828 base::debug::TracedValue* res) {
829 res->BeginArray(name);
801 res->AppendDouble(rect.x()); 830 res->AppendDouble(rect.x());
802 res->AppendDouble(rect.y()); 831 res->AppendDouble(rect.y());
803 res->AppendDouble(rect.width()); 832 res->AppendDouble(rect.width());
804 res->AppendDouble(rect.height()); 833 res->AppendDouble(rect.height());
834 res->EndArray();
805 } 835 }
806 836
807 void MathUtil::AddToTracedValue(const gfx::Transform& transform, 837 void MathUtil::AddToTracedValue(const char* name,
838 const gfx::Transform& transform,
808 base::debug::TracedValue* res) { 839 base::debug::TracedValue* res) {
840 res->BeginArray(name);
809 const SkMatrix44& m = transform.matrix(); 841 const SkMatrix44& m = transform.matrix();
810 for (int row = 0; row < 4; ++row) { 842 for (int row = 0; row < 4; ++row) {
811 for (int col = 0; col < 4; ++col) 843 for (int col = 0; col < 4; ++col)
812 res->AppendDouble(m.getDouble(row, col)); 844 res->AppendDouble(m.getDouble(row, col));
813 } 845 }
846 res->EndArray();
814 } 847 }
815 848
816 void MathUtil::AddToTracedValue(const gfx::BoxF& box, 849 void MathUtil::AddToTracedValue(const char* name,
850 const gfx::BoxF& box,
817 base::debug::TracedValue* res) { 851 base::debug::TracedValue* res) {
852 res->BeginArray(name);
818 res->AppendInteger(box.x()); 853 res->AppendInteger(box.x());
819 res->AppendInteger(box.y()); 854 res->AppendInteger(box.y());
820 res->AppendInteger(box.z()); 855 res->AppendInteger(box.z());
821 res->AppendInteger(box.width()); 856 res->AppendInteger(box.width());
822 res->AppendInteger(box.height()); 857 res->AppendInteger(box.height());
823 res->AppendInteger(box.depth()); 858 res->AppendInteger(box.depth());
859 res->EndArray();
824 } 860 }
825 861
826 double MathUtil::AsDoubleSafely(double value) { 862 double MathUtil::AsDoubleSafely(double value) {
827 return std::min(value, std::numeric_limits<double>::max()); 863 return std::min(value, std::numeric_limits<double>::max());
828 } 864 }
829 865
830 float MathUtil::AsFloatSafely(float value) { 866 float MathUtil::AsFloatSafely(float value) {
831 return std::min(value, std::numeric_limits<float>::max()); 867 return std::min(value, std::numeric_limits<float>::max());
832 } 868 }
833 869
834 } // namespace cc 870 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/math_util.h ('k') | cc/layers/layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698