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

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

Issue 394193003: Implement HiDPI and pinch-zoom scaling of filter params (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unittests Created 6 years, 5 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 | Annotate | Revision Log
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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 return res.PassAs<base::Value>(); 599 return res.PassAs<base::Value>();
600 } 600 }
601 601
602 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Vector2d& v) { 602 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Vector2d& v) {
603 scoped_ptr<base::ListValue> res(new base::ListValue()); 603 scoped_ptr<base::ListValue> res(new base::ListValue());
604 res->AppendInteger(v.x()); 604 res->AppendInteger(v.x());
605 res->AppendInteger(v.y()); 605 res->AppendInteger(v.y());
606 return res.PassAs<base::Value>(); 606 return res.PassAs<base::Value>();
607 } 607 }
608 608
609 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Vector2dF& v) {
610 scoped_ptr<base::ListValue> res(new base::ListValue());
611 res->AppendDouble(v.x());
612 res->AppendDouble(v.y());
613 return res.PassAs<base::Value>();
614 }
615
609 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::QuadF& q) { 616 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::QuadF& q) {
610 scoped_ptr<base::ListValue> res(new base::ListValue()); 617 scoped_ptr<base::ListValue> res(new base::ListValue());
611 res->AppendDouble(q.p1().x()); 618 res->AppendDouble(q.p1().x());
612 res->AppendDouble(q.p1().y()); 619 res->AppendDouble(q.p1().y());
613 res->AppendDouble(q.p2().x()); 620 res->AppendDouble(q.p2().x());
614 res->AppendDouble(q.p2().y()); 621 res->AppendDouble(q.p2().y());
615 res->AppendDouble(q.p3().x()); 622 res->AppendDouble(q.p3().x());
616 res->AppendDouble(q.p3().y()); 623 res->AppendDouble(q.p3().y());
617 res->AppendDouble(q.p4().x()); 624 res->AppendDouble(q.p4().x());
618 res->AppendDouble(q.p4().y()); 625 res->AppendDouble(q.p4().y());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 return scoped_ptr<base::Value>(new base::FundamentalValue( 660 return scoped_ptr<base::Value>(new base::FundamentalValue(
654 std::min(value, std::numeric_limits<double>::max()))); 661 std::min(value, std::numeric_limits<double>::max())));
655 } 662 }
656 663
657 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { 664 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) {
658 return scoped_ptr<base::Value>(new base::FundamentalValue( 665 return scoped_ptr<base::Value>(new base::FundamentalValue(
659 std::min(value, std::numeric_limits<float>::max()))); 666 std::min(value, std::numeric_limits<float>::max())));
660 } 667 }
661 668
662 } // namespace cc 669 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698