vcl/inc/win/winlayout.hxx | 2 +- vcl/win/gdi/winlayout.cxx | 24 +++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-)
New commits: commit c5f8a296fcfc08f8ac441cb8300a7565caa50b53 Author: Khaled Hosny <khaledho...@eglug.org> Date: Wed May 9 19:41:27 2018 +0200 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 <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> 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; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits