diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-07 22:20:53 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-08 05:56:44 +0200 |
commit | 3e82710d1e368a4c1a942270efa3ee6f4c936f67 (patch) | |
tree | 67ac6a4a44529332c7a9c552370f4baed416f24e /vcl/qt5 | |
parent | 92c03d9bf644b0f10de52ce0da09f97056e46247 (diff) |
KDE5 merge KDE5SalGraphics into Qt5SvpGraphics
Nothing KDE specific left in there, so just merge it.
Change-Id: I11712961f2abc5e11256a158300ec6b388f9ee44
Reviewed-on: https://gerrit.libreoffice.org/73680
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r-- | vcl/qt5/Qt5Frame.cxx | 2 | ||||
-rw-r--r-- | vcl/qt5/Qt5Instance.cxx | 5 | ||||
-rw-r--r-- | vcl/qt5/Qt5SvpGraphics.cxx | 65 | ||||
-rw-r--r-- | vcl/qt5/Qt5SvpVirtualDevice.hxx | 36 |
4 files changed, 101 insertions, 7 deletions
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index ed8af3f1542d..0520465c190e 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -257,7 +257,7 @@ SalGraphics* Qt5Frame::AcquireGraphics() { if (!m_pOurSvpGraphics.get() || m_bGraphicsInvalid) { - m_pOurSvpGraphics.reset(new Qt5SvpGraphics(m_pQWidget)); + m_pOurSvpGraphics.reset(new Qt5SvpGraphics(this)); InitQt5SvpGraphics(m_pOurSvpGraphics.get()); m_bGraphicsInvalid = false; } diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx index 52eab795682e..bdfb0473c55b 100644 --- a/vcl/qt5/Qt5Instance.cxx +++ b/vcl/qt5/Qt5Instance.cxx @@ -31,6 +31,7 @@ #include <Qt5Menu.hxx> #include <Qt5Object.hxx> #include <Qt5OpenGLContext.hxx> +#include "Qt5SvpVirtualDevice.hxx" #include <Qt5System.hxx> #include <Qt5Timer.hxx> #include <Qt5VirtualDevice.hxx> @@ -283,10 +284,10 @@ Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, D { if (m_bUseCairo) { - SvpSalGraphics* pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics); + SvpSalGraphics* pSvpSalGraphics = dynamic_cast<Qt5SvpGraphics*>(pGraphics); assert(pSvpSalGraphics); std::unique_ptr<SalVirtualDevice> pVD( - new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface())); + new Qt5SvpVirtualDevice(eFormat, pSvpSalGraphics->getSurface())); pVD->SetSize(nDX, nDY); return pVD; } diff --git a/vcl/qt5/Qt5SvpGraphics.cxx b/vcl/qt5/Qt5SvpGraphics.cxx index f746381e6561..1e6ae94be070 100644 --- a/vcl/qt5/Qt5SvpGraphics.cxx +++ b/vcl/qt5/Qt5SvpGraphics.cxx @@ -9,17 +9,22 @@ #include <sal/config.h> #include <sal/log.hxx> +#include <salbmp.hxx> #include <config_cairo_canvas.h> +#include <Qt5Frame.hxx> #include <Qt5SvpGraphics.hxx> #include <Qt5SvpSurface.hxx> +#include <Qt5Tools.hxx> +#include <QtGui/QScreen> +#include <QtGui/QWindow> #include <QtWidgets/QWidget> -Qt5SvpGraphics::Qt5SvpGraphics(QWidget* pQWidget) +Qt5SvpGraphics::Qt5SvpGraphics(Qt5Frame* pFrame) : SvpSalGraphics() - , m_pQWidget(pQWidget) + , m_pFrame(pFrame) { } @@ -27,8 +32,11 @@ Qt5SvpGraphics::~Qt5SvpGraphics() {} void Qt5SvpGraphics::updateQWidget() const { - if (m_pQWidget) - m_pQWidget->update(m_pQWidget->rect()); + if (!m_pFrame) + return; + QWidget* pQWidget = m_pFrame->GetQWidget(); + if (pQWidget) + pQWidget->update(pQWidget->rect()); } #if ENABLE_CAIRO_CANVAS @@ -49,4 +57,53 @@ cairo::SurfaceSharedPtr Qt5SvpGraphics::CreateSurface(const OutputDevice& /*rRef #endif +static void QImage2BitmapBuffer(QImage* pImg, BitmapBuffer* pBuf) +{ + if (pImg->width() != 0 && pImg->height() != 0) + { + pBuf->mnWidth = pImg->width(); + pBuf->mnHeight = pImg->height(); + pBuf->mnBitCount = getFormatBits(pImg->format()); + pBuf->mpBits = pImg->bits(); + pBuf->mnScanlineSize = pImg->bytesPerLine(); + } +} + +bool Qt5SvpGraphics::drawNativeControl(ControlType nType, ControlPart nPart, + const tools::Rectangle& rControlRegion, ControlState nState, + const ImplControlValue& aValue, const OUString& aCaption) +{ + bool bHandled + = m_aControl.drawNativeControl(nType, nPart, rControlRegion, nState, aValue, aCaption); + if (bHandled) + { + QImage* pImage = &m_aControl.getImage(); + BitmapBuffer* pBuffer = new BitmapBuffer; + QImage2BitmapBuffer(pImage, pBuffer); + SalTwoRect aTR(0, 0, pImage->width(), pImage->height(), rControlRegion.getX(), + rControlRegion.getY(), rControlRegion.GetWidth(), + rControlRegion.GetHeight()); + drawBitmap(aTR, pBuffer, CAIRO_OPERATOR_OVER); + } + return bHandled; +} + +void Qt5SvpGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) +{ + char* pForceDpi; + if ((pForceDpi = getenv("SAL_FORCEDPI"))) + { + OString sForceDPI(pForceDpi); + rDPIX = rDPIY = sForceDPI.toInt32(); + return; + } + + if (!m_pFrame || !m_pFrame->GetQWidget()->window()->windowHandle()) + return; + + QScreen* pScreen = m_pFrame->GetQWidget()->window()->windowHandle()->screen(); + rDPIX = pScreen->logicalDotsPerInchX() * pScreen->devicePixelRatio() + 0.5; + rDPIY = pScreen->logicalDotsPerInchY() * pScreen->devicePixelRatio() + 0.5; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5SvpVirtualDevice.hxx b/vcl/qt5/Qt5SvpVirtualDevice.hxx new file mode 100644 index 000000000000..75c446bafb33 --- /dev/null +++ b/vcl/qt5/Qt5SvpVirtualDevice.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 <qt5/Qt5SvpGraphics.hxx> + +class VCL_DLLPUBLIC Qt5SvpVirtualDevice : public SvpSalVirtualDevice +{ +public: + Qt5SvpVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface) + : SvpSalVirtualDevice(eFormat, pRefSurface) + { + } + + SalGraphics* AcquireGraphics() override { return AddGraphics(new Qt5SvpGraphics(nullptr)); } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |