summaryrefslogtreecommitdiff
path: root/chromium/ui/gfx/geometry/insets_conversions.cc
blob: e41a600b5e55535b2a4b3c3bf7e907e35e8a3483 (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
// Copyright 2020 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 "ui/gfx/geometry/insets_conversions.h"

#include "base/numerics/safe_conversions.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/insets_f.h"

namespace gfx {

Insets ToFlooredInsets(const InsetsF& insets) {
  return Insets(base::ClampFloor(insets.top()), base::ClampFloor(insets.left()),
                base::ClampFloor(insets.bottom()),
                base::ClampFloor(insets.right()));
}

Insets ToCeiledInsets(const InsetsF& insets) {
  return Insets(base::ClampCeil(insets.top()), base::ClampCeil(insets.left()),
                base::ClampCeil(insets.bottom()),
                base::ClampCeil(insets.right()));
}

Insets ToRoundedInsets(const InsetsF& insets) {
  return Insets(base::ClampRound(insets.top()), base::ClampRound(insets.left()),
                base::ClampRound(insets.bottom()),
                base::ClampRound(insets.right()));
}

}  // namespace gfx