diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-03-16 15:04:08 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-03-17 22:49:33 +0100 |
commit | 7439cabc643de2f07c18adc35056f802997f484a (patch) | |
tree | 1fb8f6bd207a81936617263091dca32d3536f1d6 /vcl/qa/cppunit | |
parent | 9d02d86e8a9111b7a689062eb9a856146a9e80b1 (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/qa/cppunit')
-rw-r--r-- | vcl/qa/cppunit/complextext.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx index f769fe4688b4..f953c3060eb4 100644 --- a/vcl/qa/cppunit/complextext.cxx +++ b/vcl/qa/cppunit/complextext.cxx @@ -121,17 +121,15 @@ void VclComplexTextTest::testKashida() = OUString(u"ﻊﻨﺻﺭ ﺎﻠﻓﻮﺴﻓﻭﺭ ﻊﻨﺻﺭ ﻒﻟﺰﻳ ﺺﻠﺑ. ﺖﺘﻛﻮﻧ ﺎﻟﺩﻭﺭﺓ ﺎﻟﺭﺎﺒﻋﺓ ﻢﻧ ١٥ ﻊﻨﺻﺭﺍ."); std::unique_ptr<SalLayout> pLayout = pOutputDevice->ImplLayout( aText, 0, aText.getLength(), Point(0, 0), 0, nullptr, SalLayoutFlags::GlyphItemsOnly); - const SalLayoutGlyphs* pGlyphs = pLayout->GetGlyphs(); - if (!pGlyphs) - // Failed in some non-interesting ways. - return; - SalLayoutGlyphs aGlyphs = *pGlyphs; + SalLayoutGlyphs aGlyphs = pLayout->GetGlyphs(); + CPPUNIT_ASSERT(aGlyphs.IsValid()); + CPPUNIT_ASSERT(aGlyphs.Impl(0) != nullptr); // Now lay it out using the cached glyph list. ImplLayoutArgs aLayoutArgs(aText, 0, aText.getLength(), SalLayoutFlags::NONE, pOutputDevice->GetFont().GetLanguageTag(), nullptr); pLayout = pOutputDevice->GetGraphics()->GetTextLayout(0); - CPPUNIT_ASSERT(pLayout->LayoutText(aLayoutArgs, &aGlyphs)); + CPPUNIT_ASSERT(pLayout->LayoutText(aLayoutArgs, aGlyphs.Impl(0))); // Without the accompanying fix in place, this test would have failed with 'assertion failed'. // The kashida justification flag was lost when going via the glyph cache. |