summaryrefslogtreecommitdiffstats
path: root/editeng
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-04-07 12:06:27 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-04-08 21:29:19 +0200
commit3e5863605881c6de6ad130fe06883c176ca1c69f (patch)
tree9e7863107a162eba8952710af00c281b91a12633 /editeng
parentignore Point logicalPos argument in SalLayoutGlyphsCache (diff)
downloadcore-3e5863605881c6de6ad130fe06883c176ca1c69f.tar.gz
core-3e5863605881c6de6ad130fe06883c176ca1c69f.zip
use just one shared global SalLayoutGlyphsCache
Now the cache should be capable of detecting what needs to stay the same for having the same result, so it should be enough to have just one cache that can reuse results even between callers from different places. Change-Id: Ibdc0303f5b727d1a1d7be91d61db9465ed95e1c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132673 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit.hxx3
-rw-r--r--editeng/source/editeng/impedit2.cxx2
-rw-r--r--editeng/source/editeng/impedit3.cxx28
-rw-r--r--editeng/source/items/svxfont.cxx27
4 files changed, 27 insertions, 33 deletions
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 36480f26bc1c..894bb822f676 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -36,7 +36,6 @@
#include <vcl/idle.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/ptrstyle.hxx>
-#include <vcl/glyphitemcache.hxx>
#include <vcl/dndhelp.hxx>
#include <svl/ondemand.hxx>
@@ -608,8 +607,6 @@ private:
bool mbNbspRunNext; // can't be a bitfield as it is passed as bool&
- SalLayoutGlyphsCache mGlyphsCache;
-
// Methods...
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 402d606d8b57..4b7b3490d138 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3439,7 +3439,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
aTmpFont.SetPhysFont(*GetRefDevice());
ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(),
- pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen(), nullptr, &mGlyphsCache ).Width();
+ pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen(), nullptr ).Width();
}
}
break;
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 4f341fd65959..cdcc05100730 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -997,7 +997,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
// Height needed...
SeekCursor( pNode, nTmpPos+1, aTmpFont );
pPortion->GetSize().setHeight(
- aTmpFont.QuickGetTextSize( GetRefDevice(), OUString(), 0, 0, nullptr, &mGlyphsCache ).Height() );
+ aTmpFont.QuickGetTextSize( GetRefDevice(), OUString(), 0, 0, nullptr ).Height() );
DBG_ASSERT( pPortion->GetSize().Width() >= 0, "Tab incorrectly calculated!" );
@@ -1043,7 +1043,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
// get size, but also DXArray to allow length information in line breaking below
std::vector<sal_Int32> aTmpDXArray;
pPortion->GetSize() = aTmpFont.QuickGetTextSize(GetRefDevice(),
- aFieldValue, 0, aFieldValue.getLength(), &aTmpDXArray, &mGlyphsCache);
+ aFieldValue, 0, aFieldValue.getLength(), &aTmpDXArray);
// So no scrolling for oversized fields
if ( pPortion->GetSize().Width() > nXWidth )
@@ -1148,7 +1148,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
if (bContinueLastPortion)
{
Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
- rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf, &mGlyphsCache ));
+ rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf ));
pPortion->GetSize().AdjustWidth(aSize.Width() );
if (pPortion->GetSize().Height() < aSize.Height())
pPortion->GetSize().setHeight( aSize.Height() );
@@ -1156,7 +1156,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
else
{
pPortion->GetSize() = aTmpFont.QuickGetTextSize( GetRefDevice(),
- rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf, &mGlyphsCache );
+ rParaPortion.GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf );
}
// #i9050# Do Kerning also behind portions...
@@ -1225,7 +1225,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
{
nW -= rParaPortion.GetTextPortions()[nTmpPortion].GetSize().Width();
nW += aTmpFont.QuickGetTextSize( GetRefDevice(), rParaPortion.GetNode()->GetString(),
- nTmpPos, nDecPos, nullptr, &mGlyphsCache ).Width();
+ nTmpPos, nDecPos, nullptr ).Width();
aCurrentTab.bValid = false;
}
}
@@ -2371,7 +2371,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
GetRefDevice()->Push( vcl::PushFlags::TEXTLANGUAGE );
ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(),
- nTxtPortionStart, pTextPortion->GetLen(), nullptr, &mGlyphsCache );
+ nTxtPortionStart, pTextPortion->GetLen(), nullptr );
GetRefDevice()->Pop();
pTextPortion->GetExtraInfos()->nOrgWidth = aSz.Width();
}
@@ -3301,7 +3301,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
if ( 0x200B == cChar || 0x2060 == cChar )
{
tools::Long nHalfBlankWidth = aTmpFont.QuickGetTextSize( &rOutDev,
- " ", 0, 1, nullptr, &mGlyphsCache ).Width() / 2;
+ " ", 0, 1, nullptr ).Width() / 2;
const tools::Long nAdvanceX = ( nTmpIdx == nTmpEnd ?
rTextPortion.GetSize().Width() :
@@ -3338,13 +3338,13 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
aTmpFont.SetPhysFont(rOutDev);
const Size aSlashSize = aTmpFont.QuickGetTextSize( &rOutDev,
- aSlash, 0, 1, nullptr, &mGlyphsCache );
+ aSlash, 0, 1, nullptr );
Point aSlashPos( aTmpPos );
const tools::Long nAddX = nHalfBlankWidth - aSlashSize.Width() / 2;
setXDirectionAwareFrom(aSlashPos, aTopLeftRectPos);
adjustXDirectionAware(aSlashPos, nAddX);
- aTmpFont.QuickDrawText( &rOutDev, aSlashPos, aSlash, 0, 1, {}, &mGlyphsCache );
+ aTmpFont.QuickDrawText( &rOutDev, aSlashPos, aSlash, 0, 1, {} );
aTmpFont.SetEscapement( nOldEscapement );
aTmpFont.SetPropr( nOldPropr );
@@ -3406,7 +3406,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
aTmpFont.SetPhysFont(*GetRefDevice());
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, nTextStart, nTextLen,
- &aTmpDXArray, &mGlyphsCache );
+ &aTmpDXArray );
pDXArray = aTmpDXArray;
// add a meta file comment if we record to a metafile
@@ -3433,7 +3433,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
// crash when accessing 0 pointer in pDXArray
aTmpFont.SetPhysFont(*GetRefDevice());
aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.getLength(),
- &aTmpDXArray, &mGlyphsCache );
+ &aTmpDXArray );
pDXArray = aTmpDXArray;
}
@@ -3634,7 +3634,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
--nTextLen;
// output directly
- aTmpFont.QuickDrawText( &rOutDev, aRealOutPos, aText, nTextStart, nTextLen, pDXArray, &mGlyphsCache );
+ aTmpFont.QuickDrawText( &rOutDev, aRealOutPos, aText, nTextStart, nTextLen, pDXArray );
if ( bDrawFrame )
{
@@ -3725,7 +3725,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
aTmpFont.SetEscapement( 0 );
aTmpFont.SetPhysFont(rOutDev);
tools::Long nCharWidth = aTmpFont.QuickGetTextSize( &rOutDev,
- OUString(rTextPortion.GetExtraValue()), 0, 1, {}, &mGlyphsCache ).Width();
+ OUString(rTextPortion.GetExtraValue()), 0, 1, {} ).Width();
sal_Int32 nChars = 2;
if( nCharWidth )
nChars = rTextPortion.GetSize().Width() / nCharWidth;
@@ -3737,7 +3737,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
OUStringBuffer aBuf(nChars);
comphelper::string::padToLength(aBuf, nChars, rTextPortion.GetExtraValue());
OUString aText(aBuf.makeStringAndClear());
- aTmpFont.QuickDrawText( &rOutDev, aTmpPos, aText, 0, aText.getLength(), {}, &mGlyphsCache );
+ aTmpFont.QuickDrawText( &rOutDev, aTmpPos, aText, 0, aText.getLength(), {} );
rOutDev.DrawStretchText( aTmpPos, rTextPortion.GetSize().Width(), aText );
if ( bStripOnly )
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index 7c73d0c9d628..4b549d49d711 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -454,27 +454,26 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut )
}
static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, std::vector<sal_Int32>* pDXAry,
- sal_Int32 nIndex, sal_Int32 nLen, SalLayoutGlyphsCache* cache )
+ sal_Int32 nIndex, sal_Int32 nLen )
{
- const SalLayoutGlyphs* layoutGlyphs = cache ? cache->GetLayoutGlyphs(pOut, rStr, nIndex, nLen) : nullptr;
+ const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(pOut, rStr, nIndex, nLen);
return pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, nullptr, layoutGlyphs);
}
Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
- const sal_Int32 nIdx, const sal_Int32 nLen, std::vector<sal_Int32>* pDXArray,
- SalLayoutGlyphsCache* cache ) const
+ const sal_Int32 nIdx, const sal_Int32 nLen, std::vector<sal_Int32>* pDXArray ) const
{
if ( !IsCaseMap() && !IsKern() )
- return Size( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen, cache ),
+ return Size( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen ),
pOut->GetTextHeight() );
Size aTxtSize;
aTxtSize.setHeight( pOut->GetTextHeight() );
if ( !IsCaseMap() )
- aTxtSize.setWidth( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen, cache ) );
+ aTxtSize.setWidth( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen ) );
else
aTxtSize.setWidth( GetTextArray( pOut, CalcCaseMap( rTxt ),
- pDXArray, nIdx, nLen, cache ) );
+ pDXArray, nIdx, nLen ) );
if( IsKern() && ( nLen > 1 ) )
{
@@ -510,23 +509,21 @@ Size SvxFont::GetTextSize(const OutputDevice& rOut, const OUString &rTxt,
static void DrawTextArray( OutputDevice* pOut, const Point& rStartPt, const OUString& rStr,
o3tl::span<const sal_Int32> pDXAry,
- sal_Int32 nIndex, sal_Int32 nLen,
- SalLayoutGlyphsCache* cache )
+ sal_Int32 nIndex, sal_Int32 nLen )
{
- const SalLayoutGlyphs* layoutGlyphs = cache ? cache->GetLayoutGlyphs(pOut, rStr, nIndex, nLen) : nullptr;
+ const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(pOut, rStr, nIndex, nLen);
pOut->DrawTextArray(rStartPt, rStr, pDXAry, nIndex, nLen, SalLayoutFlags::NONE, layoutGlyphs);
}
void SvxFont::QuickDrawText( OutputDevice *pOut,
const Point &rPos, const OUString &rTxt,
- const sal_Int32 nIdx, const sal_Int32 nLen, o3tl::span<const sal_Int32> pDXArray,
- SalLayoutGlyphsCache* cache ) const
+ const sal_Int32 nIdx, const sal_Int32 nLen, o3tl::span<const sal_Int32> pDXArray ) const
{
// Font has to be selected in OutputDevice...
if ( !IsCaseMap() && !IsCapital() && !IsKern() && !IsEsc() )
{
- DrawTextArray( pOut, rPos, rTxt, pDXArray, nIdx, nLen, cache );
+ DrawTextArray( pOut, rPos, rTxt, pDXArray, nIdx, nLen );
return;
}
@@ -563,9 +560,9 @@ void SvxFont::QuickDrawText( OutputDevice *pOut,
else
{
if ( !IsCaseMap() )
- DrawTextArray( pOut, aPos, rTxt, pDXArray, nIdx, nLen, cache );
+ DrawTextArray( pOut, aPos, rTxt, pDXArray, nIdx, nLen );
else
- DrawTextArray( pOut, aPos, CalcCaseMap( rTxt ), pDXArray, nIdx, nLen, cache );
+ DrawTextArray( pOut, aPos, CalcCaseMap( rTxt ), pDXArray, nIdx, nLen );
}
}
}