diff options
author | Norbert Thiebaud <nthieabaud@gmail.com> | 2015-03-28 20:38:22 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthieabaud@gmail.com> | 2015-03-28 20:38:22 -0500 |
commit | 3c6fd5a59b08cec8705a31d17a60204acf6b7173 (patch) | |
tree | 9c98cc5549f08082045f8d80f5c95cc4f99e0d03 /vcl | |
parent | 9eeee5466fba5a3ff1de6d47b6341d83cf14c275 (diff) |
Revert "tdf#89666: vcl: speed up HbLayoutEngine with cache in SwTxtFormatInfo"
This reverts commit 1efe5fe38031f7bc23150c35e4c68940621a1d5b.
which broke windows.
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/generic/glyphs/gcach_layout.cxx | 64 | ||||
-rw-r--r-- | vcl/inc/generic/glyphcache.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/sallayout.hxx | 12 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 10 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 53 |
5 files changed, 22 insertions, 120 deletions
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<HbScriptRun> 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<vcl::Run> runs; - TextLayoutCache(OUString const& rString, sal_Int32 const nEnd) - { - vcl::ScriptRun aScriptRun( - reinterpret_cast<const UChar *>(rString.getStr()), - nEnd); - while (aScriptRun.next()) - { - runs.push_back(Run(aScriptRun.getScriptStart(), - aScriptRun.getScriptEnd(), aScriptRun.getScriptCode())); - } - } - }; -} - -std::shared_ptr<vcl::TextLayoutCache> ServerFontLayout::CreateTextLayoutCache( - OUString const& rString) const -{ - return std::make_shared<vcl::TextLayoutCache>(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<vcl::TextLayoutCache> pNewScriptRun; - vcl::TextLayoutCache const* pTextLayout; - if (rArgs.m_pTextLayoutCache) - { - pTextLayout = rArgs.m_pTextLayoutCache; // use cache! - } - else - { - pNewScriptRun.reset(new vcl::TextLayoutCache( - reinterpret_cast<const UChar *>(rArgs.mpStr), rArgs.mnEndCharPos)); - pTextLayout = pNewScriptRun.get(); - } + vcl::ScriptRun aScriptRun(reinterpret_cast<const UChar *>(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; diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx index ae9e30b9c59a..c8d3552ba7c9 100644 --- a/vcl/inc/generic/glyphcache.hxx +++ b/vcl/inc/generic/glyphcache.hxx @@ -299,9 +299,6 @@ public: ServerFont& GetServerFont() const { return mrServerFont; } - virtual std::shared_ptr<vcl::TextLayoutCache> - CreateTextLayoutCache(OUString const&) const SAL_OVERRIDE; - private: ServerFont& mrServerFont; com::sun::star::uno::Reference<com::sun::star::i18n::XBreakIterator> mxBreak; diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 7ad886640d5c..943f8eb6bf5b 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -41,9 +41,6 @@ typedef unsigned short LanguageType; class SalGraphics; class PhysicalFontFace; -namespace vcl { - class TextLayoutCache; -} // used for managing runs e.g. for BiDi, glyph and script fallback class VCL_PLUGIN_PUBLIC ImplLayoutRuns @@ -79,9 +76,6 @@ public: int mnEndCharPos; const sal_Unicode* mpStr; - // performance hack - vcl::TextLayoutCache const* m_pTextLayoutCache; - // positioning related inputs const DeviceCoordinate* mpDXArray; // in pixel units DeviceCoordinate mnLayoutWidth; // in pixel units @@ -94,8 +88,7 @@ public: public: ImplLayoutArgs( const sal_Unicode* pStr, int nLength, int nMinCharPos, int nEndCharPos, int nFlags, - const LanguageTag& rLanguageTag, - vcl::TextLayoutCache const* pLayoutCache); + const LanguageTag& rLanguageTag ); void SetLayoutWidth( DeviceCoordinate nWidth ) { mnLayoutWidth = nWidth; } void SetDXArray( const DeviceCoordinate* pDXArray ) { mpDXArray = pDXArray; } @@ -201,9 +194,6 @@ public: virtual void Simplify( bool bIsBase ) = 0; virtual void DisableGlyphInjection( bool /*bDisable*/ ) {} - virtual std::shared_ptr<vcl::TextLayoutCache> - CreateTextLayoutCache(OUString const&) const; - protected: // used by layout engines SalLayout(); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 82d87c322caf..e83264765bd0 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -486,8 +486,7 @@ bool ImplLayoutRuns::GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRightToLef } ImplLayoutArgs::ImplLayoutArgs( const sal_Unicode* pStr, int nLen, - int nMinCharPos, int nEndCharPos, int nFlags, const LanguageTag& rLanguageTag, - vcl::TextLayoutCache const*const pLayoutCache) + int nMinCharPos, int nEndCharPos, int nFlags, const LanguageTag& rLanguageTag ) : maLanguageTag( rLanguageTag ), mnFlags( nFlags ), @@ -495,7 +494,6 @@ ImplLayoutArgs::ImplLayoutArgs( const sal_Unicode* pStr, int nLen, mnMinCharPos( nMinCharPos ), mnEndCharPos( nEndCharPos ), mpStr( pStr ), - m_pTextLayoutCache(pLayoutCache), mpDXArray( NULL ), mnLayoutWidth( 0 ), mnOrientation( 0 ) @@ -2130,10 +2128,4 @@ bool MultiSalLayout::GetOutline( SalGraphics& rGraphics, return bRet; } -std::shared_ptr<vcl::TextLayoutCache> SalLayout::CreateTextLayoutCache( - OUString const&) const -{ - return 0; // by default, nothing to cache -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 8f25c4ca72c0..d273d5bc3722 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -925,11 +925,10 @@ void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr, mpAlphaVDev->DrawText( rStartPt, rStr, nIndex, nLen, pVector, pDisplayText ); } -long OutputDevice::GetTextWidth( const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen, - vcl::TextLayoutCache const*const pLayoutCache) const +long OutputDevice::GetTextWidth( const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen ) const { - long nWidth = GetTextArray( rStr, NULL, nIndex, nLen, pLayoutCache ); + long nWidth = GetTextArray( rStr, NULL, nIndex, nLen ); return nWidth; } @@ -994,8 +993,7 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr, } long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry, - sal_Int32 nIndex, sal_Int32 nLen, - vcl::TextLayoutCache const*const pLayoutCache) const + sal_Int32 nIndex, sal_Int32 nLen ) const { if(nLen == 0x0FFFF) { @@ -1011,8 +1009,7 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry, nLen = rStr.getLength() - nIndex; } // do layout - SalLayout *const pSalLayout = ImplLayout(rStr, nIndex, nLen, - Point(0,0), 0, nullptr, 0, pLayoutCache); + SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen ); if( !pSalLayout ) return 0; #if VCL_FLOAT_DEVICE_PIXEL @@ -1194,8 +1191,7 @@ void OutputDevice::DrawStretchText( const Point& rStartPt, sal_uLong nWidth, ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, const sal_Int32 nMinIndex, const sal_Int32 nLen, DeviceCoordinate nPixelWidth, const DeviceCoordinate* pDXArray, - int nLayoutFlags, - vcl::TextLayoutCache const*const pLayoutCache) const + int nLayoutFlags ) const { assert(nMinIndex >= 0); assert(nLen >= 0); @@ -1294,7 +1290,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, nLayoutFlags |= SAL_LAYOUT_RIGHT_ALIGN; // set layout options - ImplLayoutArgs aLayoutArgs( rStr.getStr(), rStr.getLength(), nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguageTag(), pLayoutCache ); + ImplLayoutArgs aLayoutArgs( rStr.getStr(), rStr.getLength(), nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguageTag() ); int nOrientation = mpFontEntry ? mpFontEntry->mnOrientation : 0; aLayoutArgs.SetOrientation( nOrientation ); @@ -1308,8 +1304,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr, sal_Int32 nMinIndex, sal_Int32 nLen, const Point& rLogicalPos, long nLogicalWidth, - const long* pDXArray, int flags, - vcl::TextLayoutCache const* pLayoutCache) const + const long* pDXArray, int flags) const { // we need a graphics if( !mpGraphics ) @@ -1338,7 +1333,6 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr, // recode string if needed if( mpFontEntry->mpConversion ) { mpFontEntry->mpConversion->RecodeString( aStr, 0, aStr.getLength() ); - pLayoutCache = nullptr; // don't use cache with modified string! } DeviceCoordinate nPixelWidth = (DeviceCoordinate)nLogicalWidth; DeviceCoordinate* pDXPixelArray = NULL; @@ -1374,8 +1368,7 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr, } } - ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, - nPixelWidth, pDXPixelArray, flags, pLayoutCache); + ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen, nPixelWidth, pDXPixelArray, flags); // get matching layout object for base font SalLayout* pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 ); @@ -1414,24 +1407,6 @@ SalLayout* OutputDevice::ImplLayout(const OUString& rOrigStr, return pSalLayout; } -std::shared_ptr<vcl::TextLayoutCache> OutputDevice::CreateTextLayoutCache( - OUString const& rString) const -{ - if (!mpGraphics) // can happen in e.g Insert Index/Table dialog - return nullptr; - OUString copyBecausePrepareModifiesIt(rString); - ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs(copyBecausePrepareModifiesIt, - 0, rString.getLength(), 0, nullptr, 0, nullptr); - - SalLayout *const pSalLayout = mpGraphics->GetTextLayout( aLayoutArgs, 0 ); - if (!pSalLayout) - return nullptr; - std::shared_ptr<vcl::TextLayoutCache> const ret( - pSalLayout->CreateTextLayoutCache(copyBecausePrepareModifiesIt)); - pSalLayout->Release(); - return ret; -} - bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, sal_Int32 nLen ) const { OUString aStr( rString ); @@ -1445,11 +1420,9 @@ bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, sal_ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, sal_Int32 nIndex, sal_Int32 nLen, - long nCharExtra, - vcl::TextLayoutCache const*const pLayoutCache) const + long nCharExtra ) const { - SalLayout *const pSalLayout = ImplLayout( rStr, nIndex, nLen, - Point(0,0), 0, nullptr, 0, pLayoutCache); + SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen ); sal_Int32 nRetVal = -1; if( pSalLayout ) { @@ -1478,13 +1451,11 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth, sal_Unicode nHyphenChar, sal_Int32& rHyphenPos, sal_Int32 nIndex, sal_Int32 nLen, - long nCharExtra, - vcl::TextLayoutCache const*const pLayoutCache) const + long nCharExtra ) const { rHyphenPos = -1; - SalLayout *const pSalLayout = ImplLayout( rStr, nIndex, nLen, - Point(0,0), 0, nullptr, 0, pLayoutCache); + SalLayout* pSalLayout = ImplLayout( rStr, nIndex, nLen ); sal_Int32 nRetVal = -1; if( pSalLayout ) { |