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@fbihome.de>
This commit is contained in:
Jan-Marek Glogowski
2019-06-07 19:09:18 +02:00
parent 9870ff897f
commit 2cb6a591b6
7 changed files with 73 additions and 7 deletions

View File

@@ -45,12 +45,16 @@ SvpSalVirtualDevice::~SvpSalVirtualDevice()
cairo_surface_destroy(m_pRefSurface);
}
SvpSalGraphics* SvpSalVirtualDevice::AddGraphics(SvpSalGraphics* pGraphics)
{
pGraphics->setSurface(m_pSurface, m_aFrameSize);
m_aGraphics.push_back(pGraphics);
return pGraphics;
}
SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
{
SvpSalGraphics* pGraphics = new SvpSalGraphics();
pGraphics->setSurface(m_pSurface, m_aFrameSize);
m_aGraphics.push_back( pGraphics );
return pGraphics;
return AddGraphics(new SvpSalGraphics());
}
void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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)
{
}

View File

@@ -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()
{

View File

@@ -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: */

View File

@@ -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: */