diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-03-03 15:26:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-03-28 15:34:34 +0000 |
commit | 1efe5fe38031f7bc23150c35e4c68940621a1d5b (patch) | |
tree | 7b6f08680b1e6810a0f13e756b99eee4d21a4145 /include/vcl | |
parent | 7fe192da23f4fac73b6ef7393bd8499a373170f3 (diff) |
tdf#89666: vcl: speed up HbLayoutEngine with cache in SwTxtFormatInfo
When a SwTxtFormatInfo is created to format a paragraph, pre-compute the
result of vcl::ScriptRun::next() and cache it for future calls to
OutputDevice::GetTextBreak() and GetTextWidth().
This requires adapting a bunch of methods to pass the additional
parameter, and some classes to backup and restore the cache when they
replace the text of the SwTxtFormatInfo.
There is some code in vcl OutputDevice::ImplPrepareLayoutArgs()
to modify the passed string and replace digits depending on
"meTextLanguage" member; try to set it to the correct value when
creating the layout cache (unfortunately it's not possible if the user
sets the CTL Numerals config to the non-default "Context" value).
Another issue is the check in OutputDevice::ImplLayout() if there is
a mpConversion member on the font; apparently this is used to translate
between different Symbol fonts, so not very important; just ignore the
cache in this case.
This reduces vcl::ScriptRun::next() from 11 to 0.36 billion callgrind
cycles when built with GCC 4.9.2 -m32 -Os (which is still 16% of the
formatting).
Change-Id: I61fb8530333f2e7a9199f767c00cf2181ba49951
Reviewed-on: https://gerrit.libreoffice.org/14732
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/vcl')
-rw-r--r-- | include/vcl/outdev.hxx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 7911b662b285..47c77ad4c47c 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -140,6 +140,7 @@ namespace vcl class ExtOutDevData; class ITextLayout; struct FontCapabilities; + class TextLayoutCache; } // OutputDevice-Types @@ -1066,7 +1067,8 @@ public: See also GetTextBoundRect() for more explanation + code examples. */ - long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const; + long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + vcl::TextLayoutCache const* = nullptr) const; /** Height where any character of the current font fits; in logic coordinates. @@ -1081,7 +1083,8 @@ public: sal_Int32 nLen = -1, int flags = 0); long GetTextArray( const OUString& rStr, long* pDXAry = NULL, - sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const; + sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + vcl::TextLayoutCache const* = nullptr) const; bool GetCaretPositions( const OUString&, long* pCaretXArray, sal_Int32 nIndex, sal_Int32 nLen, @@ -1092,11 +1095,14 @@ public: sal_Int32 nIndex = 0, sal_Int32 nLen = -1); sal_Int32 GetTextBreak( const OUString& rStr, long nTextWidth, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, - long nCharExtra = 0 ) const; + long nCharExtra = 0, + vcl::TextLayoutCache const* = nullptr) const; sal_Int32 GetTextBreak( const OUString& rStr, long nTextWidth, sal_Unicode nExtraChar, sal_Int32& rExtraCharPos, sal_Int32 nIndex, sal_Int32 nLen, - long nCharExtra = 0 ) const; + long nCharExtra = 0, + vcl::TextLayoutCache const* = nullptr) const; + std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const; private: SAL_DLLPRIVATE void ImplInitTextColor(); @@ -1247,9 +1253,11 @@ public: virtual bool HasMirroredGraphics() const; SAL_DLLPRIVATE SalLayout* ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen, const Point& rLogicPos = Point(0,0), long nLogicWidth=0, - const long* pLogicDXArray=NULL, int flags=0 ) const; + const long* pLogicDXArray=NULL, int flags=0, + vcl::TextLayoutCache const* = nullptr) const; SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen, - DeviceCoordinate nPixelWidth, const DeviceCoordinate* pPixelDXArray, int flags = 0 ) const; + DeviceCoordinate nPixelWidth, const DeviceCoordinate* pPixelDXArray, int flags = 0, + vcl::TextLayoutCache const* = nullptr) const; SAL_DLLPRIVATE SalLayout* ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const; // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI SAL_DLLPRIVATE SalLayout* getFallbackFont(ImplFontEntry &rFallbackFont, |