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

Unified Diff: cc/math/clamp.h

Issue 10984053: cc: Use ui/gfx geometry types for the CCRenderPass and CCDrawQuad classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « cc/cc.gyp ('k') | cc/math/float_point.h » ('j') | cc/math/int_point.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/math/clamp.h
diff --git a/cc/math/clamp.h b/cc/math/clamp.h
new file mode 100644
index 0000000000000000000000000000000000000000..355ac0cbcfd322e8163d8157be113d7af8db2946
--- /dev/null
+++ b/cc/math/clamp.h
@@ -0,0 +1,34 @@
+// Copyright 2012 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.
+
+#ifndef CC_MATH_CLAMP_H_
+#define CC_MATH_CLAMP_H_
+
+#include "cc/math/clamp.h"
tfarina 2012/09/28 19:39:30 we are self including here?
+#include "cc/math/int_point.h"
tfarina 2012/09/28 19:39:30 I guess unused in this header file.
+#include <limits>
+
+namespace ccmath {
+
+class Clamp {
+private:
tfarina 2012/09/28 19:39:30 private sections after public the other we usuall
+ template<typename FromType, typename ToType>
+ static ToType ClampFromTo(FromType value) {
+ ToType min = std::numeric_limits<ToType>::min();
+ ToType max = std::numeric_limits<ToType>::max();
+ if (value >= static_cast<FromType>(max))
+ return max;
+ if (value <= static_cast<FromType>(min))
+ return min;
+ return value;
+ }
+
+public:
+ static int ToInteger(double d) { return ClampFromTo<double, int>(d); }
+ static int ToInteger(float f) { return ClampFromTo<float, int>(f); }
+};
tfarina 2012/09/28 19:39:30 DISALLOW_IMPLICIT_CONSTRUCTORS
+
+} // namespace ccmath
+
+#endif // CC_MATH_CLAMP_H_
« no previous file with comments | « cc/cc.gyp ('k') | cc/math/float_point.h » ('j') | cc/math/int_point.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698