Kaydet (Commit) f688acfd authored tarafından Khaled Hosny's avatar Khaled Hosny Kaydeden (comit) Markus Mohrhard

Try to fix perf regression in HbLayoutEngine::Layout()

Regression from 1da9b4c2. We should
cache the break iterator as creating it is pretty expensive.

Change-Id: Id9bbe9aa9835d1b38bc7c8219464ee9c62335325
Reviewed-on: https://gerrit.libreoffice.org/25073Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst bdcb4968
...@@ -326,6 +326,7 @@ private: ...@@ -326,6 +326,7 @@ private:
hb_script_t maHbScript; hb_script_t maHbScript;
hb_face_t* mpHbFace; hb_face_t* mpHbFace;
int mnUnitsPerEM; int mnUnitsPerEM;
css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
public: public:
explicit HbLayoutEngine(ServerFont&); explicit HbLayoutEngine(ServerFont&);
...@@ -514,7 +515,8 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -514,7 +515,8 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
sal_Int32 nGraphemeStartPos = std::numeric_limits<sal_Int32>::max(); sal_Int32 nGraphemeStartPos = std::numeric_limits<sal_Int32>::max();
sal_Int32 nGraphemeEndPos = std::numeric_limits<sal_Int32>::min(); sal_Int32 nGraphemeEndPos = std::numeric_limits<sal_Int32>::min();
css::uno::Reference<css::i18n::XBreakIterator> xBreak = vcl::unohelper::CreateBreakIterator(); if (!mxBreak.is())
mxBreak = vcl::unohelper::CreateBreakIterator();
com::sun::star::lang::Locale aLocale(rArgs.maLanguageTag.getLocale()); com::sun::star::lang::Locale aLocale(rArgs.maLanguageTag.getLocale());
for (int i = 0; i < nRunGlyphCount; ++i) { for (int i = 0; i < nRunGlyphCount; ++i) {
...@@ -539,13 +541,13 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -539,13 +541,13 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
if(bRightToLeft && (nCharPos < nGraphemeStartPos)) if(bRightToLeft && (nCharPos < nGraphemeStartPos))
{ {
sal_Int32 nDone; sal_Int32 nDone;
nGraphemeStartPos = xBreak->previousCharacters(rArgs.mrStr, nCharPos+1, aLocale, nGraphemeStartPos = mxBreak->previousCharacters(rArgs.mrStr, nCharPos+1, aLocale,
com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
} }
else if(!bRightToLeft && (nCharPos >= nGraphemeEndPos)) else if(!bRightToLeft && (nCharPos >= nGraphemeEndPos))
{ {
sal_Int32 nDone; sal_Int32 nDone;
nGraphemeEndPos = xBreak->nextCharacters(rArgs.mrStr, nCharPos, aLocale, nGraphemeEndPos = mxBreak->nextCharacters(rArgs.mrStr, nCharPos, aLocale,
com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment