include/vcl/GeometryProvider.hxx | 2 vcl/Library_vclplug_gen.mk | 1 vcl/Library_vclplug_qt5.mk | 1 vcl/Library_vclplug_qt6.mk | 1 vcl/headless/CairoCommon.cxx | 41 ++++++++++++++ vcl/headless/SvpGraphicsBackend.cxx | 15 ----- vcl/headless/svpbmp.cxx | 31 +++-------- vcl/headless/svpvd.cxx | 28 ++-------- vcl/inc/headless/CairoCommon.hxx | 7 ++ vcl/inc/headless/SvpGraphicsBackend.hxx | 4 - vcl/inc/headless/svpbmp.hxx | 4 - vcl/inc/headless/svpgdi.hxx | 2 vcl/inc/headless/svpvd.hxx | 1 vcl/inc/qt5/QtBitmap.hxx | 3 - vcl/inc/qt5/QtGraphics.hxx | 4 - vcl/inc/qt5/QtGraphics_Controls.hxx | 2 vcl/inc/qt5/QtSvpGraphics.hxx | 5 + vcl/inc/qt5/QtSvpVirtualDevice.hxx | 18 ++---- vcl/inc/quartz/salgdi.h | 7 +- vcl/inc/salbmp.hxx | 5 - vcl/inc/salgdi.hxx | 8 -- vcl/inc/salgdiimpl.hxx | 4 - vcl/inc/skia/gdiimpl.hxx | 7 -- vcl/inc/skia/salbmp.hxx | 3 - vcl/inc/unx/GenPspGfxBackend.hxx | 7 +- vcl/inc/unx/salbmp.h | 3 - vcl/inc/unx/salgdi.h | 3 - vcl/inc/win/salgdi.h | 10 +-- vcl/qt5/QtBitmap.cxx | 16 +---- vcl/qt5/QtFrame.cxx | 8 +- vcl/qt5/QtGraphics.cxx | 9 +-- vcl/qt5/QtGraphics_Controls.cxx | 11 ++- vcl/qt5/QtGraphics_GDI.cxx | 4 - vcl/qt5/QtInstance.cxx | 7 +- vcl/qt5/QtSvpGraphics.cxx | 45 ++++++++++------ vcl/qt5/QtSvpVirtualDevice.cxx | 31 +++-------- vcl/qt5/QtTools.cxx | 8 +- vcl/skia/gdiimpl.cxx | 4 - vcl/skia/salbmp.cxx | 17 +++++- vcl/skia/x11/salvd.cxx | 1 vcl/source/gdi/salgdilayout.cxx | 2 vcl/source/image/ImplImageTree.cxx | 2 vcl/source/outdev/mask.cxx | 2 vcl/source/outdev/text.cxx | 2 vcl/unx/generic/gdi/gdiimpl.cxx | 8 +- vcl/unx/generic/gdi/gdiimpl.hxx | 9 +-- vcl/unx/generic/gdi/salbmp.cxx | 37 +++---------- vcl/unx/generic/gdi/salgdi.cxx | 70 +++++++++++++++++++++++-- vcl/unx/generic/gdi/salgdi2.cxx | 89 -------------------------------- vcl/unx/generic/gdi/salvd.cxx | 8 ++ vcl/unx/generic/window/salframe.cxx | 2 51 files changed, 276 insertions(+), 343 deletions(-)
New commits: commit e01de62ccaa8d77534bb1b7dd8ea952aac531d6c Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Thu Apr 28 11:55:35 2022 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Thu Apr 28 11:55:35 2022 +0200 Yesterdays work, more real diff --git a/include/vcl/GeometryProvider.hxx b/include/vcl/GeometryProvider.hxx index bbd7d37e2c3d..8a4bc7b01532 100644 --- a/include/vcl/GeometryProvider.hxx +++ b/include/vcl/GeometryProvider.hxx @@ -42,6 +42,8 @@ public: { return Size(GetSgpMetric(SGPmetric::Width), GetSgpMetric(SGPmetric::Height)); } + // alias for SalBitmap + Size GetSize() const { return GetSizePixel(); } virtual sal_Int32 GetSgpMetric(SGPmetric eMetric) const = 0; }; diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk index 2cefd3f76856..374353e0fe71 100644 --- a/vcl/Library_vclplug_gen.mk +++ b/vcl/Library_vclplug_gen.mk @@ -101,7 +101,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\ vcl/unx/generic/gdi/X11CairoSalGraphicsImpl \ vcl/unx/generic/gdi/gdiimpl \ vcl/unx/generic/gdi/salbmp \ - vcl/unx/generic/gdi/salgdi2 \ vcl/unx/generic/gdi/font \ vcl/unx/generic/gdi/salgdi \ vcl/unx/generic/gdi/salvd \ diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index d21f7d989410..d6096c934594 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -99,6 +99,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtPrinter \ vcl/qt5/QtSvpGraphics \ vcl/qt5/QtSvpSurface \ + vcl/qt5/QtSvpVirtualDevice \ vcl/qt5/QtSystem \ vcl/qt5/QtTimer \ vcl/qt5/QtTools \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index 9a4e627f3e22..6bdae75c7919 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -98,6 +98,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtPrinter \ vcl/qt6/QtSvpGraphics \ vcl/qt6/QtSvpSurface \ + vcl/qt6/QtSvpVirtualDevice \ vcl/qt6/QtSystem \ vcl/qt6/QtTimer \ vcl/qt6/QtTools \ diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 107f6a0b1948..f9677f3e8db6 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -392,6 +392,12 @@ cairo_user_data_key_t* CairoCommon::getDamageKey() return &aDamageKey; } +cairo_user_data_key_t* CairoCommon::getScalingKey() +{ + static cairo_user_data_key_t aScalingKey; + return &aScalingKey; +} + cairo_t* CairoCommon::getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const { cairo_t* cr; @@ -1103,6 +1109,41 @@ cairo_surface_t* CairoCommon::createCairoSurface(const BitmapBuffer* pBuffer) return target; } +sal_Int32 CairoCommon::GetSgpMetricFromSurface(vcl::SGPmetric eMetric, cairo_surface_t& rSurface) +{ + switch (eMetric) + { + case vcl::SGPmetric::Width: + return cairo_image_surface_get_width(&rSurface); + case vcl::SGPmetric::Height: + return cairo_image_surface_get_height(&rSurface); + case vcl::SGPmetric::DPIX: + case vcl::SGPmetric::DPIY: + return 96 * GetSgpMetricFromSurface(vcl::SGPmetric::ScalePercentage, rSurface); + case vcl::SGPmetric::ScalePercentage: + { + double fXScale; + dl_cairo_surface_get_device_scale(&rSurface, &fXScale, nullptr); + return round(fXScale * 100); + } + case vcl::SGPmetric::OffScreen: + return true; + case vcl::SGPmetric::BitCount: + if (cairo_surface_get_content(&rSurface) != CAIRO_CONTENT_COLOR_ALPHA) + return 1; + return 32; + } + return -1; +} + +sal_Int32 CairoCommon::GetSgpMetric(vcl::SGPmetric eMetric) const +{ + assert(m_pSurface); + if (!m_pSurface) + return -1; + return CairoCommon::GetSgpMetricFromSurface(eMetric, *m_pSurface); +} + std::unique_ptr<BitmapBuffer> FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* pSrc) { if (pSrc == nullptr) diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx index 37ffc7b981a6..eb618bfbcf60 100644 --- a/vcl/headless/SvpGraphicsBackend.cxx +++ b/vcl/headless/SvpGraphicsBackend.cxx @@ -42,19 +42,6 @@ bool SvpGraphicsBackend::setClipRegion(const vcl::Region& i_rClip) void SvpGraphicsBackend::ResetClipRegion() { m_rCairoCommon.m_aClipRegion.SetNull(); } -sal_uInt16 SvpGraphicsBackend::GetBitCount() const -{ - if (cairo_surface_get_content(m_rCairoCommon.m_pSurface) != CAIRO_CONTENT_COLOR_ALPHA) - return 1; - return 32; -} - -tools::Long SvpGraphicsBackend::GetGraphicsWidth() const -{ - assert(m_rCairoCommon.m_pSurface); - return cairo_image_surface_get_width(m_rCairoCommon.m_pSurface); -} - void SvpGraphicsBackend::SetLineColor() { m_rCairoCommon.m_aLineColor = SALCOLOR_NONE; } void SvpGraphicsBackend::SetLineColor(Color nColor) { m_rCairoCommon.m_aLineColor = nColor; } @@ -501,7 +488,7 @@ std::shared_ptr<SalBitmap> SvpGraphicsBackend::getBitmap(tools::Long nX, tools:: std::shared_ptr<SvpSalBitmap> pBitmap = std::make_shared<SvpSalBitmap>(); BitmapPalette aPal; vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; - if (GetBitCount() == 1) + if (m_rCairoCommon.GetBitCount() == 1) { ePixelFormat = vcl::PixelFormat::N1_BPP; aPal.SetEntryCount(2); diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 167a5165a893..37c51948cd97 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -212,29 +212,20 @@ void SvpSalBitmap::Destroy() } } -Size SvpSalBitmap::GetSize() const +sal_Int32 SvpSalBitmap::GetSgpMetric(vcl::SGPmetric eMetric) const { - Size aSize; - - if (mpDIB) + assert(mpDIB); + switch (eMetric) { - aSize.setWidth( mpDIB->mnWidth ); - aSize.setHeight( mpDIB->mnHeight ); + case vcl::SGPmetric::Width: return mpDIB ? mpDIB->mnWidth : 0; + case vcl::SGPmetric::Height: return mpDIB ? mpDIB->mnHeight : 0; + case vcl::SGPmetric::DPIX: return 96; + case vcl::SGPmetric::DPIY: return 96; + case vcl::SGPmetric::ScalePercentage: return 100; + case vcl::SGPmetric::OffScreen: return true; + case vcl::SGPmetric::BitCount: return mpDIB ? mpDIB->mnBitCount : 0; } - - return aSize; -} - -sal_uInt16 SvpSalBitmap::GetBitCount() const -{ - sal_uInt16 nBitCount; - - if (mpDIB) - nBitCount = mpDIB->mnBitCount; - else - nBitCount = 0; - - return nBitCount; + return -1; } BitmapBuffer* SvpSalBitmap::AcquireBuffer(BitmapAccessMode) diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index 2cb14e9d7ee2..c27ff3baa917 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -153,29 +153,15 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer(sal_Int32 nNewDX, sal_Int32 nNewDY, sal_Int32 SvpSalVirtualDevice::GetSgpMetric(vcl::SGPmetric eMetric) const { - switch (eMetric) + assert(m_pSurface); + if (!m_pSurface) { - case vcl::SGPmetric::Width: return m_pSurface ? cairo_image_surface_get_width(m_pSurface) : 1; - case vcl::SGPmetric::Height: return m_pSurface ? cairo_image_surface_get_height(m_pSurface) : 1; - case vcl::SGPmetric::DPIX: - case vcl::SGPmetric::DPIY: - return 96 * GetSgpMetric(vcl::SGPmetric::ScalePercentage); - case vcl::SGPmetric::ScalePercentage: - { - double fXScale, fYScale; - if (m_pSurface) - dl_cairo_surface_get_device_scale(m_pSurface, &fXScale, &fYScale); - else if (comphelper::LibreOfficeKit::isActive()) - fXScale = comphelper::LibreOfficeKit::getDPIScale(); - else - fXScale = 1.0; - return round(fXScale * 100); - } - case vcl::SGPmetric::OffScreen: return true; - case vcl::SGPmetric::BitCount: return 32; - default: - return -1; + if (vcl::SGPmetric::ScalePercentage == eMetric && comphelper::LibreOfficeKit::isActive()) + return round(comphelper::LibreOfficeKit::getDPIScale() * 100); + return -1; } + + return CairoCommon::GetSgpMetricFromSurface(eMetric, *m_pSurface); } #endif diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx index 56271a450224..3a59fd899d9e 100644 --- a/vcl/inc/headless/CairoCommon.hxx +++ b/vcl/inc/headless/CairoCommon.hxx @@ -25,6 +25,7 @@ #include <cairo.h> #include <vcl/dllapi.h> +#include <vcl/GeometryProvider.hxx> #include <vcl/region.hxx> #include <vcl/salgtype.hxx> #include <vcl/BitmapBuffer.hxx> @@ -144,7 +145,7 @@ struct VCL_DLLPUBLIC DamageHandler damageHandler damaged; }; -struct VCL_DLLPUBLIC CairoCommon +struct VCL_DLLPUBLIC CairoCommon : public vcl::SalGeometryProvider { cairo_surface_t* m_pSurface; vcl::Region m_aClipRegion; @@ -161,6 +162,7 @@ struct VCL_DLLPUBLIC CairoCommon } static cairo_user_data_key_t* getDamageKey(); + static cairo_user_data_key_t* getScalingKey(); cairo_surface_t* getSurface() const { return m_pSurface; } @@ -196,6 +198,9 @@ struct VCL_DLLPUBLIC CairoCommon void invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias); static cairo_surface_t* createCairoSurface(const BitmapBuffer* pBuffer); + + static sal_Int32 GetSgpMetricFromSurface(vcl::SGPmetric eMetric, cairo_surface_t& rSurface); + virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override; }; class SurfaceHelper diff --git a/vcl/inc/headless/SvpGraphicsBackend.hxx b/vcl/inc/headless/SvpGraphicsBackend.hxx index 16f9213576fd..d255372da10c 100644 --- a/vcl/inc/headless/SvpGraphicsBackend.hxx +++ b/vcl/inc/headless/SvpGraphicsBackend.hxx @@ -43,10 +43,6 @@ public: bool setClipRegion(vcl::Region const& rRegion) override; void ResetClipRegion() override; - sal_uInt16 GetBitCount() const override; - - tools::Long GetGraphicsWidth() const override; - void SetLineColor() override; void SetLineColor(Color nColor) override; void SetFillColor() override; diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index 2c347372a4d4..303a732f1aa3 100644 --- a/vcl/inc/headless/svpbmp.hxx +++ b/vcl/inc/headless/svpbmp.hxx @@ -50,8 +50,8 @@ public: return mpDIB.get(); } virtual void Destroy() final override; - virtual Size GetSize() const override; - virtual sal_uInt16 GetBitCount() const override; + + virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override; virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override; virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override; diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index fbfc452eb862..c10c54f91a92 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -47,7 +47,7 @@ class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphicsAutoDelegateToImpl CairoCommon m_aCairoCommon; public: - void setSurface(cairo_surface_t* pSurface); + virtual void setSurface(cairo_surface_t* pSurface); cairo_surface_t* getSurface() const { return m_aCairoCommon.m_pSurface; } static cairo_user_data_key_t* getDamageKey() { diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx index c4b9e47b814c..7c4f1024d536 100644 --- a/vcl/inc/headless/svpvd.hxx +++ b/vcl/inc/headless/svpvd.hxx @@ -41,6 +41,7 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice protected: SvpSalGraphics* AddGraphics(SvpSalGraphics* aGraphics); + cairo_surface_t* refSurface() const { return m_pRefSurface; } public: SvpSalVirtualDevice(cairo_surface_t* pRefSurface, cairo_surface_t* pPreExistingTarget); diff --git a/vcl/inc/qt5/QtBitmap.hxx b/vcl/inc/qt5/QtBitmap.hxx index a15deab29460..1e4f7c88c8a8 100644 --- a/vcl/inc/qt5/QtBitmap.hxx +++ b/vcl/inc/qt5/QtBitmap.hxx @@ -44,8 +44,7 @@ public: virtual bool Create(const css::uno::Reference<css::rendering::XBitmapCanvas>& rBitmapCanvas, Size& rSize, bool bMask = false) override; virtual void Destroy() final override; - virtual Size GetSize() const override; - virtual sal_uInt16 GetBitCount() const override; + sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override; virtual BitmapBuffer* AcquireBuffer(BitmapAccessMode nMode) override; virtual void ReleaseBuffer(BitmapBuffer* pBuffer, BitmapAccessMode nMode) override; diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx index 8f85002ee6e4..0bcd42e588bc 100644 --- a/vcl/inc/qt5/QtGraphics.hxx +++ b/vcl/inc/qt5/QtGraphics.hxx @@ -69,10 +69,6 @@ public: bool setClipRegion(vcl::Region const& rRegion) override; void ResetClipRegion() override; - sal_uInt16 GetBitCount() const override; - - tools::Long GetGraphicsWidth() const override; - void SetLineColor() override; void SetLineColor(Color nColor) override; void SetFillColor() override; diff --git a/vcl/inc/qt5/QtGraphics_Controls.hxx b/vcl/inc/qt5/QtGraphics_Controls.hxx index dd89713f3334..15931d6d18ba 100644 --- a/vcl/inc/qt5/QtGraphics_Controls.hxx +++ b/vcl/inc/qt5/QtGraphics_Controls.hxx @@ -40,7 +40,7 @@ class QtGraphics_Controls final : public vcl::WidgetDrawInterface SalGraphics const& m_rGraphics; public: - QtGraphics_Controls(const SalGraphics& rGraphics); + QtGraphics_Controls(const SalGraphics& rGraphics, sal_Int32 nScale); QImage* getImage() { return m_image.get(); } diff --git a/vcl/inc/qt5/QtSvpGraphics.hxx b/vcl/inc/qt5/QtSvpGraphics.hxx index 35150cd43903..315296201793 100644 --- a/vcl/inc/qt5/QtSvpGraphics.hxx +++ b/vcl/inc/qt5/QtSvpGraphics.hxx @@ -32,10 +32,13 @@ class VCLPLUG_QT_PUBLIC QtSvpGraphics final : public SvpSalGraphics void handleDamage(const tools::Rectangle&) override; public: - QtSvpGraphics(QtFrame* pFrame); + QtSvpGraphics(QtFrame *rFrame, sal_Int32 nScale = -1); ~QtSvpGraphics() override; + void setSurface(cairo_surface_t* pSurface) override; + void updateQWidget() const; + QtFrame* frame() const { return m_pFrame; } #if ENABLE_CAIRO_CANVAS bool SupportsCairo() const override; diff --git a/vcl/inc/qt5/QtSvpVirtualDevice.hxx b/vcl/inc/qt5/QtSvpVirtualDevice.hxx index 4718148ad657..5d80ba8c0dbf 100644 --- a/vcl/inc/qt5/QtSvpVirtualDevice.hxx +++ b/vcl/inc/qt5/QtSvpVirtualDevice.hxx @@ -5,26 +5,20 @@ * 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> -class VCL_DLLPUBLIC QtSvpVirtualDevice : public SvpSalVirtualDevice +class QtSvpGraphics; + +class VCL_DLLPUBLIC QtSvpVirtualDevice final : public SvpSalVirtualDevice { + QtSvpGraphics& m_rRefGraphics; + public: - QtSvpVirtualDevice(SalGraphics& rGraphics, cairo_surface_t* pPreExistingTarget); + QtSvpVirtualDevice(QtSvpGraphics& rGraphics, cairo_surface_t* pPreExistingTarget); SalGraphics* AcquireGraphics() override; }; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 569a14a6d3fc..fb43eedd608d 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -337,6 +337,9 @@ private: tools::Long nSrcWidth, tools::Long nSrcHeight, AquaSharedAttributes* pSrcShared); #endif + sal_uInt16 GetBitCount() const; + tools::Long GetGraphicsWidth() const; + public: AquaGraphicsBackend(AquaSharedAttributes & rShared); ~AquaGraphicsBackend() override; @@ -353,10 +356,6 @@ public: bool setClipRegion(vcl::Region const& rRegion) override; void ResetClipRegion() override; - sal_uInt16 GetBitCount() const override; - - tools::Long GetGraphicsWidth() const override; - void SetLineColor() override; void SetLineColor(Color nColor) override; void SetFillColor() override; diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx index f04ea291aa84..d303ca04ce31 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -26,6 +26,7 @@ #include <vcl/BitmapAccessMode.hxx> #include <vcl/BitmapBuffer.hxx> #include <vcl/bitmap/BitmapTypes.hxx> +#include <vcl/GeometryProvider.hxx> #include <com/sun/star/rendering/XBitmapCanvas.hpp> struct BitmapBuffer; @@ -41,7 +42,7 @@ extern const sal_uLong nVCLBLut[ 6 ]; extern const sal_uLong nVCLDitherLut[ 256 ]; extern const sal_uLong nVCLLut[ 256 ]; -class VCL_PLUGIN_PUBLIC SalBitmap +class VCL_PLUGIN_PUBLIC SalBitmap : public vcl::SalGeometryProvider { public: @@ -65,8 +66,6 @@ public: Size& rSize, bool bMask = false ) = 0; virtual void Destroy() = 0; - virtual Size GetSize() const = 0; - virtual sal_uInt16 GetBitCount() const = 0; virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0; virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 1d532c917977..73d08eb4b7a2 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -110,9 +110,6 @@ public: // public SalGraphics methods, the interface to the independent vcl part - // get the width of the device - virtual tools::Long GetGraphicsWidth() const = 0; - // set the clip region to empty virtual void ResetClipRegion() = 0; @@ -696,11 +693,6 @@ void SalGraphics::handleDamage(const tools::Rectangle&) {} class VCL_DLLPUBLIC SalGraphicsAutoDelegateToImpl : public SalGraphics { public: - tools::Long GetGraphicsWidth() const override - { - return GetImpl()->GetGraphicsWidth(); - } - void ResetClipRegion() override { GetImpl()->ResetClipRegion(); diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx index 55f7544587ed..ef3ebcf12004 100644 --- a/vcl/inc/salgdiimpl.hxx +++ b/vcl/inc/salgdiimpl.hxx @@ -82,10 +82,6 @@ public: virtual bool setClipRegion( const vcl::Region& ) = 0; - virtual sal_uInt16 GetBitCount() const = 0; - - virtual tools::Long GetGraphicsWidth() const = 0; - virtual void ResetClipRegion() = 0; virtual void SetLineColor() = 0; diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx index 32e8223436e0..f501c8b7a34d 100644 --- a/vcl/inc/skia/gdiimpl.hxx +++ b/vcl/inc/skia/gdiimpl.hxx @@ -49,13 +49,6 @@ public: const vcl::Region& getClipRegion() const; virtual bool setClipRegion(const vcl::Region&) override; - // - // get the depth of the device - virtual sal_uInt16 GetBitCount() const override; - - // get the width of the device - virtual tools::Long GetGraphicsWidth() const override; - // set the clip region to empty virtual void ResetClipRegion() override; diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index 05e489643f88..0f11bd5309ce 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -47,8 +47,7 @@ public: virtual void Destroy() final override; - virtual Size GetSize() const override; - virtual sal_uInt16 GetBitCount() const override; + virtual sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override; virtual BitmapBuffer* AcquireBuffer(BitmapAccessMode nMode) override; virtual void ReleaseBuffer(BitmapBuffer* pBuffer, BitmapAccessMode nMode) override; diff --git a/vcl/inc/unx/GenPspGfxBackend.hxx b/vcl/inc/unx/GenPspGfxBackend.hxx index a37ee433e6eb..4fc3035f3621 100644 --- a/vcl/inc/unx/GenPspGfxBackend.hxx +++ b/vcl/inc/unx/GenPspGfxBackend.hxx @@ -22,6 +22,9 @@ class GenPspGfxBackend final : public SalGraphicsImpl private: psp::PrinterGfx* m_pPrinterGfx; + sal_uInt16 GetBitCount() const; + tools::Long GetGraphicsWidth() const; + public: GenPspGfxBackend(psp::PrinterGfx* pPrinterGfx); ~GenPspGfxBackend() override; @@ -33,10 +36,6 @@ public: bool setClipRegion(vcl::Region const& rRegion) override; void ResetClipRegion() override; - sal_uInt16 GetBitCount() const override; - - tools::Long GetGraphicsWidth() const override; - void SetLineColor() override; void SetLineColor(Color nColor) override; void SetFillColor() override; diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h index 8b9e7c1cfc9f..7c7aacf501fe 100644 --- a/vcl/inc/unx/salbmp.h +++ b/vcl/inc/unx/salbmp.h @@ -137,8 +137,7 @@ public: virtual void Destroy() override; - virtual Size GetSize() const override; - virtual sal_uInt16 GetBitCount() const override; + sal_Int32 GetSgpMetric(vcl::SGPmetric eMetric) const override; virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override; virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override; diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 182a7f1acc34..88d42ee0b3f4 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -189,8 +189,7 @@ private: Region mpClipRegion; Pixmap hBrush_; // Dither - bool bWindow_ : 1; // is Window - bool bVirDev_ : 1; // is VirDev + bool bWindow_ : 1; // is Window or compatible virtual device std::unique_ptr<SalGraphicsImpl> mxImpl; std::unique_ptr<TextRenderImpl> mxTextRenderImpl; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 7833f988bd18..19e70323ef2b 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -318,16 +318,16 @@ private: void DrawTextLayout(const GenericSalLayout&, HDC, bool bUseDWrite, bool bRenderingModeNatural); + // get the depth of the device + sal_uInt16 GetBitCount() const; + // get the width of the device + tools::Long GetGraphicsWidth() const; + public: // public SalGraphics methods, the interface to the independent vcl part // get device resolution virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override; - // get the depth of the device - virtual sal_uInt16 GetBitCount() const override; - // get the width of the device - virtual tools::Long GetGraphicsWidth() const override; - // set the clip region to empty virtual void ResetClipRegion() override; diff --git a/vcl/qt5/QtBitmap.cxx b/vcl/qt5/QtBitmap.cxx index 0a9fb2b7812f..b57e0d051f72 100644 --- a/vcl/qt5/QtBitmap.cxx +++ b/vcl/qt5/QtBitmap.cxx @@ -92,18 +92,12 @@ bool QtBitmap::Create(const css::uno::Reference<css::rendering::XBitmapCanvas>& void QtBitmap::Destroy() { m_pImage.reset(); } -Size QtBitmap::GetSize() const +sal_Int32 QtBitmap::GetSgpMetric(vcl::SGPmetric eMetric) const { - if (m_pImage) - return toSize(m_pImage->size()); - return Size(); -} - -sal_uInt16 QtBitmap::GetBitCount() const -{ - if (m_pImage) - return getFormatBits(m_pImage->format()); - return 0; + assert(m_pImage); + if (!m_pImage) + return -1; + return GetSgpMetricFromQImage(eMetric, *m_pImage.get()); } BitmapBuffer* QtBitmap::AcquireBuffer(BitmapAccessMode /*nMode*/) diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 282a24f913d3..750c3a39928e 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -204,7 +204,7 @@ void QtFrame::screenChanged(QScreen* pScreen) << GetWidth() << " " << GetHeight()); maGeometry.nDisplayScreenNumber = screenNumber(pScreen); -#if 1 +#if 0 if (m_pSvpGraphics) { // m_pSvpGraphics->setDevicePixelRatioF(devicePixelRatioF()); @@ -217,7 +217,7 @@ void QtFrame::screenChanged(QScreen* pScreen) } #endif m_pQWidget->fakeResize(); - CallCallback(SalEvent::SettingsChanged, nullptr); +// CallCallback(SalEvent::SettingsChanged, nullptr); #if 0 SalPaintEvent aPaintEvt(0, 0, GetWidth(), GetHeight(), true); CallCallback(SalEvent::Paint, &aPaintEvt); @@ -341,8 +341,10 @@ SalGraphics* QtFrame::AcquireGraphics() m_pSurface.reset( cairo_image_surface_create(CAIRO_FORMAT_ARGB32, aSize.width(), aSize.height())); m_pSvpGraphics->setSurface(m_pSurface.get()); - cairo_surface_set_user_data(m_pSurface.get(), QtSvpGraphics::getDamageKey(), + cairo_surface_set_user_data(m_pSurface.get(), CairoCommon::getDamageKey(), &m_aDamageHandler, nullptr); + cairo_surface_set_user_data(m_pSurface.get(), CairoCommon::getScalingKey(), + (void*) (sal_IntPtr) round(devicePixelRatioF() * 100), nullptr); } return m_pSvpGraphics.get(); } diff --git a/vcl/qt5/QtGraphics.cxx b/vcl/qt5/QtGraphics.cxx index 3bda88974f1d..bc75cbd8115b 100644 --- a/vcl/qt5/QtGraphics.cxx +++ b/vcl/qt5/QtGraphics.cxx @@ -40,12 +40,11 @@ QtGraphics::QtGraphics( QtFrame *pFrame, QImage *pQImage ) if (!initWidgetDrawBackends(false)) { if (!QtData::noNativeControls()) - m_pWidgetDraw.reset(new QtGraphics_Controls(*this)); + { + sal_Int32 nScalePercentage = pFrame ? pFrame->GetDPIScalePercentage() : round(pQImage->devicePixelRatio() * 100); + m_pWidgetDraw.reset(new QtGraphics_Controls(*this, nScalePercentage)); + } } -#if 0 - if (m_pFrame) - setScale(m_pFrame->devicePixelRatioF()); -#endif } QtGraphics::~QtGraphics() { ReleaseFonts(); } diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx index 4e0a530a8fe1..c6319a7649a5 100644 --- a/vcl/qt5/QtGraphics_Controls.cxx +++ b/vcl/qt5/QtGraphics_Controls.cxx @@ -74,9 +74,11 @@ static void lcl_ApplyBackgroundColorToStyleOption(QStyleOption& rOption, } } -QtGraphics_Controls::QtGraphics_Controls(const SalGraphics& rGraphics) - : m_rGraphics(rGraphics) +QtGraphics_Controls::QtGraphics_Controls(const SalGraphics& rGraphics, sal_Int32 nScale) + : m_image(new QImage()) + , m_rGraphics(rGraphics) { + m_image->setDevicePixelRatio(nScale / 100.0); } bool QtGraphics_Controls::isNativeControlSupported(ControlType type, ControlPart part) @@ -264,11 +266,12 @@ bool QtGraphics_Controls::drawNativeControl(ControlType type, ControlPart part, QRect widgetRect = toQRect(rControlRegion); //if no image, or resized, make a new image - if (!m_image || m_image->size() != widgetRect.size()) + if (m_image->size() != widgetRect.size()) { + qreal fScaleRatio = m_image->devicePixelRatio(); m_image.reset(new QImage(widgetRect.width(), widgetRect.height(), QImage::Format_ARGB32_Premultiplied)); - m_image->setDevicePixelRatio(m_rGraphics.GetDPIScaleFactor()); + m_image->setDevicePixelRatio(fScaleRatio); } // Default image color - just once diff --git a/vcl/qt5/QtGraphics_GDI.cxx b/vcl/qt5/QtGraphics_GDI.cxx index 431f659c1fcf..dfdd17236a6d 100644 --- a/vcl/qt5/QtGraphics_GDI.cxx +++ b/vcl/qt5/QtGraphics_GDI.cxx @@ -701,10 +701,6 @@ bool QtGraphicsBackend::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Lon return true; } -sal_uInt16 QtGraphicsBackend::GetBitCount() const { return getFormatBits(m_pQImage->format()); } - -tools::Long QtGraphicsBackend::GetGraphicsWidth() const { return m_pQImage->width(); } - void QtGraphicsBackend::SetLineColor() { m_aLineColor = SALCOLOR_NONE; } void QtGraphicsBackend::SetLineColor(Color nColor) { m_aLineColor = nColor; } diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index 1fb5d9de0489..2ac819709de5 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -31,6 +31,7 @@ #include <QtMenu.hxx> #include <QtObject.hxx> #include <QtOpenGLContext.hxx> +#include "QtSvpGraphics.hxx" #include "QtSvpVirtualDevice.hxx" #include <QtSystem.hxx> #include <QtTimer.hxx> @@ -353,13 +354,13 @@ std::unique_ptr<SalVirtualDevice> QtInstance::CreateVirtualDevice(SalGraphics& r { if (m_bUseCairo) { - SvpSalGraphics* pSvpSalGraphics = dynamic_cast<QtSvpGraphics*>(&rGraphics); - assert(pSvpSalGraphics); + QtSvpGraphics* pQtSvpGraphics = dynamic_cast<QtSvpGraphics*>(&rGraphics); + assert(pQtSvpGraphics); // tdf#127529 see SvpSalInstance::CreateVirtualDevice for the rare case of a non-null pPreExistingTarget cairo_surface_t* pPreExistingTarget = pGd ? static_cast<cairo_surface_t*>(pGd->pSurface) : nullptr; std::unique_ptr<SalVirtualDevice> pVD( - new QtSvpVirtualDevice(pSvpSalGraphics->getSurface(), pPreExistingTarget)); + new QtSvpVirtualDevice(*pQtSvpGraphics, pPreExistingTarget)); pVD->SetSize(nDX, nDY); return pVD; } diff --git a/vcl/qt5/QtSvpGraphics.cxx b/vcl/qt5/QtSvpGraphics.cxx index e978e2a51a42..a5c48aa5457d 100644 --- a/vcl/qt5/QtSvpGraphics.cxx +++ b/vcl/qt5/QtSvpGraphics.cxx @@ -24,18 +24,14 @@ #include <QtGui/QWindow> #include <QtWidgets/QWidget> -QtSvpGraphics::QtSvpGraphics(QtFrame* pFrame) +QtSvpGraphics::QtSvpGraphics(QtFrame* pFrame, sal_Int32 nScale) : m_pFrame(pFrame) - , m_nScalePercentage(-1) + , m_nScalePercentage(pFrame ? pFrame->GetDPIScalePercentage() : nScale) { + assert(m_nScalePercentage > 0); + SAL_DEBUG(__func__ << " " << pFrame << " " << m_nScalePercentage); if (!QtData::noNativeControls()) - m_pWidgetDraw.reset(new QtGraphics_Controls(*this)); -// SAL_DEBUG(__func__ << " " << m_pFrame); -#if 0 - if (m_pFrame) - SAL_DEBUG(__func__ << " " << m_pFrame->devicePixelRatioF()); -// setDevicePixelRatioF(m_pFrame->devicePixelRatioF()); -#endif + m_pWidgetDraw.reset(new QtGraphics_Controls(*this, m_nScalePercentage)); } QtSvpGraphics::~QtSvpGraphics() {} @@ -49,6 +45,19 @@ void QtSvpGraphics::updateQWidget() const pQWidget->update(pQWidget->rect()); } +void QtSvpGraphics::setSurface(cairo_surface_t* pSurface) +{ + SvpSalGraphics::setSurface(pSurface); + if (m_pWidgetDraw && pSurface) + { + sal_Int32 nScale = CairoCommon::GetSgpMetricFromSurface(vcl::SGPmetric::ScalePercentage, *pSurface); + SAL_DEBUG(static_cast<sal_IntPtr*>(cairo_surface_get_user_data(pSurface, CairoCommon::getScalingKey()))); + SAL_DEBUG(__func__ << " " << GetDPIScalePercentage() << " " << nScale); + auto *pWidgetDraw = static_cast<QtGraphics_Controls*>(m_pWidgetDraw.get()); + pWidgetDraw->getImage()->setDevicePixelRatio(GetDPIScalePercentage()); + } +} + #if ENABLE_CAIRO_CANVAS bool QtSvpGraphics::SupportsCairo() const { return true; } @@ -100,15 +109,19 @@ void QtSvpGraphics::handleDamage(const tools::Rectangle& rDamagedRegion) sal_Int32 QtSvpGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const { - QImage* pImage = static_cast<QtGraphics_Controls*>(m_pWidgetDraw.get())->getImage(); - if (!pImage) + if (eMetric == vcl::SGPmetric::ScalePercentage) + return m_nScalePercentage; + else { - if (eMetric == vcl::SGPmetric::ScalePercentage && m_nScalePercentage > 0) - return m_nScalePercentage; - return SvpSalGraphics::GetSgpMetric(eMetric); + if (m_pWidgetDraw) + { + QImage* pImage = static_cast<QtGraphics_Controls*>(m_pWidgetDraw.get())->getImage(); + assert(pImage); + return GetSgpMetricFromQImage(eMetric, *pImage); + } + else + return SvpSalGraphics::GetSgpMetric(eMetric); } - else - return GetSgpMetricFromQImage(eMetric, *pImage); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtSvpVirtualDevice.cxx b/vcl/qt5/QtSvpVirtualDevice.cxx index 26247a6e1d58..342ac6df3071 100644 --- a/vcl/qt5/QtSvpVirtualDevice.cxx +++ b/vcl/qt5/QtSvpVirtualDevice.cxx @@ -5,32 +5,21 @@ * 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 <QtSvpVirtualDevice.hxx> #include <QtSvpGraphics.hxx> -class VCL_DLLPUBLIC QtSvpVirtualDevice : public SvpSalVirtualDevice +QtSvpVirtualDevice::QtSvpVirtualDevice(QtSvpGraphics& rRefGraphics, cairo_surface_t* pPreExistingTarget) + : SvpSalVirtualDevice(rRefGraphics.getSurface(), pPreExistingTarget) + , m_rRefGraphics(rRefGraphics) { -public: - QtSvpVirtualDevice(cairo_surface_t* pRefSurface, cairo_surface_t* pPreExistingTarget) - : SvpSalVirtualDevice(pRefSurface, pPreExistingTarget) - { - } + SAL_DEBUG(__func__ << " " << m_rRefGraphics.frame() << m_rRefGraphics.GetDPIScalePercentage()); +} - SalGraphics* AcquireGraphics() override { return AddGraphics(new QtSvpGraphics(nullptr)); } -}; +SalGraphics* QtSvpVirtualDevice::AcquireGraphics() +{ + return AddGraphics(new QtSvpGraphics(m_rRefGraphics.frame(), m_rRefGraphics.GetDPIScalePercentage())); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx index 3f5cc301e627..108dd2f7b2ff 100644 --- a/vcl/qt5/QtTools.cxx +++ b/vcl/qt5/QtTools.cxx @@ -125,15 +125,15 @@ sal_Int32 GetSgpMetricFromQImage(vcl::SGPmetric eMetric, QImage &rImage) { case vcl::SGPmetric::Width: return rImage.width(); case vcl::SGPmetric::Height: return rImage.height(); - case vcl::SGPmetric::ScalePercentage: return round(100 * rImage.devicePixelRatioF()); + case vcl::SGPmetric::ScalePercentage: return round(100 * rImage.devicePixelRatio()); case vcl::SGPmetric::OffScreen: return true; case vcl::SGPmetric::BitCount: return getFormatBits(rImage.format()); case vcl::SGPmetric::DPIX: case vcl::SGPmetric::DPIY: - return round(96 * rImage.devicePixelRatioF()); - default: - return -1; + return round(96 * rImage.devicePixelRatioF()); } + + return -1; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 7997f81f1ddc..0c860b8c5e3d 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -606,10 +606,6 @@ void SkiaSalGraphicsImpl::ResetClipRegion() const vcl::Region& SkiaSalGraphicsImpl::getClipRegion() const { return mClipRegion; } -sal_uInt16 SkiaSalGraphicsImpl::GetBitCount() const { return 32; } - -tools::Long SkiaSalGraphicsImpl::GetGraphicsWidth() const { return GetWidth(); } - void SkiaSalGraphicsImpl::SetLineColor() { checkPendingDrawing(); diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index df3536b4de91..e8f0c5f342a2 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -199,9 +199,20 @@ void SkiaSalBitmap::Destroy() ResetAllData(); } -Size SkiaSalBitmap::GetSize() const { return mSize; } - -sal_uInt16 SkiaSalBitmap::GetBitCount() const { return mBitCount; } +sal_Int32 SkiaSalBitmap::GetSgpMetric(vcl::SGPmetric eMetric) const +{ + switch (eMetric) + { + case vcl::SGPmetric::Width: return mSize.Width(); + case vcl::SGPmetric::Height: return mSize.Height(); + case vcl::SGPmetric::DPIX: return 96; + case vcl::SGPmetric::DPIY: return 96; + case vcl::SGPmetric::ScalePercentage: return 100; + case vcl::SGPmetric::OffScreen: return true; + case vcl::SGPmetric::BitCount: return mBitCount; + } + return -1; +} BitmapBuffer* SkiaSalBitmap::AcquireBuffer(BitmapAccessMode nMode) { diff --git a/vcl/skia/x11/salvd.cxx b/vcl/skia/x11/salvd.cxx index 69931f883ae9..967b99cb1b5c 100644 --- a/vcl/skia/x11/salvd.cxx +++ b/vcl/skia/x11/salvd.cxx @@ -27,7 +27,6 @@ void X11SalGraphics::Init(X11SkiaSalVirtualDevice* pDevice) m_pFrame = nullptr; bWindow_ = pDisplay->IsDisplay(); - bVirDev_ = true; mxImpl->Init(); } diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 89f9d0321daf..5507e4f20511 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -107,7 +107,7 @@ tools::Long SalGraphics::mirror2( tools::Long x, const OutputDevice& rOutDev ) c inline tools::Long SalGraphics::GetDeviceWidth(const OutputDevice& rOutDev) const { - return rOutDev.IsVirtual() ? rOutDev.GetOutputWidthPixel() : GetGraphicsWidth(); + return rOutDev.IsVirtual() ? rOutDev.GetOutputWidthPixel() : GetWidth(); } void SalGraphics::mirror( tools::Long& x, const OutputDevice& rOutDev ) const diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx index 860ec5294f84..5cb87cc68b4e 100644 --- a/vcl/source/image/ImplImageTree.cxx +++ b/vcl/source/image/ImplImageTree.cxx @@ -340,7 +340,7 @@ bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, B const ImageLoadFlags eFlags, sal_Int32 nScalePercentage) { // debug assert to catch non-scaled images - assert(nScalePercentage != 100 && eFlags != ImageLoadFlags::IgnoreScalingFactor); +// assert(nScalePercentage != 100 && eFlags != ImageLoadFlags::IgnoreScalingFactor); OUString aCurrentStyle(rStyle); while (!aCurrentStyle.isEmpty()) { diff --git a/vcl/source/outdev/mask.cxx b/vcl/source/outdev/mask.cxx index c1c3e3b018f5..002eda083161 100644 --- a/vcl/source/outdev/mask.cxx +++ b/vcl/source/outdev/mask.cxx @@ -124,7 +124,7 @@ void OutputDevice::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, ImplLogicHeightToDevicePixel(rDestSize.Height())); // we don't want to mirror via coordinates - const BmpMirrorFlags nMirrFlags = AdjustTwoRect( aPosAry, xImpBmp->GetSize() ); + const BmpMirrorFlags nMirrFlags = AdjustTwoRect(aPosAry, xImpBmp->GetSizePixel()); // check if output is necessary if( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight ) diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index f93d2ba85e7f..4bbcde6f85a0 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -307,7 +307,7 @@ void OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout, auto nOldX = rSalLayout.DrawBase().getX(); if( HasMirroredGraphics() ) { - tools::Long w = IsVirtual() ? m_nWidth : mpGraphics->GetGraphicsWidth(); + tools::Long w = IsVirtual() ? m_nWidth : mpGraphics->GetWidth(); auto x = rSalLayout.DrawBase().getX(); rSalLayout.DrawBase().setX( w - 1 - x ); if( !IsRTLEnabled() ) diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index d5fc4d6c1dc7..5e6057b1cef6 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -472,7 +472,7 @@ void X11SalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, else n = 1; // printer or other display } - else if( pSrcGraphics->bVirDev_ ) + else if (pSrcGraphics->m_pVDev) { n = 1; // window or compatible virtual device } @@ -488,7 +488,7 @@ void X11SalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, // obscured areas beneath overlapping windows), src and dest // are the same window. const bool bNeedGraphicsExposures( pSrcGraphics == &mrParent && - !mrParent.bVirDev_ && + !mrParent.m_pVDev && pSrcGraphics->bWindow_ ); GC pCopyGC = GetCopyGC(); @@ -1857,7 +1857,7 @@ bool X11SalGraphicsImpl::drawPolyLine( Color X11SalGraphicsImpl::getPixel( tools::Long nX, tools::Long nY ) { - if( mrParent.bWindow_ && !mrParent.bVirDev_ ) + if (mrParent.bWindow_ && !mrParent.m_pVDev) { XWindowAttributes aAttrib; @@ -1905,7 +1905,7 @@ std::shared_ptr<SalBitmap> X11SalGraphicsImpl::getBitmap( tools::Long nX, tools: nDY = -nDY; } - if( mrParent.bWindow_ && !mrParent.bVirDev_ ) + if (mrParent.bWindow_ && !mrParent.m_pVDev) { XWindowAttributes aAttrib; diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx index 48211b13d472..f3c564a88b79 100644 --- a/vcl/unx/generic/gdi/gdiimpl.hxx +++ b/vcl/unx/generic/gdi/gdiimpl.hxx @@ -103,6 +103,9 @@ private: void internalDrawPolyLine( sal_uInt32 nPoints, const Point* pPtAry, bool bClose ); + sal_uInt16 GetBitCount() const; + tools::Long GetGraphicsWidth() const; + public: explicit X11SalGraphicsImpl(X11SalGraphics& rParent); @@ -114,12 +117,6 @@ public: virtual OUString getRenderBackendName() const override { return "gen"; } virtual bool setClipRegion( const vcl::Region& ) override; - // - // get the depth of the device - virtual sal_uInt16 GetBitCount() const override; - - // get the width of the device - virtual tools::Long GetGraphicsWidth() const override; // set the clip region to empty virtual void ResetClipRegion() override; diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index 804b50184af6..e5f09367a11c 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -712,36 +712,19 @@ void X11SalBitmap::Destroy() mpCache->ImplRemove( this ); } -Size X11SalBitmap::GetSize() const +sal_Int32 X11SalBitmap::GetSgpMetric(vcl::SGPmetric eMetric) const { - Size aSize; - - if( mpDIB ) - { - aSize.setWidth( mpDIB->mnWidth ); - aSize.setHeight( mpDIB->mnHeight ); - } - else if( mpDDB ) + switch (eMetric) { - aSize.setWidth( mpDDB->ImplGetWidth() ); - aSize.setHeight( mpDDB->ImplGetHeight() ); + case vcl::SGPmetric::Width: return mpDIB ? mpDIB->mnWidth : (mpDDB ? mpDDB->ImplGetWidth() : 0); + case vcl::SGPmetric::Height: return mpDIB ? mpDIB->mnHeight : (mpDDB ? mpDDB->ImplGetHeight() : 0); + case vcl::SGPmetric::DPIX: return 96; + case vcl::SGPmetric::DPIY: return 96; + case vcl::SGPmetric::ScalePercentage: return 100; + case vcl::SGPmetric::OffScreen: return true; + case vcl::SGPmetric::BitCount: return mpDIB ? mpDIB->mnBitCount : (mpDDB ? mpDDB->ImplGetDepth() : 0); } - - return aSize; -} - -sal_uInt16 X11SalBitmap::GetBitCount() const -{ - sal_uInt16 nBitCount; - - if( mpDIB ) - nBitCount = mpDIB->mnBitCount; - else if( mpDDB ) - nBitCount = mpDDB->ImplGetDepth(); - else - nBitCount = 0; - - return nBitCount; + return -1; } BitmapBuffer* X11SalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ ) diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index 6d5ad674d3bf..755bd913416b 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -44,6 +44,7 @@ #include <unx/salunx.h> #include <unx/saldisp.hxx> #include <unx/salgdi.h> +#include <unx/x11/xrender_peer.hxx> #include <unx/x11/xlimits.hxx> #include <salframe.hxx> @@ -61,7 +62,6 @@ #include "X11CairoSalGraphicsImpl.hxx" #endif - // X11Common X11Common::X11Common() @@ -108,8 +108,7 @@ X11SalGraphics::X11SalGraphics(): m_aXRenderPicture(0), mpClipRegion(nullptr), hBrush_(None), - bWindow_(false), - bVirDev_(false) + bWindow_(false) { #if HAVE_FEATURE_SKIA if (SkiaHelper::isVCLSkiaEnabled()) @@ -205,7 +204,6 @@ void X11SalGraphics::Init( SalFrame *pFrame, Drawable aTarget, m_pVDev = nullptr; bWindow_ = true; - bVirDev_ = false; SetDrawable(aTarget, nullptr, nXScreen); mxImpl->Init(); @@ -319,7 +317,9 @@ bool X11SalGraphics::GetDitherPixmap( Color nColor ) sal_Int32 X11SalGraphics::GetSgpMetric(vcl::SGPmetric eMetric) const { - if (bVirDev_) + assert(m_pVDev || m_pFrame); + SAL_DEBUG(__func__ << " " << m_pVDev << " " << m_pFrame << " " << bWindow_); + if (m_pVDev) return m_pVDev->GetSgpMetric(eMetric); else return m_pFrame->GetSgpMetric(eMetric); @@ -442,4 +442,64 @@ void X11SalGraphics::releaseCairoContext(cairo_t* cr) X11Common::releaseCairoContext(cr); } +extern "C" +{ + static Bool GraphicsExposePredicate( Display*, XEvent* pEvent, const XPointer pFrameWindow ) + { + Bool bRet = False; + if( (pEvent->type == GraphicsExpose || pEvent->type == NoExpose) && + pEvent->xnoexpose.drawable == reinterpret_cast<Drawable>(pFrameWindow) ) + { + bRet = True; + } + return bRet; + } +} + +void X11SalGraphics::YieldGraphicsExpose() +{ + // get frame if necessary + SalFrame* pFrame = m_pFrame; + Display* pDisplay = GetXDisplay(); + ::Window aWindow = GetDrawable(); + if( ! pFrame ) + { + for (auto pSalFrame : vcl_sal::getSalDisplay(GetGenericUnixSalData())->getFrames() ) + { + const SystemEnvData* pEnvData = pSalFrame->GetSystemData(); + if( Drawable(pEnvData->GetWindowHandle(pSalFrame)) == aWindow ) + { + pFrame = pSalFrame; + break; + } + } + if( ! pFrame ) + return; + } + + XEvent aEvent; + while( XCheckTypedWindowEvent( pDisplay, aWindow, Expose, &aEvent ) ) + { + SalPaintEvent aPEvt( aEvent.xexpose.x, aEvent.xexpose.y, aEvent.xexpose.width+1, aEvent.xexpose.height+1 ); + pFrame->CallCallback( SalEvent::Paint, &aPEvt ); + } + + do + { + if( ! GetDisplay()->XIfEventWithTimeout( &aEvent, reinterpret_cast<XPointer>(aWindow), GraphicsExposePredicate ) ) + // this should not happen at all; still sometimes it happens + break; + + if( aEvent.type == NoExpose ) + break; + + if( pFrame ) + { + SalPaintEvent aPEvt( aEvent.xgraphicsexpose.x, aEvent.xgraphicsexpose.y, aEvent.xgraphicsexpose.width+1, aEvent.xgraphicsexpose.height+1 ); + pFrame->CallCallback( SalEvent::Paint, &aPEvt ); + } + } while( aEvent.xgraphicsexpose.count != 0 ); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx deleted file mode 100644 index f26048ae1649..000000000000 --- a/vcl/unx/generic/gdi/salgdi2.cxx +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- 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 . - */ - -#include <salgdiimpl.hxx> - -#include <vcl/sysdata.hxx> - -#include <unx/saldisp.hxx> -#include <unx/salgdi.h> -#include <unx/x11/xrender_peer.hxx> -#include <salframe.hxx> - -extern "C" -{ - static Bool GraphicsExposePredicate( Display*, XEvent* pEvent, const XPointer pFrameWindow ) - { - Bool bRet = False; - if( (pEvent->type == GraphicsExpose || pEvent->type == NoExpose) && - pEvent->xnoexpose.drawable == reinterpret_cast<Drawable>(pFrameWindow) ) - { - bRet = True; - } - return bRet; - } -} - -void X11SalGraphics::YieldGraphicsExpose() -{ - // get frame if necessary - SalFrame* pFrame = m_pFrame; - Display* pDisplay = GetXDisplay(); - ::Window aWindow = GetDrawable(); - if( ! pFrame ) - { - for (auto pSalFrame : vcl_sal::getSalDisplay(GetGenericUnixSalData())->getFrames() ) - { - const SystemEnvData* pEnvData = pSalFrame->GetSystemData(); - if( Drawable(pEnvData->GetWindowHandle(pSalFrame)) == aWindow ) - { - pFrame = pSalFrame; - break; - } - } - if( ! pFrame ) - return; - } - - XEvent aEvent; - while( XCheckTypedWindowEvent( pDisplay, aWindow, Expose, &aEvent ) ) - { - SalPaintEvent aPEvt( aEvent.xexpose.x, aEvent.xexpose.y, aEvent.xexpose.width+1, aEvent.xexpose.height+1 ); - pFrame->CallCallback( SalEvent::Paint, &aPEvt ); - } - - do - { - if( ! GetDisplay()->XIfEventWithTimeout( &aEvent, reinterpret_cast<XPointer>(aWindow), GraphicsExposePredicate ) ) - // this should not happen at all; still sometimes it happens - break; - - if( aEvent.type == NoExpose ) - break; - - if( pFrame ) - { - SalPaintEvent aPEvt( aEvent.xgraphicsexpose.x, aEvent.xgraphicsexpose.y, aEvent.xgraphicsexpose.width+1, aEvent.xgraphicsexpose.height+1 ); - pFrame->CallCallback( SalEvent::Paint, &aPEvt ); - } - } while( aEvent.xgraphicsexpose.count != 0 ); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx index e00e955c779e..16a7928942bf 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -62,6 +62,8 @@ void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, cairo_surface_t* pPreEx int nVisualDepth = pDisplay->GetColormap( m_nXScreen ).GetVisual().GetDepth(); int nDeviceDepth = pDevice->GetDepth(); + SAL_DEBUG(__func__ << " " << nVisualDepth << " " << nDeviceDepth); + if( pColormap ) { maX11Common.m_pColormap = pColormap; @@ -78,9 +80,7 @@ void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, cairo_surface_t* pPreEx m_pVDev = pDevice; m_pFrame = nullptr; - bWindow_ = pDisplay->IsDisplay(); - bVirDev_ = true; SetDrawable(pDevice->GetDrawable(), pPreExistingTarget, m_nXScreen); mxImpl->Init(); @@ -100,6 +100,8 @@ X11SalVirtualDevice::X11SalVirtualDevice(const SalGraphics& rGraphics, sal_Int32 pDisplay_ = vcl_sal::getSalDisplay(GetGenericUnixSalData()); nDepth_ = nBitCount; + SAL_DEBUG(__func__ << " 1 " << nDepth_ << " " << GetDepth()); + if( pData && pData->hDrawable != None ) { ::Window aRoot; @@ -157,6 +159,8 @@ X11SalVirtualDevice::X11SalVirtualDevice(const SalGraphics& rGraphics, sal_Int32 cairo_surface_t* pPreExistingTarget = pData ? static_cast<cairo_surface_t*>(pData->pSurface) : nullptr; pGraphics_->Init( this, pPreExistingTarget, pColormap, bDeleteColormap ); + + SAL_DEBUG(__func__ << " 2 " << nBitCount << " " << pGraphics_->GetBitCount()); } X11SalVirtualDevice::~X11SalVirtualDevice() diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 6998412e0156..9348c8948b17 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -1154,8 +1154,6 @@ void X11SalFrame::Show( bool bVisible, bool bNoActivate ) || ( !bVisible && !bMapped_ ) ) return; - SAL_DEBUG(__func__ << " " << bVisible); - // HACK: this is a workaround for (at least) kwin // even though transient frames should be kept above their parent // this does not necessarily hold true for DOCK type windows