Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(897)

Unified Diff: ui/gfx/mojo/transform_struct_traits.h

Issue 2028573003: Implement gfx::Transform StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing build file Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/mojo/transform.typemap ('k') | ui/gfx/mojo/transform_type_converters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mojo/transform_struct_traits.h
diff --git a/ui/gfx/mojo/transform_struct_traits.h b/ui/gfx/mojo/transform_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..cdf36489bea48c9c7ffb82475650229464cc0724
--- /dev/null
+++ b/ui/gfx/mojo/transform_struct_traits.h
@@ -0,0 +1,34 @@
+// Copyright 2016 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_GFX_IPC_TRANSFORM_STRUCT_TRAITS_H_
+#define UI_GFX_IPC_TRANSFORM_STRUCT_TRAITS_H_
+
+#include "ui/gfx/mojo/transform.mojom.h"
+#include "ui/gfx/transform.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<gfx::mojom::Transform, gfx::Transform> {
+ static mojo::Array<float> matrix(const gfx::Transform& transform) {
+ std::vector<float> storage(16);
+ transform.matrix().asRowMajorf(&storage[0]);
+ mojo::Array<float> matrix;
+ matrix.Swap(&storage);
+ return matrix;
+ }
+
+ static bool Read(gfx::mojom::TransformDataView data, gfx::Transform* out) {
+ mojo::Array<float> matrix;
+ if (!data.ReadMatrix(&matrix))
+ return false;
+ out->matrix().setRowMajorf(&matrix.storage()[0]);
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // UI_GFX_IPC_TRANSFORM_STRUCT_TRAITS_H_
« no previous file with comments | « ui/gfx/mojo/transform.typemap ('k') | ui/gfx/mojo/transform_type_converters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698