summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-03-16 15:04:08 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-03-17 22:49:33 +0100
commit7439cabc643de2f07c18adc35056f802997f484a (patch)
tree1fb8f6bd207a81936617263091dca32d3536f1d6 /vcl/source/window
parent9d02d86e8a9111b7a689062eb9a856146a9e80b1 (diff)
make SalLayoutGlyphs work with MultiSalLayout
Code that needs to lay out texts repeatedly can cache the result of SalLayout::GetGlyphs() can reuse it. But GetGlyphs() returns nullptr for MultiSalLayout, so caching for it doesn't work. Worse still, it actually increases the number of layout calls, because there's the initial layout for caching and then each call will need to do the layout again because of the nullptr that's not cached. This commit changes SalLayoutGlyphs to possibly include multiple SalLayoutGlyphsImpl objects, one for each SalLayout handled by MultiSalLayout. Changes include making GenericSalLayout work directly with the Impl class, which avoids an indirection and simplifies code. Change-Id: Ic4b19934a8a06d4955b51527fe3777c5e91107b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112590 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/menuitemlist.cxx6
-rw-r--r--vcl/source/window/status.cxx16
2 files changed, 9 insertions, 13 deletions
diff --git a/vcl/source/window/menuitemlist.cxx b/vcl/source/window/menuitemlist.cxx
index 6921e6208118..a9903447c748 100644
--- a/vcl/source/window/menuitemlist.cxx
+++ b/vcl/source/window/menuitemlist.cxx
@@ -52,12 +52,8 @@ SalLayoutGlyphs* MenuItemData::GetTextGlyphs(const OutputDevice* pOutputDevice)
if (!pLayout)
return nullptr;
- const SalLayoutGlyphs* pGlyphs = pLayout->GetGlyphs();
- if (!pGlyphs)
- return nullptr;
-
// Remember the calculation result.
- aTextGlyphs = *pGlyphs;
+ aTextGlyphs = pLayout->GetGlyphs();
return &aTextGlyphs;
}
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index e24a76da30c1..e3c193609bd3 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -398,8 +398,8 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen
pLayoutCache = pItem->mxLayoutCache.get();
}
- const SalLayoutGlyphs* pGlyphs = pLayoutCache ? pLayoutCache->GetGlyphs() : nullptr;
- Size aTextSize(rRenderContext.GetTextWidth(pItem->maText,0,-1,nullptr,pGlyphs), rRenderContext.GetTextHeight());
+ const SalLayoutGlyphs glyphs = pLayoutCache ? pLayoutCache->GetGlyphs() : SalLayoutGlyphs();
+ Size aTextSize(rRenderContext.GetTextWidth(pItem->maText,0,-1,nullptr,&glyphs), rRenderContext.GetTextHeight());
Point aTextPos = ImplGetItemTextPos(aTextRectSize, aTextSize, pItem->mnBits);
if (bOffScreen)
@@ -408,7 +408,7 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen
aTextPos,
pItem->maText,
0, -1, nullptr, nullptr,
- pGlyphs );
+ &glyphs );
}
else
{
@@ -418,7 +418,7 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen
aTextPos,
pItem->maText,
0, -1, nullptr, nullptr,
- pGlyphs );
+ &glyphs );
}
}
@@ -1139,15 +1139,15 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText, int nCha
if (nCharsWidth != -1)
{
std::unique_ptr<SalLayout> pSalLayout = ImplLayout("0",0,-1);
- const SalLayoutGlyphs* pGlyphs = pSalLayout ? pSalLayout->GetGlyphs() : nullptr;
- nWidth = GetTextWidth("0",0,-1,nullptr,pGlyphs );
+ const SalLayoutGlyphs glyphs = pSalLayout ? pSalLayout->GetGlyphs() : SalLayoutGlyphs();
+ nWidth = GetTextWidth("0",0,-1,nullptr,&glyphs);
nWidth = nWidth * nCharsWidth + nFudge;
}
else
{
std::unique_ptr<SalLayout> pSalLayout = ImplLayout(pItem->maText,0,-1);
- const SalLayoutGlyphs* pGlyphs = pSalLayout ? pSalLayout->GetGlyphs() : nullptr;
- nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,pGlyphs ) + nFudge;
+ const SalLayoutGlyphs glyphs = pSalLayout ? pSalLayout->GetGlyphs() : SalLayoutGlyphs();
+ nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,&glyphs) + nFudge;
// Store the calculated layout.
pItem->mxLayoutCache = std::move(pSalLayout);
}