OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h" | 5 #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "mojo/common/common_custom_types_struct_traits.h" | 8 #include "mojo/common/common_custom_types_struct_traits.h" |
9 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" | 9 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" |
10 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" | 10 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "ui/base/cursor/cursor.h" | |
13 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | 12 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" |
14 | 13 |
15 namespace mojo { | 14 namespace mojo { |
16 | 15 |
17 // static | 16 // static |
18 ui::mojom::CursorType | 17 ui::mojom::CursorType |
19 EnumTraits<ui::mojom::CursorType, ui::CursorType>::ToMojom( | 18 EnumTraits<ui::mojom::CursorType, ui::CursorType>::ToMojom( |
20 ui::CursorType input) { | 19 ui::CursorType input) { |
21 switch (input) { | 20 switch (input) { |
22 case ui::CursorType::kNull: | 21 case ui::CursorType::kNull: |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 case ui::mojom::CursorType::kCustom: | 261 case ui::mojom::CursorType::kCustom: |
263 *out = ui::CursorType::kCustom; | 262 *out = ui::CursorType::kCustom; |
264 return true; | 263 return true; |
265 } | 264 } |
266 | 265 |
267 NOTREACHED(); | 266 NOTREACHED(); |
268 return false; | 267 return false; |
269 } | 268 } |
270 | 269 |
271 // static | 270 // static |
| 271 ui::mojom::CursorSet EnumTraits<ui::mojom::CursorSet, ui::CursorSet>::ToMojom( |
| 272 ui::CursorSet input) { |
| 273 switch (input) { |
| 274 case ui::CursorSet::kNormal: |
| 275 return ui::mojom::CursorSet::kNormal; |
| 276 case ui::CursorSet::kLarge: |
| 277 return ui::mojom::CursorSet::kLarge; |
| 278 } |
| 279 |
| 280 NOTREACHED(); |
| 281 return ui::mojom::CursorSet::kNormal; |
| 282 } |
| 283 |
| 284 // static |
| 285 bool EnumTraits<ui::mojom::CursorSet, ui::CursorSet>::FromMojom( |
| 286 ui::mojom::CursorSet input, |
| 287 ui::CursorSet* out) { |
| 288 switch (input) { |
| 289 case ui::mojom::CursorSet::kNormal: |
| 290 *out = ui::CursorSet::kNormal; |
| 291 return true; |
| 292 case ui::mojom::CursorSet::kLarge: |
| 293 *out = ui::CursorSet::kLarge; |
| 294 return true; |
| 295 } |
| 296 |
| 297 NOTREACHED(); |
| 298 return false; |
| 299 } |
| 300 |
| 301 // static |
272 const base::TimeDelta& | 302 const base::TimeDelta& |
273 StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::frame_delay( | 303 StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::frame_delay( |
274 const ui::CursorData& c) { | 304 const ui::CursorData& c) { |
275 return c.frame_delay(); | 305 return c.frame_delay(); |
276 } | 306 } |
277 | 307 |
278 // static | 308 // static |
279 const gfx::Point& | 309 const gfx::Point& |
280 StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::hotspot_in_pixels( | 310 StructTraits<ui::mojom::CursorDataDataView, ui::CursorData>::hotspot_in_pixels( |
281 const ui::CursorData& c) { | 311 const ui::CursorData& c) { |
(...skipping 30 matching lines...) Expand all Loading... |
312 !data.ReadFrameDelay(&frame_delay)) { | 342 !data.ReadFrameDelay(&frame_delay)) { |
313 return false; | 343 return false; |
314 } | 344 } |
315 | 345 |
316 *out = ui::CursorData(hotspot_in_pixels, cursor_frames, scale_factor, | 346 *out = ui::CursorData(hotspot_in_pixels, cursor_frames, scale_factor, |
317 frame_delay); | 347 frame_delay); |
318 return true; | 348 return true; |
319 } | 349 } |
320 | 350 |
321 } // namespace mojo | 351 } // namespace mojo |
OLD | NEW |