[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/source vcl/unx

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 8 01:31:43 UTC 2019


 vcl/headless/svpvd.cxx                |   10 ++++++---
 vcl/inc/headless/svpvd.hxx            |    5 ++++
 vcl/source/window/bufferdevice.cxx    |    2 -
 vcl/unx/kde5/KDE5SalGraphics.cxx      |    2 -
 vcl/unx/kde5/KDE5SalInstance.cxx      |   19 +++++++++++++++++
 vcl/unx/kde5/KDE5SalInstance.hxx      |    4 +++
 vcl/unx/kde5/KDE5SalVirtualDevice.hxx |   36 ++++++++++++++++++++++++++++++++++
 7 files changed, 72 insertions(+), 6 deletions(-)

New commits:
commit 2cb6a591b643a0f65dc58f060f60cc707ad3589c
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Jun 7 19:09:18 2019 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Sat Jun 8 03:30:45 2019 +0200

    tdf#125673 KDE5 implement a KDE5SalVirtualDevice
    
    We just need AcquireGraphics() to return a KDE5Graphics.
    Otherwise the BufferDevice's SVP will use a SvpSalGraphics
    instead of the KDE5Graphics, which knows about Qt's theming.
    
    Change-Id: I0ea646df260f2067d61c753f03dee01a003f382a
    Reviewed-on: https://gerrit.libreoffice.org/73673
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index eeccf2c014a9..a1e415739d6b 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -45,14 +45,18 @@ SvpSalVirtualDevice::~SvpSalVirtualDevice()
     cairo_surface_destroy(m_pRefSurface);
 }
 
-SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
+SvpSalGraphics* SvpSalVirtualDevice::AddGraphics(SvpSalGraphics* pGraphics)
 {
-    SvpSalGraphics* pGraphics = new SvpSalGraphics();
     pGraphics->setSurface(m_pSurface, m_aFrameSize);
-    m_aGraphics.push_back( pGraphics );
+    m_aGraphics.push_back(pGraphics);
     return pGraphics;
 }
 
+SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
+{
+    return AddGraphics(new SvpSalGraphics());
+}
+
 void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
 {
     m_aGraphics.erase(std::remove(m_aGraphics.begin(), m_aGraphics.end(), dynamic_cast<SvpSalGraphics*>(pGraphics)), m_aGraphics.end());
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index 776cee7cde15..3da74b5e1ba8 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -21,6 +21,8 @@
 #define INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
 
 #include <salvd.hxx>
+#include <vcl/salgtype.hxx>
+#include <basegfx/vector/b2ivector.hxx>
 
 #include <vector>
 
@@ -35,6 +37,9 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice
     basegfx::B2IVector                  m_aFrameSize;
     std::vector< SvpSalGraphics* >      m_aGraphics;
 
+protected:
+    SvpSalGraphics* AddGraphics(SvpSalGraphics* aGraphics);
+
 public:
     SvpSalVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface);
     virtual ~SvpSalVirtualDevice() override;
diff --git a/vcl/source/window/bufferdevice.cxx b/vcl/source/window/bufferdevice.cxx
index 5db4cfff458a..d1480588d48f 100644
--- a/vcl/source/window/bufferdevice.cxx
+++ b/vcl/source/window/bufferdevice.cxx
@@ -12,7 +12,7 @@
 namespace vcl
 {
 BufferDevice::BufferDevice(const VclPtr<vcl::Window>& pWindow, vcl::RenderContext& rRenderContext)
-    : m_pBuffer(VclPtr<VirtualDevice>::Create())
+    : m_pBuffer(VclPtr<VirtualDevice>::Create(rRenderContext))
     , m_pWindow(pWindow)
     , m_rRenderContext(rRenderContext)
 {
diff --git a/vcl/unx/kde5/KDE5SalGraphics.cxx b/vcl/unx/kde5/KDE5SalGraphics.cxx
index 6e30b9599740..268f8331f7e7 100644
--- a/vcl/unx/kde5/KDE5SalGraphics.cxx
+++ b/vcl/unx/kde5/KDE5SalGraphics.cxx
@@ -40,7 +40,7 @@ static void QImage2BitmapBuffer(QImage* pImg, BitmapBuffer* pBuf)
 }
 
 KDE5SalGraphics::KDE5SalGraphics(Qt5Frame* pFrame)
-    : Qt5SvpGraphics(pFrame->GetQWidget())
+    : Qt5SvpGraphics(pFrame ? pFrame->GetQWidget() : nullptr)
     , m_pFrame(pFrame)
 {
 }
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index e2bd75277d23..e83d48007712 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -28,8 +28,9 @@
 #include <Qt5Data.hxx>
 
 #include "KDE5FilePicker.hxx"
-#include "KDE5SalInstance.hxx"
 #include "KDE5SalFrame.hxx"
+#include "KDE5SalInstance.hxx"
+#include "KDE5SalVirtualDevice.hxx"
 
 using namespace com::sun::star;
 
@@ -69,6 +70,22 @@ Qt5FilePicker* KDE5SalInstance::createPicker(QFileDialog::FileMode eMode)
     return Qt5Instance::createPicker(eMode);
 }
 
+std::unique_ptr<SalVirtualDevice> KDE5SalInstance::CreateVirtualDevice(SalGraphics* pGraphics,
+                                                                       long& nDX, long& nDY,
+                                                                       DeviceFormat eFormat,
+                                                                       const SystemGraphicsData*)
+{
+    std::unique_ptr<SalVirtualDevice> pVD;
+    assert(pGraphics);
+    RunInMainThread(std::function([&]() {
+        KDE5SalGraphics* pKDE5Graphics = dynamic_cast<KDE5SalGraphics*>(pGraphics);
+        assert(pKDE5Graphics);
+        pVD.reset(new KDE5SalVirtualDevice(eFormat, pKDE5Graphics->getSurface()));
+        pVD->SetSize(nDX, nDY);
+    }));
+    return pVD;
+}
+
 extern "C" {
 VCLPLUG_KDE5_PUBLIC SalInstance* create_SalInstance()
 {
diff --git a/vcl/unx/kde5/KDE5SalInstance.hxx b/vcl/unx/kde5/KDE5SalInstance.hxx
index 53993a5ecc34..6b9f8eb29806 100644
--- a/vcl/unx/kde5/KDE5SalInstance.hxx
+++ b/vcl/unx/kde5/KDE5SalInstance.hxx
@@ -30,6 +30,10 @@ class KDE5SalInstance final : public Qt5Instance
 
 public:
     explicit KDE5SalInstance(std::unique_ptr<QApplication>& pQApp);
+
+    std::unique_ptr<SalVirtualDevice>
+    CreateVirtualDevice(SalGraphics*, long&, long&, DeviceFormat,
+                        const SystemGraphicsData* = nullptr) override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5SalVirtualDevice.hxx b/vcl/unx/kde5/KDE5SalVirtualDevice.hxx
new file mode 100644
index 000000000000..baa8a2e31aa8
--- /dev/null
+++ b/vcl/unx/kde5/KDE5SalVirtualDevice.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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <headless/svpvd.hxx>
+#include "KDE5SalGraphics.hxx"
+
+class VCL_DLLPUBLIC KDE5SalVirtualDevice : public SvpSalVirtualDevice
+{
+public:
+    KDE5SalVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface)
+        : SvpSalVirtualDevice(eFormat, pRefSurface)
+    {
+    }
+
+    SalGraphics* AcquireGraphics() override { return AddGraphics(new KDE5SalGraphics(nullptr)); }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list