1 // Copyright 2016 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 #ifndef UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_ 6 #define UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_ 7 8 #include "ui/gfx/range/mojo/range.mojom-shared.h" 9 #include "ui/gfx/range/range.h" 10 #include "ui/gfx/range/range_f.h" 11 12 namespace mojo { 13 14 template <> 15 struct StructTraits<gfx::mojom::RangeDataView, gfx::Range> { 16 static uint32_t start(const gfx::Range& r) { return r.start(); } 17 static uint32_t end(const gfx::Range& r) { return r.end(); } 18 static bool Read(gfx::mojom::RangeDataView data, gfx::Range* out) { 19 out->set_start(data.start()); 20 out->set_end(data.end()); 21 return true; 22 } 23 }; 24 25 template <> 26 struct StructTraits<gfx::mojom::RangeFDataView, gfx::RangeF> { 27 static float start(const gfx::RangeF& r) { return r.start(); } 28 static float end(const gfx::RangeF& r) { return r.end(); } 29 static bool Read(gfx::mojom::RangeFDataView data, gfx::RangeF* out) { 30 out->set_start(data.start()); 31 out->set_end(data.end()); 32 return true; 33 } 34 }; 35 36 } // namespace mojo 37 38 #endif // UI_GFX_RANGE_MOJO_RANGE_STRUCT_TRAITS_H_ 39