summaryrefslogtreecommitdiff
path: root/vcl/generic
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2014-10-04 21:55:58 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2014-10-06 00:13:38 +0000
commit9177329a425cf70b515d1f266132838894fe54c6 (patch)
treedd064e9b56019046faa0966d0147c19a7fa2ca3e /vcl/generic
parent36e1d19af8585bc2f36322ba32acbed46e58c4de (diff)
vcl: FontCharMap to use intrusive_ptr ImplFontCharMap
ImplFontCharMap was using it's own reference counting mechanism, however we can use intrusive_ptr more effectively. Added a unit test around FontCharMap. Change-Id: Ifab6ce002fd1df8feb7e017dea3012ff9ea7f18a Reviewed-on: https://gerrit.libreoffice.org/11804 Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com> Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl/generic')
-rw-r--r--vcl/generic/fontmanager/fontmanager.cxx6
-rw-r--r--vcl/generic/glyphs/gcach_ftyp.cxx15
-rw-r--r--vcl/generic/glyphs/gcach_ftyp.hxx4
-rw-r--r--vcl/generic/print/genpspgraphics.cxx4
4 files changed, 17 insertions, 12 deletions
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 273707699350..05fc829d0e5e 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -2088,11 +2088,11 @@ void PrintFontManager::getGlyphWidths( fontID nFont,
CmapResult aCmapResult;
if( ParseCMAP( pCmapData, nCmapSize, aCmapResult ) )
{
- const ImplFontCharMap aCharMap( aCmapResult );
+ const ImplFontCharMapPtr pCharMap( new ImplFontCharMap(aCmapResult) );
for( sal_uInt32 cOld = 0;;)
{
// get next unicode covered by font
- const sal_uInt32 c = aCharMap.GetNextChar( cOld );
+ const sal_uInt32 c = pCharMap->GetNextChar( cOld );
if( c == cOld )
break;
cOld = c;
@@ -2101,7 +2101,7 @@ void PrintFontManager::getGlyphWidths( fontID nFont,
break;
#endif
// get the matching glyph index
- const sal_GlyphId aGlyphId = aCharMap.GetGlyphIndex( c );
+ const sal_GlyphId aGlyphId = pCharMap->GetGlyphIndex( c );
// update the requested map
rUnicodeEnc[ (sal_Unicode)c ] = aGlyphId;
}
diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index 9db574ee407b..fa93fc603738 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -242,7 +242,7 @@ FtFontInfo::FtFontInfo( const ImplDevFontAttributes& rDevFontAttributes,
FtFontInfo::~FtFontInfo()
{
if( mpFontCharMap )
- mpFontCharMap->DeReference();
+ mpFontCharMap = 0;
delete mpChar2Glyph;
delete mpGlyph2Char;
#if ENABLE_GRAPHITE
@@ -1265,13 +1265,13 @@ bool ServerFont::GetGlyphBitmap8( sal_GlyphId aGlyphId, RawBitmap& rRawBitmap )
// determine unicode ranges in font
-const ImplFontCharMap* ServerFont::GetImplFontCharMap( void ) const
+const ImplFontCharMapPtr ServerFont::GetImplFontCharMap( void ) const
{
- const ImplFontCharMap* pIFCMap = mpFontInfo->GetImplFontCharMap();
+ const ImplFontCharMapPtr pIFCMap = mpFontInfo->GetImplFontCharMap();
return pIFCMap;
}
-const ImplFontCharMap* FtFontInfo::GetImplFontCharMap( void )
+const ImplFontCharMapPtr FtFontInfo::GetImplFontCharMap( void )
{
// check if the charmap is already cached
if( mpFontCharMap )
@@ -1281,9 +1281,14 @@ const ImplFontCharMap* FtFontInfo::GetImplFontCharMap( void )
CmapResult aCmapResult;
bool bOK = GetFontCodeRanges( aCmapResult );
if( bOK )
- mpFontCharMap = new ImplFontCharMap( aCmapResult );
+ {
+ ImplFontCharMapPtr pFontCharMap( new ImplFontCharMap( aCmapResult ) );
+ mpFontCharMap = pFontCharMap;
+ }
else
+ {
mpFontCharMap = ImplFontCharMap::GetDefaultMap();
+ }
// mpFontCharMap on either branch now has a refcount of 1
return mpFontCharMap;
}
diff --git a/vcl/generic/glyphs/gcach_ftyp.hxx b/vcl/generic/glyphs/gcach_ftyp.hxx
index b43d47b39397..803ce072a955 100644
--- a/vcl/generic/glyphs/gcach_ftyp.hxx
+++ b/vcl/generic/glyphs/gcach_ftyp.hxx
@@ -84,7 +84,7 @@ public:
void CacheGlyphIndex( sal_UCS4 cChar, int nGI ) const;
bool GetFontCodeRanges( CmapResult& ) const;
- const ImplFontCharMap* GetImplFontCharMap( void );
+ const ImplFontCharMapPtr GetImplFontCharMap( void );
private:
FT_FaceRec_* maFaceFT;
@@ -99,7 +99,7 @@ private:
sal_IntPtr mnFontId;
ImplDevFontAttributes maDevFontAttributes;
- const ImplFontCharMap* mpFontCharMap;
+ ImplFontCharMapPtr mpFontCharMap;
// cache unicode->glyphid mapping because looking it up is expensive
// TODO: change to boost::unordered_multimap when a use case requires a m:n mapping
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index 401f5c7af5e8..759519b3cefa 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -777,12 +777,12 @@ void GenPspGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout )
DrawPrinterLayout( rLayout, *m_pPrinterGfx, true );
}
-const ImplFontCharMap* GenPspGraphics::GetImplFontCharMap() const
+const ImplFontCharMapPtr GenPspGraphics::GetImplFontCharMap() const
{
if( !m_pServerFont[0] )
return NULL;
- const ImplFontCharMap* pIFCMap = m_pServerFont[0]->GetImplFontCharMap();
+ const ImplFontCharMapPtr pIFCMap = m_pServerFont[0]->GetImplFontCharMap();
return pIFCMap;
}