From 22ec51681687c4d700336603f6f37e981ad37bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 22 Mar 2011 12:59:42 +0000 Subject: [PATCH] Cut Gordian Knot of who owns the font options --- vcl/inc/vcl/glyphcache.hxx | 8 +++++--- vcl/source/glyphs/gcach_ftyp.cxx | 5 ++--- vcl/source/glyphs/gcach_ftyp.hxx | 6 +++--- vcl/source/glyphs/glyphcache.cxx | 2 -- vcl/unx/source/gdi/salgdi3.cxx | 8 ++++---- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx index 351eb13..6a375a4 100644 --- a/vcl/inc/vcl/glyphcache.hxx +++ b/vcl/inc/vcl/glyphcache.hxx @@ -45,6 +45,7 @@ #include #include #include +#include namespace basegfx { class B2DPolyPolygon; } @@ -182,8 +183,9 @@ virtual bool TestFont() const { return true; } virtual void* GetFtFace() const { return 0; } virtual int GetLoadFlags() const { return 0; } - virtual void SetFontOptions( const ImplFontOptions*) {} - virtual const ImplFontOptions* GetFontOptions() const { return 0; } + virtual void SetFontOptions( boost::shared_ptr ) {} + virtual boost::shared_ptr GetFontOptions() const + { return boost::shared_ptr(); } virtual bool NeedsArtificialBold() const { return false; } virtual bool NeedsArtificialItalic() const { return false; } @@ -261,7 +263,7 @@ { private: ServerFont* mpServerFont; - ImplFontOptions* mpFontOptions; + boost::shared_ptr mpFontOptions; bool mbGotFontOptions; public: diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index 3de5082..d482916 100644 --- a/vcl/source/glyphs/gcach_ftyp.cxx +++ b/vcl/source/glyphs/gcach_ftyp.cxx @@ -769,7 +769,6 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn mpFontInfo( pFI ), maFaceFT( NULL ), maSizeFT( NULL ), - mpFontOptions( NULL ), mbFaceOk( false ), maRecodeConverter( NULL ), mpLayoutEngine( NULL ) @@ -915,7 +914,7 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn mnLoadFlags |= FT_LOAD_NO_BITMAP; } -void FreetypeServerFont::SetFontOptions( const ImplFontOptions* pFontOptions) +void FreetypeServerFont::SetFontOptions( boost::shared_ptr pFontOptions) { mpFontOptions = pFontOptions; @@ -970,7 +969,7 @@ void FreetypeServerFont::SetFontOptions( const ImplFontOptions* pFontOptions) mnLoadFlags |= FT_LOAD_NO_BITMAP; } -const ImplFontOptions* FreetypeServerFont::GetFontOptions() const +boost::shared_ptr FreetypeServerFont::GetFontOptions() const { return mpFontOptions; } diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx index 8ebef45..0af4ed1 100644 --- a/vcl/source/glyphs/gcach_ftyp.hxx +++ b/vcl/source/glyphs/gcach_ftyp.hxx @@ -191,8 +191,8 @@ public: virtual int GetFontFaceNum() const { return mpFontInfo->GetFaceNum(); } virtual bool TestFont() const; virtual void* GetFtFace() const; - virtual void SetFontOptions( const ImplFontOptions*); - virtual const ImplFontOptions* GetFontOptions() const; + virtual void SetFontOptions( boost::shared_ptr ); + virtual boost::shared_ptr GetFontOptions() const; virtual int GetLoadFlags() const { return (mnLoadFlags & ~FT_LOAD_IGNORE_TRANSFORM); } virtual bool NeedsArtificialBold() const { return mbArtBold; } virtual bool NeedsArtificialItalic() const { return mbArtItalic; } @@ -239,7 +239,7 @@ private: FT_FaceRec_* maFaceFT; FT_SizeRec_* maSizeFT; - const ImplFontOptions* mpFontOptions; + boost::shared_ptr mpFontOptions; bool mbFaceOk; bool mbArtItalic; diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx index 649ffb4..373c430 100644 --- a/vcl/source/glyphs/glyphcache.cxx +++ b/vcl/source/glyphs/glyphcache.cxx @@ -534,7 +534,6 @@ bool ServerFont::IsGlyphInvisible( int nGlyphIndex ) ImplServerFontEntry::ImplServerFontEntry( ImplFontSelectData& rFSD ) : ImplFontEntry( rFSD ) , mpServerFont( NULL ) -, mpFontOptions( NULL ) , mbGotFontOptions( false ) {} @@ -543,7 +542,6 @@ ImplServerFontEntry::ImplServerFontEntry( ImplFontSelectData& rFSD ) ImplServerFontEntry::~ImplServerFontEntry() { // TODO: remove the ServerFont here instead of in the GlyphCache - delete mpFontOptions; } // ======================================================================= diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx index 20fd3cd..4365356 100644 --- a/vcl/unx/source/gdi/salgdi3.cxx +++ b/vcl/unx/source/gdi/salgdi3.cxx @@ -665,8 +665,8 @@ { // get and cache the font options mbGotFontOptions = true; - mpFontOptions = GetFCFontOptions( *maFontSelData.mpFontData, - maFontSelData.mnHeight ); + mpFontOptions.reset(GetFCFontOptions( *maFontSelData.mpFontData, + maFontSelData.mnHeight )); } // apply the font options mpServerFont->SetFontOptions( mpFontOptions ); @@ -1043,7 +1043,7 @@ font_face = (cairo_font_face_t*)m_aCairoFontsCache.FindCachedFont(pId); if (!font_face) { - const ImplFontOptions *pOptions = rFont.GetFontOptions(); + const ImplFontOptions *pOptions = rFont.GetFontOptions().get(); void *pPattern = pOptions ? pOptions->GetPattern(pId) : NULL; if (pPattern) font_face = rCairo.ft_font_face_create_for_pattern(pPattern); -- 1.7.4.1