[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/Library_vcl.mk vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 13 19:21:19 UTC 2019
vcl/Library_vcl.mk | 1
vcl/source/window/bufferdevice.cxx | 36 +++++++++++++++++++++++++++++++
vcl/source/window/bufferdevice.hxx | 36 +++++++++++++++++++++++++++++++
vcl/source/window/menubarwindow.cxx | 11 +--------
vcl/source/window/menufloatingwindow.cxx | 9 +------
5 files changed, 77 insertions(+), 16 deletions(-)
New commits:
commit 7ae354290af7f3fcd9c5031e437af0037e61e984
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri May 31 14:56:46 2019 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Thu Jun 13 21:20:41 2019 +0200
tdf#125550 vcl menu bar / floating window: fix text color
Regression from commit e8d5b8beb5958147235ff955ed38c47b51d860ff
(tdf#113714 vcl menu bar window: avoid flicker, 2019-05-20), the problem
was that a freshly created VirtualDevice doesn't have the default text
color, so we need to initialize that explicitly based on the render
context text color.
Also introduce a BufferDevice to do this initialization, instead of
fixing this in MenuBarWindow::Paint(), then copy&pasting the fix to
MenuFloatingWindow::Paint().
Change-Id: Ib171cd52e7cabe0bc3c639821f558d8303039fe6
Reviewed-on: https://gerrit.libreoffice.org/73269
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
(cherry picked from commit 42bf893a8479f70d7d8f00e03105ce15e8545f8b)
Reviewed-on: https://gerrit.libreoffice.org/73314
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
Tested-by: Michael Weghorn <m.weghorn at posteo.de>
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index da9bc387ca2f..b68252642bec 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -121,6 +121,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/accel \
vcl/source/window/accmgr \
vcl/source/window/brdwin \
+ vcl/source/window/bufferdevice \
vcl/source/window/accessibility \
vcl/source/window/legacyaccessibility \
vcl/source/window/clipping \
diff --git a/vcl/source/window/bufferdevice.cxx b/vcl/source/window/bufferdevice.cxx
new file mode 100644
index 000000000000..5db4cfff458a
--- /dev/null
+++ b/vcl/source/window/bufferdevice.cxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "bufferdevice.hxx"
+
+namespace vcl
+{
+BufferDevice::BufferDevice(const VclPtr<vcl::Window>& pWindow, vcl::RenderContext& rRenderContext)
+ : m_pBuffer(VclPtr<VirtualDevice>::Create())
+ , m_pWindow(pWindow)
+ , m_rRenderContext(rRenderContext)
+{
+ m_pBuffer->SetOutputSizePixel(pWindow->GetOutputSizePixel(), false);
+ m_pBuffer->SetTextColor(rRenderContext.GetTextColor());
+ m_pBuffer->DrawOutDev(Point(0, 0), pWindow->GetOutputSizePixel(), Point(0, 0),
+ pWindow->GetOutputSizePixel(), rRenderContext);
+}
+
+BufferDevice::~BufferDevice()
+{
+ m_rRenderContext.DrawOutDev(Point(0, 0), m_pWindow->GetOutputSizePixel(), Point(0, 0),
+ m_pWindow->GetOutputSizePixel(), *m_pBuffer);
+}
+
+vcl::RenderContext* BufferDevice::operator->() { return m_pBuffer.get(); }
+
+vcl::RenderContext& BufferDevice::operator*() { return *m_pBuffer; }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/bufferdevice.hxx b/vcl/source/window/bufferdevice.hxx
new file mode 100644
index 000000000000..26bf28e615fa
--- /dev/null
+++ b/vcl/source/window/bufferdevice.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_VCL_SOURCE_WINDOW_BUFFERDEVICE_HXX
+#define INCLUDED_VCL_SOURCE_WINDOW_BUFFERDEVICE_HXX
+
+#include <vcl/virdev.hxx>
+#include <vcl/window.hxx>
+
+namespace vcl
+{
+/// Buffers drawing on a vcl::RenderContext using a VirtualDevice.
+class BufferDevice
+{
+ ScopedVclPtr<VirtualDevice> m_pBuffer;
+ VclPtr<vcl::Window> m_pWindow;
+ vcl::RenderContext& m_rRenderContext;
+
+public:
+ BufferDevice(const VclPtr<vcl::Window>& pWindow, vcl::RenderContext& rRenderContext);
+ ~BufferDevice();
+
+ vcl::RenderContext* operator->();
+ vcl::RenderContext& operator*();
+};
+}
+
+#endif // INCLUDED_VCL_SOURCE_WINDOW_BUFFERDEVICE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index ccee51895c3e..fd0f54b4138f 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -33,6 +33,7 @@
#include <strings.hrc>
#include <bitmaps.hlst>
#include <window.h>
+#include "bufferdevice.hxx"
// document closing button
#define IID_DOCUMENTCLOSE 1
@@ -918,11 +919,7 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
}
// Make sure that all actual rendering happens in one go to avoid flicker.
- ScopedVclPtrInstance<VirtualDevice> pBuffer;
- pBuffer->SetOutputSizePixel(aOutputSize, false);
- // Copy the current state to the buffer.
- pBuffer->DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
- rRenderContext);
+ vcl::BufferDevice pBuffer(this, rRenderContext);
if (rRenderContext.IsNativeControlSupported(ControlType::Menubar, ControlPart::Entire))
{
@@ -965,10 +962,6 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
Point(aSize.Width() - 1, aSize.Height() - 1));
pBuffer->Pop();
}
-
- // Copy the current state from the buffer.
- rRenderContext.DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
- *pBuffer);
}
void MenuBarWindow::Resize()
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 9debcff5e5b4..9a6728766672 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -20,6 +20,7 @@
#include "menufloatingwindow.hxx"
#include "menuitemlist.hxx"
#include "menubarwindow.hxx"
+#include "bufferdevice.hxx"
#include <sal/log.hxx>
#include <salmenu.hxx>
@@ -1208,10 +1209,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
return;
// 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);
+ vcl::BufferDevice pBuffer(this, rRenderContext);
pBuffer->Push(PushFlags::CLIPREGION);
pBuffer->SetClipRegion(vcl::Region(rPaintRect));
@@ -1239,9 +1237,6 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
RenderHighlightItem(*pBuffer, nHighlightedItem);
pBuffer->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