diff options
author | Akash Jain <akash96j@gmail.com> | 2016-07-06 17:56:15 +0530 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2016-10-18 20:41:29 +0200 |
commit | f6db8af1eb2e6d8e511e6158ddabf8fae7a1c3ca (patch) | |
tree | b9698a198e647d4762f1e4df927bd86991e700eb /vcl/win | |
parent | 828b8cf4d26c4d72c1f2146fd7a5bbb3b0465718 (diff) |
GSoC: Integrate new CommonSalLayout in win/ code
Change-Id: Ifeb2fa7ca9e2cd0da1c504d4e770aa0bb1b0b0de
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 3 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 136 |
2 files changed, 86 insertions, 53 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 55f3a2747e7d..6d4fd5eba630 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -2454,7 +2454,4 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont, } } -void WinSalGraphics::DrawSalLayout( const CommonSalLayout& ) -{} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 2c41b8f5bd10..fc1dd9ddac58 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -34,6 +34,7 @@ #include "sft.hxx" #include "sallayout.hxx" +#include "CommonSalLayout.hxx" #include <cstdio> #include <cstdlib> @@ -67,7 +68,7 @@ public: virtual ~TextOutRenderer() = default; - virtual bool operator ()(WinLayout const &rLayout, HDC hDC, + virtual bool operator ()(SalLayout const &rLayout, HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) = 0; }; @@ -81,7 +82,7 @@ public: explicit ExTextOutRenderer() = default; virtual ~ExTextOutRenderer() override = default; - bool operator ()(WinLayout const &rLayout, HDC hDC, + bool operator ()(SalLayout const &rLayout, HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) override; }; @@ -106,7 +107,7 @@ public: explicit D2DWriteTextOutRenderer(); virtual ~D2DWriteTextOutRenderer() override; - bool operator ()(WinLayout const &rLayout, HDC hDC, + bool operator ()(SalLayout const &rLayout, HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) override; @@ -138,7 +139,7 @@ private: D2DWriteTextOutRenderer & operator = (const D2DWriteTextOutRenderer &) = delete; bool GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** ppFontFace, float * lfSize) const; - bool GetDWriteInkBox(IDWriteFontFace & rFontFace, WinLayout const &rLayout, float const lfEmHeight, Rectangle &) const; + bool GetDWriteInkBox(IDWriteFontFace & rFontFace, SalLayout const &rLayout, float const lfEmHeight, Rectangle &) const; ID2D1Factory * mpD2DFactory; IDWriteFactory * mpDWriteFactory; @@ -3483,7 +3484,7 @@ TextOutRenderer & TextOutRenderer::get() } -bool ExTextOutRenderer::operator ()(WinLayout const &rLayout, HDC hDC, +bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) { @@ -3542,7 +3543,7 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer() CleanupModules(); } -bool D2DWriteTextOutRenderer::operator ()(WinLayout const &rLayout, HDC hDC, +bool D2DWriteTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, const Rectangle* pRectToErase, Point* pPos, int* pGetNextGlypInfo) { @@ -3708,7 +3709,7 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** p return succeeded; } -bool D2DWriteTextOutRenderer::GetDWriteInkBox(IDWriteFontFace & rFontFace, WinLayout const &rLayout, float const /*lfEmHeight*/, Rectangle & rOut) const +bool D2DWriteTextOutRenderer::GetDWriteInkBox(IDWriteFontFace & rFontFace, SalLayout const &rLayout, float const /*lfEmHeight*/, Rectangle & rOut) const { rOut.SetEmpty(); @@ -3903,66 +3904,73 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe const WinFontFace& rFontFace = *mpWinFontData[ nFallbackLevel ]; WinFontInstance& rFontInstance = *mpWinFontEntry[ nFallbackLevel ]; - bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter; - - if (!bUspInited) - InitUSP(); - - if( !(rArgs.mnFlags & SalLayoutFlags::ComplexDisabled) ) + if (getenv("SAL_USE_COMMON_LAYOUT")) { -#if ENABLE_GRAPHITE - if (rFontFace.SupportsGraphite()) - { - pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); - } - else -#endif // ENABLE_GRAPHITE - { - // script complexity is determined in upper layers - pWinLayout = new UniscribeLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); - // NOTE: it must be guaranteed that the WinSalGraphics lives longer than - // the created UniscribeLayout, otherwise the data passed into the - // constructor might become invalid too early - } + return new CommonSalLayout(getHDC(), rFontInstance); } else { -#if ENABLE_GRAPHITE - if (rFontFace.SupportsGraphite()) - { - pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); - } - else -#endif // ENABLE_GRAPHITE - { - static bool bAvoidSimpleWinLayout = (std::getenv("VCL_NO_SIMPLEWINLAYOUT") != nullptr); + bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter; - if (!bAvoidSimpleWinLayout) - { - if( (rArgs.mnFlags & SalLayoutFlags::KerningPairs) && !rFontInstance.HasKernData() ) - { - // TODO: directly cache kerning info in the rFontInstance - // TODO: get rid of kerning methods+data in WinSalGraphics object - GetKernPairs(); - rFontInstance.SetKernData( mnFontKernPairCount, mpFontKernPairs ); - } + if (!bUspInited) + InitUSP(); - pWinLayout = new SimpleWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); + if( !(rArgs.mnFlags & SalLayoutFlags::ComplexDisabled) ) + { +#if ENABLE_GRAPHITE + if (rFontFace.SupportsGraphite()) + { + pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); } else +#endif // ENABLE_GRAPHITE { + // script complexity is determined in upper layers pWinLayout = new UniscribeLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); // NOTE: it must be guaranteed that the WinSalGraphics lives longer than // the created UniscribeLayout, otherwise the data passed into the // constructor might become invalid too early } } - } + else + { +#if ENABLE_GRAPHITE + if (rFontFace.SupportsGraphite()) + { + pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); + } + else +#endif // ENABLE_GRAPHITE + { + static bool bAvoidSimpleWinLayout = (std::getenv("VCL_NO_SIMPLEWINLAYOUT") != nullptr); - if( mfFontScale[nFallbackLevel] != 1.0 ) - pWinLayout->SetFontScale( mfFontScale[nFallbackLevel] ); + if (!bAvoidSimpleWinLayout) + { + if( (rArgs.mnFlags & SalLayoutFlags::KerningPairs) && !rFontInstance.HasKernData() ) + { + // TODO: directly cache kerning info in the rFontInstance + // TODO: get rid of kerning methods+data in WinSalGraphics object + GetKernPairs(); + rFontInstance.SetKernData( mnFontKernPairCount, mpFontKernPairs ); + } - return pWinLayout; + pWinLayout = new SimpleWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); + } + else + { + pWinLayout = new UniscribeLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL); + // NOTE: it must be guaranteed that the WinSalGraphics lives longer than + // the created UniscribeLayout, otherwise the data passed into the + // constructor might become invalid too early + } + } + } + + if( mfFontScale[nFallbackLevel] != 1.0 ) + pWinLayout->SetFontScale( mfFontScale[nFallbackLevel] ); + + return pWinLayout; + } } int WinSalGraphics::GetMinKashidaWidth() @@ -4071,4 +4079,32 @@ LogicalFontInstance* WinFontFace::CreateFontInstance( FontSelectPattern& rFSD ) return pFontInstance; } +void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout) +{ + HDC hDC = getHDC(); + + if (getenv("SAL_DWRITE_COMMON_LAYOUT")) + { + Point aPos(0, 0); + int nGlyphCount(0); + TextOutRenderer &render = TextOutRenderer::get(); + bool result = render(rLayout, hDC, nullptr, &aPos, &nGlyphCount); + assert(!result); + } + else + { + Point aPos; + sal_GlyphId aGlyphId; + int nFetchedGlyphs = 0; + UINT oldTa = GetTextAlign(hDC); + SetTextAlign(hDC, (oldTa & ~TA_NOUPDATECP)); + while (rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nFetchedGlyphs)) + { + ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, reinterpret_cast<LPCWSTR>(&aGlyphId), + 1, nullptr); + } + SetTextAlign(hDC, oldTa); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |