diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-05 14:48:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-07 13:27:53 +0200 |
commit | 77a01802d1a0452814718789bb0c76adeeb747c0 (patch) | |
tree | 00198f9cc2c3e4ea4f91597adebb1c52eb6cc395 /vcl/inc | |
parent | d9fc8b494be53bacffe45564e98da61ae5b28bd3 (diff) |
manage PhysicalFontFace by rtl::Reference
Change-Id: I8f66b5afb066fe83abb83c56ebde6f21197f894b
Reviewed-on: https://gerrit.libreoffice.org/55333
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/PhysicalFontFace.hxx | 10 | ||||
-rw-r--r-- | vcl/inc/PhysicalFontFamily.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/fontinstance.hxx | 5 | ||||
-rw-r--r-- | vcl/inc/outdev.h | 4 | ||||
-rw-r--r-- | vcl/inc/qt5/Qt5FontFace.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 4 | ||||
-rw-r--r-- | vcl/inc/unx/freetype_glyphcache.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 2 |
8 files changed, 17 insertions, 16 deletions
diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx index 39237ff46f89..2406b6cf41da 100644 --- a/vcl/inc/PhysicalFontFace.hxx +++ b/vcl/inc/PhysicalFontFace.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_VCL_INC_PHYSICALFONTFACE_HXX #define INCLUDED_VCL_INC_PHYSICALFONTFACE_HXX +#include <salhelper/simplereferenceobject.hxx> +#include <rtl/ref.hxx> #include <vcl/dllapi.h> #include "fontattributes.hxx" @@ -40,7 +42,6 @@ public: // TODO: no more direct access to members -// TODO: add reference counting // TODO: get rid of height/width for scalable fonts // TODO: make cloning cheaper @@ -50,13 +51,11 @@ public: * It acts as a factory for its corresponding LogicalFontInstances and * can be extended to cache device and font instance specific data. */ -class VCL_PLUGIN_PUBLIC PhysicalFontFace : public FontAttributes +class VCL_PLUGIN_PUBLIC PhysicalFontFace : public FontAttributes, public salhelper::SimpleReferenceObject { public: - virtual ~PhysicalFontFace() {} - virtual LogicalFontInstance* CreateFontInstance(const FontSelectPattern&) const; - virtual PhysicalFontFace* Clone() const = 0; + virtual rtl::Reference<PhysicalFontFace> Clone() const = 0; int GetHeight() const { return mnHeight; } int GetWidth() const { return mnWidth; } @@ -68,6 +67,7 @@ public: protected: explicit PhysicalFontFace(const FontAttributes&); + PhysicalFontFace(const PhysicalFontFace&); void SetBitmapSize( int nW, int nH ) { mnWidth=nW; mnHeight=nH; } long mnWidth; // Width (in pixels) diff --git a/vcl/inc/PhysicalFontFamily.hxx b/vcl/inc/PhysicalFontFamily.hxx index e88db8203809..990256590c88 100644 --- a/vcl/inc/PhysicalFontFamily.hxx +++ b/vcl/inc/PhysicalFontFamily.hxx @@ -67,7 +67,7 @@ public: void InitMatchData( const utl::FontSubstConfiguration&, const OUString& rSearchName ); - bool AddFontFace( PhysicalFontFace* ); + void AddFontFace( PhysicalFontFace* ); PhysicalFontFace* FindBestFontFace( const FontSelectPattern& rFSD ) const; @@ -78,7 +78,7 @@ static void CalcType( ImplFontAttrs& rType, FontWeight& rWeight, Fon FontFamily eFamily, const utl::FontNameAttr* pFontAttr ); private: - std::vector< std::unique_ptr<PhysicalFontFace> > maFontFaces; + std::vector< rtl::Reference<PhysicalFontFace> > maFontFaces; OUString maFamilyName; // original font family name OUString maSearchName; // normalized font family name diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx index 90ed83d3ab33..317b7181198d 100644 --- a/vcl/inc/fontinstance.hxx +++ b/vcl/inc/fontinstance.hxx @@ -23,6 +23,7 @@ #include "fontselect.hxx" #include "impfontmetricdata.hxx" +#include <rtl/ref.hxx> #include <unordered_map> #include <memory> @@ -64,7 +65,7 @@ public: // TODO: make data members private double GetAverageWidthFactor() const { return m_nAveWidthFactor; } const FontSelectPattern& GetFontSelectPattern() const { return m_aFontSelData; } - const PhysicalFontFace* GetFontFace() const { return m_pFontFace; } + const PhysicalFontFace* GetFontFace() const { return m_pFontFace.get(); } const ImplFontCache* GetFontCache() const { return mpFontCache; } int GetKashidaWidth(); @@ -91,7 +92,7 @@ private: const FontSelectPattern m_aFontSelData; hb_font_t* m_pHbFont; double m_nAveWidthFactor; - const PhysicalFontFace* m_pFontFace; + rtl::Reference<PhysicalFontFace> m_pFontFace; }; inline hb_font_t* LogicalFontInstance::GetHbFont() diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h index 3b626f3b0d8e..2aabdfa93acf 100644 --- a/vcl/inc/outdev.h +++ b/vcl/inc/outdev.h @@ -41,12 +41,12 @@ enum class AddFontSubstituteFlags; class ImplDeviceFontList { private: - std::vector<PhysicalFontFace*> maDevFontVector; + std::vector<rtl::Reference<PhysicalFontFace>> maDevFontVector; public: ImplDeviceFontList() { maDevFontVector.reserve(1024); } void Add( PhysicalFontFace* pFace ) { maDevFontVector.push_back( pFace ); } - PhysicalFontFace* Get( int nIndex ) const { return maDevFontVector[ nIndex ]; } + PhysicalFontFace* Get( int nIndex ) const { return maDevFontVector[ nIndex ].get(); } int Count() const { return maDevFontVector.size(); } }; diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx index 9468cf15b4e3..4cc21010a8b7 100644 --- a/vcl/inc/qt5/Qt5FontFace.hxx +++ b/vcl/inc/qt5/Qt5FontFace.hxx @@ -38,7 +38,7 @@ public: static Qt5FontFace* fromQFont(const QFont& rFont); - PhysicalFontFace* Clone() const override; + rtl::Reference<PhysicalFontFace> Clone() const override; sal_IntPtr GetFontId() const override; int GetFontTable(const char pTagName[5], unsigned char*) const; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 064b2125e8be..2f53a44d694e 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -61,7 +61,7 @@ public: CoreTextFontFace( const FontAttributes&, sal_IntPtr nFontID ); virtual ~CoreTextFontFace() override; - PhysicalFontFace* Clone() const override; + rtl::Reference<PhysicalFontFace> Clone() const override; sal_IntPtr GetFontId() const override; int GetFontTable( uint32_t nTagCode, unsigned char* ) const; @@ -128,7 +128,7 @@ private: CTFontCollectionRef mpCTFontCollection; CFArrayRef mpCTFontArray; - std::unordered_map<sal_IntPtr,CoreTextFontFace*> maFontContainer; + std::unordered_map<sal_IntPtr, rtl::Reference<CoreTextFontFace>> maFontContainer; }; diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx index 0a7b88887b24..d6b87b7ab7a9 100644 --- a/vcl/inc/unx/freetype_glyphcache.hxx +++ b/vcl/inc/unx/freetype_glyphcache.hxx @@ -115,7 +115,7 @@ public: FreetypeFontFace( FreetypeFontInfo*, const FontAttributes& ); virtual LogicalFontInstance* CreateFontInstance( const FontSelectPattern& ) const override; - virtual PhysicalFontFace* Clone() const override { return new FreetypeFontFace( *this ); } + virtual rtl::Reference<PhysicalFontFace> Clone() const override { return new FreetypeFontFace( *this ); } virtual sal_IntPtr GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); } }; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index f2580aa05d5d..59190f87e17d 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -63,7 +63,7 @@ public: BYTE nPitchAndFamily ); virtual ~WinFontFace() override; - virtual PhysicalFontFace* Clone() const override; + virtual rtl::Reference<PhysicalFontFace> Clone() const override; virtual LogicalFontInstance* CreateFontInstance( const FontSelectPattern& ) const override; virtual sal_IntPtr GetFontId() const override; void SetFontId( sal_IntPtr nId ) { mnId = nId; } |