summaryrefslogtreecommitdiff
path: root/chromium/ui/events/devices/mojo
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/events/devices/mojo')
-rw-r--r--chromium/ui/events/devices/mojo/BUILD.gn2
-rw-r--r--chromium/ui/events/devices/mojo/OWNERS3
-rw-r--r--chromium/ui/events/devices/mojo/touch_device_transform.mojom14
-rw-r--r--chromium/ui/events/devices/mojo/touch_device_transform.typemap14
-rw-r--r--chromium/ui/events/devices/mojo/touch_device_transform_struct_traits.h46
-rw-r--r--chromium/ui/events/devices/mojo/touch_device_transform_struct_traits_unittest.cc30
-rw-r--r--chromium/ui/events/devices/mojo/typemaps.gni5
7 files changed, 113 insertions, 1 deletions
diff --git a/chromium/ui/events/devices/mojo/BUILD.gn b/chromium/ui/events/devices/mojo/BUILD.gn
index fe65d7d1973..ee7bc482818 100644
--- a/chromium/ui/events/devices/mojo/BUILD.gn
+++ b/chromium/ui/events/devices/mojo/BUILD.gn
@@ -7,10 +7,12 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojo") {
sources = [
"input_devices.mojom",
+ "touch_device_transform.mojom",
]
public_deps = [
"//ui/gfx/geometry/mojo",
+ "//ui/gfx/mojo",
]
}
diff --git a/chromium/ui/events/devices/mojo/OWNERS b/chromium/ui/events/devices/mojo/OWNERS
index 1841ff6198d..e75daf744a0 100644
--- a/chromium/ui/events/devices/mojo/OWNERS
+++ b/chromium/ui/events/devices/mojo/OWNERS
@@ -3,3 +3,6 @@ per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
+
+per-file *.typemap=set noparent
+per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/events/devices/mojo/touch_device_transform.mojom b/chromium/ui/events/devices/mojo/touch_device_transform.mojom
new file mode 100644
index 00000000000..5b8e9c23f5d
--- /dev/null
+++ b/chromium/ui/events/devices/mojo/touch_device_transform.mojom
@@ -0,0 +1,14 @@
+// Copyright 2017 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 ui.mojom;
+
+import "ui/gfx/mojo/transform.mojom";
+
+struct TouchDeviceTransform {
+ int64 display_id;
+ int32 device_id;
+ gfx.mojom.Transform transform;
+ double radius_scale;
+};
diff --git a/chromium/ui/events/devices/mojo/touch_device_transform.typemap b/chromium/ui/events/devices/mojo/touch_device_transform.typemap
new file mode 100644
index 00000000000..689eb3b1e3b
--- /dev/null
+++ b/chromium/ui/events/devices/mojo/touch_device_transform.typemap
@@ -0,0 +1,14 @@
+# Copyright 2017 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.
+
+mojom = "//ui/events/devices/mojo/touch_device_transform.mojom"
+public_headers = [ "//ui/events/devices/touch_device_transform.h" ]
+traits_headers =
+ [ "//ui/events/devices/mojo/touch_device_transform_struct_traits.h" ]
+deps = []
+public_deps = [
+ "//ui/gfx",
+ "//ui/gfx/mojo",
+]
+type_mappings = [ "ui.mojom.TouchDeviceTransform=ui::TouchDeviceTransform" ]
diff --git a/chromium/ui/events/devices/mojo/touch_device_transform_struct_traits.h b/chromium/ui/events/devices/mojo/touch_device_transform_struct_traits.h
new file mode 100644
index 00000000000..b9dd4506cbf
--- /dev/null
+++ b/chromium/ui/events/devices/mojo/touch_device_transform_struct_traits.h
@@ -0,0 +1,46 @@
+// Copyright 2017 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 UI_DISPLAY_MANAGER_CHROMEOS_MOJO_TOUCH_DEVICE_TRANSFORM_STRUCT_TRAITS_H_
+#define UI_DISPLAY_MANAGER_CHROMEOS_MOJO_TOUCH_DEVICE_TRANSFORM_STRUCT_TRAITS_H_
+
+#include <stdint.h>
+
+#include "ui/events/devices/mojo/touch_device_transform.mojom.h"
+#include "ui/events/devices/touch_device_transform.h"
+#include "ui/gfx/mojo/transform_struct_traits.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<ui::mojom::TouchDeviceTransformDataView,
+ ui::TouchDeviceTransform> {
+ public:
+ static int64_t display_id(const ui::TouchDeviceTransform& r) {
+ return r.display_id;
+ }
+ static int32_t device_id(const ui::TouchDeviceTransform& r) {
+ return r.device_id;
+ }
+ static const gfx::Transform& transform(const ui::TouchDeviceTransform& r) {
+ return r.transform;
+ }
+ static double radius_scale(const ui::TouchDeviceTransform& r) {
+ return r.radius_scale;
+ }
+
+ static bool Read(ui::mojom::TouchDeviceTransformDataView data,
+ ui::TouchDeviceTransform* out) {
+ out->display_id = data.display_id();
+ out->device_id = data.device_id();
+ if (!data.ReadTransform(&(out->transform)))
+ return false;
+ out->radius_scale = data.radius_scale();
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // UI_DISPLAY_MANAGER_CHROMEOS_MOJO_TOUCH_DEVICE_TRANSFORM_STRUCT_TRAITS_H_
diff --git a/chromium/ui/events/devices/mojo/touch_device_transform_struct_traits_unittest.cc b/chromium/ui/events/devices/mojo/touch_device_transform_struct_traits_unittest.cc
new file mode 100644
index 00000000000..c9453d5cd83
--- /dev/null
+++ b/chromium/ui/events/devices/mojo/touch_device_transform_struct_traits_unittest.cc
@@ -0,0 +1,30 @@
+// Copyright 2017 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 "ui/events/devices/mojo/touch_device_transform_struct_traits.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/events/devices/mojo/touch_device_transform.mojom.h"
+#include "ui/events/devices/touch_device_transform.h"
+
+namespace ui {
+
+TEST(TouchDeviceTransformStructTraitsTest, SerializeAndDeserialize) {
+ TouchDeviceTransform touch_device_transform;
+ touch_device_transform.display_id = 101;
+ touch_device_transform.device_id = 202;
+ touch_device_transform.transform =
+ gfx::Transform(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+ touch_device_transform.radius_scale = 4;
+ TouchDeviceTransform deserialized;
+ ASSERT_TRUE(mojom::TouchDeviceTransform::Deserialize(
+ mojom::TouchDeviceTransform::Serialize(&touch_device_transform),
+ &deserialized));
+ EXPECT_EQ(touch_device_transform.display_id, deserialized.display_id);
+ EXPECT_EQ(touch_device_transform.device_id, deserialized.device_id);
+ EXPECT_EQ(touch_device_transform.transform, deserialized.transform);
+ EXPECT_EQ(touch_device_transform.radius_scale, deserialized.radius_scale);
+}
+
+} // namespace ui
diff --git a/chromium/ui/events/devices/mojo/typemaps.gni b/chromium/ui/events/devices/mojo/typemaps.gni
index 7ce719ad827..727e53fcf73 100644
--- a/chromium/ui/events/devices/mojo/typemaps.gni
+++ b/chromium/ui/events/devices/mojo/typemaps.gni
@@ -2,4 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-typemaps = [ "//ui/events/devices/mojo/input_device.typemap" ]
+typemaps = [
+ "//ui/events/devices/mojo/input_device.typemap",
+ "//ui/events/devices/mojo/touch_device_transform.typemap",
+]