summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2018-05-09 19:41:27 +0200
committerTomaž Vajngerl <quikee@gmail.com>2018-05-10 03:44:10 +0200
commitc5f8a296fcfc08f8ac441cb8300a7565caa50b53 (patch)
treec1b54ade768a7b4006cdcce56179f75285d3c5c4
parentfe93b771602be86a748ca4e0337a977d7b171d24 (diff)
tdf#117517: Fix OpenGL text rendering on Windows
Use the HDC we already selected the HFONT on instead of creating a new HDC and selecting the font on it, apparently selecting the font the second time fails. Change-Id: I2a26469ce70bce763562b6cd2171707e482fb1d8 Reviewed-on: https://gerrit.libreoffice.org/54046 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--vcl/inc/win/winlayout.hxx2
-rw-r--r--vcl/win/gdi/winlayout.cxx24
2 files changed, 4 insertions, 22 deletions
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index ca0945949265..bd10aa997aa8 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -151,7 +151,7 @@ class WinFontInstance : public LogicalFontInstance
public:
virtual ~WinFontInstance() override;
- bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& rGraphics);
+ bool CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& rGraphics);
GlyphCache& GetGlyphCache() { return maGlyphCache; }
bool hasHScale() const;
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 3188f7f3d0bb..3b7b6c044083 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -56,24 +56,10 @@ GlobalGlyphCache * GlobalGlyphCache::get() {
return data->m_pGlobalGlyphCache.get();
}
-bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& rGraphics)
+bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& rGraphics)
{
OpenGLGlyphDrawElement aElement;
- ScopedHDC aHDC(CreateCompatibleDC(hDC));
-
- if (!aHDC)
- {
- SAL_WARN("vcl.gdi", "CreateCompatibleDC failed: " << WindowsErrorString(GetLastError()));
- return false;
- }
- HFONT hOrigFont = static_cast<HFONT>(SelectObject(aHDC.get(), hFont));
- if (hOrigFont == nullptr)
- {
- SAL_WARN("vcl.gdi", "SelectObject failed: " << WindowsErrorString(GetLastError()));
- return false;
- }
-
// For now we assume DWrite is present and we won't bother with fallback paths.
D2DWriteTextOutRenderer * pTxt = dynamic_cast<D2DWriteTextOutRenderer *>(&TextOutRenderer::get(true));
if (!pTxt)
@@ -81,7 +67,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, S
pTxt->changeTextAntiAliasMode(D2DTextAntiAliasMode::AntiAliased);
- if (!pTxt->BindFont(aHDC.get()))
+ if (!pTxt->BindFont(hDC))
{
SAL_WARN("vcl.gdi", "Binding of font failed. The font might not be supported by DirectWrite.");
return false;
@@ -194,7 +180,6 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, S
break;
default:
SAL_WARN("vcl.gdi", "DrawGlyphRun-EndDraw failed: " << WindowsErrorString(GetLastError()));
- SelectFont(aDC.getCompatibleHDC(), hOrigFont);
return false;
}
@@ -207,8 +192,6 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, S
maGlyphCache.PutDrawElementInCache(aElement, nGlyphIndex);
- SelectFont(aDC.getCompatibleHDC(), hOrigFont);
-
return true;
}
@@ -406,7 +389,6 @@ bool WinSalGraphics::CacheGlyphs(const CommonSalLayout& rLayout)
HDC hDC = getHDC();
WinFontInstance& rFont = *static_cast<WinFontInstance*>(&rLayout.getFont());
- HFONT hFONT = rFont.GetHFONT();
int nStart = 0;
Point aPos(0, 0);
@@ -415,7 +397,7 @@ bool WinSalGraphics::CacheGlyphs(const CommonSalLayout& rLayout)
{
if (!rFont.GetGlyphCache().IsGlyphCached(pGlyph->maGlyphId))
{
- if (!rFont.CacheGlyphToAtlas(hDC, hFONT, pGlyph->maGlyphId, *this))
+ if (!rFont.CacheGlyphToAtlas(hDC, pGlyph->maGlyphId, *this))
return false;
}
}