summaryrefslogtreecommitdiffstats
path: root/cc/base/math_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc/base/math_util.cc')
-rw-r--r--cc/base/math_util.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
index 39a183e..fa7b21a 100644
--- a/cc/base/math_util.cc
+++ b/cc/base/math_util.cc
@@ -487,6 +487,13 @@ scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) {
return res.PassAs<base::Value>();
}
+scoped_ptr<base::Value> MathUtil::AsValue(gfx::SizeF s) {
+ scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
+ res->SetDouble("width", s.width());
+ res->SetDouble("height", s.height());
+ return res.PassAs<base::Value>();
+}
+
scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) {
scoped_ptr<base::ListValue> res(new base::ListValue());
res->AppendInteger(r.x());
@@ -546,6 +553,16 @@ scoped_ptr<base::Value> MathUtil::AsValue(const gfx::RectF& rect) {
return res.PassAs<base::Value>();
}
+scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Transform& transform) {
+ scoped_ptr<base::ListValue> res(new base::ListValue());
+ 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));
+ }
+ return res.PassAs<base::Value>();
+}
+
scoped_ptr<base::Value> MathUtil::AsValueSafely(double value) {
return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
std::min(value, std::numeric_limits<double>::max())));