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

Unified Diff: cc/geometry.h

Issue 11366089: cc: Remove all remaining use of WebCore Rect/Point/Size types from the compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove gyp entries for stubs Created 8 years, 1 month 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/input_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/geometry.h
diff --git a/cc/geometry.h b/cc/geometry.h
index 1e5e25a95d4ab931ffb9ef52d2cdcc99f11335fd..91989270997e17155654c2f9aa3be0338fdc81b2 100644
--- a/cc/geometry.h
+++ b/cc/geometry.h
@@ -5,9 +5,10 @@
#ifndef CC_GEOMETRY_H_
#define CC_GEOMETRY_H_
-#include "ui/gfx/size.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/rect_f.h"
+#include "ui/gfx/vector2d.h"
#include "ui/gfx/vector2d_f.h"
-#include <cmath>
namespace cc {
@@ -16,6 +17,67 @@ inline gfx::Size ClampSizeFromAbove(gfx::Size s, gfx::Size other) {
s.height() < other.height() ? s.height() : other.height());
}
+inline gfx::Vector2dF ClampFromAbove(gfx::Vector2dF s, gfx::Vector2dF max) {
+ return gfx::Vector2dF(s.x() < max.x() ? s.x() : max.x(),
+ s.y() < max.y() ? s.y() : max.y());
+}
+
+inline gfx::Vector2dF ClampFromBelow(gfx::Vector2dF s, gfx::Vector2dF min) {
+ return gfx::Vector2dF(s.x() > min.x() ? s.x() : min.x(),
+ s.y() > min.y() ? s.y() : min.y());
+}
+
+inline gfx::Vector2d ClampFromAbove(gfx::Vector2d s, gfx::Vector2d max) {
+ return gfx::Vector2d(s.x() < max.x() ? s.x() : max.x(),
+ s.y() < max.y() ? s.y() : max.y());
+}
+
+inline gfx::Vector2d ClampFromBelow(gfx::Vector2d s, gfx::Vector2d min) {
+ return gfx::Vector2d(s.x() > min.x() ? s.x() : min.x(),
+ s.y() > min.y() ? s.y() : min.y());
+}
+
+inline gfx::PointF ClampFromAbove(gfx::PointF s, gfx::PointF max) {
+ return gfx::PointF(s.x() < max.x() ? s.x() : max.x(),
+ s.y() < max.y() ? s.y() : max.y());
+}
+
+inline gfx::PointF ClampFromBelow(gfx::PointF s, gfx::PointF min) {
+ return gfx::PointF(s.x() > min.x() ? s.x() : min.x(),
+ s.y() > min.y() ? s.y() : min.y());
+}
+
+inline gfx::Point ClampFromAbove(gfx::Point s, gfx::Point max) {
+ return gfx::Point(s.x() < max.x() ? s.x() : max.x(),
+ s.y() < max.y() ? s.y() : max.y());
+}
+
+inline gfx::Point ClampFromBelow(gfx::Point s, gfx::Point min) {
+ return gfx::Point(s.x() > min.x() ? s.x() : min.x(),
+ s.y() > min.y() ? s.y() : min.y());
+}
+
+inline gfx::Point BottomRight(gfx::Rect rect) {
+ return gfx::Point(rect.right(), rect.bottom());
+}
+
+inline gfx::PointF BottomRight(gfx::RectF rect) {
+ return gfx::PointF(rect.right(), rect.bottom());
+}
+
+// Return a vector that is |v| scaled by the given scale factors along each
+// axis.
+inline gfx::Vector2dF ScaleVector2d(gfx::Vector2dF v, float x_scale, float y_scale) {
+ gfx::Vector2dF scaled = v;
+ scaled.Scale(x_scale, y_scale);
+ return scaled;
+}
+
+// Return a vector that is |v| scaled by the given scale factor.
+inline gfx::Vector2dF ScaleVector2d(gfx::Vector2dF v, float scale) {
+ return ScaleVector2d(v, scale, scale);
+}
+
} // namespace cc
#endif // CC_GEOMETRY_H_
« no previous file with comments | « cc/cc.gyp ('k') | cc/input_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698