[Libreoffice-commits] core.git: vcl/inc vcl/win

Khaled Hosny khaledhosny at eglug.org
Tue Nov 15 15:37:35 UTC 2016


 vcl/inc/win/salgdi.h      |    2 +-
 vcl/inc/win/winlayout.hxx |    2 +-
 vcl/win/gdi/salfont.cxx   |    2 +-
 vcl/win/gdi/winlayout.cxx |   40 +++++++++++++++++++++++++++++-----------
 4 files changed, 32 insertions(+), 14 deletions(-)

New commits:
commit d436065bc1c68fc2d90e73253d8c00503c72dfd0
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Tue Nov 15 13:48:45 2016 +0200

    tdf#103725: Default to GDI even with the new layout engine
    
    It seems that our DirectWrite integration is missing few key features,
    so back to GDI so at least people who need these feature can have away
    to make them work.
    
    So the situation is now with the new layout engine is like the old one;
    GDI when OpenGL is not use and DirectWrite when OpenGL is used.
    
    Fixing DirectWrite is now someone else’s problem.
    
    Should also fix tdf#100986.
    
    Change-Id: I102cac8a324f77b050d5183911b5cfda0b6b8f2b
    Reviewed-on: https://gerrit.libreoffice.org/30868
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 8f75c1b..3050055 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -357,7 +357,7 @@ private:
     // get kernign pairs of the current font
     sal_uLong               GetKernPairs();
 
-    static void             DrawTextLayout(const CommonSalLayout&, HDC);
+    static void             DrawTextLayout(const CommonSalLayout&, HDC, bool bUseDWrite);
 
 public:
     // public SalGraphics methods, the interface to the independent vcl part
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 64e78d4..0e30e07 100755
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -421,7 +421,7 @@ protected:
     TextOutRenderer & operator = (const TextOutRenderer &) = delete;
 
 public:
-    static TextOutRenderer & get();
+    static TextOutRenderer & get(bool bUseDWrite);
 
     virtual ~TextOutRenderer() = default;
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index f290bdd..d2e11f8 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1072,7 +1072,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
         rLogFont.lfQuality = NONANTIALIASED_QUALITY;
 
     // select vertical mode if requested and available
-    if (!SalLayout::UseCommonLayout() && pFont->mbVertical && nNameLen )
+    if ( pFont->mbVertical && nNameLen )
     {
         // vertical fonts start with an '@'
         memmove( &rLogFont.lfFaceName[1], &rLogFont.lfFaceName[0],
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 335bb8c..f4ead1d 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -93,7 +93,7 @@ bool WinFontInstance::CacheGlyphToAtlas(bool bRealGlyphIndices, int nGlyphIndex,
     }
 
     // For now we assume DWrite is present and we won't bother with fallback paths.
-    D2DWriteTextOutRenderer * pTxt = dynamic_cast<D2DWriteTextOutRenderer *>(&TextOutRenderer::get());
+    D2DWriteTextOutRenderer * pTxt = dynamic_cast<D2DWriteTextOutRenderer *>(&TextOutRenderer::get(true));
     if (!pTxt)
         return false;
 
@@ -3366,13 +3366,22 @@ void D2DWriteTextOutRenderer::CleanupModules()
     DWriteCreateFactory = nullptr;
 }
 
-TextOutRenderer & TextOutRenderer::get()
+TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
 {
-    static std::unique_ptr<TextOutRenderer> _impl(D2DWriteTextOutRenderer::InitModules()
-        ? static_cast<TextOutRenderer*>(new D2DWriteTextOutRenderer())
-        : static_cast<TextOutRenderer*>(new ExTextOutRenderer()));
+    if (bUseDWrite)
+    {
+        static std::unique_ptr<TextOutRenderer> _impl(D2DWriteTextOutRenderer::InitModules()
+            ? static_cast<TextOutRenderer*>(new D2DWriteTextOutRenderer())
+            : static_cast<TextOutRenderer*>(new ExTextOutRenderer()));
+
+        return *_impl;
+    }
+    else
+    {
+        static std::unique_ptr<TextOutRenderer> _impl(new ExTextOutRenderer());
 
-    return *_impl;
+        return *_impl;
+    }
 }
 
 
@@ -3390,6 +3399,15 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
         if (nGlyphs < 1)
             break;
 
+        if (SalLayout::UseCommonLayout())
+        {
+            for (int i = 0; i < nGlyphs; i++)
+            {
+                if ((glyphIntStr[i] & GF_ROTMASK) == GF_ROTL)
+                    glyphIntStr[i] |= GF_VERT;
+            }
+        }
+
         std::copy_n(glyphIntStr, nGlyphs, glyphWStr);
         ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), nGlyphs, nullptr);
     } while (!pRectToErase);
@@ -3788,7 +3806,7 @@ bool GraphiteWinLayout::DrawTextImpl(HDC hDC,
     maImpl.DrawBase() = WinLayout::maDrawBase;
     maImpl.DrawOffset() = WinLayout::maDrawOffset;
 
-    TextOutRenderer & render = TextOutRenderer::get();
+    TextOutRenderer & render = TextOutRenderer::get(true);
     bool const ok = render(*this, hDC, pRectToErase, pPos, pGetNextGlypInfo);
     if( hOrigFont )
         DeleteFont(SelectFont(hDC, hOrigFont));
@@ -4035,11 +4053,11 @@ LogicalFontInstance* WinFontFace::CreateFontInstance( FontSelectPattern& rFSD )
     return pFontInstance;
 }
 
-void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC)
+void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC, bool bUseDWrite)
 {
     Point aPos(0, 0);
     int nGlyphCount(0);
-    TextOutRenderer &render = TextOutRenderer::get();
+    TextOutRenderer &render = TextOutRenderer::get(bUseDWrite);
     bool result = render(rLayout, hDC, nullptr, &aPos, &nGlyphCount);
     assert(!result);
 }
@@ -4051,7 +4069,7 @@ void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
     if (!bUseOpenGL)
     {
         // no OpenGL, just classic rendering
-        DrawTextLayout(rLayout, hDC);
+        DrawTextLayout(rLayout, hDC, false);
     }
     else
     {
@@ -4115,7 +4133,7 @@ void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
             SalColor salColor = MAKE_SALCOLOR(GetRValue(color), GetGValue(color), GetBValue(color));
 
             // the actual drawing
-            DrawTextLayout(rLayout, aDC.getCompatibleHDC());
+            DrawTextLayout(rLayout, aDC.getCompatibleHDC(), true);
 
             std::unique_ptr<OpenGLTexture> xTexture(aDC.getTexture());
             if (xTexture)


More information about the Libreoffice-commits mailing list