[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed May 29 11:54:03 UTC 2019


 vcl/source/window/menubarwindow.cxx |   36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

New commits:
commit 0be7366d87fb2b2c7e3d2091dbfe17660bce057f
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon May 20 18:30:08 2019 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed May 29 13:53:16 2019 +0200

    tdf#113714 vcl menu bar window: avoid flicker
    
    Regression from commit 458a827e96523ac52d021f1fd3653b5a734940c0 (further
    refactor Menu to use RenderContext, 2015-05-15), if we do full paint
    instead of incremental paint, then need to ensure that an intermediate
    state is not painted.
    
    Paint happens at idle time by default on Windows (OpenGL) and also on
    Linux (gtk3), but some other backends like Windows GDI had flicker, this
    fixes the problem.
    
    (cherry picked from commit e8d5b8beb5958147235ff955ed38c47b51d860ff)
    
    Change-Id: I530166cea93513aec4648dd0a385359f4b998b6f
    Reviewed-on: https://gerrit.libreoffice.org/72673
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 25ab264bc9d9..66444c082153 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -24,6 +24,7 @@
 #include <vcl/dockingarea.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/taskpanelist.hxx>
+#include <vcl/virdev.hxx>
 #include <sal/log.hxx>
 
 #include <salframe.hxx>
@@ -916,47 +917,54 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
         return;
     }
 
+    // Make sure that all actual rendering happens in one go to avoid flicker.
+    ScopedVclPtrInstance<VirtualDevice> pBuffer;
+    pBuffer->SetOutputSizePixel(aOutputSize, false);
+
     if (rRenderContext.IsNativeControlSupported(ControlType::Menubar, ControlPart::Entire))
     {
         MenubarValue aMenubarValue;
         aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight(this);
 
         if (!rStyleSettings.GetPersonaHeader().IsEmpty())
-            Erase(rRenderContext);
+            Erase(*pBuffer);
         else
         {
             tools::Rectangle aCtrlRegion( Point(), aOutputSize );
 
-            rRenderContext.DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aCtrlRegion,
-                                             ControlState::ENABLED, aMenubarValue, OUString());
+            pBuffer->DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aCtrlRegion,
+                                       ControlState::ENABLED, aMenubarValue, OUString());
         }
 
-        ImplAddNWFSeparator(rRenderContext, aOutputSize, aMenubarValue);
+        ImplAddNWFSeparator(*pBuffer, aOutputSize, aMenubarValue);
     }
 
     // shrink the area of the buttons
     aOutputSize.AdjustWidth( -(aCloseBtn->GetSizePixel().Width()) );
 
-    rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
-    pMenu->ImplPaint(rRenderContext, aOutputSize, 0);
+    pBuffer->SetFillColor(rStyleSettings.GetMenuColor());
+    pMenu->ImplPaint(*pBuffer, aOutputSize, 0);
 
     if (nHighlightedItem != ITEMPOS_INVALID && pMenu && !pMenu->GetItemList()->GetDataFromPos(nHighlightedItem)->bHiddenOnGUI)
-        HighlightItem(rRenderContext, nHighlightedItem);
+        HighlightItem(*pBuffer, nHighlightedItem);
     else if (ImplGetSVData()->maNWFData.mbRolloverMenubar && nRolloveredItem != ITEMPOS_INVALID)
-        HighlightItem(rRenderContext, nRolloveredItem);
+        HighlightItem(*pBuffer, nRolloveredItem);
 
     // in high contrast mode draw a separating line on the lower edge
     if (!rRenderContext.IsNativeControlSupported( ControlType::Menubar, ControlPart::Entire) &&
         rStyleSettings.GetHighContrastMode())
     {
-        rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::MAPMODE);
-        rRenderContext.SetLineColor(COL_WHITE);
-        rRenderContext.SetMapMode(MapMode(MapUnit::MapPixel));
+        pBuffer->Push(PushFlags::LINECOLOR | PushFlags::MAPMODE);
+        pBuffer->SetLineColor(COL_WHITE);
+        pBuffer->SetMapMode(MapMode(MapUnit::MapPixel));
         Size aSize = GetSizePixel();
-        rRenderContext.DrawLine(Point(0, aSize.Height() - 1),
-                                Point(aSize.Width() - 1, aSize.Height() - 1));
-        rRenderContext.Pop();
+        pBuffer->DrawLine(Point(0, aSize.Height() - 1),
+                          Point(aSize.Width() - 1, aSize.Height() - 1));
+        pBuffer->Pop();
     }
+
+    rRenderContext.DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
+                              *pBuffer);
 }
 
 void MenuBarWindow::Resize()


More information about the Libreoffice-commits mailing list