From 9177329a425cf70b515d1f266132838894fe54c6 Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Sat, 4 Oct 2014 21:55:58 +1000 Subject: 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 Tested-by: Chris Sherlock --- vcl/inc/generic/genpspgraphics.h | 2 +- vcl/inc/generic/glyphcache.hxx | 2 +- vcl/inc/headless/svpgdi.hxx | 2 +- vcl/inc/impfont.hxx | 24 ++++++++++++++++++++---- vcl/inc/quartz/salgdi.h | 6 +++--- vcl/inc/salgdi.hxx | 4 ++-- vcl/inc/unx/salgdi.h | 2 +- vcl/inc/win/salgdi.h | 6 +++--- 8 files changed, 32 insertions(+), 16 deletions(-) (limited to 'vcl/inc') diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index ec54d5bd66eb..66c7f31f3802 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -89,7 +89,7 @@ public: virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE; virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE; virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; - virtual const ImplFontCharMap* GetImplFontCharMap() const SAL_OVERRIDE; + virtual const ImplFontCharMapPtr GetImplFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE; // graphics must drop any cached font info diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx index a3b1c4f9ea87..40a07dad1640 100644 --- a/vcl/inc/generic/glyphcache.hxx +++ b/vcl/inc/generic/glyphcache.hxx @@ -182,7 +182,7 @@ public: const unsigned char* GetTable( const char* pName, sal_uLong* pLength ); int GetEmUnits() const { return maFaceFT->units_per_EM;} const FT_Size_Metrics& GetMetricsFT() const { return maSizeFT->metrics; } - const ImplFontCharMap* GetImplFontCharMap() const; + const ImplFontCharMapPtr GetImplFontCharMap() const; bool GetFontCapabilities(vcl::FontCapabilities &) const; GlyphData& GetGlyphData( sal_GlyphId ); diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 65a8fc2a15bf..aad4693d35e7 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -156,7 +156,7 @@ public: virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE; virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE; virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; - virtual const ImplFontCharMap* GetImplFontCharMap() const SAL_OVERRIDE; + virtual const ImplFontCharMapPtr GetImplFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE; virtual void ClearDevFontCache() SAL_OVERRIDE; diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx index 3c42f6e1a465..af97677f3999 100644 --- a/vcl/inc/impfont.hxx +++ b/vcl/inc/impfont.hxx @@ -29,6 +29,11 @@ #include #include +#include + +class ImplFontCharMap; +typedef boost::intrusive_ptr< ImplFontCharMap > ImplFontCharMapPtr; + // - Impl_Font - class Impl_Font @@ -158,7 +163,7 @@ public: explicit ImplFontCharMap( const CmapResult& ); virtual ~ImplFontCharMap(); - static ImplFontCharMap* GetDefaultMap( bool bSymbols=false); + static ImplFontCharMapPtr GetDefaultMap( bool bSymbols=false); bool IsDefaultMap() const; bool HasChar( sal_uInt32 ) const; @@ -174,12 +179,12 @@ public: int GetIndexFromChar( sal_uInt32 ) const; sal_uInt32 GetCharFromIndex( int ) const; - void AddReference() const; - void DeReference() const; - int GetGlyphIndex( sal_uInt32 ) const; private: + friend void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap); + friend void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap); + int ImplFindRangeIndex( sal_uInt32 ) const; // prevent assignment and copy construction @@ -195,6 +200,17 @@ private: mutable sal_uInt32 mnRefCount; }; +inline void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap) +{ + ++pImplFontCharMap->mnRefCount; +} + +inline void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap) +{ + if (--pImplFontCharMap->mnRefCount == 0) + delete pImplFontCharMap; +} + // CmapResult is a normalized version of the many CMAP formats class VCL_PLUGIN_PUBLIC CmapResult { diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 8aad5348292b..0c58ca7da621 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -73,7 +73,7 @@ public: CoreTextStyle* CreateTextStyle( const FontSelectPattern& ) const; int GetFontTable( const char pTagName[5], unsigned char* ) const; - const ImplFontCharMap* GetImplFontCharMap() const; + const ImplFontCharMapPtr GetImplFontCharMap() const; bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; bool HasChar( sal_uInt32 cChar ) const; @@ -85,7 +85,7 @@ protected: private: const sal_IntPtr mnFontId; - mutable const ImplFontCharMap* mpCharMap; + mutable ImplFontCharMapPtr mpCharMap; mutable vcl::FontCapabilities maFontCapabilities; mutable bool mbOs2Read; // true if OS2-table related info is valid mutable bool mbHasOs2Table; @@ -330,7 +330,7 @@ public: // get the current font's metrics virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; // get the repertoire of the current font - virtual const ImplFontCharMap* + virtual const ImplFontCharMapPtr GetImplFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; // graphics must fill supplied font list diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index bed847472fc6..c2752b92447f 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -28,6 +28,7 @@ #include "vcl/salnativewidgets.hxx" #include "salglyphid.hxx" #include "sallayout.hxx" +#include #include @@ -36,7 +37,6 @@ class SalBitmap; class FontSelectPattern; class ImplFontMetricData; class PhysicalFontFace; -class ImplFontCharMap; class SalLayout; class ImplLayoutArgs; class Rectangle; @@ -231,7 +231,7 @@ public: virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel = 0 ) = 0; // get the repertoire of the current font - virtual const ImplFontCharMap* + virtual const ImplFontCharMapPtr GetImplFontCharMap() const = 0; // get the layout capabilities of the current font diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 978e51421834..ba0814be8671 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -229,7 +229,7 @@ public: virtual void SetTextColor( SalColor nSalColor ) SAL_OVERRIDE; virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE; virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE; - virtual const ImplFontCharMap* GetImplFontCharMap() const SAL_OVERRIDE; + virtual const ImplFontCharMapPtr GetImplFontCharMap() const SAL_OVERRIDE; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE; virtual void GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE; virtual void ClearDevFontCache() SAL_OVERRIDE; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 957db9103215..ace973cde206 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -94,7 +94,7 @@ public: const gr_face* GraphiteFace() const; #endif - const ImplFontCharMap* GetImplFontCharMap() const; + const ImplFontCharMapPtr GetImplFontCharMap() const; bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; const Ucs2SIntMap* GetEncodingVector() const { return mpEncodingVector; } void SetEncodingVector( const Ucs2SIntMap* pNewVec ) const @@ -116,7 +116,7 @@ private: #endif mutable bool mbHasArabicSupport; mutable bool mbFontCapabilitiesRead; - mutable ImplFontCharMap* mpUnicodeMap; + mutable ImplFontCharMapPtr mpUnicodeMap; mutable const Ucs2SIntMap* mpEncodingVector; mutable vcl::FontCapabilities maFontCapabilities; @@ -310,7 +310,7 @@ public: // get the current font's metrics virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ); // get the repertoire of the current font - virtual const ImplFontCharMap* GetImplFontCharMap() const; + virtual const ImplFontCharMapPtr GetImplFontCharMap() const; // get the layout capabilities of the current font virtual bool GetFontCapabilities(vcl::FontCapabilities &rGetFontCapabilities) const; // graphics must fill supplied font list -- cgit ption> LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author