diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-21 19:07:40 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-21 19:07:40 +0000 |
commit | 7eb25d94230406a437e34acb7316b07135ae1ac0 (patch) | |
tree | 44da68548dab627baa22fbe438e6c3999c06428b | |
parent | cbf426d5c0530101898dd9b78f462041340f21a5 (diff) | |
download | chromium_src-7eb25d94230406a437e34acb7316b07135ae1ac0.zip chromium_src-7eb25d94230406a437e34acb7316b07135ae1ac0.tar.gz chromium_src-7eb25d94230406a437e34acb7316b07135ae1ac0.tar.bz2 |
Move geometry types to a more central location.
R=sky@chromium.org
BUG=
Review URL: https://codereview.chromium.org/298563003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271936 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | mojo/aura/window_tree_host_mojo.cc | 2 | ||||
-rw-r--r-- | mojo/examples/compositor_app/compositor_app.cc | 2 | ||||
-rw-r--r-- | mojo/geometry/DEPS | 3 | ||||
-rw-r--r-- | mojo/geometry/geometry_type_converters.cc | 52 | ||||
-rw-r--r-- | mojo/geometry/geometry_type_converters.h | 43 | ||||
-rw-r--r-- | mojo/geometry/mojo_geometry_export.h | 32 | ||||
-rw-r--r-- | mojo/mojo.gyp | 18 | ||||
-rw-r--r-- | mojo/mojo_examples.gypi | 8 | ||||
-rw-r--r-- | mojo/mojo_public.gypi | 17 | ||||
-rw-r--r-- | mojo/mojo_services.gypi | 6 | ||||
-rw-r--r-- | mojo/public/interfaces/geometry/geometry.mojom | 22 | ||||
-rw-r--r-- | mojo/services/native_viewport/DEPS | 1 | ||||
-rw-r--r-- | mojo/services/native_viewport/geometry_conversions.h | 64 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport.mojom | 17 | ||||
-rw-r--r-- | mojo/services/native_viewport/native_viewport_service.cc | 2 |
15 files changed, 206 insertions, 83 deletions
diff --git a/mojo/aura/window_tree_host_mojo.cc b/mojo/aura/window_tree_host_mojo.cc index 9aba1d8..e028e0c 100644 --- a/mojo/aura/window_tree_host_mojo.cc +++ b/mojo/aura/window_tree_host_mojo.cc @@ -5,9 +5,9 @@ #include "mojo/aura/window_tree_host_mojo.h" #include "mojo/aura/context_factory_mojo.h" +#include "mojo/geometry/geometry_type_converters.h" #include "mojo/public/c/gles2/gles2.h" #include "mojo/public/cpp/bindings/allocation_scope.h" -#include "mojo/services/native_viewport/geometry_conversions.h" #include "ui/aura/env.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc index 3339804..72de8cb 100644 --- a/mojo/examples/compositor_app/compositor_app.cc +++ b/mojo/examples/compositor_app/compositor_app.cc @@ -8,12 +8,12 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "mojo/examples/compositor_app/compositor_host.h" +#include "mojo/geometry/geometry_type_converters.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/gles2/gles2.h" #include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/interfaces/shell/shell.mojom.h" -#include "mojo/services/native_viewport/geometry_conversions.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" #include "ui/gfx/rect.h" diff --git a/mojo/geometry/DEPS b/mojo/geometry/DEPS new file mode 100644 index 0000000..194be1c --- /dev/null +++ b/mojo/geometry/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+ui/gfx/geometry", +] diff --git a/mojo/geometry/geometry_type_converters.cc b/mojo/geometry/geometry_type_converters.cc new file mode 100644 index 0000000..b01d249 --- /dev/null +++ b/mojo/geometry/geometry_type_converters.cc @@ -0,0 +1,52 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/geometry/geometry_type_converters.h" + +namespace mojo { + +// static +Point TypeConverter<Point, gfx::Point>::ConvertFrom(const gfx::Point& input, + Buffer* buf) { + Point::Builder point(buf); + point.set_x(input.x()); + point.set_y(input.y()); + return point.Finish(); +} + +// static +gfx::Point TypeConverter<Point, gfx::Point>::ConvertTo(const Point& input) { + return gfx::Point(input.x(), input.y()); +} + +// static +Size TypeConverter<Size, gfx::Size>::ConvertFrom(const gfx::Size& input, + Buffer* buf) { + Size::Builder size(buf); + size.set_width(input.width()); + size.set_height(input.height()); + return size.Finish(); +} + +// static +gfx::Size TypeConverter<Size, gfx::Size>::ConvertTo(const Size& input) { + return gfx::Size(input.width(), input.height()); +} + +// static +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()); + 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()); +} + +} // namespace mojo diff --git a/mojo/geometry/geometry_type_converters.h b/mojo/geometry/geometry_type_converters.h new file mode 100644 index 0000000..3905e76 --- /dev/null +++ b/mojo/geometry/geometry_type_converters.h @@ -0,0 +1,43 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MOJO_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_ +#define MOJO_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_ + +#include "mojo/geometry/mojo_geometry_export.h" +#include "mojo/public/interfaces/geometry/geometry.mojom.h" +#include "ui/gfx/geometry/rect.h" + +namespace mojo { + +template<> +class MOJO_GEOMETRY_EXPORT TypeConverter<Point, gfx::Point> { + public: + static Point ConvertFrom(const gfx::Point& input, Buffer* buf); + static gfx::Point ConvertTo(const Point& input); + + MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); +}; + +template<> +class MOJO_GEOMETRY_EXPORT TypeConverter<Size, gfx::Size> { + public: + static Size ConvertFrom(const gfx::Size& input, Buffer* buf); + static gfx::Size ConvertTo(const Size& input); + + MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); +}; + +template<> +class MOJO_GEOMETRY_EXPORT TypeConverter<Rect, gfx::Rect> { + public: + static Rect ConvertFrom(const gfx::Rect& input, Buffer* buf); + static gfx::Rect ConvertTo(const Rect& input); + + MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); +}; + +} // namespace mojo + +#endif // MOJO_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_ diff --git a/mojo/geometry/mojo_geometry_export.h b/mojo/geometry/mojo_geometry_export.h new file mode 100644 index 0000000..a6e64ce --- /dev/null +++ b/mojo/geometry/mojo_geometry_export.h @@ -0,0 +1,32 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MOJO_GEOMETRY_MOJO_GEOMETRY_EXPORT_H_ +#define MOJO_GEOMETRY_MOJO_GEOMETRY_EXPORT_H_ + +#if defined(COMPONENT_BUILD) + +#if defined(WIN32) + +#if defined(MOJO_GEOMETRY_IMPLEMENTATION) +#define MOJO_GEOMETRY_EXPORT __declspec(dllexport) +#else +#define MOJO_GEOMETRY_EXPORT __declspec(dllimport) +#endif + +#else // !defined(WIN32) + +#if defined(MOJO_GEOMETRY_IMPLEMENTATION) +#define MOJO_GEOMETRY_EXPORT __attribute__((visibility("default"))) +#else +#define MOJO_GEOMETRY_EXPORT +#endif + +#endif // defined(WIN32) + +#else // !defined(COMPONENT_BUILD) +#define MOJO_GEOMETRY_EXPORT +#endif + +#endif // MOJO_GEOMETRY_MOJO_GEOMETRY_EXPORT_H_ diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp index c9f74d8..3893b6b 100644 --- a/mojo/mojo.gyp +++ b/mojo/mojo.gyp @@ -33,6 +33,7 @@ 'mojo_common_lib', 'mojo_common_unittests', 'mojo_cpp_bindings', + 'mojo_geometry_lib', 'mojo_js', 'mojo_js_bindings', 'mojo_js_unittests', @@ -455,6 +456,23 @@ ], }, { + 'target_name': 'mojo_geometry_lib', + 'type': '<(component)', + 'defines': [ + 'MOJO_GEOMETRY_IMPLEMENTATION', + ], + 'dependencies': [ + '../ui/gfx/gfx.gyp:gfx_geometry', + 'mojo_environment_chromium', + 'mojo_geometry_bindings', + 'mojo_system_impl', + ], + 'sources': [ + 'geometry/geometry_type_converters.cc', + 'geometry/geometry_type_converters.h', + ], + }, + { 'target_name': 'mojo_shell_lib', 'type': 'static_library', 'dependencies': [ diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi index 6b49474..6c89be3 100644 --- a/mojo/mojo_examples.gypi +++ b/mojo/mojo_examples.gypi @@ -13,6 +13,7 @@ '../ui/gfx/gfx.gyp:gfx_geometry', 'mojo_cpp_bindings', 'mojo_environment_standalone', + 'mojo_geometry_bindings', 'mojo_gles2', 'mojo_native_viewport_bindings', 'mojo_shell_client', @@ -45,6 +46,8 @@ 'mojo_cc_support', 'mojo_common_lib', 'mojo_environment_chromium', + 'mojo_geometry_bindings', + 'mojo_geometry_lib', 'mojo_gles2', 'mojo_native_viewport_bindings', 'mojo_shell_client', @@ -74,6 +77,7 @@ '../ppapi/ppapi_internal.gyp:ppapi_example_gles2_spinning_cube', 'mojo_common_lib', 'mojo_environment_chromium', + 'mojo_geometry_bindings', 'mojo_gles2', 'mojo_native_viewport_bindings', 'mojo_shell_client', @@ -173,6 +177,8 @@ 'mojo_cc_support', 'mojo_common_lib', 'mojo_environment_chromium', + 'mojo_geometry_bindings', + 'mojo_geometry_lib', 'mojo_gles2', 'mojo_shell_client', 'mojo_system_impl' @@ -223,6 +229,8 @@ 'mojo_aura_support', 'mojo_common_lib', 'mojo_environment_chromium', + 'mojo_geometry_bindings', + 'mojo_geometry_lib', 'mojo_gles2', 'mojo_launcher_bindings', 'mojo_shell_client', diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi index e103472..4bee9a3 100644 --- a/mojo/mojo_public.gypi +++ b/mojo/mojo_public.gypi @@ -347,6 +347,23 @@ ], }, { + 'target_name': 'mojo_geometry_bindings', + 'type': 'static_library', + 'sources': [ + 'public/interfaces/geometry/geometry.mojom', + ], + 'variables': { + 'mojom_base_output_dir': 'mojo', + }, + 'includes': [ 'public/tools/bindings/mojom_bindings_generator.gypi' ], + 'dependencies': [ + 'mojo_cpp_bindings', + ], + 'export_dependent_settings': [ + 'mojo_cpp_bindings', + ], + }, + { 'target_name': 'mojo_shell_bindings', 'type': 'static_library', 'sources': [ diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi index f3433ab..3c7ddf4 100644 --- a/mojo/mojo_services.gypi +++ b/mojo/mojo_services.gypi @@ -72,6 +72,7 @@ 'mojo_cpp_bindings', ], 'dependencies': [ + 'mojo_geometry_bindings', 'mojo_cpp_bindings', ], }, @@ -86,6 +87,8 @@ '../ui/gfx/gfx.gyp:gfx_geometry', 'mojo_common_lib', 'mojo_environment_chromium', + 'mojo_geometry_bindings', + 'mojo_geometry_lib', 'mojo_gles2_service', 'mojo_native_viewport_bindings', 'mojo_shell_client', @@ -95,7 +98,6 @@ 'MOJO_NATIVE_VIEWPORT_IMPLEMENTATION', ], 'sources': [ - 'services/native_viewport/geometry_conversions.h', 'services/native_viewport/native_viewport.h', 'services/native_viewport/native_viewport_android.cc', 'services/native_viewport/native_viewport_mac.mm', @@ -221,6 +223,8 @@ 'mojo_aura_support', 'mojo_common_lib', 'mojo_environment_chromium', + 'mojo_geometry_bindings', + 'mojo_geometry_lib', 'mojo_gles2', 'mojo_launcher_bindings', 'mojo_native_viewport_bindings', diff --git a/mojo/public/interfaces/geometry/geometry.mojom b/mojo/public/interfaces/geometry/geometry.mojom new file mode 100644 index 0000000..3e7490f --- /dev/null +++ b/mojo/public/interfaces/geometry/geometry.mojom @@ -0,0 +1,22 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module mojo { + +struct Point { + int32 x; + int32 y; +}; + +struct Size { + int32 width; + int32 height; +}; + +struct Rect { + Point position; + Size size; +}; + +} diff --git a/mojo/services/native_viewport/DEPS b/mojo/services/native_viewport/DEPS index 6e465aa..b5edc8b 100644 --- a/mojo/services/native_viewport/DEPS +++ b/mojo/services/native_viewport/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+mojo/geometry", "+mojo/services/gles2", "+ui/events", "+ui/gfx", diff --git a/mojo/services/native_viewport/geometry_conversions.h b/mojo/services/native_viewport/geometry_conversions.h deleted file mode 100644 index 27e9c5a..0000000 --- a/mojo/services/native_viewport/geometry_conversions.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ -#define MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ - -#include "mojo/services/native_viewport/native_viewport.mojom.h" -#include "ui/gfx/rect.h" - -namespace mojo { - -template<> -class TypeConverter<Point, gfx::Point> { -public: - static Point ConvertFrom(const gfx::Point& input, Buffer* buf) { - Point::Builder point(buf); - point.set_x(input.x()); - point.set_y(input.y()); - return point.Finish(); - } - static gfx::Point ConvertTo(const Point& input) { - return gfx::Point(input.x(), input.y()); - } - - MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); -}; - -template<> -class TypeConverter<Size, gfx::Size> { -public: - static Size ConvertFrom(const gfx::Size& input, Buffer* buf) { - Size::Builder size(buf); - size.set_width(input.width()); - size.set_height(input.height()); - return size.Finish(); - } - static gfx::Size ConvertTo(const Size& input) { - return gfx::Size(input.width(), input.height()); - } - - MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); -}; - -template<> -class TypeConverter<Rect, gfx::Rect> { - public: - static Rect ConvertFrom(const gfx::Rect& input, Buffer* buf) { - Rect::Builder rect(buf); - rect.set_position(input.origin()); - rect.set_size(input.size()); - return rect.Finish(); - } - static gfx::Rect ConvertTo(const Rect& input) { - return gfx::Rect(input.position().x(), input.position().y(), - input.size().width(), input.size().height()); - } - - MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_NATIVE_VIEWPORT_GEOMETRY_CONVERSIONS_H_ diff --git a/mojo/services/native_viewport/native_viewport.mojom b/mojo/services/native_viewport/native_viewport.mojom index eef750c..8e0edb55 100644 --- a/mojo/services/native_viewport/native_viewport.mojom +++ b/mojo/services/native_viewport/native_viewport.mojom @@ -2,22 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -module mojo { - -struct Point { - float x; - float y; -}; +import "../../public/interfaces/geometry/geometry.mojom" -struct Size { - float width; - float height; -}; - -struct Rect { - Point position; - Size size; -}; +module mojo { struct KeyData { int32 key_code; diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc index 04f7c4c..4e339bf 100644 --- a/mojo/services/native_viewport/native_viewport_service.cc +++ b/mojo/services/native_viewport/native_viewport_service.cc @@ -7,10 +7,10 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/time/time.h" +#include "mojo/geometry/geometry_type_converters.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/interfaces/shell/shell.mojom.h" #include "mojo/services/gles2/command_buffer_impl.h" -#include "mojo/services/native_viewport/geometry_conversions.h" #include "mojo/services/native_viewport/native_viewport.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" #include "ui/events/event.h" |