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

Unified Diff: cc/base/math_util.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: cc/base/math_util.cc
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
index 07ad77bd7703d8fc2ed7768858044a7a9b348688..0953c2a308a1db79311fafc966000176de9f7442 100644
--- a/cc/base/math_util.cc
+++ b/cc/base/math_util.cc
@@ -8,6 +8,7 @@
#include <cmath>
#include <limits>
+#include "base/debug/trace_event_argument.h"
#include "base/values.h"
#include "ui/gfx/quad_f.h"
#include "ui/gfx/rect.h"
@@ -649,6 +650,84 @@ scoped_ptr<base::Value> MathUtil::AsValue(const gfx::BoxF& box) {
return res.PassAs<base::Value>();
}
+void MathUtil::AddToTracedValue(const gfx::Size& s,
+ base::debug::TracedValue* res) {
+ res->SetDouble("width", s.width());
+ res->SetDouble("height", s.height());
+}
+
+void MathUtil::AddToTracedValue(const gfx::SizeF& s,
+ base::debug::TracedValue* res) {
+ res->SetDouble("width", s.width());
+ res->SetDouble("height", s.height());
+}
+
+void MathUtil::AddToTracedValue(const gfx::Rect& r,
+ base::debug::TracedValue* res) {
+ res->AppendInteger(r.x());
+ res->AppendInteger(r.y());
+ res->AppendInteger(r.width());
+ res->AppendInteger(r.height());
+}
+
+void MathUtil::AddToTracedValue(const gfx::PointF& pt,
+ base::debug::TracedValue* res) {
+ res->AppendDouble(pt.x());
+ res->AppendDouble(pt.y());
+}
+
+void MathUtil::AddToTracedValue(const gfx::Point3F& pt,
+ base::debug::TracedValue* res) {
+ res->AppendDouble(pt.x());
+ res->AppendDouble(pt.y());
+ res->AppendDouble(pt.z());
+}
+
+void MathUtil::AddToTracedValue(const gfx::Vector2d& v,
+ base::debug::TracedValue* res) {
+ res->AppendInteger(v.x());
+ res->AppendInteger(v.y());
+}
+
+void MathUtil::AddToTracedValue(const gfx::QuadF& q,
+ base::debug::TracedValue* res) {
+ res->AppendDouble(q.p1().x());
+ res->AppendDouble(q.p1().y());
+ res->AppendDouble(q.p2().x());
+ res->AppendDouble(q.p2().y());
+ res->AppendDouble(q.p3().x());
+ res->AppendDouble(q.p3().y());
+ res->AppendDouble(q.p4().x());
+ res->AppendDouble(q.p4().y());
+}
+
+void MathUtil::AddToTracedValue(const gfx::RectF& rect,
+ base::debug::TracedValue* res) {
+ res->AppendDouble(rect.x());
+ res->AppendDouble(rect.y());
+ res->AppendDouble(rect.width());
+ res->AppendDouble(rect.height());
+}
+
+void MathUtil::AddToTracedValue(const gfx::Transform& transform,
+ base::debug::TracedValue* res) {
+ const SkMatrix44& m = transform.matrix();
+ for (int row = 0; row < 4; ++row) {
+ for (int col = 0; col < 4; ++col)
+ res->AppendDouble(m.getDouble(row, col));
+ }
+}
+
+void MathUtil::AddToTracedValue(const gfx::BoxF& box,
+ base::debug::TracedValue* res) {
+ res->AppendInteger(box.x());
+ res->AppendInteger(box.y());
+ res->AppendInteger(box.z());
+ res->AppendInteger(box.width());
+ res->AppendInteger(box.height());
+ res->AppendInteger(box.depth());
+}
+
scoped_ptr<base::Value> MathUtil::AsValueSafely(double value) {
return scoped_ptr<base::Value>(new base::FundamentalValue(
std::min(value, std::numeric_limits<double>::max())));
@@ -659,4 +738,12 @@ scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) {
std::min(value, std::numeric_limits<float>::max())));
}
+double MathUtil::AsDoubleSafely(double value) {
+ return std::min(value, std::numeric_limits<double>::max());
+}
+
+float MathUtil::AsFloatSafely(float value) {
+ return std::min(value, std::numeric_limits<float>::max());
+}
+
} // namespace cc
« cc/base/math_util.h ('K') | « 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