--- a/gfx/2d/Point.h
+++ b/gfx/2d/Point.h
@@ -143,17 +143,17 @@ struct PointTyped :
};
typedef PointTyped<UnknownUnits> Point;
typedef PointTyped<UnknownUnits, double> PointDouble;
template<class units>
IntPointTyped<units> RoundedToInt(const PointTyped<units>& aPoint) {
return IntPointTyped<units>::Round(aPoint.x, aPoint.y);
}
-
+
template<class units>
IntPointTyped<units> TruncatedToInt(const PointTyped<units>& aPoint) {
return IntPointTyped<units>::Truncate(aPoint.x, aPoint.y);
}
template<class units, class F = Float>
struct Point3DTyped :
public BasePoint3D< F, Point3DTyped<units, F> > {
@@ -213,29 +213,39 @@ struct Point4DTyped :
static_assert(IsPixel<units>::value,
"'units' must be a coordinate system tag");
typedef BasePoint4D< F, Point4DTyped<units, F> > Super;
Point4DTyped() : Super() {}
Point4DTyped(F aX, F aY, F aZ, F aW) : Super(aX, aY, aZ, aW) {}
+ explicit Point4DTyped(const Point3DTyped<units, F>& aPoint)
+ : Super(aPoint.x, aPoint.y, aPoint.z, 1) {}
+
// XXX When all of the code is ported, the following functions to convert to and from
// unknown types should be removed.
static Point4DTyped<units, F> FromUnknownPoint(const Point4DTyped<UnknownUnits, F>& aPoint) {
return Point4DTyped<units, F>(aPoint.x, aPoint.y, aPoint.z, aPoint.w);
}
Point4DTyped<UnknownUnits, F> ToUnknownPoint() const {
return Point4DTyped<UnknownUnits, F>(this->x, this->y, this->z, this->w);
}
- PointTyped<units, F> As2DPoint() {
- return PointTyped<units, F>(this->x / this->w, this->y / this->w);
+ PointTyped<units, F> As2DPoint() const {
+ return PointTyped<units, F>(this->x / this->w,
+ this->y / this->w);
+ }
+
+ Point3DTyped<units, F> As3DPoint() const {
+ return Point3DTyped<units, F>(this->x / this->w,
+ this->y / this->w,
+ this->z / this->w);
}
};
typedef Point4DTyped<UnknownUnits> Point4D;
typedef Point4DTyped<UnknownUnits, double> PointDouble4D;
template<class units>
struct IntSizeTyped :
public BaseSize< int32_t, IntSizeTyped<units> >,