diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 17:23:57 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 17:23:57 +0000 |
commit | 48c6d0d0d11c49d62925606812e50496b7893592 (patch) | |
tree | 26893543a76364c407e985b5acc84fe50f3202fd /mojo | |
parent | 9ac4b3aa68b70da5d4346a6f38dd704acb5b82c2 (diff) | |
download | chromium_src-48c6d0d0d11c49d62925606812e50496b7893592.zip chromium_src-48c6d0d0d11c49d62925606812e50496b7893592.tar.gz chromium_src-48c6d0d0d11c49d62925606812e50496b7893592.tar.bz2 |
Simplify Rect
Rects are now x, y, w, h, rather than point, size.
TBR=darin@chromium.org
BUG=none
Review URL: https://codereview.chromium.org/303743002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
8 files changed, 36 insertions, 35 deletions
diff --git a/mojo/aura/window_tree_host_mojo.cc b/mojo/aura/window_tree_host_mojo.cc index 477ebd8..115924f 100644 --- a/mojo/aura/window_tree_host_mojo.cc +++ b/mojo/aura/window_tree_host_mojo.cc @@ -139,8 +139,7 @@ void WindowTreeHostMojo::OnCreated() { } void WindowTreeHostMojo::OnBoundsChanged(const Rect& bounds) { - bounds_ = gfx::Rect(bounds.position().x(), bounds.position().y(), - bounds.size().width(), bounds.size().height()); + bounds_ = bounds; window()->SetBounds(gfx::Rect(bounds_.size())); OnHostResized(bounds_.size()); } diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc index db6e4e2..7209537 100644 --- a/mojo/examples/compositor_app/compositor_app.cc +++ b/mojo/examples/compositor_app/compositor_app.cc @@ -46,7 +46,11 @@ class SampleApp : public Application, public NativeViewportClient { } virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE { - host_->SetSize(bounds.size()); + AllocationScope scope; + Size::Builder size; + size.set_width(bounds.width()); + size.set_height(bounds.height()); + host_->SetSize(size.Finish()); } virtual void OnEvent(const Event& event, diff --git a/mojo/examples/pepper_container_app/pepper_container_app.cc b/mojo/examples/pepper_container_app/pepper_container_app.cc index 3d5bf31..33c03d5 100644 --- a/mojo/examples/pepper_container_app/pepper_container_app.cc +++ b/mojo/examples/pepper_container_app/pepper_container_app.cc @@ -41,14 +41,10 @@ class PepperContainerApp: public Application, viewport_.set_client(this); Rect::Builder rect; - Point::Builder point; - point.set_x(10); - point.set_y(10); - rect.set_position(point.Finish()); - Size::Builder size; - size.set_width(800); - size.set_height(600); - rect.set_size(size.Finish()); + rect.set_x(10); + rect.set_y(10); + rect.set_width(800); + rect.set_height(600); viewport_->Create(rect.Finish()); viewport_->Show(); } diff --git a/mojo/examples/pepper_container_app/type_converters.h b/mojo/examples/pepper_container_app/type_converters.h index 3938b6e..fc4c113 100644 --- a/mojo/examples/pepper_container_app/type_converters.h +++ b/mojo/examples/pepper_container_app/type_converters.h @@ -54,15 +54,16 @@ class TypeConverter<Rect, PP_Rect> { public: static Rect ConvertFrom(const PP_Rect& input, Buffer* buf) { Rect::Builder rect(buf); - rect.set_position(input.point); - rect.set_size(input.size); + rect.set_x(input.point.x); + rect.set_y(input.point.y); + rect.set_width(input.size.width); + rect.set_height(input.size.height); return rect.Finish(); } static PP_Rect ConvertTo(const Rect& input) { - PP_Rect rect = { input.position().To<PP_Point>(), - input.size().To<PP_Size>() }; - return rect; + return PP_MakeRectFromXYWH(input.x(), input.y(), + input.width(), input.height()); } MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); diff --git a/mojo/examples/sample_app/sample_app.cc b/mojo/examples/sample_app/sample_app.cc index 1be8073..2abeb6a 100644 --- a/mojo/examples/sample_app/sample_app.cc +++ b/mojo/examples/sample_app/sample_app.cc @@ -32,16 +32,11 @@ class SampleApp : public Application, public NativeViewportClient { viewport_.set_client(this); AllocationScope scope; - Rect::Builder rect; - Point::Builder point; - point.set_x(10); - point.set_y(10); - rect.set_position(point.Finish()); - Size::Builder size; - size.set_width(800); - size.set_height(600); - rect.set_size(size.Finish()); + rect.set_x(10); + rect.set_y(10); + rect.set_width(800); + rect.set_height(600); viewport_->Create(rect.Finish()); viewport_->Show(); @@ -58,7 +53,11 @@ class SampleApp : public Application, public NativeViewportClient { } virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE { - gles2_client_->SetSize(bounds.size()); + AllocationScope scope; + Size::Builder size; + size.set_width(bounds.width()); + size.set_height(bounds.height()); + gles2_client_->SetSize(size.Finish()); } virtual void OnEvent(const Event& event, diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc index f90cef3..9bec7eac 100644 --- a/mojo/services/native_viewport/native_viewport_service.cc +++ b/mojo/services/native_viewport/native_viewport_service.cc @@ -64,9 +64,8 @@ class NativeViewportImpl } virtual void SetBounds(const Rect& bounds) OVERRIDE { - gfx::Rect gfx_bounds(bounds.position().x(), bounds.position().y(), - bounds.size().width(), bounds.size().height()); - native_viewport_->SetBounds(gfx_bounds); + AllocationScope scope; + native_viewport_->SetBounds(bounds); } virtual void CreateGLES2Context(ScopedMessagePipeHandle client_handle) diff --git a/mojo/services/public/cpp/geometry/lib/geometry_type_converters.cc b/mojo/services/public/cpp/geometry/lib/geometry_type_converters.cc index 1111744..37a8c52 100644 --- a/mojo/services/public/cpp/geometry/lib/geometry_type_converters.cc +++ b/mojo/services/public/cpp/geometry/lib/geometry_type_converters.cc @@ -38,15 +38,16 @@ gfx::Size TypeConverter<Size, gfx::Size>::ConvertTo(const Size& input) { Rect TypeConverter<Rect, gfx::Rect>::ConvertFrom(const gfx::Rect& input, Buffer* buf) { Rect::Builder rect(buf); - rect.set_position(input.origin()); - rect.set_size(input.size()); + rect.set_x(input.x()); + rect.set_y(input.y()); + rect.set_width(input.width()); + rect.set_height(input.height()); return rect.Finish(); } // static gfx::Rect TypeConverter<Rect, gfx::Rect>::ConvertTo(const Rect& input) { - return gfx::Rect(input.position().x(), input.position().y(), - input.size().width(), input.size().height()); + return gfx::Rect(input.x(), input.y(), input.width(), input.height()); } } // namespace mojo diff --git a/mojo/services/public/interfaces/geometry/geometry.mojom b/mojo/services/public/interfaces/geometry/geometry.mojom index 3e7490f..62ceddd 100644 --- a/mojo/services/public/interfaces/geometry/geometry.mojom +++ b/mojo/services/public/interfaces/geometry/geometry.mojom @@ -15,8 +15,10 @@ struct Size { }; struct Rect { - Point position; - Size size; + int32 x; + int32 y; + int32 width; + int32 height; }; } |