diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-05 14:16:23 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-08 22:29:50 +0200 |
commit | c4c56de1b0e62ec866b519b2b24c5e805f0a86d3 (patch) | |
tree | a8a5b3c67b72804a27fd2f1aea39451691a3fa0c /vcl/source/outdev/font.cxx | |
parent | d865866ec5cf6966757c9f2abd24b18a39f2f924 (diff) |
hold LogicalFontInstance with rtl::Reference
instead of manual reference counting.
Also the releasing of not-currently-in-use LogicalFontInstance objects
from the cache is made less aggressive - we now only flush entries until
we have less than CACHE_SIZE instances, instead of flushing the whole
cache.
Change-Id: Ib235b132776b5f09ae8ae93a933c2eebe5fa9610
Reviewed-on: https://gerrit.libreoffice.org/55384
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/outdev/font.cxx')
-rw-r--r-- | vcl/source/outdev/font.cxx | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index c65dd0d5cce9..439a3df75c5b 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -168,7 +168,7 @@ FontMetric OutputDevice::GetFontMetric() const if( mbNewFont && !ImplNewFont() ) return aMetric; - LogicalFontInstance* pFontInstance = mpFontInstance; + LogicalFontInstance* pFontInstance = mpFontInstance.get(); ImplFontMetricDataRef xFontMetric = pFontInstance->mxFontMetric; // prepare metric @@ -475,11 +475,7 @@ long OutputDevice::GetFontExtLeading() const void OutputDevice::ImplClearFontData( const bool bNewFontLists ) { // the currently selected logical font is no longer needed - if ( mpFontInstance ) - { - mpFontInstance->Release(); - mpFontInstance = nullptr; - } + mpFontInstance.clear(); mbInitFont = true; mbNewFont = true; @@ -884,12 +880,11 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan // get the name of the first available font float fExactHeight = static_cast<float>(aSize.Height()); - LogicalFontInstance* pFontInstance = pOutDev->mpFontCache->GetFontInstance( pOutDev->mpFontCollection, aFont, aSize, fExactHeight ); + rtl::Reference<LogicalFontInstance> pFontInstance = pOutDev->mpFontCache->GetFontInstance( pOutDev->mpFontCollection, aFont, aSize, fExactHeight ); if (pFontInstance) { assert(pFontInstance->GetFontFace()); aFont.SetFamilyName(pFontInstance->GetFontFace()->GetFamilyName()); - pFontInstance->Release(); } } } @@ -1034,12 +1029,12 @@ bool OutputDevice::ImplNewFont() const aSize.setWidth( 1 ); // get font entry - LogicalFontInstance* pOldFontInstance = mpFontInstance; + rtl::Reference<LogicalFontInstance> pOldFontInstance = mpFontInstance; mpFontInstance = mpFontCache->GetFontInstance( mpFontCollection, maFont, aSize, fExactHeight ); - if( pOldFontInstance ) - pOldFontInstance->Release(); + bool bNewFontInstance = pOldFontInstance.get() != mpFontInstance.get(); + pOldFontInstance.clear(); - LogicalFontInstance* pFontInstance = mpFontInstance; + LogicalFontInstance* pFontInstance = mpFontInstance.get(); if (!pFontInstance) { @@ -1049,7 +1044,7 @@ bool OutputDevice::ImplNewFont() const // mark when lower layers need to get involved mbNewFont = false; - if( pFontInstance != pOldFontInstance ) + if( bNewFontInstance ) mbInitFont = true; // select font when it has not been initialized yet @@ -1350,7 +1345,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt // if the system-specific glyph fallback is active aFontSelData.mpFontInstance = mpFontInstance; // reset the fontinstance to base-level - LogicalFontInstance* pFallbackFont = mpFontCache->GetGlyphFallbackFont( mpFontCollection, + rtl::Reference<LogicalFontInstance> pFallbackFont = mpFontCache->GetGlyphFallbackFont( mpFontCollection, aFontSelData, nFallbackLevel, aMissingCodes ); if( !pFallbackFont ) break; @@ -1364,7 +1359,6 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt if( mpFontInstance->GetFontFace() == pFallbackFont->GetFontFace() && aMissingCodes.indexOf(0x202F) == -1 ) { - pFallbackFont->Release(); continue; } } @@ -1382,8 +1376,6 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt pMultiSalLayout->SetIncomplete(true); } - pFallbackFont->Release(); - // break when this fallback was sufficient if( !rLayoutArgs.PrepareFallback() ) break; |