diff options
author | nduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-24 22:33:03 +0000 |
---|---|---|
committer | nduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-24 22:33:03 +0000 |
commit | dc5407d4f1f83a3004d38f42ca78880cb5bf616d (patch) | |
tree | 48e6f74041394b10a8cf86f12a67e19ab19dde77 /cc/base | |
parent | 0c53f82641e1ca6c9a741df6ba400eb11f649535 (diff) | |
download | chromium_src-dc5407d4f1f83a3004d38f42ca78880cb5bf616d.zip chromium_src-dc5407d4f1f83a3004d38f42ca78880cb5bf616d.tar.gz chromium_src-dc5407d4f1f83a3004d38f42ca78880cb5bf616d.tar.bz2 |
Store picture parameters outside the b64-encoded data
This will allow us to save skp files from js without having to round-trip
through C++ to strip out the header data.
NOTRY=True
Review URL: https://chromiumcodereview.appspot.com/15784007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202203 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base')
-rw-r--r-- | cc/base/math_util.cc | 21 | ||||
-rw-r--r-- | cc/base/math_util.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc index 4123cf8..c3c7b1c 100644 --- a/cc/base/math_util.cc +++ b/cc/base/math_util.cc @@ -535,6 +535,27 @@ scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) { return res.PassAs<base::Value>(); } +bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { + const ListValue* value = NULL; + if (!raw_value->GetAsList(&value)) + return false; + + if (value->GetSize() != 4) + return false; + + int x, y, w, h; + bool ok = true; + ok &= value->GetInteger(0, &x); + ok &= value->GetInteger(1, &y); + ok &= value->GetInteger(2, &w); + ok &= value->GetInteger(3, &h); + if (!ok) + return false; + + *out_rect = gfx::Rect(x, y, w, h); + return true; +} + scoped_ptr<base::Value> MathUtil::AsValue(gfx::PointF pt) { scoped_ptr<base::ListValue> res(new base::ListValue()); res->AppendDouble(pt.x()); diff --git a/cc/base/math_util.h b/cc/base/math_util.h index 4f9c644..69dd8d8 100644 --- a/cc/base/math_util.h +++ b/cc/base/math_util.h @@ -146,6 +146,7 @@ class CC_EXPORT MathUtil { // Conversion to value. static scoped_ptr<base::Value> AsValue(gfx::Size s); static scoped_ptr<base::Value> AsValue(gfx::Rect r); + static bool FromValue(const base::Value*, gfx::Rect* out_rect); static scoped_ptr<base::Value> AsValue(gfx::PointF q); static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); |