diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-07-10 09:23:10 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2018-07-10 14:26:01 +0200 |
commit | ca4e75d694a5fb41a1c800146319aa6ba34d8bab (patch) | |
tree | eb2bae0fd94436c6e3b88af851207c134f2887b7 | |
parent | 2d61cb923e5e3999f6fd660aec26504311f0407c (diff) |
Revert "tdf#117517: Fix OpenGL text rendering on Windows"
This actually breaks the OpenGL glyph cache, which forced a full
redraw all the time working around the original problem, which
is now fixed with commit fad862e290d727fc9fefe206f6e4b807482c4175.
This reverts commit c5f8a296fcfc08f8ac441cb8300a7565caa50b53.
Change-Id: Ibfc5a24dfc157c42b4cf796b35101191e88a6d15
Reviewed-on: https://gerrit.libreoffice.org/57221
Tested-by: Jenkins
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
-rw-r--r-- | vcl/inc/win/winlayout.hxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 24 |
2 files changed, 22 insertions, 4 deletions
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index 0b7c23bfc9a5..0ef5cc03b846 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -150,7 +150,7 @@ class WinFontInstance : public LogicalFontInstance public: virtual ~WinFontInstance() override; - bool CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& rGraphics); + bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, 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 0cd916952b3e..fa0c2b683387 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -55,10 +55,24 @@ GlobalGlyphCache * GlobalGlyphCache::get() { return data->m_pGlobalGlyphCache.get(); } -bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& rGraphics) +bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, 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) @@ -66,7 +80,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& r pTxt->changeTextAntiAliasMode(D2DTextAntiAliasMode::AntiAliased); - if (!pTxt->BindFont(hDC)) + if (!pTxt->BindFont(aHDC.get())) { SAL_WARN("vcl.gdi", "Binding of font failed. The font might not be supported by DirectWrite."); return false; @@ -179,6 +193,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& r break; default: SAL_WARN("vcl.gdi", "DrawGlyphRun-EndDraw failed: " << WindowsErrorString(GetLastError())); + SelectFont(aDC.getCompatibleHDC(), hOrigFont); return false; } @@ -191,6 +206,8 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& r maGlyphCache.PutDrawElementInCache(aElement, nGlyphIndex); + SelectFont(aDC.getCompatibleHDC(), hOrigFont); + return true; } @@ -386,6 +403,7 @@ bool WinSalGraphics::CacheGlyphs(const GenericSalLayout& rLayout) HDC hDC = getHDC(); WinFontInstance& rFont = *static_cast<WinFontInstance*>(&rLayout.GetFont()); + HFONT hFONT = rFont.GetHFONT(); int nStart = 0; Point aPos(0, 0); @@ -394,7 +412,7 @@ bool WinSalGraphics::CacheGlyphs(const GenericSalLayout& rLayout) { if (!rFont.GetGlyphCache().IsGlyphCached(pGlyph->maGlyphId)) { - if (!rFont.CacheGlyphToAtlas(hDC, pGlyph->maGlyphId, *this)) + if (!rFont.CacheGlyphToAtlas(hDC, hFONT, pGlyph->maGlyphId, *this)) return false; } } |