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

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

Issue 20994007: Add impl/comp scrolling instrumentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 4 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
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "ui/gfx/quad_f.h" 12 #include "ui/gfx/quad_f.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/rect_conversions.h" 14 #include "ui/gfx/rect_conversions.h"
15 #include "ui/gfx/rect_f.h" 15 #include "ui/gfx/rect_f.h"
16 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
17 #include "ui/gfx/vector2d.h"
17 #include "ui/gfx/vector2d_f.h" 18 #include "ui/gfx/vector2d_f.h"
18 19
19 namespace cc { 20 namespace cc {
20 21
21 const double MathUtil::kPiDouble = 3.14159265358979323846; 22 const double MathUtil::kPiDouble = 3.14159265358979323846;
22 const float MathUtil::kPiFloat = 3.14159265358979323846f; 23 const float MathUtil::kPiFloat = 3.14159265358979323846f;
23 24
24 static HomogeneousCoordinate ProjectHomogeneousPoint( 25 static HomogeneousCoordinate ProjectHomogeneousPoint(
25 const gfx::Transform& transform, 26 const gfx::Transform& transform,
26 gfx::PointF p) { 27 gfx::PointF p) {
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 490
490 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) { 491 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) {
491 scoped_ptr<base::ListValue> res(new base::ListValue()); 492 scoped_ptr<base::ListValue> res(new base::ListValue());
492 res->AppendInteger(r.x()); 493 res->AppendInteger(r.x());
493 res->AppendInteger(r.y()); 494 res->AppendInteger(r.y());
494 res->AppendInteger(r.width()); 495 res->AppendInteger(r.width());
495 res->AppendInteger(r.height()); 496 res->AppendInteger(r.height());
496 return res.PassAs<base::Value>(); 497 return res.PassAs<base::Value>();
497 } 498 }
498 499
500 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Vector2d vec) {
501 scoped_ptr<base::ListValue> res(new base::ListValue());
502 res->AppendInteger(vec.x());
503 res->AppendInteger(vec.y());
504 return res.PassAs<base::Value>();
505 }
506
507 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Vector2dF vec) {
508 scoped_ptr<base::ListValue> res(new base::ListValue());
509 res->AppendDouble(vec.x());
510 res->AppendDouble(vec.y());
511 return res.PassAs<base::Value>();
512 }
513
499 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { 514 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) {
500 const base::ListValue* value = NULL; 515 const base::ListValue* value = NULL;
501 if (!raw_value->GetAsList(&value)) 516 if (!raw_value->GetAsList(&value))
502 return false; 517 return false;
503 518
504 if (value->GetSize() != 4) 519 if (value->GetSize() != 4)
505 return false; 520 return false;
506 521
507 int x, y, w, h; 522 int x, y, w, h;
508 bool ok = true; 523 bool ok = true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( 565 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
551 std::min(value, std::numeric_limits<double>::max()))); 566 std::min(value, std::numeric_limits<double>::max())));
552 } 567 }
553 568
554 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { 569 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) {
555 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( 570 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
556 std::min(value, std::numeric_limits<float>::max()))); 571 std::min(value, std::numeric_limits<float>::max())));
557 } 572 }
558 573
559 } // namespace cc 574 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/math_util.h ('k') | cc/layers/layer.cc » ('j') | cc/trees/layer_tree_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698