summaryrefslogtreecommitdiffstats
path: root/chromium/cc/base/math_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/base/math_util.h')
-rw-r--r--chromium/cc/base/math_util.h36
1 files changed, 23 insertions, 13 deletions
diff --git a/chromium/cc/base/math_util.h b/chromium/cc/base/math_util.h
index baceb7058fe..3af21021520 100644
--- a/chromium/cc/base/math_util.h
+++ b/chromium/cc/base/math_util.h
@@ -25,6 +25,7 @@ class Rect;
class RectF;
class Transform;
class Vector2dF;
+class Vector2d;
}
namespace cc {
@@ -99,10 +100,12 @@ class CC_EXPORT MathUtil {
//
// These functions return the axis-aligned rect that encloses the correctly
// clipped, transformed polygon.
- static gfx::Rect MapClippedRect(const gfx::Transform& transform,
- gfx::Rect rect);
+ static gfx::Rect MapEnclosingClippedRect(const gfx::Transform& transform,
+ const gfx::Rect& rect);
static gfx::RectF MapClippedRect(const gfx::Transform& transform,
const gfx::RectF& rect);
+ static gfx::Rect ProjectEnclosingClippedRect(const gfx::Transform& transform,
+ const gfx::Rect& rect);
static gfx::RectF ProjectClippedRect(const gfx::Transform& transform,
const gfx::RectF& rect);
@@ -116,7 +119,7 @@ class CC_EXPORT MathUtil {
gfx::PointF clipped_quad[8],
int* num_vertices_in_clipped_quad);
- static gfx::RectF ComputeEnclosingRectOfVertices(gfx::PointF vertices[],
+ static gfx::RectF ComputeEnclosingRectOfVertices(const gfx::PointF vertices[],
int num_vertices);
static gfx::RectF ComputeEnclosingClippedRect(
const HomogeneousCoordinate& h1,
@@ -130,7 +133,7 @@ class CC_EXPORT MathUtil {
const gfx::QuadF& quad,
bool* clipped);
static gfx::PointF MapPoint(const gfx::Transform& transform,
- gfx::PointF point,
+ const gfx::PointF& point,
bool* clipped);
static gfx::Point3F MapPoint(const gfx::Transform&,
const gfx::Point3F&,
@@ -139,8 +142,13 @@ class CC_EXPORT MathUtil {
const gfx::QuadF& quad,
bool* clipped);
static gfx::PointF ProjectPoint(const gfx::Transform& transform,
- gfx::PointF point,
+ const gfx::PointF& point,
bool* clipped);
+ // Identical to the above function, but coerces the homogeneous coordinate to
+ // a 3d rather than a 2d point.
+ static gfx::Point3F ProjectPoint3D(const gfx::Transform& transform,
+ const gfx::PointF& point,
+ bool* clipped);
static gfx::Vector2dF ComputeTransform2dScaleComponents(const gfx::Transform&,
float fallbackValue);
@@ -156,20 +164,22 @@ class CC_EXPORT MathUtil {
// Returns the smallest angle between the given two vectors in degrees.
// Neither vector is assumed to be normalized.
- static float SmallestAngleBetweenVectors(gfx::Vector2dF v1,
- gfx::Vector2dF v2);
+ static float SmallestAngleBetweenVectors(const gfx::Vector2dF& v1,
+ const gfx::Vector2dF& v2);
// Projects the |source| vector onto |destination|. Neither vector is assumed
// to be normalized.
- static gfx::Vector2dF ProjectVector(gfx::Vector2dF source,
- gfx::Vector2dF destination);
+ static gfx::Vector2dF ProjectVector(const gfx::Vector2dF& source,
+ const gfx::Vector2dF& destination);
// Conversion to value.
- static scoped_ptr<base::Value> AsValue(gfx::Size s);
- static scoped_ptr<base::Value> AsValue(gfx::SizeF s);
- static scoped_ptr<base::Value> AsValue(gfx::Rect r);
+ static scoped_ptr<base::Value> AsValue(const gfx::Size& s);
+ static scoped_ptr<base::Value> AsValue(const gfx::SizeF& s);
+ static scoped_ptr<base::Value> AsValue(const gfx::Rect& r);
static bool FromValue(const base::Value*, gfx::Rect* out_rect);
- static scoped_ptr<base::Value> AsValue(gfx::PointF q);
+ static scoped_ptr<base::Value> AsValue(const gfx::PointF& q);
+ static scoped_ptr<base::Value> AsValue(const gfx::Point3F&);
+ static scoped_ptr<base::Value> AsValue(const gfx::Vector2d& v);
static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q);
static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect);
static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform);