[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 506 commits - accessibility/inc accessibility/README accessibility/README.md android/README android/README.md android/source animations/README animations/README.md animations/source apple_remote/README apple_remote/README.md avmedia/README avmedia/README.md basctl/inc basctl/README basctl/README.md basegfx/CppunitTest_basegfx.mk basegfx/README basegfx/README.md basegfx/source basegfx/test basic/CppunitTest_basic_macros.mk basic/qa basic/README basic/README.md basic/source bean/com bean/README bean/README.md binaryurp/README binaryurp/README.md bin/README bin/README.md bridges/Library_cpp_uno.mk bridges/README bridges/README.md canvas/README canvas/README.md canvas/source chart2/inc chart2/qa chart2/README chart2/README.md chart2/source chart2/uiconfig cli_ure/Module_cli_ure.mk cli_ure/README cli_ure/README.md codemaker/README codemaker/README.md comphelper/inc comphelper/README comphelper/README.md comphelper/source comphelper/u til compilerplugins/clang compilerplugins/README compilerplugins/README.md config_host/config_qrcodegen.h.in config_host/config_zxing.h.in config_host.mk.in config_host/README config_host/README.md configmgr/README configmgr/README.md configure.ac connectivity/inc connectivity/qa connectivity/README connectivity/README.md connectivity/source connectivity/workben cppcanvas/inc cppcanvas/qa cppcanvas/README cppcanvas/README.md cppcanvas/source cppuhelper/inc cppuhelper/README cppuhelper/README.md cppu/README cppu/README.md cpputools/README cpputools/README.md cpputools/source cui/inc cui/Library_cui.mk cui/README cui/README.md cui/source cui/uiconfig dbaccess/inc dbaccess/qa dbaccess/README dbaccess/README.md dbaccess/source dbaccess/util desktop/inc desktop/README desktop/README.md desktop/source distro-configs/LibreOfficeiOS_Sim.conf distro-configs/LibreOfficeOssFuzz.conf distro-configs/README distro-configs/README.md download.lst drawinglayer/inc drawinglayer/README drawinglayer/RE ADME.md drawinglayer/source editeng/inc editeng/README editeng/README.md editeng/source embeddedobj/README embeddedobj/README.md embeddedobj/source embedserv/README embedserv/README.md emfio/inc emfio/qa emfio/README emfio/README.md emfio/source eventattacher/README eventattacher/README.md extensions/README extensions/README.md extensions/source extensions/test external/libffi external/libpng external/Module_external.mk external/nss external/openssl external/owncloud-android-lib external/pdfium external/postgresql external/python3 external/qrcodegen external/README external/README.md external/skia external/zxing extras/README extras/README.md extras/source filter/inc filter/README filter/README.md filter/source forms/inc forms/README forms/README.md forms/source formula/inc formula/README formula/README.md formula/source fpicker/inc fpicker/README fpicker/README.md fpicker/source framework/inc framework/README framework/README.md framework/source framework/util helpcontent2 hwpfilte r/README hwpfilter/README.md hwpfilter/source i18nlangtag/README i18nlangtag/README.md i18npool/README i18npool/README.md i18npool/source i18nutil/README i18nutil/README.md icon-themes/breeze icon-themes/breeze_dark icon-themes/breeze_dark_svg icon-themes/breeze_svg icon-themes/colibre icon-themes/colibre_svg icon-themes/elementary icon-themes/elementary_svg icon-themes/karasa_jaga icon-themes/karasa_jaga_svg icon-themes/README icon-themes/README.md icon-themes/sifr icon-themes/sifr_dark icon-themes/sifr_dark_svg icon-themes/sifr_svg icon-themes/sukapura icon-themes/sukapura_svg idlc/README idlc/README.md idl/README idl/README.md include/basegfx include/cppuhelper include/editeng include/framework include/o3tl include/oox include/sal include/sfx2 include/svl include/svx include/test include/tools include/vcl include/xmloff instsetoo_native/README instsetoo_native/README.md io/README io/README.md ios/CustomTarget_iOS_setup.mk io/source io/test javaunohelper/README javaunohelper/READM E.md jurt/README jurt/README.md jvmaccess/README jvmaccess/README.md jvmfwk/README jvmfwk/README.md l10ntools/README l10ntools/README.md librelogo/README librelogo/README.md libreofficekit/qa libreofficekit/README libreofficekit/README.md libreofficekit/source lingucomponent/Module_lingucomponent.mk lingucomponent/README lingucomponent/README.md lingucomponent/source linguistic/README linguistic/README.md linguistic/source lotuswordpro/README lotuswordpro/README.md lotuswordpro/source m4/README m4/README.md Makefile.fetch nlpsolver/README nlpsolver/README.md o3tl/README o3tl/README.md odk/CustomTarget_check.mk odk/Module_odk.mk odk/README odk/README.md offapi/com offapi/README offapi/README.md officecfg/README officecfg/README.md officecfg/registry onlineupdate/README onlineupdate/README.md oovbaapi/README oovbaapi/README.md oox/README oox/README.md oox/source opencl/README opencl/README.md osx/README osx/README.md package/README package/README.md package/source pch/README pch/READM E.md postprocess/Rdb_services.mk postprocess/README postprocess/README.md pyuno/README pyuno/README.md pyuno/source qadevOOo/README qadevOOo/README.md qadevOOo/runner readlicense_oo/license readlicense_oo/README readlicense_oo/README.md registry/README registry/README.md remotebridges/README remotebridges/README.md reportbuilder/README reportbuilder/README.md reportdesign/inc reportdesign/README reportdesign/README.md reportdesign/source RepositoryExternal.mk Repository.mk ridljar/README ridljar/README.md salhelper/README salhelper/README.md sal/qa sal/README sal/README.md sax/README sax/README.md scaddins/inc scaddins/README scaddins/README.md scaddins/source sccomp/inc sccomp/README sccomp/README.md sccomp/source schema/libreoffice schema/odf1.3 schema/README schema/README.md sc/inc scp2/README scp2/README.md sc/qa sc/README sc/README.md scripting/README scripting/README.md scripting/source sc/source sdext/README sdext/README.md sdext/source sd/inc sd/Library_sd.mk sd/qa sd/README sd/README.md sd/sdi sd/source sd/uiconfig sd/workben sfx2/inc sfx2/Library_sfx.mk sfx2/README sfx2/README.md sfx2/sdi sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk sfx2/util shell/README shell/README.md slideshow/inc slideshow/README slideshow/README.md slideshow/source smoketest/README smoketest/README.md solenv/bin solenv/gbuild solenv/README solenv/README.md solenv/sanitizers sot/inc sot/README sot/README.md sot/source starmath/inc starmath/README starmath/README.md starmath/source stoc/README stoc/README.md stoc/source store/README store/README.md svgio/inc svgio/README svgio/README.md svl/inc svl/README svl/README.md svl/source svtools/inc svtools/README svtools/README.md svtools/source svx/inc svx/qa svx/README svx/README.md svx/source svx/uiconfig sw/CppunitTest_sw_core_text.mk sw/CppunitTest_sw_odfimport.mk swext/mediawiki swext/README swext/README.md sw/inc sw/ooxmlexport_setup.mk sw/qa sw/README sw/README.md sw/source sw/uiconfig sysui/README sysui/README.md test/README test/README.md test/source testtools/README testtools/README.md toolkit/README toolkit/README.md tools/qa tools/README tools/README.md tools/source translations ucbhelper/README ucbhelper/README.md ucb/README ucb/README.md ucb/source udkapi/README udkapi/README.md uitest/README uitest/README.md uitest/uitest UnoControls/README UnoControls/README.md UnoControls/source unodevtools/inc unodevtools/README unodevtools/README.md unodevtools/source unoidl/README unoidl/README.md unoidl/source unoil/Module_unoil.mk unoil/README unoil/README.md unotest/source unotools/README unotools/README.md unotools/source unotools/util unoxml/inc unoxml/README unoxml/README.md unoxml/source ure/README ure/README.md uui/inc uui/README uui/README.md uui/source vbahelper/inc vbahelper/README vbahelper/README.md vcl/backendtest vcl/Executable_benchmark.mk vcl/headless vcl/inc vcl/ios vcl/Library_vcl.mk vcl/Module_vcl.mk vcl/osx vcl/qa vcl/quartz vcl/README vcl/README.md vcl/source vcl/unx vcl/win vcl/workben winaccessibility/inc winaccessibility/README winaccessibility/README.md winaccessibility/source wizards/README wizards/README.md wizards/source writerfilter/inc writerfilter/README writerfilter/README.md writerfilter/source writerperfect/inc writerperfect/qa writerperfect/README writerperfect/README.md writerperfect/source xmerge/README xmerge/README.md xmlhelp/README xmlhelp/README.md xmlhelp/source xmloff/inc xmloff/qa xmloff/source xmlreader/README xmlreader/README.md xmlscript/README xmlscript/README.md xmlsecurity/inc xmlsecurity/README xmlsecurity/README.md xmlsecurity/source

Tue, 30 Mar 2021 07:56:19 -0700

Rebased ref, commits from common ancestor:
commit 62cfca2a292af3e80b17d8b6ed5537665a8b9755
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Mar 12 14:25:34 2021 +0000
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:54:20 2021 +0900

    weld the sidebar deck
    
    Change-Id: Idc6710df7e59bcb5f61fca783e0cc0666cb13a1f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112404
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sfx2/source/sidebar/DeckLayouter.cxx 
b/sfx2/source/sidebar/DeckLayouter.cxx
index aea8b9b651ee..b80c80e80407 100644
--- a/sfx2/source/sidebar/DeckLayouter.cxx
+++ b/sfx2/source/sidebar/DeckLayouter.cxx
@@ -216,6 +216,18 @@ void LayoutPanels (
             eMode==MinimumOrLarger);
     }
 
+<<<<<<< HEAD
+=======
+    if (bShowVerticalScrollBar)
+    {
+        const sal_Int32 nContentHeight(
+            eMode==Preferred
+                ? nTotalPreferredHeight + nTotalDecorationHeight
+                : aBox.GetHeight());
+        SetupVerticalScrollBar(rVerticalScrollBar, nContentHeight, 
aBox.GetHeight());
+    }
+
+>>>>>>> d03e3c66cf68 (weld the sidebar deck)
     const sal_Int32 nUsedHeight(PlacePanels(rLayoutItems, eMode));
     rMinimalHeight = nUsedHeight;
 }
commit acbbeb24968a82426d0b7f8a13a9f1f111e3d767
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Mar 18 15:59:20 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:59 2021 +0900

    vcl: bring back RGB565 scanline transformer
    
    While we don't support this as a Bitmap format anymore, we still
    need to transform a buffer that is in RGB565 format in some cases.
    For example backwards compatibility or if a certain bitmap format
    supports such pixel format.
    This change also simplifies some scanline transformers by removing
    code duplication.
    
    Change-Id: I64aa258b8b1fbebf0ed174c0d5fdd2f75f382b28

diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx
index 98e702549f2b..fcb243e72014 100644
--- a/vcl/inc/bitmap/ScanlineTools.hxx
+++ b/vcl/inc/bitmap/ScanlineTools.hxx
@@ -16,7 +16,7 @@
 
 namespace vcl::bitmap
 {
-class ScanlineTransformer
+class IScanlineTransformer
 {
 public:
     virtual void startLine(sal_uInt8* pLine) = 0;
@@ -24,127 +24,163 @@ public:
     virtual Color readPixel() = 0;
     virtual void writePixel(Color nColor) = 0;
 
-    virtual ~ScanlineTransformer() = default;
+    virtual ~IScanlineTransformer() = default;
 };
 
-class ScanlineTransformer_ARGB final : public ScanlineTransformer
+class ScanlineTransformer_RGB565 : public IScanlineTransformer
 {
-private:
-    sal_uInt8* pData;
+protected:
+    sal_uInt16* mpData;
 
 public:
-    virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+    void startLine(sal_uInt8* pLine) override { mpData = 
reinterpret_cast<sal_uInt16*>(pLine); }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel << 2; 
}
+    void skipPixel(sal_uInt32 nPixel) override { mpData += nPixel; }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
-        const Color aColor(ColorTransparency, pData[4], pData[1], pData[2], 
pData[3]);
-        pData += 4;
-        return aColor;
+        sal_uInt8 R = sal_uInt8((*mpData & 0xf800) >> 8);
+        sal_uInt8 G = sal_uInt8((*mpData & 0x07e0) >> 3);
+        sal_uInt8 B = sal_uInt8((*mpData & 0x001f) << 3);
+        mpData++;
+        return Color(R, G, B);
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
-        *pData++ = nColor.GetAlpha();
-        *pData++ = nColor.GetRed();
-        *pData++ = nColor.GetGreen();
-        *pData++ = nColor.GetBlue();
+        sal_uInt16 R = (nColor.GetRed() & 0xf8) << 8;
+        sal_uInt16 G = (nColor.GetGreen() & 0xfc) << 3;
+        sal_uInt16 B = (nColor.GetBlue() & 0xf8) >> 3;
+
+        *mpData++ = R | G | B;
     }
 };
 
-class ScanlineTransformer_BGR final : public ScanlineTransformer
+class ScanlineTransformerBase : public IScanlineTransformer
 {
-private:
-    sal_uInt8* pData;
+protected:
+    sal_uInt8* mpData;
 
 public:
-    virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+    ScanlineTransformerBase()
+        : mpData(nullptr)
+    {
+    }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { pData += (nPixel << 
1) + nPixel; }
+    void startLine(sal_uInt8* pLine) override { mpData = pLine; }
+};
 
-    virtual Color readPixel() override
+class ScanlineTransformer_ARGB final : public ScanlineTransformerBase
+{
+public:
+    void skipPixel(sal_uInt32 nPixel) override { mpData += nPixel << 2; }
+
+    Color readPixel() override
     {
-        const Color aColor(pData[2], pData[1], pData[0]);
-        pData += 3;
+        const Color aColor(ColorTransparency, mpData[4], mpData[1], mpData[2], 
mpData[3]);
+        mpData += 4;
         return aColor;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
-        *pData++ = nColor.GetBlue();
-        *pData++ = nColor.GetGreen();
-        *pData++ = nColor.GetRed();
+        *mpData++ = nColor.GetAlpha();
+        *mpData++ = nColor.GetRed();
+        *mpData++ = nColor.GetGreen();
+        *mpData++ = nColor.GetBlue();
     }
 };
 
-class ScanlineTransformer_8BitPalette final : public ScanlineTransformer
+class ScanlineTransformer_BGR final : public ScanlineTransformerBase
 {
-private:
-    sal_uInt8* pData;
+public:
+    void skipPixel(sal_uInt32 nPixel) override { mpData += (nPixel << 1) + 
nPixel; }
+
+    Color readPixel() override
+    {
+        const Color aColor(mpData[2], mpData[1], mpData[0]);
+        mpData += 3;
+        return aColor;
+    }
+
+    void writePixel(Color nColor) override
+    {
+        *mpData++ = nColor.GetBlue();
+        *mpData++ = nColor.GetGreen();
+        *mpData++ = nColor.GetRed();
+    }
+};
+
+class ScanlineTransformerPaletteBase : public ScanlineTransformerBase
+{
+protected:
     const BitmapPalette& mrPalette;
 
 public:
-    explicit ScanlineTransformer_8BitPalette(const BitmapPalette& rPalette)
-        : pData(nullptr)
+    ScanlineTransformerPaletteBase(const BitmapPalette& rPalette)
+        : ScanlineTransformerBase()
         , mrPalette(rPalette)
     {
     }
+};
 
-    virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+class ScanlineTransformer_8BitPalette final : public 
ScanlineTransformerPaletteBase
+{
+public:
+    explicit ScanlineTransformer_8BitPalette(const BitmapPalette& rPalette)
+        : ScanlineTransformerPaletteBase(rPalette)
+    {
+    }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel; }
+    void skipPixel(sal_uInt32 nPixel) override { mpData += nPixel; }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
-        const sal_uInt8 nIndex(*pData++);
+        const sal_uInt8 nIndex(*mpData++);
         if (nIndex < mrPalette.GetEntryCount())
             return mrPalette[nIndex];
         else
             return COL_BLACK;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
-        *pData++ = static_cast<sal_uInt8>(mrPalette.GetBestIndex(nColor));
+        *mpData++ = static_cast<sal_uInt8>(mrPalette.GetBestIndex(nColor));
     }
 };
 
-class ScanlineTransformer_4BitPalette final : public ScanlineTransformer
+class ScanlineTransformer_4BitPalette final : public 
ScanlineTransformerPaletteBase
 {
 private:
-    sal_uInt8* pData;
-    const BitmapPalette& mrPalette;
     sal_uInt32 mnX;
     sal_uInt32 mnShift;
 
 public:
     explicit ScanlineTransformer_4BitPalette(const BitmapPalette& rPalette)
-        : pData(nullptr)
-        , mrPalette(rPalette)
+        : ScanlineTransformerPaletteBase(rPalette)
         , mnX(0)
         , mnShift(0)
     {
     }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override
+    void skipPixel(sal_uInt32 nPixel) override
     {
         mnX += nPixel;
         if (nPixel & 1) // is nPixel an odd number
             mnShift ^= 4;
     }
 
-    virtual void startLine(sal_uInt8* pLine) override
+    void startLine(sal_uInt8* pLine) override
     {
-        pData = pLine;
+        ScanlineTransformerBase::startLine(pLine);
         mnX = 0;
         mnShift = 4;
     }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
         const sal_uInt32 nDataIndex = mnX / 2;
-        const sal_uInt8 nIndex((pData[nDataIndex] >> mnShift) & 0x0f);
+        const sal_uInt8 nIndex((mpData[nDataIndex] >> mnShift) & 0x0f);
         mnX++;
         mnShift ^= 4;
 
@@ -154,42 +190,39 @@ public:
             return COL_BLACK;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
         const sal_uInt32 nDataIndex = mnX / 2;
         const sal_uInt8 nColorIndex = mrPalette.GetBestIndex(nColor);
-        pData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift;
+        mpData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift;
         mnX++;
         mnShift ^= 4;
     }
 };
 
-class ScanlineTransformer_1BitPalette final : public ScanlineTransformer
+class ScanlineTransformer_1BitPalette final : public 
ScanlineTransformerPaletteBase
 {
 private:
-    sal_uInt8* pData;
-    const BitmapPalette& mrPalette;
     sal_uInt32 mnX;
 
 public:
     explicit ScanlineTransformer_1BitPalette(const BitmapPalette& rPalette)
-        : pData(nullptr)
-        , mrPalette(rPalette)
+        : ScanlineTransformerPaletteBase(rPalette)
         , mnX(0)
     {
     }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { mnX += nPixel; }
+    void skipPixel(sal_uInt32 nPixel) override { mnX += nPixel; }
 
-    virtual void startLine(sal_uInt8* pLine) override
+    void startLine(sal_uInt8* pLine) override
     {
-        pData = pLine;
+        ScanlineTransformerBase::startLine(pLine);
         mnX = 0;
     }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
-        const sal_uInt8 nIndex((pData[mnX >> 3] >> (7 - (mnX & 7))) & 1);
+        const sal_uInt8 nIndex((mpData[mnX >> 3] >> (7 - (mnX & 7))) & 1);
         mnX++;
 
         if (nIndex < mrPalette.GetEntryCount())
@@ -198,18 +231,18 @@ public:
             return COL_BLACK;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
         if (mrPalette.GetBestIndex(nColor) & 1)
-            pData[mnX >> 3] |= 1 << (7 - (mnX & 7));
+            mpData[mnX >> 3] |= 1 << (7 - (mnX & 7));
         else
-            pData[mnX >> 3] &= ~(1 << (7 - (mnX & 7)));
+            mpData[mnX >> 3] &= ~(1 << (7 - (mnX & 7)));
         mnX++;
     }
 };
 
-std::unique_ptr<ScanlineTransformer> getScanlineTransformer(sal_uInt16 nBits,
-                                                            const 
BitmapPalette& rPalette)
+std::unique_ptr<IScanlineTransformer> getScanlineTransformer(sal_uInt16 nBits,
+                                                             const 
BitmapPalette& rPalette)
 {
     switch (nBits)
     {
@@ -219,6 +252,8 @@ std::unique_ptr<ScanlineTransformer> 
getScanlineTransformer(sal_uInt16 nBits,
             return std::make_unique<ScanlineTransformer_4BitPalette>(rPalette);
         case 8:
             return std::make_unique<ScanlineTransformer_8BitPalette>(rPalette);
+        case 16:
+            return std::make_unique<ScanlineTransformer_RGB565>();
         case 24:
             return std::make_unique<ScanlineTransformer_BGR>();
         case 32:
diff --git a/vcl/qa/cppunit/ScanlineToolsTest.cxx 
b/vcl/qa/cppunit/ScanlineToolsTest.cxx
index 3a4fc7da9348..8f5f0c0a2f5c 100644
--- a/vcl/qa/cppunit/ScanlineToolsTest.cxx
+++ b/vcl/qa/cppunit/ScanlineToolsTest.cxx
@@ -19,6 +19,7 @@ class ScanlineToolsTest : public CppUnit::TestFixture
 {
     void ScanlineTransformer_32_ARGB();
     void ScanlineTransformer_24_BGR();
+    void ScanlineTransformer_16_RGB565();
     void ScanlineTransformer_8bit_Palette();
     void ScanlineTransformer_4bit_Palette();
     void ScanlineTransformer_1bit_Palette();
@@ -26,6 +27,7 @@ class ScanlineToolsTest : public CppUnit::TestFixture
     CPPUNIT_TEST_SUITE(ScanlineToolsTest);
     CPPUNIT_TEST(ScanlineTransformer_32_ARGB);
     CPPUNIT_TEST(ScanlineTransformer_24_BGR);
+    CPPUNIT_TEST(ScanlineTransformer_16_RGB565);
     CPPUNIT_TEST(ScanlineTransformer_8bit_Palette);
     CPPUNIT_TEST(ScanlineTransformer_4bit_Palette);
     CPPUNIT_TEST(ScanlineTransformer_1bit_Palette);
@@ -35,8 +37,7 @@ class ScanlineToolsTest : public CppUnit::TestFixture
 void ScanlineToolsTest::ScanlineTransformer_32_ARGB()
 {
     BitmapPalette aPalette;
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(32, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(32, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(5 * 4, 0); // 5 * 4 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -64,8 +65,7 @@ void ScanlineToolsTest::ScanlineTransformer_32_ARGB()
 void ScanlineToolsTest::ScanlineTransformer_24_BGR()
 {
     BitmapPalette aPalette;
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(24, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(24, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(5 * 3, 0); // 5 * 3 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -90,6 +90,51 @@ void ScanlineToolsTest::ScanlineTransformer_24_BGR()
     }
 }
 
+void ScanlineToolsTest::ScanlineTransformer_16_RGB565()
+{
+    BitmapPalette aPalette;
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(16, 
aPalette);
+
+    // Test writing - we apply colors which will be written into the scanline
+    // in the R5G6B5 format
+    std::vector<sal_uInt8> aScanLine(5 * 2, 0); // 5 * 2 BytesPerPixel
+    pScanlineTransformer->startLine(aScanLine.data());
+
+    std::vector<Color> aColors{
+        Color(ColorTransparency, 0, 10, 250, 120),   Color(ColorTransparency, 
50, 30, 230, 110),
+        Color(ColorTransparency, 100, 50, 210, 100), Color(ColorTransparency, 
150, 70, 190, 90),
+        Color(ColorTransparency, 200, 90, 170, 80),
+    };
+
+    for (Color const& aColor : aColors)
+    {
+        pScanlineTransformer->writePixel(aColor);
+    }
+
+    std::vector<sal_uInt8> aExpectedBytes{ 207, 15, 45, 31, 140, 54, 235, 69, 
74, 93 };
+
+    for (size_t i = 0; i < aScanLine.size(); ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL(int(aExpectedBytes[i]), int(aScanLine[i]));
+    }
+
+    // Test reading - we insert a scanline in R5G6B5 format and read
+    // the colors from it
+
+    pScanlineTransformer->startLine(aScanLine.data());
+
+    std::vector<Color> aExpectedColors{
+        Color(8, 248, 120), Color(24, 228, 104), Color(48, 208, 96),
+        Color(64, 188, 88), Color(88, 168, 80),
+    };
+
+    for (size_t i = 0; i < aExpectedColors.size(); ++i)
+    {
+        Color aColor = pScanlineTransformer->readPixel();
+        CPPUNIT_ASSERT_EQUAL(aExpectedColors[i], aColor);
+    }
+}
+
 void ScanlineToolsTest::ScanlineTransformer_8bit_Palette()
 {
     std::vector<Color> aColors{
@@ -102,8 +147,7 @@ void ScanlineToolsTest::ScanlineTransformer_8bit_Palette()
     for (size_t i = 0; i < aColors.size(); ++i)
         aPalette[i] = aColors[i];
 
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(8, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(8, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(5, 0); // 5 * 1 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -142,8 +186,7 @@ void ScanlineToolsTest::ScanlineTransformer_4bit_Palette()
         aPalette[i] = aColors[i];
     }
 
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(4, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(4, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(3, 0); // 6 * 0.5 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -182,8 +225,7 @@ void ScanlineToolsTest::ScanlineTransformer_1bit_Palette()
     aPalette[0] = Color(10, 250, 120);
     aPalette[1] = Color(110, 150, 70);
 
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(1, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(1, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(2, 0); // 13 * 1/8 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
commit d54432e86d28d5804d91fee6fac0e08db1aa377a
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Mar 7 13:48:39 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:59 2021 +0900

    vcl: add PNG writer based on libpng
    
    Change-Id: I52ffd1b286162ee0dd9f694c4f3210385f71daf8

diff --git a/include/vcl/filter/PngImageWriter.hxx 
b/include/vcl/filter/PngImageWriter.hxx
new file mode 100644
index 000000000000..4f64a028af53
--- /dev/null
+++ b/include/vcl/filter/PngImageWriter.hxx
@@ -0,0 +1,50 @@
+/* -*- 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/.
+ *
+ */
+
+#include <vcl/dllapi.h>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <tools/stream.hxx>
+#include <vcl/bitmapex.hxx>
+
+#pragma once
+
+namespace vcl
+{
+class VCL_DLLPUBLIC PngImageWriter
+{
+    SvStream& mrStream;
+    css::uno::Reference<css::task::XStatusIndicator> mxStatusIndicator;
+
+    int mnCompressionLevel;
+    bool mbInterlaced;
+
+public:
+    PngImageWriter(SvStream& rStream);
+
+    virtual ~PngImageWriter() {}
+
+    void setParameters(css::uno::Sequence<css::beans::PropertyValue> const& 
rParameters)
+    {
+        for (auto const& rValue : rParameters)
+        {
+            if (rValue.Name == "Compression")
+                rValue.Value >>= mnCompressionLevel;
+            else if (rValue.Name == "Interlaced")
+                rValue.Value >>= mbInterlaced;
+        }
+    }
+    bool write(BitmapEx& rBitmap);
+};
+
+} // namespace vcl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index df1fc1136fb1..fac00b731409 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -480,6 +480,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/filter/wmf/wmfexternal \
     vcl/source/filter/wmf/wmfwr \
     vcl/source/filter/png/PngImageReader \
+    vcl/source/filter/png/PngImageWriter \
     vcl/source/filter/png/pngwrite \
     vcl/source/font/Feature \
     vcl/source/font/FeatureCollector \
diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx 
b/vcl/qa/cppunit/png/PngFilterTest.cxx
index c167c4c9c636..eb57d2d5d8d7 100644
--- a/vcl/qa/cppunit/png/PngFilterTest.cxx
+++ b/vcl/qa/cppunit/png/PngFilterTest.cxx
@@ -24,14 +24,20 @@
 #include <test/bootstrapfixture.hxx>
 #include <tools/stream.hxx>
 #include <vcl/filter/PngImageReader.hxx>
+#include <vcl/filter/PngImageWriter.hxx>
 #include <vcl/BitmapReadAccess.hxx>
+#include <bitmap/BitmapWriteAccess.hxx>
 #include <vcl/alpha.hxx>
 #include <vcl/graphicfilter.hxx>
+#include <unotools/tempfile.hxx>
 
 using namespace css;
 
 class PngFilterTest : public test::BootstrapFixture
 {
+    // Should keep the temp files (should be false)
+    static constexpr bool bKeepTemp = true;
+
     OUString maDataUrl;
 
     OUString getFullUrl(std::u16string_view sFileName)
@@ -48,10 +54,16 @@ public:
 
     void testPng();
     void testMsGifInPng();
+    void testPngRoundtrip8BitGrey();
+    void testPngRoundtrip24();
+    void testPngRoundtrip32();
 
     CPPUNIT_TEST_SUITE(PngFilterTest);
     CPPUNIT_TEST(testPng);
     CPPUNIT_TEST(testMsGifInPng);
+    CPPUNIT_TEST(testPngRoundtrip8BitGrey);
+    CPPUNIT_TEST(testPngRoundtrip24);
+    CPPUNIT_TEST(testPngRoundtrip32);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -245,6 +257,106 @@ void PngFilterTest::testMsGifInPng()
     CPPUNIT_ASSERT(aGraphic.IsAnimated());
 }
 
+void PngFilterTest::testPngRoundtrip8BitGrey()
+{
+    utl::TempFile aTempFile("testPngRoundtrip8BitGrey");
+    if (!bKeepTemp)
+        aTempFile.EnableKillingFile();
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::WRITE);
+        Bitmap aBitmap(Size(16, 16), 8, &Bitmap::GetGreyPalette(256));
+        {
+            BitmapScopedWriteAccess pWriteAccess(aBitmap);
+            pWriteAccess->Erase(COL_BLACK);
+            for (int i = 0; i < 8; ++i)
+            {
+                for (int j = 0; j < 8; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_GRAY);
+                }
+            }
+            for (int i = 8; i < 16; ++i)
+            {
+                for (int j = 8; j < 16; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_LIGHTGRAY);
+                }
+            }
+        }
+        BitmapEx aBitmapEx(aBitmap);
+
+        vcl::PngImageWriter aPngWriter(rStream);
+        CPPUNIT_ASSERT_EQUAL(true, aPngWriter.write(aBitmapEx));
+        aTempFile.CloseStream();
+    }
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::READ);
+
+        vcl::PngImageReader aPngReader(rStream);
+        BitmapEx aBitmapEx;
+        CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx));
+
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width());
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height());
+
+        CPPUNIT_ASSERT_EQUAL(COL_GRAY, aBitmapEx.GetPixelColor(0, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_LIGHTGRAY, aBitmapEx.GetPixelColor(15, 15));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(15, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(0, 15));
+    }
+}
+
+void PngFilterTest::testPngRoundtrip24()
+{
+    utl::TempFile aTempFile("testPngRoundtrip24");
+    if (!bKeepTemp)
+        aTempFile.EnableKillingFile();
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::WRITE);
+        Bitmap aBitmap(Size(16, 16), 24);
+        {
+            BitmapScopedWriteAccess pWriteAccess(aBitmap);
+            pWriteAccess->Erase(COL_BLACK);
+            for (int i = 0; i < 8; ++i)
+            {
+                for (int j = 0; j < 8; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_LIGHTRED);
+                }
+            }
+            for (int i = 8; i < 16; ++i)
+            {
+                for (int j = 8; j < 16; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_LIGHTBLUE);
+                }
+            }
+        }
+        BitmapEx aBitmapEx(aBitmap);
+
+        vcl::PngImageWriter aPngWriter(rStream);
+        CPPUNIT_ASSERT_EQUAL(true, aPngWriter.write(aBitmapEx));
+    }
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::READ);
+        rStream.Seek(0);
+
+        vcl::PngImageReader aPngReader(rStream);
+        BitmapEx aBitmapEx;
+        CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx));
+
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width());
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height());
+
+        CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aBitmapEx.GetPixelColor(0, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, aBitmapEx.GetPixelColor(15, 15));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(15, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(0, 15));
+    }
+}
+
+void PngFilterTest::testPngRoundtrip32() {}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(PngFilterTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/filter/png/PngImageWriter.cxx 
b/vcl/source/filter/png/PngImageWriter.cxx
new file mode 100644
index 000000000000..c1e638e0aad0
--- /dev/null
+++ b/vcl/source/filter/png/PngImageWriter.cxx
@@ -0,0 +1,143 @@
+/* -*- 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/.
+ *
+ */
+
+#include <vcl/filter/PngImageWriter.hxx>
+#include <png.h>
+#include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/bitmap.hxx>
+
+namespace vcl
+{
+static void lclWriteStream(png_structp pPng, png_bytep pData, png_size_t 
pDataSize)
+{
+    png_voidp pIO = png_get_io_ptr(pPng);
+
+    if (pIO == nullptr)
+        return;
+
+    SvStream* pStream = static_cast<SvStream*>(pIO);
+
+    sal_Size nBytesWritten = pStream->WriteBytes(pData, pDataSize);
+
+    if (nBytesWritten != pDataSize)
+        png_error(pPng, "Write Error");
+}
+
+bool pngWrite(SvStream& rStream, BitmapEx& rBitmapEx, int nCompressionLevel)
+{
+    png_structp pPng = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, 
nullptr, nullptr);
+
+    if (!pPng)
+        return false;
+
+    png_infop pInfo = png_create_info_struct(pPng);
+    if (!pInfo)
+    {
+        png_destroy_write_struct(&pPng, nullptr);
+        return false;
+    }
+
+    Bitmap aBitmap;
+
+    if (setjmp(png_jmpbuf(pPng)))
+    {
+        png_destroy_read_struct(&pPng, &pInfo, nullptr);
+        return false;
+    }
+
+    // Set our custom stream writer
+    png_set_write_fn(pPng, &rStream, lclWriteStream, nullptr);
+
+    aBitmap = rBitmapEx.GetBitmap();
+
+    {
+        Bitmap::ScopedReadAccess pAccess(aBitmap);
+        Size aSize = rBitmapEx.GetSizePixel();
+
+        int bitDepth = -1;
+        int colorType = -1;
+
+        /* PNG_COLOR_TYPE_GRAY (1, 2, 4, 8, 16)
+           PNG_COLOR_TYPE_GRAY_ALPHA (8, 16)
+           PNG_COLOR_TYPE_PALETTE (bit depths 1, 2, 4, 8)
+           PNG_COLOR_TYPE_RGB (bit_depths 8, 16)
+           PNG_COLOR_TYPE_RGB_ALPHA (bit_depths 8, 16)
+           PNG_COLOR_MASK_PALETTE
+           PNG_COLOR_MASK_COLOR
+           PNG_COLOR_MASK_ALPHA
+        */
+        auto eScanlineFormat = pAccess->GetScanlineFormat();
+        if (eScanlineFormat == ScanlineFormat::N8BitPal && 
aBitmap.HasGreyPalette8Bit())
+        {
+            colorType = PNG_COLOR_TYPE_GRAY;
+            bitDepth = 8;
+        }
+        else if (eScanlineFormat == ScanlineFormat::N24BitTcBgr
+                 || eScanlineFormat == ScanlineFormat::N24BitTcRgb)
+        {
+            colorType = PNG_COLOR_TYPE_RGB;
+            bitDepth = 8;
+            if (eScanlineFormat == ScanlineFormat::N24BitTcBgr)
+                png_set_bgr(pPng);
+        }
+        else
+        {
+            return false;
+        }
+
+        png_set_compression_level(pPng, nCompressionLevel);
+
+        int interlaceType = PNG_INTERLACE_NONE;
+        int compressionType = PNG_COMPRESSION_TYPE_DEFAULT;
+        int filterMethod = PNG_FILTER_TYPE_DEFAULT;
+
+        png_set_IHDR(pPng, pInfo, aSize.Width(), aSize.Height(), bitDepth, 
colorType, interlaceType,
+                     compressionType, filterMethod);
+
+        png_write_info(pPng, pInfo);
+
+        int nNumberOfPasses = 1;
+
+        Scanline pSourcePointer;
+
+        tools::Long nHeight = pAccess->Height();
+
+        for (int nPass = 0; nPass < nNumberOfPasses; nPass++)
+        {
+            for (tools::Long y = 0; y <= nHeight; y++)
+            {
+                pSourcePointer = pAccess->GetScanline(y);
+                png_write_rows(pPng, &pSourcePointer, 1);
+            }
+        }
+    }
+
+    png_write_end(pPng, pInfo);
+
+    png_destroy_write_struct(&pPng, &pInfo);
+
+    return true;
+}
+
+PngImageWriter::PngImageWriter(SvStream& rStream)
+    : mrStream(rStream)
+    , mnCompressionLevel(6)
+    , mbInterlaced(false)
+{
+}
+
+bool PngImageWriter::write(BitmapEx& rBitmapEx)
+{
+    return pngWrite(mrStream, rBitmapEx, mnCompressionLevel);
+}
+
+} // namespace vcl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b3770b302ca6a4a5afada79f95c2f172f8ea1d8e
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue May 22 14:44:39 2018 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:58 2021 +0900

    Command Popup
    
    Change-Id: I92cdd3130b8de42ee0863c9e7154e7c7246d9377

diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 3f9d4a232fb7..e2a9a8cdaab6 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -385,7 +385,7 @@ class SvxSearchItem;
 
 // default-ids for windows
 
-// free                                     (SID_SFX_START + 610)
+#define SID_COMMAND_POPUP                   (SID_SFX_START + 610)
 #define SID_NEWWINDOW                       (SID_SFX_START + 620)
 #define SID_CLOSEWIN                        (SID_SFX_START + 621)
 #define SID_VIEWSHELL                       (SID_SFX_START + 623)
diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu 
b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
index 41f5888d6e6d..0711e7fa957e 100644
--- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
@@ -313,6 +313,12 @@ Ctrl+Shift+e aka E_SHIFT_MOD1 under GTK/IBUS is for some 
emoji thing
           <value xml:lang="en-US" 
install:module="unxwnt">.uno:OptionsTreeDialog</value>
         </prop>
       </node>
+      <node oor:name="F1_MOD1" oor:op="replace">
+        <prop oor:name="Command">
+          <value xml:lang="x-no-translate">I10N SHORTCUTS - NO 
TRANSLATE</value>
+          <value xml:lang="en-US">.uno:CommandPopup</value>
+        </prop>
+      </node>
     </node>
     <node oor:name="Modules">
       <node oor:name="com.sun.star.script.BasicIDE" oor:op="replace">
diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 7711f6f3da36..c36a3ee72dea 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6534,6 +6534,14 @@ bit 3 (0x8): #define 
UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:CommandPopup" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Command Popup</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:DevelopmentToolsDockingWindow" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Development Tools</value>
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index b5126ca87893..941b11e59f94 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -291,6 +291,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/styles/StyleManager \
     sfx2/source/toolbox/tbxitem \
     sfx2/source/toolbox/weldutils \
+    sfx2/source/view/CommandPopup \
     sfx2/source/view/classificationcontroller \
     sfx2/source/view/classificationhelper \
     sfx2/source/view/frame \
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk
index a9eacafe4c7b..0ba3a5700a7c 100644
--- a/sfx2/UIConfig_sfx.mk
+++ b/sfx2/UIConfig_sfx.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
        sfx2/uiconfig/ui/classificationbox \
        sfx2/uiconfig/ui/cmisinfopage \
        sfx2/uiconfig/ui/cmisline \
+       sfx2/uiconfig/ui/commandpopup \
        sfx2/uiconfig/ui/custominfopage \
        sfx2/uiconfig/ui/deck \
        sfx2/uiconfig/ui/descriptioninfopage \
diff --git a/sfx2/sdi/frmslots.sdi b/sfx2/sdi/frmslots.sdi
index 09aafef95b7d..a7c8a472e73d 100644
--- a/sfx2/sdi/frmslots.sdi
+++ b/sfx2/sdi/frmslots.sdi
@@ -262,6 +262,11 @@ interface TopWindow : BrowseWindow
         ExecMethod = MiscExec_Impl ;
         StateMethod = MiscState_Impl ;
     ]
+    SID_COMMAND_POPUP
+    [
+        ExecMethod = MiscExec_Impl ;
+        StateMethod = MiscState_Impl ;
+    ]
     SID_CLOSEWIN // ole(no) api(final/play/rec)
     [
         ExecMethod = Exec_Impl ;
@@ -307,4 +312,3 @@ shell SfxViewFrame
         StateMethod = GetState_Impl ;
     ]
 }
-
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 425724440d13..85523a6f0b46 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -1271,6 +1271,23 @@ SfxStringItem FullName SID_DOCFULLNAME
     GroupId = ;
 ]
 
+SfxVoidItem CommandPopup SID_COMMAND_POPUP
+[
+    AutoUpdate = TRUE,
+    FastCall = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = TRUE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::View;
+]
 
 SfxBoolItem FullScreen SID_WIN_FULLSCREEN
 
diff --git a/sfx2/source/view/CommandPopup.cxx 
b/sfx2/source/view/CommandPopup.cxx
new file mode 100644
index 000000000000..16bf9e4f00a9
--- /dev/null
+++ b/sfx2/source/view/CommandPopup.cxx
@@ -0,0 +1,252 @@
+/* -*- 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/.
+ */
+
+#include "CommandPopup.hxx"
+
+#include <workwin.hxx>
+
+#include <sfx2/msgpool.hxx>
+#include <sfx2/bindings.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/dispatchcommand.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
+#include <com/sun/star/ui/theUICategoryDescription.hpp>
+#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+
+#include <vcl/commandinfoprovider.hxx>
+
+using namespace css;
+
+MenuContentHandler::MenuContentHandler(uno::Reference<frame::XFrame> const& 
xFrame)
+    : m_xFrame(xFrame)
+    , m_sModuleLongName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame))
+{
+    auto xComponentContext = comphelper::getProcessComponentContext();
+
+    uno::Reference<ui::XModuleUIConfigurationManagerSupplier> 
xModuleConfigSupplier;
+    
xModuleConfigSupplier.set(ui::theModuleUIConfigurationManagerSupplier::get(xComponentContext));
+
+    uno::Reference<ui::XUIConfigurationManager> xConfigurationManager;
+    xConfigurationManager = 
xModuleConfigSupplier->getUIConfigurationManager(m_sModuleLongName);
+
+    uno::Reference<container::XIndexAccess> xConfigData;
+    xConfigData = 
xConfigurationManager->getSettings("private:resource/menubar/menubar", false);
+
+    gatherMenuContent(xConfigData, m_aMenuContent);
+}
+
+void MenuContentHandler::gatherMenuContent(
+    uno::Reference<container::XIndexAccess> const& xIndexAccess, MenuContent& 
rMenuContent)
+{
+    for (sal_Int32 n = 0; n < xIndexAccess->getCount(); n++)
+    {
+        MenuContent aNewContent;
+        uno::Sequence<beans::PropertyValue> aProperties;
+        uno::Reference<container::XIndexAccess> xIndexContainer;
+
+        if (!(xIndexAccess->getByIndex(n) >>= aProperties))
+            continue;
+
+        bool bIsVisible = true;
+        bool bIsEnabled = true;
+
+        for (auto const& rProperty : aProperties)
+        {
+            OUString aPropertyName = rProperty.Name;
+            if (aPropertyName == "CommandURL")
+                rProperty.Value >>= aNewContent.m_aCommandURL;
+            else if (aPropertyName == "ItemDescriptorContainer")
+                rProperty.Value >>= xIndexContainer;
+            else if (aPropertyName == "IsVisible")
+                rProperty.Value >>= bIsVisible;
+            else if (aPropertyName == "Enabled")
+                rProperty.Value >>= bIsEnabled;
+        }
+
+        if (!bIsEnabled || !bIsVisible)
+            continue;
+
+        auto aCommandProperties = 
vcl::CommandInfoProvider::GetCommandProperties(
+            aNewContent.m_aCommandURL, m_sModuleLongName);
+        OUString aLabel = 
vcl::CommandInfoProvider::GetLabelForCommand(aCommandProperties);
+        aNewContent.m_aMenuLabel = aLabel;
+
+        if (!rMenuContent.m_aFullLabelWithPath.isEmpty())
+            aNewContent.m_aFullLabelWithPath = 
rMenuContent.m_aFullLabelWithPath + " / ";
+        aNewContent.m_aFullLabelWithPath += aNewContent.m_aMenuLabel;
+
+        aNewContent.m_aTooltip = 
vcl::CommandInfoProvider::GetTooltipForCommand(
+            aNewContent.m_aCommandURL, aCommandProperties, m_xFrame);
+
+        if (xIndexContainer.is())
+            gatherMenuContent(xIndexContainer, aNewContent);
+
+        rMenuContent.m_aSubMenuContent.push_back(aNewContent);
+    }
+}
+
+void MenuContentHandler::findInMenu(OUString const& rText,
+                                    std::unique_ptr<weld::TreeView>& 
rpCommandTreeView,
+                                    std::vector<CurrentEntry>& rCommandList)
+{
+    findInMenuRecursive(m_aMenuContent, rText, rpCommandTreeView, 
rCommandList);
+}
+
+void MenuContentHandler::findInMenuRecursive(MenuContent const& rMenuContent, 
OUString const& rText,
+                                             std::unique_ptr<weld::TreeView>& 
rpCommandTreeView,
+                                             std::vector<CurrentEntry>& 
rCommandList)
+{
+    for (MenuContent const& aSubContent : rMenuContent.m_aSubMenuContent)
+    {
+        if (aSubContent.m_aMenuLabel.toAsciiLowerCase().startsWith(rText))
+        {
+            OUString sCommandURL = aSubContent.m_aCommandURL;
+            util::URL aCommandURL;
+            aCommandURL.Complete = sCommandURL;
+            uno::Reference<uno::XComponentContext> xContext
+                = comphelper::getProcessComponentContext();
+            uno::Reference<util::XURLTransformer> xParser = 
util::URLTransformer::create(xContext);
+            xParser->parseStrict(aCommandURL);
+
+            auto* pViewFrame = SfxViewFrame::Current();
+
+            SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool(pViewFrame);
+            const SfxSlot* pSlot = rSlotPool.GetUnoSlot(aCommandURL.Path);
+            if (pSlot)
+            {
+                std::unique_ptr<SfxPoolItem> pState;
+                SfxItemState eState
+                    = pViewFrame->GetBindings().QueryState(pSlot->GetSlotId(), 
pState);
+
+                if (eState != SfxItemState::DISABLED)
+                {
+                    auto xGraphic
+                        = 
vcl::CommandInfoProvider::GetXGraphicForCommand(sCommandURL, m_xFrame);
+                    rCommandList.emplace_back(sCommandURL, 
aSubContent.m_aTooltip);
+
+                    auto pIter = rpCommandTreeView->make_iterator();
+                    rpCommandTreeView->insert(nullptr, -1, 
&aSubContent.m_aFullLabelWithPath,
+                                              nullptr, nullptr, nullptr, 
false, pIter.get());
+                    rpCommandTreeView->set_image(*pIter, xGraphic);
+                }
+            }
+        }
+        findInMenuRecursive(aSubContent, rText, rpCommandTreeView, 
rCommandList);
+    }
+}
+
+CommandListBox::CommandListBox(weld::Window* pParent, 
uno::Reference<frame::XFrame> const& xFrame)
+    : mxBuilder(Application::CreateBuilder(pParent, "sfx/ui/commandpopup.ui"))
+    , mxPopover(mxBuilder->weld_popover("CommandPopup"))
+    , mpEntry(mxBuilder->weld_entry("command_entry"))
+    , mpCommandTreeView(mxBuilder->weld_tree_view("command_treeview"))
+    , mpMenuContentHandler(std::make_unique<MenuContentHandler>(xFrame))
+{
+    mpEntry->connect_changed(LINK(this, CommandListBox, ModifyHdl));
+    mpEntry->connect_key_press(LINK(this, CommandListBox, TreeViewKeyPress));
+    mpCommandTreeView->connect_query_tooltip(LINK(this, CommandListBox, 
QueryTooltip));
+    mpCommandTreeView->connect_row_activated(LINK(this, CommandListBox, 
RowActivated));
+    mpCommandTreeView->set_size_request(400, 400);
+
+    Size aFrameSize = pParent->get_size();
+    tools::Rectangle aRect(Point(aFrameSize.Width(), 0), Size(0, 0));
+    mxPopover->popup_at_rect(pParent, aRect);
+    mpEntry->grab_focus();
+}
+
+IMPL_LINK_NOARG(CommandListBox, QueryTooltip, const weld::TreeIter&, OUString)
+{
+    size_t nSelected = mpCommandTreeView->get_selected_index();
+    if (nSelected < maCommandList.size())
+    {
+        auto const& rCurrent = maCommandList[nSelected];
+        return rCurrent.m_aTooltip;
+    }
+    return OUString();
+}
+
+IMPL_LINK_NOARG(CommandListBox, RowActivated, weld::TreeView&, bool)
+{
+    OUString aCommandURL;
+    int nSelected = mpCommandTreeView->get_selected_index();
+    if (nSelected < int(maCommandList.size()))
+    {
+        auto const& rCurrent = maCommandList[nSelected];
+        aCommandURL = rCurrent.m_aCommandURL;
+    }
+    dispatchCommandAndClose(aCommandURL);
+    return true;
+}
+
+IMPL_LINK(CommandListBox, TreeViewKeyPress, const KeyEvent&, rKeyEvent, bool)
+{
+    if (rKeyEvent.GetKeyCode().GetCode() == KEY_DOWN || 
rKeyEvent.GetKeyCode().GetCode() == KEY_UP)
+    {
+        int nDirection = rKeyEvent.GetKeyCode().GetCode() == KEY_DOWN ? 1 : -1;
+        int nNewIndex = mpCommandTreeView->get_selected_index() + nDirection;
+        nNewIndex = std::clamp(nNewIndex, 0, mpCommandTreeView->n_children());
+        mpCommandTreeView->select(nNewIndex);
+        mpCommandTreeView->set_cursor(nNewIndex);
+        return true;
+    }
+    else if (rKeyEvent.GetKeyCode().GetCode() == KEY_RETURN)
+    {
+        RowActivated(*mpCommandTreeView);
+    }
+
+    return false;
+}
+
+IMPL_LINK_NOARG(CommandListBox, ModifyHdl, weld::Entry&, void)
+{
+    mpCommandTreeView->clear();
+    maCommandList.clear();
+
+    OUString sText = mpEntry->get_text();
+    if (sText.isEmpty())
+        return;
+
+    mpCommandTreeView->freeze();
+    mpMenuContentHandler->findInMenu(sText.toAsciiLowerCase(), 
mpCommandTreeView, maCommandList);
+    mpCommandTreeView->thaw();
+
+    if (mpCommandTreeView->n_children() > 0)
+    {
+        mpCommandTreeView->set_cursor(0);
+        mpCommandTreeView->select(0);
+    }
+
+    mpEntry->grab_focus();
+}
+
+void CommandListBox::dispatchCommandAndClose(OUString const& rCommand)
+{
+    mxPopover->popdown();
+
+    if (!rCommand.isEmpty())
+        comphelper::dispatchCommand(rCommand, 
uno::Sequence<beans::PropertyValue>());
+}
+
+void CommandPopupHandler::showPopup(weld::Window* pParent,
+                                    css::uno::Reference<css::frame::XFrame> 
const& xFrame)
+{
+    mpListBox.reset(new CommandListBox(pParent, xFrame));
+    mpListBox->connect_closed(LINK(this, CommandPopupHandler, PopupModeEnd));
+}
+
+IMPL_LINK_NOARG(CommandPopupHandler, PopupModeEnd, weld::Popover&, void) { 
mpListBox.reset(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/CommandPopup.hxx 
b/sfx2/source/view/CommandPopup.hxx
new file mode 100644
index 000000000000..4c32a5c37c4b
--- /dev/null
+++ b/sfx2/source/view/CommandPopup.hxx
@@ -0,0 +1,104 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <vcl/layout.hxx>
+
+#include <sfx2/dllapi.h>
+#include <sfx2/viewfrm.hxx>
+
+#include <vcl/weld.hxx>
+#include <vcl/window.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+
+struct CurrentEntry
+{
+    OUString m_aCommandURL;
+    OUString m_aTooltip;
+
+    CurrentEntry(OUString const& rCommandURL, OUString const& rTooltip)
+        : m_aCommandURL(rCommandURL)
+        , m_aTooltip(rTooltip)
+    {
+    }
+};
+
+struct MenuContent
+{
+    OUString m_aCommandURL;
+    OUString m_aMenuLabel;
+    OUString m_aFullLabelWithPath;
+    OUString m_aTooltip;
+    std::vector<MenuContent> m_aSubMenuContent;
+};
+
+class MenuContentHandler
+{
+private:
+    css::uno::Reference<css::frame::XFrame> m_xFrame;
+    MenuContent m_aMenuContent;
+    OUString m_sModuleLongName;
+
+public:
+    MenuContentHandler(css::uno::Reference<css::frame::XFrame> const& xFrame);
+
+    void gatherMenuContent(css::uno::Reference<css::container::XIndexAccess> 
const& xIndexAccess,
+                           MenuContent& rMenuContent);
+
+    void findInMenu(OUString const& rText, std::unique_ptr<weld::TreeView>& 
rpCommandTreeView,
+                    std::vector<CurrentEntry>& rCommandList);
+
+private:
+    void findInMenuRecursive(MenuContent const& rMenuContent, OUString const& 
rText,
+                             std::unique_ptr<weld::TreeView>& 
rpCommandTreeView,
+                             std::vector<CurrentEntry>& rCommandList);
+};
+
+class SFX2_DLLPUBLIC CommandListBox final
+{
+private:
+    std::unique_ptr<weld::Builder> mxBuilder;
+    std::unique_ptr<weld::Popover> mxPopover;
+    std::unique_ptr<weld::Entry> mpEntry;
+    std::unique_ptr<weld::TreeView> mpCommandTreeView;
+
+    std::vector<CurrentEntry> maCommandList;
+    OUString m_PreviousText;
+    std::unique_ptr<MenuContentHandler> mpMenuContentHandler;
+
+    DECL_LINK(QueryTooltip, const weld::TreeIter&, OUString);
+    DECL_LINK(RowActivated, weld::TreeView&, bool);
+    DECL_LINK(ModifyHdl, weld::Entry&, void);
+    DECL_LINK(SelectionChanged, weld::TreeView&, void);
+    DECL_LINK(TreeViewKeyPress, const KeyEvent&, bool);
+
+    void dispatchCommandAndClose(OUString const& rCommand);
+
+public:
+    CommandListBox(weld::Window* pParent, 
css::uno::Reference<css::frame::XFrame> const& xFrame);
+    void connect_closed(const Link<weld::Popover&, void>& rLink)
+    {
+        mxPopover->connect_closed(rLink);
+    }
+};
+
+class SFX2_DLLPUBLIC CommandPopupHandler
+{
+private:
+    std::unique_ptr<CommandListBox> mpListBox;
+
+public:
+    void showPopup(weld::Window* pParent, 
css::uno::Reference<css::frame::XFrame> const& xFrame);
+    DECL_LINK(PopupModeEnd, weld::Popover&, void);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 360ed8f75adb..de4e29bdeee3 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -25,6 +25,7 @@
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/classificationhelper.hxx>
 #include <sfx2/notebookbar/SfxNotebookBar.hxx>
+#include <svx/svdview.hxx>
 #include <com/sun/star/document/MacroExecMode.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/DispatchRecorder.hpp>
@@ -45,6 +46,7 @@
 #include <svl/undo.hxx>
 #include <vcl/stdtext.hxx>
 #include <vcl/weld.hxx>
+#include <vcl/weldutils.hxx>
 #include <svtools/miscopt.hxx>
 #include <tools/diagnose_ex.h>
 #include <com/sun/star/container/XIndexAccess.hpp>
@@ -90,6 +92,7 @@
 
 #include <unotools/configmgr.hxx>
 #include <comphelper/sequenceashashmap.hxx>
+#include "CommandPopup.hxx"
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -2913,8 +2916,18 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
             rReq.Done();
             break;
         }
+        case SID_COMMAND_POPUP:
+        {
+            static CommandPopupHandler spCommandPopupHandler;
+
+            tools::Rectangle aRectangle(Point(0,0), 
GetWindow().GetSizePixel());
+            weld::Window* pParent = weld::GetPopupParent(GetWindow(), 
aRectangle);
+            css::uno::Reference<css::frame::XFrame> 
xFrame(GetFrame().GetFrameInterface(), css::uno::UNO_QUERY);
+            spCommandPopupHandler.showPopup(pParent, xFrame);
 
-        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+            rReq.Done();
+            break;
+        }
         case SID_WIN_FULLSCREEN:
         {
             const SfxBoolItem* pItem = 
rReq.GetArg<SfxBoolItem>(rReq.GetSlot());
diff --git a/sfx2/uiconfig/ui/commandpopup.ui b/sfx2/uiconfig/ui/commandpopup.ui
new file mode 100644
index 000000000000..b329d64c6f1e
--- /dev/null
+++ b/sfx2/uiconfig/ui/commandpopup.ui
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface domain="sfx">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name icon -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name tooltip -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkPopover" id="CommandPopup">
+    <property name="can-focus">False</property>
+    <property name="position">bottom</property>
+    <child>
+      <object class="GtkBox" id="container">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="border-width">6</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkEntry" id="command_entry">
+            <property name="visible">True</property>
+            <property name="can-focus">True</property>
+            <property name="caps-lock-warning">False</property>
+            <property name="placeholder-text" translatable="yes" 
context="commandpopup|entry">Search command</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="visible">True</property>
+            <property name="can-focus">True</property>
+            <property name="shadow-type">in</property>
+            <child>
+              <object class="GtkTreeView" id="command_treeview">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="model">liststore1</property>
+                <property name="headers-visible">False</property>
+                <property name="headers-clickable">False</property>
+                <property name="enable-search">False</property>
+                <property name="search-column">0</property>
+                <property name="hover-selection">True</property>
+                <property name="show-expanders">False</property>
+                <property name="tooltip-column">2</property>
+                <property name="activate-on-single-click">True</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection"/>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" id="column">
+                    <property name="sizing">fixed</property>
+                    <child>
+                      <object class="GtkCellRendererPixbuf" 
id="cellrenderericon"/>
+                      <attributes>
+                        <attribute name="pixbuf">0</attribute>
+                      </attributes>
+                    </child>
+                    <child>
+                      <object class="GtkCellRendererText" 
id="cellrenderertext"/>
+                      <attributes>
+                        <attribute name="text">1</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
commit e7c1e8a633082245334e5eff24b589d2a29d90eb
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Nov 12 10:01:20 2020 +0100
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:58 2021 +0900

    basegfx: added LengthUnit class as the base unit for length
    
    Change-Id: I1d4790b60dd784e8b2e2e438274f3ebd6db4b60c

diff --git a/basegfx/CppunitTest_basegfx.mk b/basegfx/CppunitTest_basegfx.mk
index a0379e76612a..b66b1381d69a 100644
--- a/basegfx/CppunitTest_basegfx.mk
+++ b/basegfx/CppunitTest_basegfx.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,basegfx,\
     basegfx/test/basegfxtools \
     basegfx/test/clipstate \
     basegfx/test/genericclipper \
+    basegfx/test/LengthUnitTest \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
new file mode 100644
index 000000000000..0b80c33da5b0
--- /dev/null
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -0,0 +1,96 @@
+/* -*- 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/.
+ */
+
+#include <basegfx/units/LengthUnit.hxx>
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class LengthUnitTest : public CppUnit::TestFixture
+{
+public:
+    void test();
+
+    CPPUNIT_TEST_SUITE(LengthUnitTest);
+    CPPUNIT_TEST(test);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void LengthUnitTest::test()
+{
+    gfx::LengthUnit cm = 1_cm + 5_cm - 2_cm;
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, cm.as_cm(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04, cm.as_m(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(40.0, cm.as_mm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(1440000), cm.raw());
+
+    gfx::LengthUnit cm2 = 5_cm * 2;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), cm2.raw());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, cm2.as_cm(), 1e-4);
+
+    // 1 km - 50 m = 950 m = 95000 cm
+    gfx::LengthUnit cm3 = 100000_cm - 5000_cm;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), cm3.raw());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3.as_cm(), 1e-4);
+
+    gfx::LengthUnit cm4(1_cm);
+    cm4 /= 2;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4);
+
+    // (635 * 20) + 3 * (635 * 15) = 41275EMU
+    gfx::LengthUnit pt = 1_pt + 3_px;
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(3.25, pt.as_pt(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, pt.as_twip(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0451, pt.as_in(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(41275), pt.raw());
+
+    gfx::LengthUnit inch = 1_in; // 1440 * 635
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1440.0, inch.as_twip(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, inch.as_px(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, inch.as_in(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(914400.0, inch.as_emu(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(914400), inch.raw());
+
+    // Conversion
+    sal_Int64 asNumber(17_pt);
+    asNumber += sal_Int64(1_pt);
+    gfx::LengthUnit asLength = gfx::LengthUnit::emu(asNumber);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(18 * 635 * 20), asLength.raw());
+
+    gfx::LengthUnit maximum = gfx::LengthUnit::emu(SAL_MAX_INT64);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(256204778801.5, maximum.as_m(), 1e-1);
+    // 256204778 km
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MAX_INT64), maximum.raw());
+
+    gfx::LengthUnit minimum = gfx::LengthUnit::emu(SAL_MIN_INT64);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(-256204778801.5, minimum.as_m(), 1e-1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(double(SAL_MIN_INT64), minimum.as_emu(), 
1e-1);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MIN_INT64), minimum.raw());
+
+    // 27 emu + 33 emu + 360 emu = 420
+    gfx::LengthUnit emus = 27_emu + 33_emu + 1_hmm;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(420), emus.raw());
+
+    //  Creation from number
+    int number = 10;
+    auto asCm = gfx::LengthUnit::cm(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asCm.as_cm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), asCm.raw());
+
+    auto asMm = gfx::LengthUnit::mm(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asMm.as_mm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(360000), asMm.raw());
+
+    auto asInch = gfx::LengthUnit::in(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asInch.as_in(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(9144000), asInch.raw());
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(LengthUnitTest);
diff --git a/include/basegfx/units/LengthUnit.hxx 
b/include/basegfx/units/LengthUnit.hxx
new file mode 100644
index 000000000000..4edd1cc4704f
--- /dev/null
+++ b/include/basegfx/units/LengthUnit.hxx
@@ -0,0 +1,194 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <sal/types.h>
+
+namespace gfx
+{
+namespace
+{
+constexpr sal_Int64 constFactor_hmm_to_EMU = 360ll;
+constexpr sal_Int64 constFactor_mm_to_EMU = constFactor_hmm_to_EMU * 100ll;
+constexpr sal_Int64 constFactor_cm_to_EMU = constFactor_hmm_to_EMU * 1000ll;
+constexpr sal_Int64 constFactor_m_to_EMU = constFactor_hmm_to_EMU * 100000ll;
+
+constexpr sal_Int64 constFactor_twip_to_EMU = 635ll;
+constexpr sal_Int64 constFactor_in_to_EMU = constFactor_twip_to_EMU * 1440ll;
+constexpr sal_Int64 constFactor_pt_to_EMU = constFactor_twip_to_EMU * 20ll;
+constexpr sal_Int64 constFactor_px_to_EMU = constFactor_twip_to_EMU * 15ll;
+
+} // end anonymous namespace
+
+template <typename T> class LengthUnitBase
+{
+private:
+    // value in EMU units
+    T m_nValue;
+
+    constexpr explicit LengthUnitBase(T nValue)
+        : m_nValue(nValue)
+    {
+    }
+
+public:
+    static constexpr LengthUnitBase cm(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_cm_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase mm(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_mm_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase hmm(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_hmm_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase in(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_in_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase twip(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_twip_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase pt(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_pt_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase px(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_px_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase emu(T nValue) { return 
LengthUnitBase(nValue); }
+
+    constexpr explicit LengthUnitBase()
+        : m_nValue(0)
+    {
+    }
+
+    constexpr explicit operator T() const { return m_nValue; }
+
+    constexpr LengthUnitBase& operator+=(LengthUnitBase const& rhs)
+    {
+        m_nValue += rhs.m_nValue;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator-=(LengthUnitBase const& rhs)
+    {
+        m_nValue -= rhs.m_nValue;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator*=(T const& rhs)
+    {
+        m_nValue *= rhs;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator/=(T const& rhs)
+    {
+        m_nValue /= rhs;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator-()
+    {
+        m_nValue = -m_nValue;
+        return *this;
+    }
+
+    T raw() const { return m_nValue; }
+
+    double as_hmm() const { return m_nValue / double(constFactor_hmm_to_EMU); }
+    double as_mm() const { return m_nValue / double(constFactor_mm_to_EMU); }
+    double as_cm() const { return m_nValue / double(constFactor_cm_to_EMU); }
+    double as_m() const { return m_nValue / double(constFactor_m_to_EMU); }
+    double as_twip() const { return m_nValue / 
double(constFactor_twip_to_EMU); }
+    double as_in() const { return m_nValue / double(constFactor_in_to_EMU); }
+    double as_pt() const { return m_nValue / double(constFactor_pt_to_EMU); }
+    double as_px() const { return m_nValue / double(constFactor_px_to_EMU); }
+    double as_emu() const { return double(m_nValue); }
+};
+
+template <typename T>
+inline LengthUnitBase<T> operator+(LengthUnitBase<T> lhs, const 
LengthUnitBase<T>& rhs)
+{
+    return lhs += rhs;
+}
+
+template <typename T>
+inline LengthUnitBase<T> operator-(LengthUnitBase<T> lhs, const 
LengthUnitBase<T>& rhs)
+{
+    return lhs -= rhs;
+}
+
+template <typename T> inline LengthUnitBase<T> operator*(LengthUnitBase<T> 
lhs, const long rhs)
+{
+    return lhs *= rhs;
+}
+
+template <typename T> inline LengthUnitBase<T> operator/(LengthUnitBase<T> 
lhs, const long rhs)
+{
+    return lhs /= rhs;
+}
+
+typedef LengthUnitBase<sal_Int64> LengthUnit;
+typedef LengthUnitBase<double> LengthUnitD;
+
+} // end namespace gfx
+
+constexpr gfx::LengthUnit operator"" _emu(unsigned long long value)
+{
+    return gfx::LengthUnit::emu(value);
+}
+
+constexpr gfx::LengthUnit operator"" _in(unsigned long long value)
+{
+    return gfx::LengthUnit::in(value);
+}
+
+constexpr gfx::LengthUnit operator"" _cm(unsigned long long value)
+{
+    return gfx::LengthUnit::cm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _mm(unsigned long long value)
+{
+    return gfx::LengthUnit::mm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _hmm(unsigned long long value)
+{
+    return gfx::LengthUnit::hmm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _twip(unsigned long long value)
+{
+    return gfx::LengthUnit::twip(value);
+}
+
+constexpr gfx::LengthUnit operator"" _pt(unsigned long long value)
+{
+    return gfx::LengthUnit::pt(value);
+}
+
+constexpr gfx::LengthUnit operator"" _px(unsigned long long value)
+{
+    return gfx::LengthUnit::px(value);
+}
commit 82352639f181c233283873603475b8264842e3ed
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Aug 29 15:42:42 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:57 2021 +0900

    Add button 'Render Features' to Options
    
    Change-Id: I1a0aa538cdb6d32aa1d0377fd3d032c80bb742a5

diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 673815bb60ab..50b9687e9e51 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -585,6 +585,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, 
weld::DialogController* p
     , m_xMousePosLB(m_xBuilder->weld_combo_box("mousepos"))
     , m_xMouseMiddleLB(m_xBuilder->weld_combo_box("mousemiddle"))
     , m_xMoreIcons(m_xBuilder->weld_button("btnMoreIcons"))
+    , 
m_xButtonTestRenderFeatures(m_xBuilder->weld_button("button_test_render_features"))
 {
     if (Application::GetToolkitName() == "gtk3")
         m_xMenuIconBox->hide();
diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx
index 07d3cca86fb7..a81bfce2a78c 100644
--- a/cui/source/options/optgdlg.hxx
+++ b/cui/source/options/optgdlg.hxx
@@ -115,6 +115,8 @@ private:
     std::unique_ptr<weld::ComboBox> m_xMouseMiddleLB;
     std::unique_ptr<weld::Button> m_xMoreIcons;
 
+    std::unique_ptr<weld::Button> m_xButtonTestRenderFeatures;
+
     DECL_LINK(OnAntialiasingToggled, weld::ToggleButton&, void);
     DECL_LINK(OnUseSkiaToggled, weld::ToggleButton&, void);
     DECL_STATIC_LINK(OfaViewTabPage, OnMoreIconsClick, weld::Button&, void);
diff --git a/cui/uiconfig/ui/optviewpage.ui b/cui/uiconfig/ui/optviewpage.ui
index e7dd3e237fb9..03d4e50f941a 100644
--- a/cui/uiconfig/ui/optviewpage.ui
+++ b/cui/uiconfig/ui/optviewpage.ui
@@ -481,6 +481,18 @@
             <property name="top-attach">0</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkButton" id="button_test_render_features">
+            <property name="label" translatable="yes" 
context="optviewpage|button_test_render_features">Test Render 
Features</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">4</property>
+          </packing>
+        </child>
       </object>
       <packing>
         <property name="left-attach">0</property>
commit 709d2a07c942034f24729feff340dacf6ff67bb9
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Aug 29 15:22:03 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:57 2021 +0900

    Benchmark
    
    Change-Id: I22e0ac54380e2d22606e7b1fd453bed843523a29

diff --git a/Repository.mk b/Repository.mk
index cafa89924a86..0a985e59ca5f 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -72,6 +72,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
        tiledrendering \
     mtfdemo \
     visualbackendtest \
+    benchmark \
        $(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), 
gtktiledviewer) \
 ))
 
diff --git a/vcl/Executable_benchmark.mk b/vcl/Executable_benchmark.mk
new file mode 100644
index 000000000000..c72039c13f7b
--- /dev/null
+++ b/vcl/Executable_benchmark.mk
@@ -0,0 +1,56 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+#
+# 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/.
+#
+
+$(eval $(call gb_Executable_Executable,benchmark))
+
+$(eval $(call gb_Executable_use_api,benchmark,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_Executable_use_external,benchmark,boost_headers))
+
+$(eval $(call gb_Executable_set_include,benchmark,\
+    $$(INCLUDE) \
+    -I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,benchmark,\
+       basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    tl \
+    sal \
+       salhelper \
+    vcl \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,benchmark,\
+    vcl/backendtest/Benchmark \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,benchmark,\
+    vclmain \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Executable_add_libs,benchmark,\
+       -lm \
+       -ldl \
+    -lX11 \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,benchmark,\
+       glxtest \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 3a3626157b1f..1a82eaabb8be 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
             $(if $(DISABLE_GUI),, \
                 Executable_vcldemo \
                 Executable_icontest \
+                Executable_benchmark \
                 Executable_visualbackendtest \
                 Executable_mtfdemo ))) \
 ))
diff --git a/vcl/backendtest/Benchmark.cxx b/vcl/backendtest/Benchmark.cxx
new file mode 100644
index 000000000000..bd3c445c3a01
--- /dev/null
+++ b/vcl/backendtest/Benchmark.cxx
@@ -0,0 +1,278 @@
+/* -*- 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/.
+ */
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+
+#include <vcl/virdev.hxx>
+#include <vcl/vclmain.hxx>
+#include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/svapp.hxx>
+
+#include <chrono>
+#include <iostream>
+#include <tools/ScopedNanoTimer.hxx>
+
+using namespace css;
+
+class Benchmark
+{
+    ScopedVclPtr<VirtualDevice> mpVDev;
+    int mnRepeats;
+
+    Size maSource;
+    Size maTarget;
+
+public:
+    Benchmark()
+        : mpVDev(VclPtr<VirtualDevice>::Create())
+        , mnRepeats(2)
+    {
+        mpVDev->SetAntialiasing(AntialiasingFlags::Enable | 
AntialiasingFlags::PixelSnapHairline);
+        mpVDev->SetOutputSizePixel(Size(4000, 4000));
+        mpVDev->SetBackground(Wallpaper(COL_LIGHTGRAY));
+    }
+
+    void run()
+    {
+        std::vector<sal_Int64> aCompleteTimes(20, 0);
+
+        mnRepeats = 5;
+        for (long iSize : { 4000, 2000, 1000 })
+        {
+            std::vector<std::pair<OUString, sal_Int64>> aTotalTimes(20);
+
+            maSource = Size(iSize, iSize);
+            maTarget = Size(200, 200);
+
+            for (int i = 0; i < mnRepeats; i++)
+            {
+                size_t a = 0;
+                //benchBitmapScale4(aTotalTimes[a].first, 
aTotalTimes[a].second); a++;
+                //benchBitmapScale8X(aTotalTimes[a].first, 
aTotalTimes[a].second); a++;
+                //benchBitmapScale8(aTotalTimes[a].first, 
aTotalTimes[a].second); a++;
+                benchBitmapScale24(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+                benchBitmapScale24Combo(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+                benchBitmapScale32(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+                benchBitmapScale32Combo(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+
+                /*
+                benchBitmap4(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+                benchBitmap8X(aTotalTimes[a].first, aTotalTimes[a].second); 
a++;
+                benchBitmap8(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+                benchBitmap24(aTotalTimes[a].first, aTotalTimes[a].second); 
a++;
+                benchBitmap32(aTotalTimes[a].first, aTotalTimes[a].second); 
a++;*/
+            }
+
+            int i = 0;
+            for (auto& rPair : aTotalTimes)
+            {
+                if (!rPair.first.isEmpty())
+                {
+                    aCompleteTimes[i] += rPair.second / double(mnRepeats);
+                    printf("TIME %d: %s - %f\n", i, 
rPair.first.toUtf8().getStr(),
+                           rPair.second / double(mnRepeats));
+                }
+                i++;
+            }
+            printf("\n");
+        }
+        int i = 0;
+        for (auto& rTime : aCompleteTimes)
+        {
+            if (rTime > 0)
+            {
+                printf("TIME %d: %f\n", i, double(rTime));
+                i++;
+            }
+        }
+    }
+
+    void benchBitmapScale4(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "4 Scale";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N4_BPP, 
&Bitmap::GetGreyPalette(16));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale8X(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8X Scale";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N8_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale8(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8 Scale";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N8_BPP, 
&Bitmap::GetGreyPalette(256));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale24(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "24 Scale Super";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N24_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale24Combo(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "24 Scale Combo";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N24_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Combo);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale32(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "32 Scale Super";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N32_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale32Combo(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "32 Scale Combo";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N32_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Combo);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap4(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "4";
+        mpVDev->Erase();
+
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N4_BPP, 
&Bitmap::GetGreyPalette(16));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap8X(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8X";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N8_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap8(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N8_BPP, 
&Bitmap::GetGreyPalette(256));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap24(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "24";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N24_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap32(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "32";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N32_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer("32", 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+};
+
+class BenchmarkApp : public Application
+{
+public:
+    BenchmarkApp() {}
+
+    virtual int Main() override
+    {
+        Benchmark aBenchmark;
+        aBenchmark.run();
+        return 0;
+    }
+
+protected:
+    void Init() override
+    {
+        try
+        {
+            uno::Reference<uno::XComponentContext> xComponentContext
+                = ::cppu::defaultBootstrap_InitialComponentContext();
+            uno::Reference<lang::XMultiServiceFactory> xMSF
+                = 
uno::Reference<lang::XMultiServiceFactory>(xComponentContext->getServiceManager(),
+                                                             uno::UNO_QUERY);
+
+            if (!xMSF.is())
+                Application::Abort("Bootstrap failure - no service manager");
+
+            comphelper::setProcessServiceFactory(xMSF);
+        }
+        catch (const uno::Exception& e)
+        {
+            Application::Abort("Bootstrap exception " + e.Message);
+        }
+    }
+
+    void DeInit() override
+    {
+        uno::Reference<lang::XComponent> 
xComponent(comphelper::getProcessComponentContext(),
+                                                    uno::UNO_QUERY_THROW);
+        xComponent->dispose();
+        comphelper::setProcessServiceFactory(nullptr);
+    }
+};
+
+void vclmain::createApplication() { static BenchmarkApp aApplication; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8b58ab7f77a4fe83c6cce1485e336792f0ce7f03
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Aug 29 11:58:53 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:56 2021 +0900

    Update BitmapSymmetryCheck check
    
    Change-Id: I5b0080ebc76f7c1cd118cf5317b06ffe1a1c20df

diff --git a/vcl/inc/BitmapSymmetryCheck.hxx b/vcl/inc/BitmapSymmetryCheck.hxx
index 3e79a426b94c..48c73551d887 100644
--- a/vcl/inc/BitmapSymmetryCheck.hxx
+++ b/vcl/inc/BitmapSymmetryCheck.hxx
@@ -12,19 +12,24 @@
 #define INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
 
 #include <vcl/bitmap.hxx>
+#include <vcl/bitmapex.hxx>
 
 class BitmapReadAccess;
 
 class VCL_DLLPUBLIC BitmapSymmetryCheck final
 {
-public:
-    BitmapSymmetryCheck();
-    ~BitmapSymmetryCheck();
+private:
+    std::vector<std::pair<Point, Point>> maNonSymmetricPoints;
+    Size maSize;
 
-    static bool check(Bitmap& rBitmap);
+public:
+    BitmapSymmetryCheck() = default;
+    bool check(Bitmap& rBitmap);
+    BitmapEx getErrorBitmap();
 
 private:
-    static bool checkImpl(BitmapReadAccess const* pReadAccess);
+    bool checkImpl(BitmapReadAccess const* pReadAccess);
+    void addNewError(Point const& rPoint1, Point const& rPoint2);
 };
 
 #endif // INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx 
b/vcl/qa/cppunit/BitmapFilterTest.cxx
index 4bf651855937..e8dcf2716b35 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -127,7 +127,9 @@ void BitmapFilterTest::testBlurCorrectness()
     CPPUNIT_ASSERT_EQUAL(nBPP, aBitmap24Bit.GetBitCount());
 
     // Check that the bitmap is horizontally and vertically symmetrical
-    CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit));
+    BitmapSymmetryCheck aBitmapSymmetryCheck;
+    bool bSymmetryCheckResult = aBitmapSymmetryCheck.check(aBitmap24Bit);
+    CPPUNIT_ASSERT(bSymmetryCheckResult);
 
     {
         Bitmap::ScopedReadAccess aReadAccess(aBitmap24Bit);
diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx 
b/vcl/qa/cppunit/BitmapScaleTest.cxx
index c6da34c6d2c6..86c4cbc03fae 100644
--- a/vcl/qa/cppunit/BitmapScaleTest.cxx
+++ b/vcl/qa/cppunit/BitmapScaleTest.cxx
@@ -18,19 +18,82 @@
 
 #include <BitmapSymmetryCheck.hxx>
 #include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/BitmapTools.hxx>
+
+#include <svdata.hxx>
+#include <salinst.hxx>
 
 namespace
 {
 class BitmapScaleTest : public CppUnit::TestFixture
 {
+    static constexpr const bool mbExportBitmap = true;
+
+    void exportImage(OUString const& rsFilename, Bitmap const& rBitmap)
+    {
+        if (mbExportBitmap)
+        {
+            SvFileStream aStream(rsFilename, StreamMode::WRITE | 
StreamMode::TRUNC);
+            GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+            if (rBitmap.GetBitCount() == 32)
+            {
+                BitmapEx aBitmapConverted;
+                vcl::bitmap::convertBitmap32To24Plus8(BitmapEx(rBitmap), 
aBitmapConverted);
+                rFilter.compressAsPNG(aBitmapConverted, aStream);
+            }
+            else
+            {
+                rFilter.compressAsPNG(BitmapEx(rBitmap), aStream);
+            }
+        }
+    }
+
+    Bitmap createUpscaleTestImage(vcl::PixelFormat ePixelFormat)
+    {
+        long w = 10;
+        long h = 10;
+        Bitmap aBitmap(Size(w, h), ePixelFormat);
+        {
+            BitmapScopedWriteAccess aWriteAccess(aBitmap);
+            aWriteAccess->Erase(ePixelFormat == vcl::PixelFormat::N32_BPP ? 
COL_TRANSPARENT : COL_WHITE);
+            aWriteAccess->SetLineColor(COL_LIGHTRED);
+            aWriteAccess->DrawRect(tools::Rectangle(1, 1, w - 1 - 1, h - 1 - 
1));
+            aWriteAccess->SetLineColor(COL_LIGHTGREEN);
+            aWriteAccess->DrawRect(tools::Rectangle(3, 3, w - 1 - 3, h - 1 - 
3));
+            aWriteAccess->SetLineColor(COL_LIGHTBLUE);
+            aWriteAccess->DrawRect(tools::Rectangle(5, 5, w - 1 - 5, h - 1 - 
5));
+        }
+        return aBitmap;
+    }
+
+    Bitmap createDownscaleTestImage(vcl::PixelFormat ePixelFormat)
+    {
+        long w = 20;
+        long h = 20;
+        Bitmap aBitmap(Size(w, h), ePixelFormat);
+        {
+            BitmapScopedWriteAccess aWriteAccess(aBitmap);
+            aWriteAccess->Erase(ePixelFormat == vcl::PixelFormat::N32_BPP ? 
COL_TRANSPARENT : COL_WHITE);
+            aWriteAccess->SetLineColor(COL_LIGHTRED);
+            aWriteAccess->DrawRect(tools::Rectangle(2, 2, w - 1 - 2, h - 1 - 
2));
+            aWriteAccess->SetLineColor(COL_LIGHTGREEN);
+            aWriteAccess->DrawRect(tools::Rectangle(5, 5, w - 1 - 5, h - 1 - 
5));
+            aWriteAccess->SetLineColor(COL_LIGHTBLUE);
+            aWriteAccess->DrawRect(tools::Rectangle(8, 8, w - 1 - 8, h - 1 - 
8));
+        }
+        return aBitmap;
+    }
+
     void testScale();
     void testScale2();
-    void testScaleSymmetry();
+    void testScaleSymmetryUp24();
+    void testScaleSymmetryDown24();
 
     CPPUNIT_TEST_SUITE(BitmapScaleTest);
     CPPUNIT_TEST(testScale);
     CPPUNIT_TEST(testScale2);
-    CPPUNIT_TEST(testScaleSymmetry);
+    CPPUNIT_TEST(testScaleSymmetryUp24);
+    CPPUNIT_TEST(testScaleSymmetryDown24);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -269,51 +332,63 @@ void BitmapScaleTest::testScale2()
     CPPUNIT_ASSERT(checkBitmapColor(aScaledBitmap, aBitmapColor));
 }
 
-void BitmapScaleTest::testScaleSymmetry()
+void BitmapScaleTest::testScaleSymmetryUp24()
 {
-    const bool bExportBitmap(false);
+    Bitmap aBitmap = createUpscaleTestImage(vcl::PixelFormat::N24_BPP);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmap.GetBitCount());
+    exportImage("~/scale_up_24_before.png", aBitmap);
 
-    Bitmap aBitmap24Bit(Size(10, 10), vcl::PixelFormat::N24_BPP);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), 
aBitmap24Bit.GetBitCount());
-
-    {
-        BitmapScopedWriteAccess aWriteAccess(aBitmap24Bit);
-        aWriteAccess->Erase(COL_WHITE);
-        aWriteAccess->SetLineColor(COL_BLACK);
-        aWriteAccess->DrawRect(tools::Rectangle(1, 1, 8, 8));
-        aWriteAccess->DrawRect(tools::Rectangle(3, 3, 6, 6));
-    }
+    CPPUNIT_ASSERT_EQUAL(long(10), aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(long(10), aBitmap.GetSizePixel().Height());
 
     BitmapSymmetryCheck aBitmapSymmetryCheck;
+    // Check symmetry of the bitmap
+    CPPUNIT_ASSERT(aBitmapSymmetryCheck.check(aBitmap));
+
+    aBitmap.Scale(2, 2);
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap.GetSizePixel().Height());
+
+    exportImage("~/scale_up_24_after.png", aBitmap);
+
+    // After scaling the bitmap should still be symmetrical. This check 
guarantees that
+    // scaling doesn't misalign the bitmap.
+    bool bSymmetryCheckResult = aBitmapSymmetryCheck.check(aBitmap);
+    if (!bSymmetryCheckResult)
+        exportImage("~/scale_up_24_after_error.png",
+                    aBitmapSymmetryCheck.getErrorBitmap().GetBitmap());
+
+    // CPPUNIT_ASSERT(bSymmetryCheckResult);
+}
+
+void BitmapScaleTest::testScaleSymmetryDown24()
+{
+    Bitmap aBitmap = createDownscaleTestImage(vcl::PixelFormat::N24_BPP);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmap.GetBitCount());
+    exportImage("~/scale_down_24_before.png", aBitmap);
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap24Bit.GetSizePixel().Width());
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap24Bit.GetSizePixel().Height());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap.GetSizePixel().Height());
 
+    BitmapSymmetryCheck aBitmapSymmetryCheck;
     // Check symmetry of the bitmap
-    CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit));
+    CPPUNIT_ASSERT(aBitmapSymmetryCheck.check(aBitmap));
 
-    if (bExportBitmap)
-    {
-        SvFileStream aStream("~/scale_before.png", StreamMode::WRITE | 
StreamMode::TRUNC);
-        GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
-        rFilter.compressAsPNG(BitmapEx(aBitmap24Bit), aStream);
-    }
+    aBitmap.Scale(0.5, 0.5);
 
-    aBitmap24Bit.Scale(2, 2, BmpScaleFlag::Fast);
+    exportImage("~/scale_down_24_after.png", aBitmap);
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap24Bit.GetSizePixel().Width());
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap24Bit.GetSizePixel().Height());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap.GetSizePixel().Height());
 
     // After scaling the bitmap should still be symmetrical. This check 
guarantees that
     // scaling doesn't misalign the bitmap.
-    CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit));
-
-    if (bExportBitmap)
-    {
-        SvFileStream aStream("~/scale_after.png", StreamMode::WRITE | 
StreamMode::TRUNC);
-        GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
-        rFilter.compressAsPNG(BitmapEx(aBitmap24Bit), aStream);
-    }
+    bool bSymmetryCheckResult = aBitmapSymmetryCheck.check(aBitmap);
+    if (!bSymmetryCheckResult)
+        exportImage("~/scale_down_24_after_error.png",
+                    aBitmapSymmetryCheck.getErrorBitmap().GetBitmap());
+    // CPPUNIT_ASSERT(aBitmapSymmetryCheck.check(aBitmap));
 }
 
 } // namespace
diff --git a/vcl/source/bitmap/BitmapSymmetryCheck.cxx 
b/vcl/source/bitmap/BitmapSymmetryCheck.cxx
index d2e450c0337d..b9dda0a43849 100644
--- a/vcl/source/bitmap/BitmapSymmetryCheck.cxx
+++ b/vcl/source/bitmap/BitmapSymmetryCheck.cxx
@@ -8,16 +8,11 @@
  *
  */
 
+#include <bitmap/BitmapWriteAccess.hxx>
 #include <vcl/BitmapReadAccess.hxx>
 
 #include <BitmapSymmetryCheck.hxx>
 
-BitmapSymmetryCheck::BitmapSymmetryCheck()
-{}
-
-BitmapSymmetryCheck::~BitmapSymmetryCheck()
-{}
-
 bool BitmapSymmetryCheck::check(Bitmap& rBitmap)
 {
     Bitmap::ScopedReadAccess aReadAccess(rBitmap);
@@ -26,9 +21,13 @@ bool BitmapSymmetryCheck::check(Bitmap& rBitmap)
 
 bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const * pReadAccess)
 {
+    maNonSymmetricPoints.clear();
+
     tools::Long nHeight = pReadAccess->Height();
     tools::Long nWidth = pReadAccess->Width();
 
+    maSize = Size(nWidth, nHeight);
+
     tools::Long nHeightHalf = nHeight / 2;
     tools::Long nWidthHalf = nWidth / 2;
 
@@ -37,22 +36,21 @@ bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const 
* pReadAccess)
 
     for (tools::Long y = 0; y < nHeightHalf; ++y)
     {
-        Scanline pScanlineRead = pReadAccess->GetScanline( y );
-        Scanline pScanlineRead2 = pReadAccess->GetScanline( nHeight - y - 1 );
+
+        tools::Long y2 = nHeight - y - 1;
+
+        Scanline pScanlineRead1 = pReadAccess->GetScanline(y);
+        Scanline pScanlineRead2 = pReadAccess->GetScanline(y2);
         for (tools::Long x = 0; x < nWidthHalf; ++x)
         {
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, x))
-            {
-                return false;
-            }
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead, nWidth - x - 1))
-            {
-                return false;
-            }
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, nWidth - x - 1))
-            {
-                return false;
-            }
+            tools::Long x2 = nWidth - x - 1;
+
+            if (pReadAccess->GetPixelFromData(pScanlineRead1, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, x))
+                addNewError(Point(x, y), Point(x, y2));
+            if (pReadAccess->GetPixelFromData(pScanlineRead1, x) != 
pReadAccess->GetPixelFromData(pScanlineRead1, x2))
+                addNewError(Point(x, y), Point(x2, y));
+            if (pReadAccess->GetPixelFromData(pScanlineRead1, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, x2))
+                addNewError(Point(x, y), Point(x2, y2));
         }
     }
 
@@ -60,10 +58,9 @@ bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const * 
pReadAccess)
     {
         for (tools::Long y = 0; y < nHeightHalf; ++y)
         {
-            if (pReadAccess->GetPixel(y, nWidthHalf) != 
pReadAccess->GetPixel(nHeight - y - 1, nWidthHalf))
-            {
-                return false;
-            }
+            tools::Long y2 = nHeight - y - 1;
+            if (pReadAccess->GetPixel(y, nWidthHalf) != 
pReadAccess->GetPixel(y2, nWidthHalf))
+                addNewError(Point(nWidthHalf, y), Point(nWidthHalf, y2));
         }
     }
 
@@ -72,14 +69,38 @@ bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const 
* pReadAccess)
         Scanline pScanlineRead = pReadAccess->GetScanline( nHeightHalf );
         for (tools::Long x = 0; x < nWidthHalf; ++x)
         {
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead, nWidth - x - 1))
-            {
-                return false;
-            }
+            tools::Long x2 = nWidth - x - 1;
+            BitmapColor c1 = pReadAccess->GetPixelFromData(pScanlineRead, x);
+            BitmapColor c2 = pReadAccess->GetPixelFromData(pScanlineRead, x2);
+            if (c1 != c2)
+                addNewError(Point(x, nHeightHalf), Point(x2, nHeightHalf));
         }
     }
 
-    return true;
+    return maNonSymmetricPoints.empty();
+}
+
+void BitmapSymmetryCheck::addNewError(Point const & rPoint1, Point const & 
rPoint2)
+{
+    maNonSymmetricPoints.emplace_back(rPoint1, rPoint2);
+}
+
+BitmapEx BitmapSymmetryCheck::getErrorBitmap()
+{
+    if (maSize == Size() || maNonSymmetricPoints.empty())
+        return BitmapEx();
+
+    Bitmap aBitmap(maSize, vcl::PixelFormat::N24_BPP);
+    {
+        BitmapScopedWriteAccess pWrite(aBitmap);
+        pWrite->Erase(COL_BLACK);
+        for (auto const & rPairOfPoints : maNonSymmetricPoints)
+        {
+            pWrite->SetPixel(rPairOfPoints.first.Y(), rPairOfPoints.first.X(), 
COL_LIGHTRED);
+            pWrite->SetPixel(rPairOfPoints.second.Y(), 
rPairOfPoints.second.X(), COL_LIGHTGREEN);
+        }
+    }
+    return BitmapEx(aBitmap);
 }
 
 
commit e66e1f5cea3ee82777ab43ce62cb6e248df9ec1d
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Aug 29 11:44:21 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Tue Mar 30 23:52:56 2021 +0900

    Combo image down-scaler and HalfScaler
    
    Change-Id: I2c422f983e378cff47c5534f0f2774ffb41e2a25

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 1bfc484fee5b..67ee0801e40c 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -63,7 +63,8 @@ enum class BmpScaleFlag
     Lanczos,
     BiCubic,
     BiLinear,
-    Super // bilinear interpolation when supersampling and averaging when 
subsampling under certain scale
+    Super, // bilinear interpolation when supersampling and averaging when 
subsampling under certain scale
+    Combo
 };
 
 #define BMP_COL_TRANS               Color( 252, 3, 251 )
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 4ffb346ca2e1..df1fc1136fb1 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -371,6 +371,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/bitmap/BitmapSeparableUnsharpenFilter \
     vcl/source/bitmap/BitmapFastScaleFilter \
     vcl/source/bitmap/BitmapScaleSuperFilter \
+    vcl/source/bitmap/BitmapComboScaleFilter \
     vcl/source/bitmap/BitmapScaleConvolutionFilter \
     vcl/source/bitmap/BitmapSymmetryCheck \
     vcl/source/bitmap/BitmapColorQuantizationFilter \
@@ -379,6 +380,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/bitmap/checksum \
     vcl/source/bitmap/Octree \
     vcl/source/bitmap/salbmp \
+    vcl/source/bitmap/ScanlineHalfScaler \
     vcl/source/image/Image \
     vcl/source/image/ImageTree \
     vcl/source/image/ImageRepository \
diff --git a/vcl/inc/BitmapComboScaleFilter.hxx 
b/vcl/inc/BitmapComboScaleFilter.hxx
new file mode 100644
index 000000000000..b70254b96c59
--- /dev/null
+++ b/vcl/inc/BitmapComboScaleFilter.hxx
@@ -0,0 +1,52 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_VCL_BITMAPCOMBOSCALEFILTER_HXX
+#define INCLUDED_VCL_BITMAPCOMBOSCALEFILTER_HXX
+
+#include <vcl/BitmapFilter.hxx>
+
+#include <comphelper/threadpool.hxx>
+
+namespace vcl
+{
+class VCL_DLLPUBLIC BitmapComboScaleFilter : public BitmapFilter
+{
+private:
+    double mrScaleX;
+    double mrScaleY;
+
+    std::shared_ptr<comphelper::ThreadTaskTag> mpThreadPoolTag;
+
+    enum class ScaleType
+    {
+        NONE,
+        HALF,
+        HALF_HORIZONTAL,
+        HALF_VERTICAL,
+        QUARTER,
+        QUARTER_HORIZONTAL,
+        QUARTER_VERTICAL,
+        OCTAL,
+    };
+
+    bool fastPrescale(Bitmap& rBitmap);
+    bool scale(ScaleType type, Bitmap& rBitmap);
+
+public:
+    BitmapComboScaleFilter(const double& rScaleX, const double& rScaleY);
+    ~BitmapComboScaleFilter() override;
+
+    BitmapEx execute(BitmapEx const& rBitmap) const override;
+};
+}
+
+#endif // INCLUDED_VCL_BITMAPSCALESUPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/ScanlineHalfScaler.hxx 
b/vcl/inc/bitmap/ScanlineHalfScaler.hxx
new file mode 100644
index 000000000000..b935b3297f56
--- /dev/null
+++ b/vcl/inc/bitmap/ScanlineHalfScaler.hxx
@@ -0,0 +1,90 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_BITMAP_SCANLINEHALFSCALER_HXX
+#define INCLUDED_VCL_INC_BITMAP_SCANLINEHALFSCALER_HXX
+
+#include <bitmap/BitmapWriteAccess.hxx>
+
+#if defined(_MSC_VER)
+#define VCL_FORCEINLINE __forceinline
+#elif defined(__GNUC__)
+#define VCL_FORCEINLINE __attribute__((always_inline)) inline
+#else
+#define VCL_FORCEINLINE inline
+#endif
+
+namespace vcl
+{
+struct VCL_DLLPUBLIC ScaleContext
+{
+    BitmapReadAccess const* const mpSource;
+    BitmapWriteAccess* mpTarget;
+    long mnSourceW;
+    long mnSourceH;
+    long mnTargetW;
+    long mnTargetH;
+    bool mbHMirr;
+    bool mbVMirr;
+
+    VCL_FORCEINLINE Scanline getSourceScanline(long y) { return 
mpSource->GetScanline(y); }
+
+    VCL_FORCEINLINE Scanline getTargetScanline(long y) { return 
mpTarget->GetScanline(y); }
+
+    VCL_FORCEINLINE BitmapColor getSourcePixel(Scanline const& pScanline, long 
x)
+    {
+        return mpSource->GetPixelFromData(pScanline, x);
+    }
+
+    VCL_FORCEINLINE void setTargetPixel(Scanline const& pScanline, long x, 
BitmapColor& rColor)
+    {
+        return mpTarget->SetPixelOnData(pScanline, x, rColor);
+    }
+
+    ScaleContext(BitmapReadAccess* pSource, BitmapWriteAccess* pTarget, long 
nSourceW,
+                 long nTargetW, long nSourceH, long nTargetH, bool bHMirr, 
bool bVMirr)
+        : mpSource(pSource)
+        , mpTarget(pTarget)
+        , mnSourceW(nSourceW)
+        , mnSourceH(nSourceH)
+        , mnTargetW(nTargetW)
+        , mnTargetH(nTargetH)
+        , mbHMirr(bHMirr)
+        , mbVMirr(bVMirr)
+    {
+    }
+};
+
+void scaleHalfGeneralHorizontal(ScaleContext& rContext, long nStartY, long 
nEndY);
+void scaleHalfGeneralVertical(ScaleContext& rContext, long nStartY, long 
nEndY);
+void scaleHalfGeneral(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleQuarterGeneral(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleQuarterGeneralHorizontal(ScaleContext& rContext, long nStartY, long 
nEndY);
+void scaleQuarterGeneralVertical(ScaleContext& rContext, long nStartY, long 
nEndY);
+void scaleOctalGeneral(ScaleContext& rContext, long nStartY, long nEndY);
+
+void scaleOctal32(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleQuarter32_1(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleQuarter32_2(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleQuarter32_SSE(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleHalf32_SSE2(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleHalf32_2(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleHalf32_1(ScaleContext& rContext, long nStartY, long nEndY);
+
+void scaleHalf24(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleHalf32(ScaleContext& rContext, long nStartY, long nEndY);
+
+void scaleOctal24(ScaleContext& rContext, long nStartY, long nEndY);
+void scaleQuarter24(ScaleContext& rContext, long nStartY, long nEndY);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapComboScaleFilter.cxx 
b/vcl/source/bitmap/BitmapComboScaleFilter.cxx
new file mode 100644
index 000000000000..c952b5702338
--- /dev/null
+++ b/vcl/source/bitmap/BitmapComboScaleFilter.cxx
@@ -0,0 +1,370 @@
+/* -*- 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

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to