size_conversions.cc 666 B

123456789101112131415161718192021222324
  1. // Copyright (c) 2012 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. #include "ui/gfx/geometry/size_conversions.h"
  5. #include "base/numerics/safe_conversions.h"
  6. namespace gfx {
  7. Size ToFlooredSize(const SizeF& size) {
  8. return Size(base::ClampFloor(size.width()), base::ClampFloor(size.height()));
  9. }
  10. Size ToCeiledSize(const SizeF& size) {
  11. return Size(base::ClampCeil(size.width()), base::ClampCeil(size.height()));
  12. }
  13. Size ToRoundedSize(const SizeF& size) {
  14. return Size(base::ClampRound(size.width()), base::ClampRound(size.height()));
  15. }
  16. } // namespace gfx