[Libreoffice-commits] core.git: vcl/coretext vcl/inc
Tor Lillqvist
tml at collabora.com
Thu Nov 28 14:00:14 PST 2013
vcl/coretext/ctfonts.cxx | 41 +++++++++-----------------
vcl/coretext/ctfonts.hxx | 15 ---------
vcl/coretext/ctlayout.cxx | 2 -
vcl/coretext/salgdi2.cxx | 68 ++++++++++++++++++++------------------------
vcl/inc/coretext/salgdi2.h | 29 +++++++++---------
vcl/inc/headless/svpgdi.hxx | 2 -
6 files changed, 62 insertions(+), 95 deletions(-)
New commits:
commit 0379f8b6393e99667584a2964bedf82e4306c2fa
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Nov 28 23:18:20 2013 +0200
Re-factoring: Avoid pointless class derivation
Rename the CoreText-specific ImplMacFontData class to CoreTextFontData
and unify it with its sole derived class CTFontData.
Change-Id: Id3540432996ca55b2e4a20fd8798c94cb7bc84b6
diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 425fb44..bdfcfc6 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -44,16 +44,16 @@ public:
virtual ~CTFontList( void );
bool Init( void );
- void AddFont( CTFontData* );
+ void AddFont( CoreTextFontData* );
virtual void AnnounceFonts( ImplDevFontList& ) const;
- virtual ImplMacFontData* GetFontDataFromId( sal_IntPtr ) const;
+ virtual CoreTextFontData* GetFontDataFromId( sal_IntPtr ) const;
private:
CTFontCollectionRef mpCTFontCollection;
CFArrayRef mpCTFontArray;
- typedef boost::unordered_map<sal_IntPtr,CTFontData*> CTFontContainer;
+ typedef boost::unordered_map<sal_IntPtr,CoreTextFontData*> CTFontContainer;
CTFontContainer maFontContainer;
};
@@ -65,12 +65,12 @@ inline double toRadian(int nDegree)
}
CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD )
-: mpFontData( (ImplMacFontData*)rFSD.mpFontData )
+: mpFontData( (CoreTextFontData*)rFSD.mpFontData )
, mfFontStretch( 1.0 )
, mfFontRotation( 0.0 )
, mpStyleDict( NULL )
{
- mpFontData = (CTFontData*)rFSD.mpFontData;
+ mpFontData = (CoreTextFontData*)rFSD.mpFontData;
const FontSelectPattern* const pReqFont = &rFSD;
double fScaledFontHeight = pReqFont->mfExactHeight;
@@ -249,43 +249,30 @@ void CoreTextStyle::SetTextColor( const RGBAColor& rColor )
// =======================================================================
-CTFontData::CTFontData( const ImplDevFontAttributes& rDFA, sal_IntPtr nFontId )
-: ImplMacFontData( rDFA, nFontId )
-{}
-
-// -----------------------------------------------------------------------
-
-CTFontData::~CTFontData( void )
-{
- // TODO: any resources to release?
-}
-
-// -----------------------------------------------------------------------
-
-PhysicalFontFace* CTFontData::Clone( void ) const
+PhysicalFontFace* CoreTextFontData::Clone( void ) const
{
- return new CTFontData( *this);
+ return new CoreTextFontData( *this);
}
// -----------------------------------------------------------------------
-CoreTextStyle* CTFontData::CreateTextStyle( const FontSelectPattern& rFSD ) const
+CoreTextStyle* CoreTextFontData::CreateTextStyle( const FontSelectPattern& rFSD ) const
{
return new CoreTextStyle( rFSD);
}
// -----------------------------------------------------------------------
-ImplFontEntry* CTFontData::CreateFontInstance( /*const*/ FontSelectPattern& rFSD ) const
+ImplFontEntry* CoreTextFontData::CreateFontInstance( /*const*/ FontSelectPattern& rFSD ) const
{
return new ImplFontEntry( rFSD);
}
// -----------------------------------------------------------------------
-int CTFontData::GetFontTable( const char pTagName[5], unsigned char* pResultBuf ) const
+int CoreTextFontData::GetFontTable( const char pTagName[5], unsigned char* pResultBuf ) const
{
- DBG_ASSERT( pTagName[4]=='\0', "CTFontData::GetFontTable with invalid tagname!\n" );
+ DBG_ASSERT( pTagName[4]=='\0', "CoreTextFontData::GetFontTable with invalid tagname!\n" );
const CTFontTableTag nTagCode = (pTagName[0]<<24) + (pTagName[1]<<16) + (pTagName[2]<<8) + (pTagName[3]<<0);
@@ -423,7 +410,7 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext )
if( bFontEnabled)
{
const sal_IntPtr nFontId = (sal_IntPtr)pValue;
- CTFontData* pFontData = new CTFontData( rDFA, nFontId );
+ CoreTextFontData* pFontData = new CoreTextFontData( rDFA, nFontId );
CTFontList* pFontList = (CTFontList*)pContext;
pFontList->AddFont( pFontData );
}
@@ -453,7 +440,7 @@ CTFontList::~CTFontList()
// -----------------------------------------------------------------------
-void CTFontList::AddFont( CTFontData* pFontData )
+void CTFontList::AddFont( CoreTextFontData* pFontData )
{
sal_IntPtr nFontId = pFontData->GetFontId();
maFontContainer[ nFontId ] = pFontData;
@@ -470,7 +457,7 @@ void CTFontList::AnnounceFonts( ImplDevFontList& rFontList ) const
// -----------------------------------------------------------------------
-ImplMacFontData* CTFontList::GetFontDataFromId( sal_IntPtr nFontId ) const
+CoreTextFontData* CTFontList::GetFontDataFromId( sal_IntPtr nFontId ) const
{
CTFontContainer::const_iterator it = maFontContainer.find( nFontId );
if( it == maFontContainer.end() )
diff --git a/vcl/coretext/ctfonts.hxx b/vcl/coretext/ctfonts.hxx
index 5865df5..7a69b6a 100644
--- a/vcl/coretext/ctfonts.hxx
+++ b/vcl/coretext/ctfonts.hxx
@@ -23,21 +23,6 @@
#endif
#include "sallayout.hxx"
-// CoreText specific physically available font face
-class CTFontData
-: public ImplMacFontData
-{
-public:
- explicit CTFontData( const ImplDevFontAttributes&, sal_IntPtr nFontId );
- explicit CTFontData( CTFontDescriptorRef pFontDesc );
- virtual ~CTFontData( void );
- virtual PhysicalFontFace* Clone( void ) const;
-
- virtual CoreTextStyle* CreateTextStyle( const FontSelectPattern& ) const;
- virtual ImplFontEntry* CreateFontInstance( /*const*/ FontSelectPattern& ) const;
- virtual int GetFontTable( const char pTagName[5], unsigned char* ) const;
-};
-
SystemFontList* GetCoretextFontList(void);
ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef, bool* );
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 1f8bdf8..435c7b1 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -316,7 +316,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int&
if ( !CFEqual( pRunFont, pFont ) ) {
CTFontDescriptorRef pFontDesc = CTFontCopyFontDescriptor( pRunFont );
ImplDevFontAttributes rDevFontAttr = DevFontFromCTFontDescriptor( pFontDesc, NULL );
- pFallbackFont = new CTFontData( rDevFontAttr, (sal_IntPtr)pFontDesc );
+ pFallbackFont = new CoreTextFontData( rDevFontAttr, (sal_IntPtr)pFontDesc );
}
}
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index cbd49f4..c15e4aa 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -67,7 +67,7 @@ SystemFontList::~SystemFontList( void )
// =======================================================================
-ImplMacFontData::ImplMacFontData( const ImplMacFontData& rSrc )
+CoreTextFontData::CoreTextFontData( const CoreTextFontData& rSrc )
: PhysicalFontFace( rSrc )
, mnFontId( rSrc.mnFontId )
, mpCharMap( rSrc.mpCharMap )
@@ -81,7 +81,7 @@ ImplMacFontData::ImplMacFontData( const ImplMacFontData& rSrc )
// -----------------------------------------------------------------------
-ImplMacFontData::ImplMacFontData( const ImplDevFontAttributes& rDFA, sal_IntPtr nFontId )
+CoreTextFontData::CoreTextFontData( const ImplDevFontAttributes& rDFA, sal_IntPtr nFontId )
: PhysicalFontFace( rDFA, 0 )
, mnFontId( nFontId )
, mpCharMap( NULL )
@@ -89,11 +89,12 @@ ImplMacFontData::ImplMacFontData( const ImplDevFontAttributes& rDFA, sal_IntPtr
, mbHasOs2Table( false )
, mbCmapEncodingRead( false )
, mbFontCapabilitiesRead( false )
-{}
+{
+}
// -----------------------------------------------------------------------
-ImplMacFontData::~ImplMacFontData()
+CoreTextFontData::~CoreTextFontData()
{
if( mpCharMap )
mpCharMap->DeReference();
@@ -101,23 +102,16 @@ ImplMacFontData::~ImplMacFontData()
// -----------------------------------------------------------------------
-sal_IntPtr ImplMacFontData::GetFontId() const
+sal_IntPtr CoreTextFontData::GetFontId() const
{
return (sal_IntPtr)mnFontId;
}
// -----------------------------------------------------------------------
-ImplFontEntry* ImplMacFontData::CreateFontInstance(FontSelectPattern& rFSD) const
-{
- return new ImplFontEntry(rFSD);
-}
-
-// -----------------------------------------------------------------------
-
static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);}
-const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const
+const ImplFontCharMap* CoreTextFontData::GetImplFontCharMap() const
{
// return the cached charmap
if( mpCharMap )
@@ -130,17 +124,17 @@ const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const
// get the CMAP byte size
// allocate a buffer for the CMAP raw data
const int nBufSize = GetFontTable( "cmap", NULL );
- DBG_ASSERT( (nBufSize > 0), "ImplMacFontData::GetImplFontCharMap : GetFontTable1 failed!\n");
+ DBG_ASSERT( (nBufSize > 0), "CoreTextFontData::GetImplFontCharMap : GetFontTable1 failed!\n");
if( nBufSize <= 0 )
return mpCharMap;
// get the CMAP raw data
ByteVector aBuffer( nBufSize );
const int nRawLength = GetFontTable( "cmap", &aBuffer[0] );
- DBG_ASSERT( (nRawLength > 0), "ImplMacFontData::GetImplFontCharMap : GetFontTable2 failed!\n");
+ DBG_ASSERT( (nRawLength > 0), "CoreTextFontData::GetImplFontCharMap : GetFontTable2 failed!\n");
if( nRawLength <= 0 )
return mpCharMap;
- DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::GetImplFontCharMap : ByteCount mismatch!\n");
+ DBG_ASSERT( (nBufSize==nRawLength), "CoreTextFontData::GetImplFontCharMap : ByteCount mismatch!\n");
// parse the CMAP
CmapResult aCmapResult;
@@ -155,7 +149,7 @@ const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const
return mpCharMap;
}
-bool ImplMacFontData::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
+bool CoreTextFontData::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
{
// read this only once per font
if( mbFontCapabilitiesRead )
@@ -202,7 +196,7 @@ bool ImplMacFontData::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabi
// -----------------------------------------------------------------------
-void ImplMacFontData::ReadOs2Table( void ) const
+void CoreTextFontData::ReadOs2Table( void ) const
{
// read this only once per font
if( mbOs2Read )
@@ -212,24 +206,24 @@ void ImplMacFontData::ReadOs2Table( void ) const
// prepare to get the OS/2 table raw data
const int nBufSize = GetFontTable( "OS/2", NULL );
- DBG_ASSERT( (nBufSize > 0), "ImplMacFontData::ReadOs2Table : GetFontTable1 failed!\n");
+ DBG_ASSERT( (nBufSize > 0), "CoreTextFontData::ReadOs2Table : GetFontTable1 failed!\n");
if( nBufSize <= 0 )
return;
// get the OS/2 raw data
ByteVector aBuffer( nBufSize );
const int nRawLength = GetFontTable( "cmap", &aBuffer[0] );
- DBG_ASSERT( (nRawLength > 0), "ImplMacFontData::ReadOs2Table : GetFontTable2 failed!\n");
+ DBG_ASSERT( (nRawLength > 0), "CoreTextFontData::ReadOs2Table : GetFontTable2 failed!\n");
if( nRawLength <= 0 )
return;
- DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::ReadOs2Table : ByteCount mismatch!\n");
+ DBG_ASSERT( (nBufSize==nRawLength), "CoreTextFontData::ReadOs2Table : ByteCount mismatch!\n");
mbHasOs2Table = true;
// parse the OS/2 raw data
// TODO: also analyze panose info, etc.
}
-void ImplMacFontData::ReadMacCmapEncoding( void ) const
+void CoreTextFontData::ReadMacCmapEncoding( void ) const
{
// read this only once per font
if( mbCmapEncodingRead )
@@ -245,7 +239,7 @@ void ImplMacFontData::ReadMacCmapEncoding( void ) const
const int nRawLength = GetFontTable( "cmap", &aBuffer[0] );
if( nRawLength < 24 )
return;
- DBG_ASSERT( (nBufSize==nRawLength), "ImplMacFontData::ReadMacCmapEncoding : ByteCount mismatch!\n");
+ DBG_ASSERT( (nBufSize==nRawLength), "CoreTextFontData::ReadMacCmapEncoding : ByteCount mismatch!\n");
const unsigned char* pCmap = &aBuffer[0];
if( GetUShort( pCmap ) != 0x0000 )
@@ -270,7 +264,7 @@ AquaSalGraphics::AquaSalGraphics()
, mxClipPath( NULL )
, maLineColor( COL_WHITE )
, maFillColor( COL_BLACK )
- , mpMacFontData( NULL )
+ , mpFontData( NULL )
, mpTextStyle( NULL )
, maTextColor( COL_BLACK )
, mbNonAntialiasedText( false )
@@ -280,7 +274,7 @@ AquaSalGraphics::AquaSalGraphics()
#else
: mrContext( NULL )
, mfFakeDPIScale( 1.0 )
- , mpMacFontData( NULL )
+ , mpFontData( NULL )
, mpTextStyle( NULL )
, maTextColor( COL_BLACK )
, mbNonAntialiasedText( false )
@@ -458,20 +452,20 @@ sal_uInt16 AquaSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbac
// handle NULL request meaning: release-font-resources request
if( !pReqFont )
{
- mpMacFontData = NULL;
+ mpFontData = NULL;
return 0;
}
// update the text style
- mpMacFontData = static_cast<const ImplMacFontData*>( pReqFont->mpFontData );
- mpTextStyle = mpMacFontData->CreateTextStyle( *pReqFont );
+ mpFontData = static_cast<const CoreTextFontData*>( pReqFont->mpFontData );
+ mpTextStyle = mpFontData->CreateTextStyle( *pReqFont );
mpTextStyle->SetTextColor( maTextColor );
SAL_INFO("vcl.coretext",
"SetFont"
- << " to " << mpMacFontData->GetFamilyName()
- << ", " << mpMacFontData->GetStyleName()
- << " fontid=" << mpMacFontData->GetFontId()
+ << " to " << mpFontData->GetFamilyName()
+ << ", " << mpFontData->GetStyleName()
+ << " fontid=" << mpFontData->GetFontId()
<< " for " << pReqFont->GetFamilyName()
<< ", " << pReqFont->GetStyleName()
<< " weight=" << pReqFont->GetWeight()
@@ -495,18 +489,18 @@ SalLayout* AquaSalGraphics::GetTextLayout( ImplLayoutArgs& /*rArgs*/, int /*nFal
const ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const
{
- if( !mpMacFontData )
+ if( !mpFontData )
return ImplFontCharMap::GetDefaultMap();
- return mpMacFontData->GetImplFontCharMap();
+ return mpFontData->GetImplFontCharMap();
}
bool AquaSalGraphics::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
{
- if( !mpMacFontData )
+ if( !mpFontData )
return false;
- return mpMacFontData->GetImplFontCapabilities(rFontCapabilities);
+ return mpFontData->GetImplFontCapabilities(rFontCapabilities);
}
// -----------------------------------------------------------------------
@@ -543,7 +537,7 @@ static void FakeDirEntry( const char aTag[5], ByteCount nOfs, ByteCount nLen,
bool AquaSalGraphics::GetRawFontData( const PhysicalFontFace* pFontData,
ByteVector& rBuffer, bool* pJustCFF )
{
- const ImplMacFontData* pMacFont = static_cast<const ImplMacFontData*>(pFontData);
+ const CoreTextFontData* pMacFont = static_cast<const CoreTextFontData*>(pFontData);
// short circuit for CFF-only fonts
const int nCffSize = pMacFont->GetFontTable( "CFF ", NULL);
@@ -734,7 +728,7 @@ void AquaSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFontData, bool bV
free( (void*)pGlyphMetrics );
}
- const ImplFontCharMap* pMap = mpMacFontData->GetImplFontCharMap();
+ const ImplFontCharMap* pMap = mpFontData->GetImplFontCharMap();
DBG_ASSERT( pMap && pMap->GetCharCount(), "no charmap" );
pMap->AddReference(); // TODO: add and use RAII object instead
diff --git a/vcl/inc/coretext/salgdi2.h b/vcl/inc/coretext/salgdi2.h
index 3898aeb..3186461 100644
--- a/vcl/inc/coretext/salgdi2.h
+++ b/vcl/inc/coretext/salgdi2.h
@@ -49,20 +49,20 @@ class CoreTextStyle;
typedef sal_uInt32 sal_GlyphId;
typedef std::vector<unsigned char> ByteVector;
-// mac specific physically available font face
-class ImplMacFontData : public PhysicalFontFace
+// CoreText-specific physically available font face
+class CoreTextFontData : public PhysicalFontFace
{
public:
- ImplMacFontData( const ImplDevFontAttributes&, sal_IntPtr nFontID );
+ CoreTextFontData( const ImplDevFontAttributes&, sal_IntPtr nFontID );
- virtual ~ImplMacFontData();
+ ~CoreTextFontData();
- virtual PhysicalFontFace* Clone() const = 0;
- virtual ImplFontEntry* CreateFontInstance( FontSelectPattern& ) const;
- virtual sal_IntPtr GetFontId() const;
+ PhysicalFontFace* Clone() const;
+ ImplFontEntry* CreateFontInstance( FontSelectPattern& ) const;
+ sal_IntPtr GetFontId() const;
- virtual CoreTextStyle* CreateTextStyle( const FontSelectPattern& ) const = 0;
- virtual int GetFontTable( const char pTagName[5], unsigned char* ) const = 0;
+ CoreTextStyle* CreateTextStyle( const FontSelectPattern& ) const;
+ int GetFontTable( const char pTagName[5], unsigned char* ) const;
const ImplFontCharMap* GetImplFontCharMap() const;
bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
@@ -72,7 +72,8 @@ public:
void ReadMacCmapEncoding() const;
protected:
- ImplMacFontData( const ImplMacFontData&);
+ CoreTextFontData( const CoreTextFontData&);
+
private:
const sal_IntPtr mnFontId;
mutable const ImplFontCharMap* mpCharMap;
@@ -97,7 +98,7 @@ public:
void SetTextColor( const RGBAColor& );
- const ImplMacFontData* mpFontData;
+ const CoreTextFontData* mpFontData;
/// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
float mfFontStretch;
/// text rotation in radian
@@ -121,7 +122,7 @@ public:
virtual ~SystemFontList( void );
virtual void AnnounceFonts( ImplDevFontList& ) const = 0;
- virtual ImplMacFontData* GetFontDataFromId( sal_IntPtr nFontId ) const = 0;
+ virtual CoreTextFontData* GetFontDataFromId( sal_IntPtr nFontId ) const = 0;
};
#ifdef MACOSX
@@ -160,8 +161,8 @@ protected:
RGBAColor maFillColor;
// Device Font settings
- const ImplMacFontData* mpMacFontData;
- CoreTextStyle* mpTextStyle;
+ const CoreTextFontData* mpFontData;
+ CoreTextStyle* mpTextStyle;
RGBAColor maTextColor;
/// allows text to be rendered without antialiasing
bool mbNonAntialiasedText;
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index f6281ad..2853c89 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -89,7 +89,7 @@ protected:
double mfFakeDPIScale;
// Device Font settings
- const ImplMacFontData* mpMacFontData;
+ const CoreTextFontData* mpFontData;
CoreTextStyle* mpTextStyle;
RGBAColor maTextColor;
/// allows text to be rendered without antialiasing
More information about the Libreoffice-commits
mailing list