vcl/win/gdi/DWriteTextRenderer.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
New commits: commit 8d85da5616bab28c1df226bcbf4fe777b14b363e Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Apr 10 22:45:41 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Apr 11 10:38:47 2024 +0200 Only call ID2D1RenderTarget::Get/SetTransform when needed Change-Id: Ifde2c24c222e3c316f5a4f47e86c2c08f676639a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165983 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index 633dcf82b13b..c167c44c0110 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -104,7 +104,7 @@ public: private: ID2D1RenderTarget* mpRenderTarget; - D2D1::Matrix3x2F maTransform; + std::optional<D2D1::Matrix3x2F> moTransform; }; } // end anonymous namespace @@ -321,25 +321,27 @@ WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, bool bIsVertical) : mpRenderTarget(pRenderTarget) { - pRenderTarget->GetTransform(&maTransform); - D2D1::Matrix3x2F aTransform = maTransform; - Degree10 angle = rLayout.GetOrientation(); - if (bIsVertical) angle += 900_deg10; if (angle) { + D2D1::Matrix3x2F aTransform; + pRenderTarget->GetTransform(&aTransform); + moTransform = aTransform; + // DWrite angle is in clockwise degrees, our orientation is in counter-clockwise 10th // degrees. - aTransform = aTransform - * D2D1::Matrix3x2F::Rotation( - -toDegrees(angle), rBaseline); + aTransform = aTransform * D2D1::Matrix3x2F::Rotation(-toDegrees(angle), rBaseline); + mpRenderTarget->SetTransform(aTransform); } - mpRenderTarget->SetTransform(aTransform); } -WinFontTransformGuard::~WinFontTransformGuard() { mpRenderTarget->SetTransform(maTransform); } +WinFontTransformGuard::~WinFontTransformGuard() +{ + if (moTransform) + mpRenderTarget->SetTransform(*moTransform); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */