diff options
-rw-r--r-- | vcl/inc/win/winlayout.hxx | 12 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 39 |
2 files changed, 31 insertions, 20 deletions
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index bc1890b0ee11..42b25b62c91f 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 cf555de5fe00..c884c9ef6580 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) |