Index: services/ui/public/interfaces/cursor/cursor_struct_traits.cc |
diff --git a/services/ui/public/interfaces/cursor/cursor_struct_traits.cc b/services/ui/public/interfaces/cursor/cursor_struct_traits.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..464adfa13ca59d71a476252c4d65e90f8320a12d |
--- /dev/null |
+++ b/services/ui/public/interfaces/cursor/cursor_struct_traits.cc |
@@ -0,0 +1,44 @@ |
+// 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 "services/ui/public/interfaces/cursor/cursor_struct_traits.h" |
+ |
+#include "skia/public/interfaces/bitmap_array_struct_traits.h" |
+#include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" |
+#include "third_party/skia/include/core/SkBitmap.h" |
+#include "ui/base/cursor/cursor.h" |
+#include "ui/gfx/geometry/mojo/geometry_struct_traits.h" |
+ |
+namespace mojo { |
+ |
+// static |
+const std::vector<SkBitmap>& |
+StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::cursor_frames( |
+ const ui::CursorData& c) { |
+ return c.cursor_frames(); |
+} |
+ |
+// static |
+bool StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::Read( |
+ ui::mojom::CursorDataDataView data, |
+ ui::CursorData* out) { |
+ ui::mojom::CursorType type = data.native_type(); |
+ if (type != ui::mojom::CursorType::CUSTOM) { |
+ *out = ui::CursorData(static_cast<int>(type)); |
+ return true; |
+ } |
+ |
+ gfx::Point hotspot; |
+ std::vector<SkBitmap> cursor_frames; |
+ uint32_t frame_delay_ms = data.frame_delay_ms(); |
+ |
+ if (!data.ReadHotspot(&hotspot) || !data.ReadCursorFrames(&cursor_frames)) { |
sky
2017/03/31 04:57:57
no {}
Elliot Glaysher
2017/03/31 21:18:15
(now legitimately multiline.)
|
+ return false; |
+ } |
+ |
+ *out = ui::CursorData(hotspot, cursor_frames, frame_delay_ms); |
+ return true; |
+} |
+ |
+} // namespace mojo |