]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dc.cpp
Applied #10639 (Not all previewed fonts are displayed with the correct nameface)
[wxWidgets.git] / src / msw / dc.cpp
index d25954bd326cde007f881e528f6ce8e472aead3a..15f83c4955d97322ef583faea5d09bae3de2a40c 100644 (file)
@@ -1214,13 +1214,20 @@ void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool
 #ifdef __WIN32__
         // use MaskBlt() with ROP which doesn't do anything to dst in the mask
         // points
+        bool ok = false;
+
+#if wxUSE_SYSTEM_OPTIONS
         // On some systems, MaskBlt succeeds yet is much much slower
         // than the wxWidgets fall-back implementation. So we need
         // to be able to switch this on and off at runtime.
-        bool ok = false;
-#if wxUSE_SYSTEM_OPTIONS
-        if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0)
-#endif
+        //
+        // NB: don't query the value of the option every time but do it only
+        //     once as otherwise it can have real (and bad) performance
+        //     implications (see #11172)
+        static bool
+            s_maskBltAllowed = wxSystemOptions::GetOptionInt("no-maskblt") == 0;
+        if ( s_maskBltAllowed )
+#endif // wxUSE_SYSTEM_OPTIONS
         {
             HDC cdc = GetHdc();
             HDC hdcMem = ::CreateCompatibleDC(GetHdc());
@@ -1543,15 +1550,22 @@ void wxMSWDCImpl::SetBrush(const wxBrush& brush)
     if ( brush.IsOk() )
     {
         // we must make sure the brush is aligned with the logical coordinates
-        // before selecting it
+        // before selecting it or using the same brush for the background of
+        // different windows would result in discontinuities
+        wxSize sizeBrushBitmap = wxDefaultSize;
         wxBitmap *stipple = brush.GetStipple();
         if ( stipple && stipple->IsOk() )
+            sizeBrushBitmap = stipple->GetSize();
+        else if ( brush.IsHatch() )
+            sizeBrushBitmap = wxSize(8, 8);
+
+        if ( sizeBrushBitmap.IsFullySpecified() )
         {
             if ( !::SetBrushOrgEx
                     (
                         GetHdc(),
-                        m_deviceOriginX % stipple->GetWidth(),
-                        m_deviceOriginY % stipple->GetHeight(),
+                        m_deviceOriginX % sizeBrushBitmap.x,
+                        m_deviceOriginY % sizeBrushBitmap.y,
                         NULL                    // [out] previous brush origin
                     ) )
             {