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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/base/region.h » ('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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 char* name, 736 void MathUtil::AddToTracedValue(const char* name,
737 const gfx::Size& s, 737 const gfx::Size& s,
738 base::debug::TracedValue* res) { 738 base::trace_event::TracedValue* res) {
739 res->BeginDictionary(name); 739 res->BeginDictionary(name);
740 res->SetDouble("width", s.width()); 740 res->SetDouble("width", s.width());
741 res->SetDouble("height", s.height()); 741 res->SetDouble("height", s.height());
742 res->EndDictionary(); 742 res->EndDictionary();
743 } 743 }
744 744
745 void MathUtil::AddToTracedValue(const char* name, 745 void MathUtil::AddToTracedValue(const char* name,
746 const gfx::SizeF& s, 746 const gfx::SizeF& s,
747 base::debug::TracedValue* res) { 747 base::trace_event::TracedValue* res) {
748 res->BeginDictionary(name); 748 res->BeginDictionary(name);
749 res->SetDouble("width", s.width()); 749 res->SetDouble("width", s.width());
750 res->SetDouble("height", s.height()); 750 res->SetDouble("height", s.height());
751 res->EndDictionary(); 751 res->EndDictionary();
752 } 752 }
753 753
754 void MathUtil::AddToTracedValue(const char* name, 754 void MathUtil::AddToTracedValue(const char* name,
755 const gfx::Rect& r, 755 const gfx::Rect& r,
756 base::debug::TracedValue* res) { 756 base::trace_event::TracedValue* res) {
757 res->BeginArray(name); 757 res->BeginArray(name);
758 res->AppendInteger(r.x()); 758 res->AppendInteger(r.x());
759 res->AppendInteger(r.y()); 759 res->AppendInteger(r.y());
760 res->AppendInteger(r.width()); 760 res->AppendInteger(r.width());
761 res->AppendInteger(r.height()); 761 res->AppendInteger(r.height());
762 res->EndArray(); 762 res->EndArray();
763 } 763 }
764 764
765 void MathUtil::AddToTracedValue(const char* name, 765 void MathUtil::AddToTracedValue(const char* name,
766 const gfx::PointF& pt, 766 const gfx::PointF& pt,
767 base::debug::TracedValue* res) { 767 base::trace_event::TracedValue* res) {
768 res->BeginArray(name); 768 res->BeginArray(name);
769 res->AppendDouble(pt.x()); 769 res->AppendDouble(pt.x());
770 res->AppendDouble(pt.y()); 770 res->AppendDouble(pt.y());
771 res->EndArray(); 771 res->EndArray();
772 } 772 }
773 773
774 void MathUtil::AddToTracedValue(const char* name, 774 void MathUtil::AddToTracedValue(const char* name,
775 const gfx::Point3F& pt, 775 const gfx::Point3F& pt,
776 base::debug::TracedValue* res) { 776 base::trace_event::TracedValue* res) {
777 res->BeginArray(name); 777 res->BeginArray(name);
778 res->AppendDouble(pt.x()); 778 res->AppendDouble(pt.x());
779 res->AppendDouble(pt.y()); 779 res->AppendDouble(pt.y());
780 res->AppendDouble(pt.z()); 780 res->AppendDouble(pt.z());
781 res->EndArray(); 781 res->EndArray();
782 } 782 }
783 783
784 void MathUtil::AddToTracedValue(const char* name, 784 void MathUtil::AddToTracedValue(const char* name,
785 const gfx::Vector2d& v, 785 const gfx::Vector2d& v,
786 base::debug::TracedValue* res) { 786 base::trace_event::TracedValue* res) {
787 res->BeginArray(name); 787 res->BeginArray(name);
788 res->AppendInteger(v.x()); 788 res->AppendInteger(v.x());
789 res->AppendInteger(v.y()); 789 res->AppendInteger(v.y());
790 res->EndArray(); 790 res->EndArray();
791 } 791 }
792 792
793 void MathUtil::AddToTracedValue(const char* name, 793 void MathUtil::AddToTracedValue(const char* name,
794 const gfx::Vector2dF& v, 794 const gfx::Vector2dF& v,
795 base::debug::TracedValue* res) { 795 base::trace_event::TracedValue* res) {
796 res->BeginArray(name); 796 res->BeginArray(name);
797 res->AppendDouble(v.x()); 797 res->AppendDouble(v.x());
798 res->AppendDouble(v.y()); 798 res->AppendDouble(v.y());
799 res->EndArray(); 799 res->EndArray();
800 } 800 }
801 801
802 void MathUtil::AddToTracedValue(const char* name, 802 void MathUtil::AddToTracedValue(const char* name,
803 const gfx::ScrollOffset& v, 803 const gfx::ScrollOffset& v,
804 base::debug::TracedValue* res) { 804 base::trace_event::TracedValue* res) {
805 res->BeginArray(name); 805 res->BeginArray(name);
806 res->AppendDouble(v.x()); 806 res->AppendDouble(v.x());
807 res->AppendDouble(v.y()); 807 res->AppendDouble(v.y());
808 res->EndArray(); 808 res->EndArray();
809 } 809 }
810 810
811 void MathUtil::AddToTracedValue(const char* name, 811 void MathUtil::AddToTracedValue(const char* name,
812 const gfx::QuadF& q, 812 const gfx::QuadF& q,
813 base::debug::TracedValue* res) { 813 base::trace_event::TracedValue* res) {
814 res->BeginArray(name); 814 res->BeginArray(name);
815 res->AppendDouble(q.p1().x()); 815 res->AppendDouble(q.p1().x());
816 res->AppendDouble(q.p1().y()); 816 res->AppendDouble(q.p1().y());
817 res->AppendDouble(q.p2().x()); 817 res->AppendDouble(q.p2().x());
818 res->AppendDouble(q.p2().y()); 818 res->AppendDouble(q.p2().y());
819 res->AppendDouble(q.p3().x()); 819 res->AppendDouble(q.p3().x());
820 res->AppendDouble(q.p3().y()); 820 res->AppendDouble(q.p3().y());
821 res->AppendDouble(q.p4().x()); 821 res->AppendDouble(q.p4().x());
822 res->AppendDouble(q.p4().y()); 822 res->AppendDouble(q.p4().y());
823 res->EndArray(); 823 res->EndArray();
824 } 824 }
825 825
826 void MathUtil::AddToTracedValue(const char* name, 826 void MathUtil::AddToTracedValue(const char* name,
827 const gfx::RectF& rect, 827 const gfx::RectF& rect,
828 base::debug::TracedValue* res) { 828 base::trace_event::TracedValue* res) {
829 res->BeginArray(name); 829 res->BeginArray(name);
830 res->AppendDouble(rect.x()); 830 res->AppendDouble(rect.x());
831 res->AppendDouble(rect.y()); 831 res->AppendDouble(rect.y());
832 res->AppendDouble(rect.width()); 832 res->AppendDouble(rect.width());
833 res->AppendDouble(rect.height()); 833 res->AppendDouble(rect.height());
834 res->EndArray(); 834 res->EndArray();
835 } 835 }
836 836
837 void MathUtil::AddToTracedValue(const char* name, 837 void MathUtil::AddToTracedValue(const char* name,
838 const gfx::Transform& transform, 838 const gfx::Transform& transform,
839 base::debug::TracedValue* res) { 839 base::trace_event::TracedValue* res) {
840 res->BeginArray(name); 840 res->BeginArray(name);
841 const SkMatrix44& m = transform.matrix(); 841 const SkMatrix44& m = transform.matrix();
842 for (int row = 0; row < 4; ++row) { 842 for (int row = 0; row < 4; ++row) {
843 for (int col = 0; col < 4; ++col) 843 for (int col = 0; col < 4; ++col)
844 res->AppendDouble(m.getDouble(row, col)); 844 res->AppendDouble(m.getDouble(row, col));
845 } 845 }
846 res->EndArray(); 846 res->EndArray();
847 } 847 }
848 848
849 void MathUtil::AddToTracedValue(const char* name, 849 void MathUtil::AddToTracedValue(const char* name,
850 const gfx::BoxF& box, 850 const gfx::BoxF& box,
851 base::debug::TracedValue* res) { 851 base::trace_event::TracedValue* res) {
852 res->BeginArray(name); 852 res->BeginArray(name);
853 res->AppendInteger(box.x()); 853 res->AppendInteger(box.x());
854 res->AppendInteger(box.y()); 854 res->AppendInteger(box.y());
855 res->AppendInteger(box.z()); 855 res->AppendInteger(box.z());
856 res->AppendInteger(box.width()); 856 res->AppendInteger(box.width());
857 res->AppendInteger(box.height()); 857 res->AppendInteger(box.height());
858 res->AppendInteger(box.depth()); 858 res->AppendInteger(box.depth());
859 res->EndArray(); 859 res->EndArray();
860 } 860 }
861 861
862 double MathUtil::AsDoubleSafely(double value) { 862 double MathUtil::AsDoubleSafely(double value) {
863 return std::min(value, std::numeric_limits<double>::max()); 863 return std::min(value, std::numeric_limits<double>::max());
864 } 864 }
865 865
866 float MathUtil::AsFloatSafely(float value) { 866 float MathUtil::AsFloatSafely(float value) {
867 return std::min(value, std::numeric_limits<float>::max()); 867 return std::min(value, std::numeric_limits<float>::max());
868 } 868 }
869 869
870 } // namespace cc 870 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/math_util.h ('k') | cc/base/region.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698