OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h" | |
6 | |
7 #include "skia/public/interfaces/bitmap_array_struct_traits.h" | |
8 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" | |
9 #include "third_party/skia/include/core/SkBitmap.h" | |
10 #include "ui/base/cursor/cursor.h" | |
11 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | |
12 | |
13 namespace mojo { | |
14 | |
15 // static | |
16 const std::vector<SkBitmap>& | |
17 StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::cursor_frames( | |
18 const ui::CursorData& c) { | |
19 return c.cursor_frames(); | |
20 } | |
21 | |
22 // static | |
23 bool StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::Read( | |
24 ui::mojom::CursorDataDataView data, | |
25 ui::CursorData* out) { | |
26 ui::mojom::CursorType type = data.native_type(); | |
27 if (type != ui::mojom::CursorType::CUSTOM) { | |
28 *out = ui::CursorData(static_cast<int>(type)); | |
29 return true; | |
30 } | |
31 | |
32 gfx::Point hotspot; | |
33 std::vector<SkBitmap> cursor_frames; | |
34 uint32_t frame_delay_ms = data.frame_delay_ms(); | |
35 | |
36 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.)
| |
37 return false; | |
38 } | |
39 | |
40 *out = ui::CursorData(hotspot, cursor_frames, frame_delay_ms); | |
41 return true; | |
42 } | |
43 | |
44 } // namespace mojo | |
OLD | NEW |