[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/win
Khaled Hosny
khaledhosny at eglug.org
Sat Mar 4 12:24:28 UTC 2017
vcl/inc/win/winlayout.hxx | 12 +++---------
vcl/win/gdi/winlayout.cxx | 39 +++++++++++++++++----------------------
2 files changed, 20 insertions(+), 31 deletions(-)
New commits:
commit 7453cb58df4ce434a1252567f961cfe497064aca
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Sat Mar 4 05:40:39 2017 +0200
pPos and pGetNextGlypInfo always have the same value
Change-Id: Iec46e0aefff71cbeb2face4f55e5c3a4d6698995
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 2c6cc26..bc1890b 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -179,8 +179,7 @@ public:
virtual bool operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
- HDC hDC,
- Point* pPos, int* pGetNextGlypInfo) = 0;
+ HDC hDC) = 0;
};
class ExTextOutRenderer : public TextOutRenderer
@@ -193,8 +192,7 @@ public:
bool operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
- HDC hDC,
- Point* pPos, int* pGetNextGlypInfo) override;
+ HDC hDC) override;
};
class D2DWriteTextOutRenderer : public TextOutRenderer
@@ -217,8 +215,7 @@ public:
bool operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
- HDC hDC,
- Point* pPos, int* pGetNextGlypInfo) override;
+ HDC hDC) 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 21116d3..cf555de 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -264,10 +264,8 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
SalGraphics & /*rGraphics*/,
- HDC hDC,
- Point* pPos, int* pGetNextGlypInfo)
+ HDC hDC)
{
- const GlyphItem* pGlyph;
HFONT hFont = static_cast<HFONT>(GetCurrentObject( hDC, OBJ_FONT ));
HFONT hAltFont = nullptr;
bool bUseAltFont = false;
@@ -282,7 +280,11 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
hAltFont = CreateFontIndirectW(&aLogFont);
}
}
- while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo))
+
+ int nStart = 0;
+ Point aPos(0, 0);
+ const GlyphItem* pGlyph;
+ while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart))
{
WORD glyphWStr[] = { pGlyph->maGlyphId };
if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
@@ -290,7 +292,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
bUseAltFont = !bUseAltFont;
SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
}
- ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr);
+ ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr);
}
if (hAltFont)
{
@@ -340,8 +342,7 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
- HDC hDC,
- Point* pPos, int* pGetNextGlypInfo)
+ HDC hDC)
{
if (!Ready())
return false;
@@ -349,7 +350,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, pPos, pGetNextGlypInfo);
+ return ExTextOutRenderer()(rLayout, rGraphics, hDC);
}
Rectangle bounds;
@@ -365,13 +366,15 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
{
mpRT->BeginDraw();
+ int nStart = 0;
+ Point aPos(0, 0);
const GlyphItem* pGlyph;
- while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo))
+ while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart))
{
UINT16 glyphIndices[] = { pGlyph->maGlyphId };
FLOAT glyphAdvances[] = { pGlyph->mnNewWidth };
DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, };
- D2D1_POINT_2F baseline = { pPos->X() - bounds.Left(), pPos->Y() - bounds.Top() };
+ D2D1_POINT_2F baseline = { aPos.X() - bounds.Left(), aPos.Y() - bounds.Top() };
DWRITE_GLYPH_RUN glyphs = {
mpFontFace,
mlfEmHeight,
@@ -600,10 +603,8 @@ 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, &aPos, &nGlyphCount);
+ bool result = render(rLayout, *this, hDC);
assert(result);
}
commit 073d920ef5914b5dfe491dbaf7fb18ba56293b85
Author: Khaled Hosny <khaledhosny at eglug.org>
Date: Sat Mar 4 05:29:38 2017 +0200
pEraseRect is always null
Simplify the code accordingly and make it return true for success.
Change-Id: I661eea739e23b59ebff2573f52036b25ecb5a1ed
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 42b25b6..2c6cc26 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -180,7 +180,6 @@ public:
virtual bool operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
HDC hDC,
- const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo) = 0;
};
@@ -195,7 +194,6 @@ public:
bool operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
HDC hDC,
- const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo) override;
};
@@ -220,7 +218,6 @@ public:
bool operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
HDC hDC,
- const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo) override;
inline bool BindDC(HDC hDC, Rectangle const & rRect = Rectangle(0, 0, 0, 0)) {
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index c884c9e..21116d3 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -265,10 +265,8 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
SalGraphics & /*rGraphics*/,
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;
@@ -286,7 +284,6 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
}
while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo))
{
- bGlyphs = true;
WORD glyphWStr[] = { pGlyph->maGlyphId };
if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
{
@@ -302,7 +299,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
DeleteObject(hAltFont);
}
- return (pRectToErase && bGlyphs);
+ return true;
}
D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
@@ -344,7 +341,6 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
SalGraphics &rGraphics,
HDC hDC,
- const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo)
{
if (!Ready())
@@ -353,7 +349,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, pRectToErase, pPos, pGetNextGlypInfo);
+ return ExTextOutRenderer()(rLayout, rGraphics, hDC, pPos, pGetNextGlypInfo);
}
Rectangle bounds;
@@ -365,7 +361,6 @@ 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();
@@ -373,7 +368,6 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
const GlyphItem* pGlyph;
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 }, };
@@ -403,7 +397,7 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
if (hr == D2DERR_RECREATE_TARGET)
CreateRenderTarget();
- return (succeeded && bGlyphs && pRectToErase);
+ return succeeded;
}
bool D2DWriteTextOutRenderer::BindFont(HDC hDC)
@@ -609,8 +603,8 @@ void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC, boo
Point aPos(0, 0);
int nGlyphCount(0);
TextOutRenderer &render = TextOutRenderer::get(bUseDWrite);
- bool result = render(rLayout, *this, hDC, nullptr, &aPos, &nGlyphCount);
- assert(!result);
+ bool result = render(rLayout, *this, hDC, &aPos, &nGlyphCount);
+ assert(result);
}
void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout)
More information about the Libreoffice-commits
mailing list