Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(901)

Unified Diff: ui/ios/uikit_util.mm

Issue 539253002: Add a couple UIKit util functions in src/ui/ios/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use WARN_UNUSED_RESULT Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ios/uikit_util.h ('k') | ui/ios/uikit_util_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ios/uikit_util.mm
diff --git a/ui/ios/uikit_util.mm b/ui/ios/uikit_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..13f743be916c81f7be82a68247bfe823f409c281
--- /dev/null
+++ b/ui/ios/uikit_util.mm
@@ -0,0 +1,23 @@
+// Copyright 2014 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/ios/uikit_util.h"
+
+#import <UIKit/UIKit.h>
+
+#include <cmath>
+
+namespace ui {
+
+CGFloat AlignValueToUpperPixel(CGFloat value) {
+ CGFloat scale = [[UIScreen mainScreen] scale];
+ return std::ceil(value * scale) / scale;
+}
+
+CGSize AlignSizeToUpperPixel(CGSize size) {
+ return CGSizeMake(AlignValueToUpperPixel(size.width),
+ AlignValueToUpperPixel(size.height));
+}
+
+} // namespace ui
« no previous file with comments | « ui/ios/uikit_util.h ('k') | ui/ios/uikit_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698