tdf#141415 speed up a perf hotspot in SalLayout
a translation is just 2 additions, no need to do expensive matrix math Change-Id: I76949e6168acc8c50ade358fdccb61575b59a5e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183220 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
This commit is contained in:
@@ -48,6 +48,17 @@ namespace basegfx
|
||||
}
|
||||
}
|
||||
|
||||
void B2DRange::translate(double fTranslateX, double fTranslateY)
|
||||
{
|
||||
if(!(fTools::equalZero(fTranslateX) && fTools::equalZero(fTranslateY)))
|
||||
{
|
||||
*this = basegfx::B2DRange(fTranslateX + getMinX(),
|
||||
fTranslateY + getMinY(),
|
||||
fTranslateX + getMaxX(),
|
||||
fTranslateY + getMaxY());
|
||||
}
|
||||
}
|
||||
|
||||
B2DRange& B2DRange::operator*=(const basegfx::B2DHomMatrix& rMatrix)
|
||||
{
|
||||
transform(rMatrix);
|
||||
|
||||
@@ -114,6 +114,15 @@ namespace basegfx
|
||||
/** Transform Range by given transformation matrix. */
|
||||
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix& rMatrix);
|
||||
|
||||
/** Translate Range (ie. move).
|
||||
Much faster equivalent of transform(createTranslateB2DHomMatrix(xx)). */
|
||||
BASEGFX_DLLPUBLIC void translate(double fTranslateX, double fTranslateY);
|
||||
|
||||
inline void translate(const B2DTuple& rTranslate)
|
||||
{
|
||||
translate(rTranslate.getX(), rTranslate.getY());
|
||||
}
|
||||
|
||||
/** Transform Range by given transformation matrix.
|
||||
|
||||
This operation transforms the Range by transforming all four possible
|
||||
|
||||
@@ -236,7 +236,8 @@ bool SalLayout::GetBoundRect(basegfx::B2DRectangle& rRect) const
|
||||
{
|
||||
if (!aRectangle.isEmpty())
|
||||
{
|
||||
aRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix(aPos));
|
||||
// translate rectangle to correct position
|
||||
aRectangle.translate(aPos);
|
||||
// merge rectangle
|
||||
rRect.expand(aRectangle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user