summaryrefslogtreecommitdiffstats
path: root/vcl/generic/glyphs
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/glyphs
parentdo not copy properties from oneself (diff)
downloadcore-9177329a425cf70b515d1f266132838894fe54c6.tar.gz
core-9177329a425cf70b515d1f266132838894fe54c6.zip
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/glyphs')
-rw-r--r--vcl/generic/glyphs/gcach_ftyp.cxx15
-rw-r--r--vcl/generic/glyphs/gcach_ftyp.hxx4
2 files changed, 12 insertions, 7 deletions
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