mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1167882 - Add utility functions MaxScaleRatio() and MinScaleRatio() to Units.h. r=kats
--HG-- extra : source : 17698f57d1cf14958e1ce3006abe5d9671cd18a7
This commit is contained in:
parent
a1ee749697
commit
9f96d5973b
@ -576,6 +576,21 @@ gfx::MarginTyped<dst> operator/(const gfx::MarginTyped<src>& aMargin, const gfx:
|
||||
aMargin.left / aScale.xScale);
|
||||
}
|
||||
|
||||
// Calculate the max or min or the ratios of the widths and heights of two
|
||||
// sizes, returning a scale factor in the correct units.
|
||||
|
||||
template<class src, class dst>
|
||||
gfx::ScaleFactor<src, dst> MaxScaleRatio(const gfx::SizeTyped<dst>& aDestSize, const gfx::SizeTyped<src>& aSrcSize) {
|
||||
return gfx::ScaleFactor<src, dst>(std::max(aDestSize.width / aSrcSize.width,
|
||||
aDestSize.height / aSrcSize.height));
|
||||
}
|
||||
|
||||
template<class src, class dst>
|
||||
gfx::ScaleFactor<src, dst> MinScaleRatio(const gfx::SizeTyped<dst>& aDestSize, const gfx::SizeTyped<src>& aSrcSize) {
|
||||
return gfx::ScaleFactor<src, dst>(std::min(aDestSize.width / aSrcSize.width,
|
||||
aDestSize.height / aSrcSize.height));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user