aboutsummaryrefslogtreecommitdiff
path: root/ui/gfx/range/mojo/range_struct_traits.h
blob: e717d418c46fe148899cc0177ecb7bc90116d188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 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_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_
#define UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_

#include "ui/gfx/range/mojo/range.mojom-shared.h"
#include "ui/gfx/range/range.h"
#include "ui/gfx/range/range_f.h"

namespace mojo {

template <>
struct StructTraits<gfx::mojom::RangeDataView, gfx::Range> {
  static uint32_t start(const gfx::Range& r) { return r.start(); }
  static uint32_t end(const gfx::Range& r) { return r.end(); }
  static bool Read(gfx::mojom::RangeDataView data, gfx::Range* out) {
    out->set_start(data.start());
    out->set_end(data.end());
    return true;
  }
};

template <>
struct StructTraits<gfx::mojom::RangeFDataView, gfx::RangeF> {
  static float start(const gfx::RangeF& r) { return r.start(); }
  static float end(const gfx::RangeF& r) { return r.end(); }
  static bool Read(gfx::mojom::RangeFDataView data, gfx::RangeF* out) {
    out->set_start(data.start());
    out->set_end(data.end());
    return true;
  }
};

}  // namespace mojo

#endif  // UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_