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

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

Issue 20667002: cc: Add frame data to LTHI tracing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 projected_length * destination.y()); 519 projected_length * destination.y());
520 } 520 }
521 521
522 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) { 522 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) {
523 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); 523 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
524 res->SetDouble("width", s.width()); 524 res->SetDouble("width", s.width());
525 res->SetDouble("height", s.height()); 525 res->SetDouble("height", s.height());
526 return res.PassAs<base::Value>(); 526 return res.PassAs<base::Value>();
527 } 527 }
528 528
529 scoped_ptr<base::Value> MathUtil::AsValue(gfx::SizeF s) {
530 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
531 res->SetDouble("width", s.width());
532 res->SetDouble("height", s.height());
533 return res.PassAs<base::Value>();
534 }
535
529 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) { 536 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) {
530 scoped_ptr<base::ListValue> res(new base::ListValue()); 537 scoped_ptr<base::ListValue> res(new base::ListValue());
531 res->AppendInteger(r.x()); 538 res->AppendInteger(r.x());
532 res->AppendInteger(r.y()); 539 res->AppendInteger(r.y());
533 res->AppendInteger(r.width()); 540 res->AppendInteger(r.width());
534 res->AppendInteger(r.height()); 541 res->AppendInteger(r.height());
535 return res.PassAs<base::Value>(); 542 return res.PassAs<base::Value>();
536 } 543 }
537 544
538 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { 545 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 585
579 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::RectF& rect) { 586 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::RectF& rect) {
580 scoped_ptr<base::ListValue> res(new base::ListValue()); 587 scoped_ptr<base::ListValue> res(new base::ListValue());
581 res->AppendDouble(rect.x()); 588 res->AppendDouble(rect.x());
582 res->AppendDouble(rect.y()); 589 res->AppendDouble(rect.y());
583 res->AppendDouble(rect.width()); 590 res->AppendDouble(rect.width());
584 res->AppendDouble(rect.height()); 591 res->AppendDouble(rect.height());
585 return res.PassAs<base::Value>(); 592 return res.PassAs<base::Value>();
586 } 593 }
587 594
595 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Transform& transform) {
596 scoped_ptr<base::ListValue> res(new base::ListValue());
597 const SkMatrix44& m = transform.matrix();
598 for (int row = 0; row < 3; ++row) {
599 for (int col = 0; col < 3; ++col)
600 res->AppendDouble(m.getDouble(row, col));
601 }
602 return res.PassAs<base::Value>();
603 }
604
588 scoped_ptr<base::Value> MathUtil::AsValueSafely(double value) { 605 scoped_ptr<base::Value> MathUtil::AsValueSafely(double value) {
589 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( 606 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
590 std::min(value, std::numeric_limits<double>::max()))); 607 std::min(value, std::numeric_limits<double>::max())));
591 } 608 }
592 609
593 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { 610 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) {
594 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( 611 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
595 std::min(value, std::numeric_limits<float>::max()))); 612 std::min(value, std::numeric_limits<float>::max())));
596 } 613 }
597 614
598 } // namespace cc 615 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/math_util.h ('k') | cc/output/filter_operation.h » ('j') | cc/output/filter_operation.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698