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

Caolán McNamara caolanm at redhat.com
Sun Mar 5 21:34:32 UTC 2017


 vcl/inc/win/winlayout.hxx |   12 +++++++++---
 vcl/win/gdi/winlayout.cxx |   39 ++++++++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 20 deletions(-)

New commits:
commit b398dacbb471913e573e9b0b4cd31d94a9109223
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Mar 5 21:31:09 2017 +0000

    Revert "pPos and pGetNextGlypInfo always have the same value"
    
    This reverts commit 7453cb58df4ce434a1252567f961cfe497064aca.
    
    and...
    
    Revert "pEraseRect is always null"
    
    I suspect the problem is the change to D2DWriteTextOutRenderer::operator
    in 7453cb58df4ce434a1252567f961cfe497064aca
    
    aborts during windows tinderboxes CppunitTest_dbaccess_empty_stdlib_save etc
    
    This reverts commit 073d920ef5914b5dfe491dbaf7fb18ba56293b85.
    
    Change-Id: I372e104bd09e49bcf08306169db9777f2f26fff5

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index bc1890b..42b25b6 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -179,7 +179,9 @@ public:
 
     virtual bool operator ()(CommonSalLayout const &rLayout,
         SalGraphics &rGraphics,
-        HDC hDC) = 0;
+        HDC hDC,
+        const Rectangle* pRectToErase,
+        Point* pPos, int* pGetNextGlypInfo) = 0;
 };
 
 class ExTextOutRenderer : public TextOutRenderer
@@ -192,7 +194,9 @@ public:
 
     bool operator ()(CommonSalLayout const &rLayout,
         SalGraphics &rGraphics,
-        HDC hDC) override;
+        HDC hDC,
+        const Rectangle* pRectToErase,
+        Point* pPos, int* pGetNextGlypInfo) override;
 };
 
 class D2DWriteTextOutRenderer : public TextOutRenderer
@@ -215,7 +219,9 @@ public:
 
     bool operator ()(CommonSalLayout const &rLayout,
         SalGraphics &rGraphics,
-        HDC hDC) override;
+        HDC hDC,
+        const Rectangle* pRectToErase,
+        Point* pPos, int* pGetNextGlypInfo) override;
 
     inline bool BindDC(HDC hDC, Rectangle const & rRect = Rectangle(0, 0, 0, 0)) {
         RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() };
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index cf555de..c884c9e 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -264,8 +264,12 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
 
 bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
     SalGraphics & /*rGraphics*/,
-    HDC hDC)
+    HDC hDC,
+    const Rectangle* pRectToErase,
+    Point* pPos, int* pGetNextGlypInfo)
 {
+    bool bGlyphs = false;
+    const GlyphItem* pGlyph;
     HFONT hFont = static_cast<HFONT>(GetCurrentObject( hDC, OBJ_FONT ));
     HFONT hAltFont = nullptr;
     bool bUseAltFont = false;
@@ -280,19 +284,16 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
             hAltFont = CreateFontIndirectW(&aLogFont);
         }
     }
-
-    int nStart = 0;
-    Point aPos(0, 0);
-    const GlyphItem* pGlyph;
-    while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart))
+    while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo))
     {
+        bGlyphs = true;
         WORD glyphWStr[] = { pGlyph->maGlyphId };
         if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
         {
             bUseAltFont = !bUseAltFont;
             SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
         }
-        ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr);
+        ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr);
     }
     if (hAltFont)
     {
@@ -301,7 +302,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
         DeleteObject(hAltFont);
     }
 
-    return true;
+    return (pRectToErase && bGlyphs);
 }
 
 D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
@@ -342,7 +343,9 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
 
 bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
     SalGraphics &rGraphics,
-    HDC hDC)
+    HDC hDC,
+    const Rectangle* pRectToErase,
+    Point* pPos, int* pGetNextGlypInfo)
 {
     if (!Ready())
         return false;
@@ -350,7 +353,7 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
     if (!BindFont(hDC))
     {
         // If for any reason we can't bind fallback to legacy APIs.
-        return ExTextOutRenderer()(rLayout, rGraphics, hDC);
+        return ExTextOutRenderer()(rLayout, rGraphics, hDC, pRectToErase, pPos, pGetNextGlypInfo);
     }
 
     Rectangle bounds;
@@ -362,19 +365,19 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
     succeeded &= SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetRValue(bgrTextColor) / 255.0f, GetGValue(bgrTextColor) / 255.0f, GetBValue(bgrTextColor) / 255.0f), &pBrush));
 
     HRESULT hr = S_OK;
+    bool bGlyphs = false;
     if (succeeded)
     {
         mpRT->BeginDraw();
 
-        int nStart = 0;
-        Point aPos(0, 0);
         const GlyphItem* pGlyph;
-        while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart))
+        while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo))
         {
+            bGlyphs = true;
             UINT16 glyphIndices[] = { pGlyph->maGlyphId };
             FLOAT glyphAdvances[] = { pGlyph->mnNewWidth };
             DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, };
-            D2D1_POINT_2F baseline = { aPos.X() - bounds.Left(), aPos.Y() - bounds.Top() };
+            D2D1_POINT_2F baseline = { pPos->X() - bounds.Left(), pPos->Y() - bounds.Top() };
             DWRITE_GLYPH_RUN glyphs = {
                 mpFontFace,
                 mlfEmHeight,
@@ -400,7 +403,7 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
     if (hr == D2DERR_RECREATE_TARGET)
         CreateRenderTarget();
 
-    return succeeded;
+    return (succeeded && bGlyphs && pRectToErase);
 }
 
 bool D2DWriteTextOutRenderer::BindFont(HDC hDC)
@@ -603,9 +606,11 @@ bool WinSalGraphics::DrawCachedGlyphs(const CommonSalLayout& rLayout)
 
 void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC, bool bUseDWrite)
 {
+    Point aPos(0, 0);
+    int nGlyphCount(0);
     TextOutRenderer &render = TextOutRenderer::get(bUseDWrite);
-    bool result = render(rLayout, *this, hDC);
-    assert(result);
+    bool result = render(rLayout, *this, hDC, nullptr, &aPos, &nGlyphCount);
+    assert(!result);
 }
 
 void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout)


More information about the Libreoffice-commits mailing list