Bug 1205511 - Add overloaded operators for multiplying and dividing an IntPointTyped by a ScaleFactor[2D]. r=kats

The overloads return PointTyped, leaving it to the caller to round or truncate
if desired, much like the existing Rect counterparts.
This commit is contained in:
Botond Ballo 2015-09-28 20:13:16 -04:00
parent 6f5d9f43e2
commit 2ef7ce7a80

View File

@ -448,6 +448,30 @@ gfx::PointTyped<dst> operator/(const gfx::PointTyped<src>& aPoint, const gfx::Sc
aPoint.y / aScale.yScale);
}
template<class src, class dst>
gfx::PointTyped<dst> operator*(const gfx::IntPointTyped<src>& aPoint, const gfx::ScaleFactor<src, dst>& aScale) {
return gfx::PointTyped<dst>(float(aPoint.x) * aScale.scale,
float(aPoint.y) * aScale.scale);
}
template<class src, class dst>
gfx::PointTyped<dst> operator/(const gfx::IntPointTyped<src>& aPoint, const gfx::ScaleFactor<dst, src>& aScale) {
return gfx::PointTyped<dst>(float(aPoint.x) / aScale.scale,
float(aPoint.y) / aScale.scale);
}
template<class src, class dst>
gfx::PointTyped<dst> operator*(const gfx::IntPointTyped<src>& aPoint, const gfx::ScaleFactors2D<src, dst>& aScale) {
return gfx::PointTyped<dst>(float(aPoint.x) * aScale.xScale,
float(aPoint.y) * aScale.yScale);
}
template<class src, class dst>
gfx::PointTyped<dst> operator/(const gfx::IntPointTyped<src>& aPoint, const gfx::ScaleFactors2D<dst, src>& aScale) {
return gfx::PointTyped<dst>(float(aPoint.x) / aScale.xScale,
float(aPoint.y) / aScale.yScale);
}
template<class src, class dst>
gfx::RectTyped<dst> operator*(const gfx::RectTyped<src>& aRect, const gfx::ScaleFactor<src, dst>& aScale) {
return gfx::RectTyped<dst>(aRect.x * aScale.scale,