summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorAkash Jain <akash96j@gmail.com>2016-08-17 21:31:22 +0530
committerKhaled Hosny <khaledhosny@eglug.org>2016-10-18 20:41:30 +0200
commit5e65efcaa38ea5fbe655a18082a3ba7c8cf7d5fe (patch)
treef4d343cd38c51bf3ed86561aef951b3abf91db0f /vcl/win
parent3eda74cf7e9d23cc08f07c38f3bee04b565ff9db (diff)
GSoC: Speed up CommonSalLayout by caching hb_face
Cache hb_face so it is not created again and again. Switch from GDI to DirectWrite on Windows to obtain SFNT table data. Change-Id: I9c532cd72e1f6b57313f3b7d42a6b9b0633eb0ef
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/salfont.cxx28
-rw-r--r--vcl/win/gdi/winlayout.cxx23
2 files changed, 41 insertions, 10 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 6d4fd5eba630..a832b4596c34 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -865,7 +865,8 @@ WinFontFace::WinFontFace( const FontAttributes& rDFS,
mnPitchAndFamily( nPitchAndFamily ),
mbAliasSymbolsHigh( false ),
mbAliasSymbolsLow( false ),
- mbGsubRead( false )
+ mbGsubRead( false ),
+ mpHbFace( nullptr )
{
SetBitmapSize( 0, nHeight );
@@ -906,6 +907,9 @@ WinFontFace::~WinFontFace()
#endif
#endif // ENABLE_GRAPHITE
delete mpEncodingVector;
+
+ if( mpHbFace )
+ hb_face_destroy( mpHbFace );
}
sal_IntPtr WinFontFace::GetFontId() const
@@ -1058,16 +1062,22 @@ void WinFontFace::ReadCmapTable( HDC hDC ) const
}
}
-int WinFontFace::GetTable(const char pTagName[5], const unsigned char*& pResBuffer, HDC hDC)
+sal_uLong WinSalGraphics::GetTable( const char pTagName[5], const unsigned char*& pResBuffer, void*& pTableContext, IDWriteFontFace*& pIDFace )
{
- const DWORD nTableTag = CalcTag( pTagName );
- RawFontData aRawFontData( hDC, nTableTag );
-
- if( !aRawFontData.get() )
+ if( !pIDFace )
return 0;
-
- pResBuffer = aRawFontData.steal();
- return aRawFontData.size();
+ const void* pResBuf;
+ UINT32 nSize;
+ BOOL bExists;
+ HRESULT hr = S_OK;
+ const DWORD nTableTag = DWRITE_MAKE_OPENTYPE_TAG( pTagName[0], pTagName[1], pTagName[2], pTagName[3] );
+ hr = pIDFace->TryGetFontTable( nTableTag, &pResBuf, &nSize, &pTableContext, &bExists );
+ if( SUCCEEDED( hr ) && ( bExists ) )
+ {
+ pResBuffer = static_cast<const unsigned char*>(pResBuf);
+ return static_cast<sal_uLong>(nSize);
+ }
+ return 0;
}
void WinFontFace::GetFontCapabilities( HDC hDC ) const
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 051f3547910f..fe724e4dbf0f 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -3518,6 +3518,24 @@ bool D2DWriteTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
return (succeeded && nGlyphs >= 1 && pRectToErase);
}
+IDWriteFontFace* D2DWriteTextOutRenderer::GetDWriteFontFace(HDC hDC) const
+{
+ IDWriteFontFace* pFontFace;
+ bool succeeded = false;
+ try
+ {
+ succeeded = SUCCEEDED(mpGdiInterop->CreateFontFaceFromHdc(hDC, &pFontFace));
+ }
+ catch (const std::exception& e)
+ {
+ SAL_WARN("vcl.gdi.opengl", "Error in dwrite while creating font face: " << e.what());
+ return nullptr;
+ }
+ if(succeeded)
+ return pFontFace;
+ else return nullptr;
+}
+
bool D2DWriteTextOutRenderer::BindFont(HDC hDC)
{
// A TextOutRender can only be bound to one font at a time, so the
@@ -3810,7 +3828,7 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
if (getenv("SAL_USE_COMMON_LAYOUT"))
{
- return new CommonSalLayout(getHDC(), rFontInstance);
+ return new CommonSalLayout(this, rFontInstance, rFontFace);
}
else
{
@@ -3973,6 +3991,9 @@ PhysicalFontFace* WinFontFace::Clone() const
if ( mpGraphiteData )
mpGraphiteData->AddReference();
#endif
+ if( mpHbFace )
+ hb_face_reference( mpHbFace );
+
PhysicalFontFace* pClone = new WinFontFace( *this );
return pClone;
}