From 5ee408eb4c9f55d3438426290e91ac31d04821de Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Fri, 7 Jun 2019 19:09:18 +0200 Subject: 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. Reviewed-on: https://gerrit.libreoffice.org/73673 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski (cherry picked from commit 2cb6a591b643a0f65dc58f060f60cc707ad3589c) Reviewed-on: https://gerrit.libreoffice.org/73722 Change-Id: I0ea646df260f2067d61c753f03dee01a003f382a Reviewed-on: https://gerrit.libreoffice.org/73963 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- 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 | 18 +++++++++++++++++- vcl/unx/kde5/KDE5SalInstance.hxx | 4 ++++ vcl/unx/kde5/KDE5SalVirtualDevice.hxx | 36 +++++++++++++++++++++++++++++++++++ 7 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 vcl/unx/kde5/KDE5SalVirtualDevice.hxx 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(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 +#include +#include #include @@ -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& pWindow, vcl::RenderContext& rRenderContext) - : m_pBuffer(VclPtr::Create()) + : m_pBuffer(VclPtr::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 cbbf40f87a4d..96d1501cca19 100644 --- a/vcl/unx/kde5/KDE5SalInstance.cxx +++ b/vcl/unx/kde5/KDE5SalInstance.cxx @@ -35,7 +35,7 @@ #include "KDE5FilePicker.hxx" #include "KDE5SalData.hxx" #include "KDE5SalInstance.hxx" -#include "KDE5SalFrame.hxx" +#include "KDE5SalVirtualDevice.hxx" using namespace com::sun::star; @@ -89,6 +89,22 @@ KDE5SalInstance::createFolderPicker(const uno::Reference bool KDE5SalInstance::IsMainThread() const { return qApp->thread() == QThread::currentThread(); } +std::unique_ptr KDE5SalInstance::CreateVirtualDevice(SalGraphics* pGraphics, + long& nDX, long& nDY, + DeviceFormat eFormat, + const SystemGraphicsData*) +{ + std::unique_ptr pVD; + assert(pGraphics); + RunInMainThread([&]() { + KDE5SalGraphics* pKDE5Graphics = dynamic_cast(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 5980ea4699cc..ecb8f74627bb 100644 --- a/vcl/unx/kde5/KDE5SalInstance.hxx +++ b/vcl/unx/kde5/KDE5SalInstance.hxx @@ -42,6 +42,10 @@ public: virtual bool IsMainThread() const override; + virtual std::unique_ptr + CreateVirtualDevice(SalGraphics*, long&, long&, DeviceFormat, + const SystemGraphicsData* = nullptr) override; + private: virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override; 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 +#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: */ -- cgit