uikit_util.mm 583 B

1234567891011121314151617181920212223
  1. // Copyright 2014 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/ios/uikit_util.h"
  5. #import <UIKit/UIKit.h>
  6. #include <cmath>
  7. namespace ui {
  8. CGFloat AlignValueToUpperPixel(CGFloat value) {
  9. CGFloat scale = [[UIScreen mainScreen] scale];
  10. return std::ceil(value * scale) / scale;
  11. }
  12. CGSize AlignSizeToUpperPixel(CGSize size) {
  13. return CGSizeMake(AlignValueToUpperPixel(size.width),
  14. AlignValueToUpperPixel(size.height));
  15. }
  16. } // namespace ui