OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 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 |
| 5 #ifndef CC_GEOMETRY_H_ |
| 6 #define CC_GEOMETRY_H_ |
| 7 |
| 8 #include "ui/gfx/size.h" |
| 9 #include "ui/gfx/vector2d_f.h" |
| 10 #include <cmath> |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 inline gfx::Size ClampSizeFromAbove(gfx::Size s, gfx::Size other) { |
| 15 return gfx::Size(s.width() < other.width() ? s.width() : other.width(), |
| 16 s.height() < other.height() ? s.height() : other.height()); |
| 17 } |
| 18 |
| 19 inline float LengthSquared(gfx::Vector2dF v) { |
| 20 return v.x() * v.x() + v.y() * v.y(); |
| 21 } |
| 22 |
| 23 inline float Length(gfx::Vector2dF v) { |
| 24 return std::sqrt(LengthSquared(v)); |
| 25 } |
| 26 |
| 27 } // namespace cc |
| 28 |
| 29 #endif // CC_GEOMETRY_H_ |
OLD | NEW |