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

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


 vcl/source/window/menufloatingwindow.cxx |   36 +++++++++++++++++++------------
 1 file changed, 23 insertions(+), 13 deletions(-)

New commits:
commit 3c40f60c1693e477d0bb85b549b30a56a8ab9378
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue May 21 17:45:05 2019 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed May 29 13:55:39 2019 +0200

    tdf#125415 vcl menu floating window: avoid flicker
    
    This is similar to e8d5b8beb5958147235ff955ed38c47b51d860ff (tdf#113714
    vcl menu bar window: avoid flicker, 2019-05-20), except that was for the
    menu bar window, and this is for the floating window opening from that
    one.
    
    (cherry picked from commit c04169c586ef1d55b1d0ac469bb4fbd4f50bd08a)
    
    Change-Id: Ib24f4999ad3e8cbbecc058368e9d112e106e9178
    Reviewed-on: https://gerrit.libreoffice.org/72726
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 2db8caab9aba..9debcff5e5b4 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -27,6 +27,7 @@
 #include <svdata.hxx>
 #include <vcl/decoview.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/virdev.hxx>
 #include <window.h>
 
 MenuFloatingWindow::MenuFloatingWindow( Menu* pMen, vcl::Window* pParent, WinBits nStyle ) :
@@ -1206,32 +1207,41 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
     if (!pMenu)
         return;
 
-    rRenderContext.Push( PushFlags::CLIPREGION );
-    rRenderContext.SetClipRegion(vcl::Region(rPaintRect));
+    // Make sure that all actual rendering happens in one go to avoid flicker.
+    ScopedVclPtrInstance<VirtualDevice> pBuffer;
+    pBuffer->SetOutputSizePixel(GetOutputSizePixel(), false);
+    pBuffer->DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
+                        rRenderContext);
+
+    pBuffer->Push(PushFlags::CLIPREGION);
+    pBuffer->SetClipRegion(vcl::Region(rPaintRect));
 
     if (rRenderContext.IsNativeControlSupported(ControlType::MenuPopup, ControlPart::Entire))
     {
-        rRenderContext.SetClipRegion();
+        pBuffer->SetClipRegion();
         long nX = 0;
         Size aPxSize(GetOutputSizePixel());
         aPxSize.AdjustWidth( -nX );
         ImplControlValue aVal(pMenu->nTextPos - GUTTERBORDER);
-        rRenderContext.DrawNativeControl(ControlType::MenuPopup, ControlPart::Entire,
-                                         tools::Rectangle(Point(nX, 0), aPxSize),
-                                         ControlState::ENABLED, aVal, OUString());
-        InitMenuClipRegion(rRenderContext);
+        pBuffer->DrawNativeControl(ControlType::MenuPopup, ControlPart::Entire,
+                                   tools::Rectangle(Point(nX, 0), aPxSize), ControlState::ENABLED,
+                                   aVal, OUString());
+        InitMenuClipRegion(*pBuffer);
     }
     if (IsScrollMenu())
     {
-        ImplDrawScroller(rRenderContext, true);
-        ImplDrawScroller(rRenderContext, false);
+        ImplDrawScroller(*pBuffer, true);
+        ImplDrawScroller(*pBuffer, false);
     }
-    rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
-    pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, ImplGetStartY());
+    pBuffer->SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
+    pMenu->ImplPaint(*pBuffer, GetOutputSizePixel(), nScrollerHeight, ImplGetStartY());
     if (nHighlightedItem != ITEMPOS_INVALID)
-        RenderHighlightItem(rRenderContext, nHighlightedItem);
+        RenderHighlightItem(*pBuffer, nHighlightedItem);
+
+    pBuffer->Pop();
 
-    rRenderContext.Pop();
+    rRenderContext.DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
+                              *pBuffer);
 }
 
 void MenuFloatingWindow::ImplDrawScroller(vcl::RenderContext& rRenderContext, bool bUp)


More information about the Libreoffice-commits mailing list