From 55735ff858696426509af625a56f3bea8c37d00d Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 27 Apr 2019 11:25:24 +1000 Subject: Backport: Feature [feature-requests:#1279]. Removed invalid check when avoiding SelectFont if font not changed. Didn't correct the check as its not justified by minimal performance benefit so removed the supporting variable. Backport of changeset 7474:6bb2a6d284d9. --- win32/PlatWin.cxx | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 2b807198a..d0a4f4fdd 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -422,7 +422,6 @@ class SurfaceGDI : public Surface { HPEN penOld{}; HBRUSH brush{}; HBRUSH brushOld{}; - HFONT font{}; HFONT fontOld{}; HBITMAP bitmap{}; HBITMAP bitmapOld{}; @@ -513,7 +512,6 @@ void SurfaceGDI::Clear() noexcept { ::SelectObject(hdc, fontOld); fontOld = 0; } - font = 0; if (bitmapOld) { ::SelectObject(hdc, bitmapOld); ::DeleteObject(bitmap); @@ -583,16 +581,14 @@ void SurfaceGDI::BrushColor(ColourDesired back) { brush = ::CreateSolidBrush(colourNearest.AsInteger()); brushOld = SelectBrush(hdc, brush); } + void SurfaceGDI::SetFont(Font &font_) { - if (font_.GetID() != font) { - const FormatAndMetrics *pfm = FamFromFontID(font_.GetID()); - PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_GDI); - if (fontOld) { - SelectFont(hdc, pfm->hfont); - } else { - fontOld = SelectFont(hdc, pfm->hfont); - } - font = pfm->hfont; + const FormatAndMetrics *pfm = FamFromFontID(font_.GetID()); + PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_GDI); + if (fontOld) { + SelectFont(hdc, pfm->hfont); + } else { + fontOld = SelectFont(hdc, pfm->hfont); } } @@ -951,7 +947,6 @@ void SurfaceGDI::SetClip(PRectangle rc) { void SurfaceGDI::FlushCachedState() { pen = 0; brush = 0; - font = 0; } void SurfaceGDI::SetUnicodeMode(bool unicodeMode_) { -- cgit v1.2.3