From 3c6fd5a59b08cec8705a31d17a60204acf6b7173 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Sat, 28 Mar 2015 20:38:22 -0500 Subject: Revert "tdf#89666: vcl: speed up HbLayoutEngine with cache in SwTxtFormatInfo" This reverts commit 1efe5fe38031f7bc23150c35e4c68940621a1d5b. which broke windows. --- vcl/generic/glyphs/gcach_layout.cxx | 64 +++++-------------------------------- 1 file changed, 8 insertions(+), 56 deletions(-) (limited to 'vcl/generic/glyphs/gcach_layout.cxx') diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx index 94486a1a8813..debcbe79eb4c 100644 --- a/vcl/generic/glyphs/gcach_layout.cxx +++ b/vcl/generic/glyphs/gcach_layout.cxx @@ -349,41 +349,6 @@ struct HbScriptRun typedef std::vector HbScriptRuns; -namespace vcl { - struct Run - { - int32_t nStart; - int32_t nEnd; - UScriptCode nCode; - Run(int32_t nStart_, int32_t nEnd_, UScriptCode nCode_) - : nStart(nStart_), nEnd(nEnd_), nCode(nCode_) - {} - }; - - class TextLayoutCache - { - public: - std::vector runs; - TextLayoutCache(OUString const& rString, sal_Int32 const nEnd) - { - vcl::ScriptRun aScriptRun( - reinterpret_cast(rString.getStr()), - nEnd); - while (aScriptRun.next()) - { - runs.push_back(Run(aScriptRun.getScriptStart(), - aScriptRun.getScriptEnd(), aScriptRun.getScriptCode())); - } - } - }; -} - -std::shared_ptr ServerFontLayout::CreateTextLayoutCache( - OUString const& rString) const -{ - return std::make_shared(rString, rString.getLength()); -} - bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) { ServerFont& rFont = rLayout.GetServerFont(); @@ -405,18 +370,7 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) rLayout.Reserve(nGlyphCapacity); - std::unique_ptr pNewScriptRun; - vcl::TextLayoutCache const* pTextLayout; - if (rArgs.m_pTextLayoutCache) - { - pTextLayout = rArgs.m_pTextLayoutCache; // use cache! - } - else - { - pNewScriptRun.reset(new vcl::TextLayoutCache( - reinterpret_cast(rArgs.mpStr), rArgs.mnEndCharPos)); - pTextLayout = pNewScriptRun.get(); - } + vcl::ScriptRun aScriptRun(reinterpret_cast(rArgs.mpStr), rArgs.mnEndCharPos); Point aCurrPos(0, 0); while (true) @@ -429,25 +383,21 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) // Find script subruns. int nCurrentPos = nBidiMinRunPos; HbScriptRuns aScriptSubRuns; - size_t k = 0; - for (; k < pTextLayout->runs.size(); ++k) + while (aScriptRun.next()) { - vcl::Run const& rRun(pTextLayout->runs[k]); - if (rRun.nStart <= nCurrentPos && nCurrentPos < rRun.nEnd) - { + if (aScriptRun.getScriptStart() <= nCurrentPos && aScriptRun.getScriptEnd() > nCurrentPos) break; - } } while (nCurrentPos < nBidiEndRunPos) { int32_t nMinRunPos = nCurrentPos; - int32_t nEndRunPos = std::min(pTextLayout->runs[k].nEnd, nBidiEndRunPos); - HbScriptRun aRun(nMinRunPos, nEndRunPos, pTextLayout->runs[k].nCode); + int32_t nEndRunPos = std::min(aScriptRun.getScriptEnd(), nBidiEndRunPos); + HbScriptRun aRun(nMinRunPos, nEndRunPos, aScriptRun.getScriptCode()); aScriptSubRuns.push_back(aRun); nCurrentPos = nEndRunPos; - ++k; + aScriptRun.next(); } // RTL subruns should be reversed to ensure that final glyph order is @@ -455,6 +405,8 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) if (bRightToLeft) std::reverse(aScriptSubRuns.begin(), aScriptSubRuns.end()); + aScriptRun.reset(); + for (HbScriptRuns::iterator it = aScriptSubRuns.begin(); it != aScriptSubRuns.end(); ++it) { int nMinRunPos = it->mnMin; -- cgit v1.2.3