[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 775 commits - accessibility/inc accessibility/source avmedia/source basctl/inc basctl/source basegfx/CppunitTest_basegfx.mk basegfx/test basic/inc basic/qa basic/source bean/BUCK binaryurp/source bin/merge-app-bundles bridges/source BUCK canvas/inc canvas/Library_vclcanvas.mk canvas/source chart2/inc chart2/qa chart2/source chart2/workbench codemaker/source comphelper/inc comphelper/qa comphelper/source compilerplugins/clang config_host/config_oauth2.h.in config_host.mk.in configmgr/inc configmgr/source configure.ac connectivity/Configuration_mork.mk connectivity/CppunitTest_connectivity_mork.mk connectivity/Executable_mork_helper.mk connectivity/inc connectivity/IwyuFilter_connectivity.yaml connectivity/Library_mork.mk connectivity/Library_mozbootstrap.mk connectivity/Module_connectivity.mk connectivity/qa connectivity/registry connectivity/source cppcanvas/inc cppuhelper/inc cppu/source cpputools/source cui/inc cui/source cui/ uiconfig dbaccess/inc dbaccess/qa dbaccess/source desktop/inc desktop/qa desktop/source desktop/win32 dictionaries download.lst drawinglayer/inc drawinglayer/source editeng/inc editeng/qa editeng/source editeng/uiconfig embeddedobj/source emfio/inc emfio/qa emfio/source extensions/source external/firebird external/gpgmepp external/libcmis external/mariadb-connector-c external/nss external/python3 external/redland external/skia extras/source filter/source forms/inc forms/source formula/source fpicker/source framework/inc framework/source hardened_runtime.xcent.in helpcompiler/source helpcontent2 hwpfilter/inc i18nlangtag/qa i18nlangtag/source i18npool/CustomTarget_breakiterator.mk i18npool/inc i18npool/qa i18npool/source icon-themes/colibre icon-themes/colibre_svg icon-themes/elementary icon-themes/elementary_svg idlc/inc idlc/source idl/inc idl/source include/avmedia include/basegfx include/codemaker include/comphelper include/connectivity include/drawinglayer include/editeng includ e/formula include/framework include/helpcompiler include/i18nlangtag include/LibreOfficeKit include/linguistic include/o3tl include/oox include/rtl include/sal include/sax include/sfx2 include/sot include/svl include/svtools include/svx include/test include/tools include/unotools include/vcl include/xmloff javaunohelper/BUCK jurt/BUCK jvmfwk/inc jvmfwk/plugins jvmfwk/source l10ntools/source libreofficekit/qa lingucomponent/source linguistic/source lotuswordpro/inc lotuswordpro/source m4/README Makefile.fetch odk/CustomTarget_check.mk odk/CustomTarget_unowinreg.mk odk/examples odk/Library_unowinreg.mk odk/Module_odk.mk odk/Package_unowinreg.mk odk/settings odk/source offapi/com offapi/UnoApi_offapi.mk officecfg/registry onlineupdate/source oox/inc oox/qa oox/source opencl/source osx/soffice.xcodeproj package/inc package/source postprocess/CustomTarget_registry.mk postprocess/qa postprocess/Rdb_services.mk pyuno/source readlicense_oo/license registry/source reportdesign/inc reportdesi gn/source RepositoryExternal.mk Repository.mk ridljar/BUCK ridljar/source sal/cppunittester sal/osl sal/qa sal/rtl sax/qa sax/source scaddins/IwyuFilter_scaddins.yaml scaddins/source sccomp/IwyuFilter_sccomp.yaml sc/inc sc/IwyuFilter_sc.yaml sc/qa scripting/source sc/sdi sc/source sc/uiconfig sdext/inc sdext/source sd/inc sd/IwyuFilter_sd.yaml sd/Library_sd.mk sd/qa sd/source sd/uiconfig sfx2/inc sfx2/IwyuFilter_sfx2.yaml sfx2/Library_sfx.mk sfx2/sdi sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk shell/inc shell/source slideshow/inc slideshow/IwyuFilter_slideshow.yaml slideshow/source solenv/bin solenv/buck solenv/clang-format solenv/flatpak-manifest.in solenv/gbuild solenv/maven solenv/sanitizers sot/inc sot/source starmath/inc starmath/IwyuFilter_starmath.yaml starmath/Library_sm.mk starmath/qa starmath/source stoc/IwyuFilter_stoc.yaml stoc/source svgio/inc svgio/source svl/inc svl/IwyuFilter_svl.yaml svl/source svtools/inc svtools/IwyuFilter_svtools.yaml svtools/Library_svt.mk sv tools/qa svtools/source svtools/uiconfig svtools/UIConfig_svt.mk svx/inc svx/IwyuFilter_svx.yaml svx/Library_svx.mk svx/Module_svx.mk svx/qa svx/source svx/uiconfig svx/UITest_svx_table.mk svx/util sw/CppunitTest_sw_ooxmlexport16.mk sw/inc sw/IwyuFilter_sw.yaml sw/Module_sw.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk test/source testtools/source toolkit/inc toolkit/source tools/inc tools/qa tools/source translations ucbhelper/source ucb/source UnoControls/source unodevtools/source unoidl/source unotest/source unotools/inc unotools/source unoxml/inc unoxml/source uui/inc uui/source vbahelper/inc vbahelper/source vcl/backendtest vcl/Executable_benchmark.mk vcl/headless vcl/inc vcl/jsdialog vcl/Library_vcl.mk vcl/Library_vclplug_gen.mk vcl/Library_vclplug_win.mk vcl/Module_vcl.mk vcl/opengl vcl/osx vcl/Package_opengl_denylist.mk vcl/Package_opengl_shader.mk vcl/Package_tipoftheday.mk vcl/qa vcl/qt5 vcl/quartz vcl/README.scheduler vcl/README.vars vcl/skia vcl/source vcl /unx vcl/win vcl/workben .vscode/vs-code-template.code-workspace.in winaccessibility/source wizards/Package_sfdialogs.mk wizards/source writerfilter/inc writerfilter/qa writerfilter/source writerperfect/qa writerperfect/source xmlhelp/source xmloff/inc xmloff/source xmlscript/source xmlsecurity/inc xmlsecurity/qa xmlsecurity/source xmlsecurity/workben

Mon, 28 Dec 2020 18:23:17 -0800

Rebased ref, commits from common ancestor:
commit e0701dc8b19c49522ece6bade94228f020e5384c
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: Wed Dec 16 15:50:57 2020 +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 231854cdf057..2922934bc6be 100644
--- a/basegfx/CppunitTest_basegfx.mk
+++ b/basegfx/CppunitTest_basegfx.mk
@@ -41,6 +41,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..a6afb154afc0
--- /dev/null
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -0,0 +1,89 @@
+/* -*- 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._cm(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04, cm._m(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(40.0, cm._mm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(1440000), cm.value());
+
+    gfx::LengthUnit cm2 = 5_cm * 2;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), cm2.value());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, cm2._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.value());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3._cm(), 1e-4);
+
+    // (635 * 20) + 3 * (635 * 15) = 41275EMU
+    gfx::LengthUnit pt = 1_pt + 3_px;
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(3.25, pt._pt(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, pt._twip(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0451, pt._in(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(41275), pt.value());
+
+    gfx::LengthUnit inch = 1_in; // 1440 * 635
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1440.0, inch._twip(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, inch._px(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, inch._in(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(914400), inch.value());
+
+    // Conversion
+    sal_Int64 asNumber(17_pt);
+    asNumber += sal_Int64(1_pt);
+    gfx::LengthUnit asLength(asNumber);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(18 * 635 * 20), asLength.value());
+
+    gfx::LengthUnit maximum(SAL_MAX_INT64);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(256204778801.5, maximum._m(), 1e-1);
+    // 256204778 km
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MAX_INT64), maximum.value());
+
+    gfx::LengthUnit minimum(SAL_MIN_INT64);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(-256204778801.5, minimum._m(), 1e-1);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MIN_INT64), minimum.value());
+
+    // 27 emu + 33 emu + 360 emu = 420
+    gfx::LengthUnit emus = 27_emu + 33_emu + 1_hmm;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(420), emus.value());
+
+    //  Creation from number
+    int number = 10;
+    auto asCm = gfx::LengthUnit::cm(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asCm._cm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), asCm.value());
+
+    auto asMm = gfx::LengthUnit::mm(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asMm._mm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(360000), asMm.value());
+
+    auto asInch = gfx::LengthUnit::in(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asInch._in(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(9144000), asInch.value());
+}
+
+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..ff85e05de9fb
--- /dev/null
+++ b/include/basegfx/units/LengthUnit.hxx
@@ -0,0 +1,187 @@
+/* -*- 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
+{
+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;
+
+template <typename T> class LengthUnitBase
+{
+private:
+    // value in EMU units
+    T m_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);
+    }
+
+    constexpr explicit LengthUnitBase()
+        : m_nValue(0)
+    {
+    }
+
+    constexpr explicit LengthUnitBase(T nValue)
+        : m_nValue(nValue)
+    {
+    }
+
+    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 value() const { return m_nValue; }
+
+    double _hmm() const { return m_nValue / double(constFactor_hmm_to_EMU); }
+    double _mm() const { return m_nValue / double(constFactor_mm_to_EMU); }
+    double _cm() const { return m_nValue / double(constFactor_cm_to_EMU); }
+    double _m() const { return m_nValue / double(constFactor_m_to_EMU); }
+    double _twip() const { return m_nValue / double(constFactor_twip_to_EMU); }
+    double _in() const { return m_nValue / double(constFactor_in_to_EMU); }
+    double _pt() const { return m_nValue / double(constFactor_pt_to_EMU); }
+    double _px() const { return m_nValue / double(constFactor_px_to_EMU); }
+};
+
+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(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 c5970079e58edfb7e8121acd8acdd4e5d46c0852
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: Wed Dec 16 15:50:57 2020 +0900

    Command Popup
    
    Change-Id: I92cdd3130b8de42ee0863c9e7154e7c7246d9377

diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 2fd69fd3e1e2..c036e221d4a3 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -382,7 +382,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 d3d7c38e0789..ce05cc891c6a 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="SPACE_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 64952eb92710..54f4f1de02f4 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6531,6 +6531,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>
     <node oor:name="Popups">
       <node oor:name=".uno:PasteSpecialMenu" oor:op="replace">
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 4673541ec989..8e660abf2a85 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -287,6 +287,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 635b77324998..b3e6dbf5282f 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/decktitlebar \
        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 40bf3e93b424..1648c73711b7 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..0bbe8adba5b2
--- /dev/null
+++ b/sfx2/source/view/CommandPopup.cxx
@@ -0,0 +1,220 @@
+/* -*- 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 <vcl/layout.hxx>
+#include <vcl/fixed.hxx>
+#include <workwin.hxx>
+#include <sfx2/msgpool.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/dispatchcommand.hxx>
+
+#include <com/sun/star/frame/XDispatchInformationProvider.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 <vcl/commandinfoprovider.hxx>
+
+using namespace css;
+
+CommandListBox::CommandListBox(vcl::Window* pParent, CommandPopup& rPopUp,
+                               uno::Reference<frame::XFrame> xFrame)
+    : InterimItemWindow(pParent, "sfx/ui/commandpopup.ui", "CommandBox")
+    , m_rPopUp(rPopUp)
+    , m_xFrame(xFrame)
+    , m_pEntry(m_xBuilder->weld_entry("entry"))
+    , m_pListBox(m_xBuilder->weld_tree_view("listBox"))
+{
+    m_pEntry->connect_changed(LINK(this, CommandListBox, ModifyHdl));
+}
+
+void CommandListBox::recurse(uno::Reference<container::XIndexAccess> 
xIndexAccess,
+                             MenuContent& rMenuContent)
+{
+    for (sal_Int32 n = 0; n < xIndexAccess->getCount(); n++)
+    {
+        MenuContent aNewContent;
+        OUString aModuleIdentifier;
+        uno::Sequence<beans::PropertyValue> aProperty;
+        uno::Reference<container::XIndexAccess> xIndexContainer;
+        try
+        {
+            if (xIndexAccess->getByIndex(n) >>= aProperty)
+            {
+                bool bShow = true;
+                bool bEnabled = true;
+
+                for (int i = 0; i < aProperty.getLength(); i++)
+                {
+                    OUString aPropName = aProperty[i].Name;
+                    if (aPropName == "CommandURL")
+                        aProperty[i].Value >>= aNewContent.m_aCommandURL;
+                    else if (aPropName == "ItemDescriptorContainer")
+                        aProperty[i].Value >>= xIndexContainer;
+                    else if (aPropName == "ModuleIdentifier")
+                        aProperty[i].Value >>= aModuleIdentifier;
+                    else if (aPropName == "IsVisible")
+                        aProperty[i].Value >>= bShow;
+                    else if (aPropName == "Enabled")
+                        aProperty[i].Value >>= bEnabled;
+                }
+
+                OUString 
aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
+                auto aProperties = 
vcl::CommandInfoProvider::GetCommandProperties(
+                    aNewContent.m_aCommandURL, aModuleName);
+                aNewContent.m_aMenuLabel
+                    = 
vcl::CommandInfoProvider::GetMenuLabelForCommand(aProperties)
+                          .replaceAll("~", "");
+                aNewContent.m_aLabel = rMenuContent.m_aLabel + " -> " + 
aNewContent.m_aMenuLabel;
+                //OUString 
aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(aNewContent.m_aCommandURL,
 aProperties, m_xFrame));
+                if (xIndexContainer.is())
+                    recurse(xIndexContainer, aNewContent);
+
+                rMenuContent.m_aSubMenuContent.push_back(aNewContent);
+            }
+        }
+        catch (const lang::IndexOutOfBoundsException&)
+        {
+            return;
+        }
+    }
+}
+
+void CommandListBox::initialize()
+{
+    m_xGlobalCategoryInfo
+        = 
ui::theUICategoryDescription::get(comphelper::getProcessComponentContext());
+    m_sModuleLongName = 
vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame);
+    
m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName),
+                              uno::UNO_QUERY_THROW);
+    m_xUICmdDescription
+        = 
frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
+
+    uno::Reference<ui::XModuleUIConfigurationManagerSupplier> 
xModuleCfgSupplier
+        = ui::theModuleUIConfigurationManagerSupplier::get(
+            comphelper::getProcessComponentContext());
+
+    uno::Reference<ui::XUIConfigurationManager> xCfgMgr
+        = xModuleCfgSupplier->getUIConfigurationManager(m_sModuleLongName);
+    uno::Reference<container::XIndexAccess> xConfigData
+        = xCfgMgr->getSettings("private:resource/menubar/menubar", false);
+
+    recurse(xConfigData, m_aMenuContent);
+
+    Size aSize(400, 400);
+    SetSizePixel(aSize);
+    m_rPopUp.SetOutputSizePixel(aSize);
+    m_rPopUp.StartPopupMode(tools::Rectangle(Point(10, 10), aSize),
+                            FloatWinPopupFlags::Down | 
FloatWinPopupFlags::GrabFocus
+                                | FloatWinPopupFlags::AllMouseButtonClose
+                                | FloatWinPopupFlags::NoMouseUpClose);
+
+    Show();
+
+    GrabFocus();
+    m_pEntry->grab_focus();
+}
+
+void CommandListBox::dispose()
+{
+    m_pEntry.reset();
+    m_pListBox.reset();
+    InterimItemWindow::dispose();
+}
+
+IMPL_LINK_NOARG(CommandListBox, ModifyHdl, weld::Entry&, void)
+{
+    m_pListBox->clear();
+
+    OUString sText = m_pEntry->get_text();
+    if (sText.isEmpty())
+        return;
+
+    m_aCommandList.clear();
+
+    m_pListBox->freeze();
+    findInMenu(m_aMenuContent, sText.toAsciiLowerCase());
+    m_pListBox->thaw();
+
+    if (m_pListBox->n_children() > 0)
+    {
+        m_pListBox->set_cursor(0);
+        m_pListBox->select(0);
+    }
+
+    m_pEntry->grab_focus();
+}
+
+void CommandListBox::findInMenu(MenuContent& aMenuContent, OUString const& 
rText)
+{
+    for (MenuContent& aSubContent : aMenuContent.m_aSubMenuContent)
+    {
+        if (aSubContent.m_aMenuLabel.toAsciiLowerCase().startsWith(rText))
+        {
+            OUString sCommandURL = aSubContent.m_aCommandURL;
+            //Image aImage = 
vcl::CommandInfoProvider::GetImageForCommand(sCommandURL, m_xFrame);
+            m_pListBox->append_text(aSubContent.m_aLabel);
+            m_aCommandList.push_back(sCommandURL);
+        }
+        findInMenu(aSubContent, rText);
+    }
+}
+
+bool CommandListBox::EventNotify(NotifyEvent& rNotifyEvent)
+{
+    const KeyEvent* pKeyEvent = rNotifyEvent.GetKeyEvent();
+
+    if (pKeyEvent)
+    {
+        if (pKeyEvent->GetKeyCode().GetCode() == KEY_DOWN
+            || pKeyEvent->GetKeyCode().GetCode() == KEY_UP)
+        {
+            m_pListBox->grab_focus();
+        }
+        else if (pKeyEvent->GetKeyCode().GetCode() == KEY_RETURN)
+        {
+            size_t nSelected = m_pListBox->get_selected_index();
+            if (nSelected < m_aCommandList.size())
+            {
+                OUString sCommand = m_aCommandList[nSelected];
+                dispatchCommandAndClose(sCommand);
+            }
+        }
+        else
+        {
+            m_pEntry->grab_focus();
+        }
+    }
+
+    return InterimItemWindow::EventNotify(rNotifyEvent);
+}
+
+void CommandListBox::dispatchCommandAndClose(OUString const& rCommand)
+{
+    m_rPopUp.EndPopupMode(FloatWinPopupEndFlags::CloseAll);
+    comphelper::dispatchCommand(rCommand, 
uno::Sequence<beans::PropertyValue>());
+}
+
+CommandPopup::CommandPopup(vcl::Window* pParent)
+    : FloatingWindow(pParent, WB_BORDER | WB_SYSTEMWINDOW)
+{
+}
+
+CommandPopup::~CommandPopup() { disposeOnce(); }
+
+void CommandPopup::dispose() { FloatingWindow::dispose(); }
+
+/* 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..a3469c04cf6d
--- /dev/null
+++ b/sfx2/source/view/CommandPopup.hxx
@@ -0,0 +1,80 @@
+/* -*- 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/floatwin.hxx>
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <vcl/InterimItemWindow.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/window.hxx>
+
+struct MenuContent
+{
+    OUString m_aCommandURL;
+    OUString m_aLabel;
+    OUString m_aMenuLabel;
+    std::vector<MenuContent> m_aSubMenuContent;
+};
+
+class SFX2_DLLPUBLIC CommandPopup : public FloatingWindow
+{
+public:
+    explicit CommandPopup(vcl::Window* pWorkWindow);
+
+    ~CommandPopup() override;
+
+    void dispose() override;
+};
+
+class SFX2_DLLPUBLIC CommandListBox final : public InterimItemWindow
+{
+private:
+    CommandPopup& m_rPopUp;
+
+    std::vector<OUString> m_aCommandList;
+    css::uno::Reference<css::frame::XFrame> m_xFrame;
+    css::uno::Reference<css::container::XNameAccess> m_xGlobalCategoryInfo;
+    css::uno::Reference<css::container::XNameAccess> m_xModuleCategoryInfo;
+    css::uno::Reference<css::container::XNameAccess> m_xUICmdDescription;
+    OUString m_sModuleLongName;
+
+    MenuContent m_aMenuContent;
+    OUString m_PreviousText;
+
+    std::unique_ptr<weld::Entry> m_pEntry;
+    std::unique_ptr<weld::TreeView> m_pListBox;
+
+    DECL_LINK(ModifyHdl, weld::Entry&, void);
+
+    void recurse(css::uno::Reference<css::container::XIndexAccess> 
xIndexAccess,
+                 MenuContent& rMenuContent);
+    void findInMenu(MenuContent& aMenuContent, OUString const& rText);
+
+    void dispatchCommandAndClose(OUString const& rCommand);
+    bool EventNotify(NotifyEvent& rNotifyEvent) override;
+
+public:
+    CommandListBox(vcl::Window* pParent, CommandPopup& rPopUp,
+                   css::uno::Reference<css::frame::XFrame> xFrame);
+
+    void initialize();
+
+    void dispose() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 70894ffc5439..81b9790849bc 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>
@@ -90,6 +91,7 @@
 
 #include <unotools/configmgr.hxx>
 #include <comphelper/sequenceashashmap.hxx>
+#include "CommandPopup.hxx"
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -2914,8 +2916,26 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
             rReq.Done();
             break;
         }
+        case SID_COMMAND_POPUP:
+        {
+            static VclPtr<CommandPopup> spCommandPopup;
+            static VclPtr<CommandListBox> spCommandListBox;
+
+            if (spCommandListBox)
+                spCommandListBox.disposeAndClear();
+
+            if (spCommandPopup)
+                spCommandPopup.disposeAndClear();
+
+            css::uno::Reference<css::frame::XFrame> 
xFrame(GetFrame().GetFrameInterface(), css::uno::UNO_QUERY);
+            spCommandPopup.reset(VclPtr<CommandPopup>::Create(&GetWindow()));
 
-        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+            
spCommandListBox.reset(VclPtr<CommandListBox>::Create(spCommandPopup.get(), 
*spCommandPopup.get(), xFrame));
+            spCommandListBox->initialize();
+
+            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..c6e035b9d7bf
--- /dev/null
+++ b/sfx2/uiconfig/ui/commandpopup.ui
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.36.0 -->
+<interface domain="sfx">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkBox" id="CommandBox">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkEntry" id="entry">
+        <property name="visible">True</property>
+        <property name="can_focus">True</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="height_request">400</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="shadow_type">in</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkTreeView" id="listBox">
+                <property name="visible">True</property>
+                <property name="can_focus">True</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="activate_on_single_click">True</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection"/>
+                </child>
+                <child>
+                  <object class="GtkTreeViewColumn" id="column">
+                    <child>
+                      <object class="GtkCellRendererText" 
id="cellrenderertext"/>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </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>
+</interface>
commit 1981cd4a340f16582320f6dcaf24456ccefcda90
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: Wed Dec 16 15:50:56 2020 +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 a1b820b93585..2d1d89825cf6 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -582,6 +582,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 59a5ec07e7d2..80b6dff5b771 100644
--- a/cui/uiconfig/ui/optviewpage.ui
+++ b/cui/uiconfig/ui/optviewpage.ui
@@ -508,6 +508,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 e5534bb7aa0b2abf2d9e8e7f4ec10e40d610c0ae
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: Wed Dec 16 15:50:56 2020 +0900

    Benchmark
    
    Change-Id: I22e0ac54380e2d22606e7b1fd453bed843523a29

diff --git a/Repository.mk b/Repository.mk
index 5311a5d1b84b..be08f888c3ca 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 8bfc67c1e2ef..b623f242dbcc 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..dc9edc9601bf
--- /dev/null
+++ b/vcl/backendtest/Benchmark.cxx
@@ -0,0 +1,301 @@
+/* -*- 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 <vcl/bitmapaccess.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;
+                //benchBitmapScale2(aTotalTimes[a].first, 
aTotalTimes[a].second); a++;
+                //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++;
+
+                /*benchBitmap2(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 benchBitmapScale2(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "2 Scale";
+        Bitmap aBitmap(maSource, 2, &Bitmap::GetGreyPalette(2));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale4(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "4 Scale";
+        Bitmap aBitmap(maSource, 4, &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, 8);
+        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, 8, &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, 24);
+        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, 24);
+        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, 32);
+        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, 32);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Combo);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap2(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "2";
+        mpVDev->Erase();
+
+        Bitmap aBitmap(Size(4000, 4000), 2, &Bitmap::GetGreyPalette(2));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap4(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "4";
+        mpVDev->Erase();
+
+        Bitmap aBitmap(Size(4000, 4000), 4, &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), 8);
+        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), 8, &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), 24);
+        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), 32);
+        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 9a22bc80481791b1251cbad5d63f2ba15f050684
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: Wed Dec 16 15:50:55 2020 +0900

    Update BitmapSymmetryCheck check
    
    Change-Id: I5b0080ebc76f7c1cd118cf5317b06ffe1a1c20df

diff --git a/vcl/inc/BitmapSymmetryCheck.hxx b/vcl/inc/BitmapSymmetryCheck.hxx
index 0c7d4444c774..2ef66dc3f806 100644
--- a/vcl/inc/BitmapSymmetryCheck.hxx
+++ b/vcl/inc/BitmapSymmetryCheck.hxx
@@ -12,18 +12,24 @@
 #define INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
 
 #include <vcl/bitmap.hxx>
+#include <vcl/bitmapex.hxx>
 #include <vcl/bitmapaccess.hxx>
+#include <bitmapwriteaccess.hxx>
 
 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);
+    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 1f9e14d2ef94..622aa6d07cf6 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 7de2f7d8678d..2fd4b7e63fac 100644
--- a/vcl/qa/cppunit/BitmapScaleTest.cxx
+++ b/vcl/qa/cppunit/BitmapScaleTest.cxx
@@ -19,19 +19,82 @@
 
 #include <BitmapSymmetryCheck.hxx>
 #include <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(sal_uInt16 nBitCount)
+    {
+        long w = 10;
+        long h = 10;
+        Bitmap aBitmap(Size(w, h), nBitCount);
+        {
+            BitmapScopedWriteAccess aWriteAccess(aBitmap);
+            aWriteAccess->Erase(nBitCount == 32 ? 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(sal_uInt16 nBitCount)
+    {
+        long w = 20;
+        long h = 20;
+        Bitmap aBitmap(Size(w, h), nBitCount);
+        {
+            BitmapScopedWriteAccess aWriteAccess(aBitmap);
+            aWriteAccess->Erase(nBitCount == 32 ? 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();
 };
 
@@ -270,51 +333,63 @@ void BitmapScaleTest::testScale2()
     CPPUNIT_ASSERT(checkBitmapColor(aScaledBitmap, aBitmapColor));
 }
 
-void BitmapScaleTest::testScaleSymmetry()
+void BitmapScaleTest::testScaleSymmetryUp24()
 {
-    const bool bExportBitmap(false);
+    Bitmap aBitmap = createUpscaleTestImage(24);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmap.GetBitCount());
+    exportImage("~/scale_up_24_before.png", aBitmap);
 
-    Bitmap aBitmap24Bit(Size(10, 10), 24);
-    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(24);
+    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>(10), 
aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
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 ce5235132e80..686394d01b1f 100644
--- a/vcl/source/bitmap/BitmapSymmetryCheck.cxx
+++ b/vcl/source/bitmap/BitmapSymmetryCheck.cxx
@@ -10,12 +10,6 @@
 
 #include <BitmapSymmetryCheck.hxx>
 
-BitmapSymmetryCheck::BitmapSymmetryCheck()
-{}
-
-BitmapSymmetryCheck::~BitmapSymmetryCheck()
-{}
-
 bool BitmapSymmetryCheck::check(Bitmap& rBitmap)
 {
     Bitmap::ScopedReadAccess aReadAccess(rBitmap);
@@ -24,9 +18,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;
 
@@ -35,22 +33,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));
         }
     }
 
@@ -58,10 +55,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));
         }
     }
 
@@ -70,14 +66,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, 24);
+    {
+        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 66c062f12912792b36ced2653c2953debe164a3f
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: Wed Dec 16 15:50:55 2020 +0900

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

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 810ece4e5286..50fced8548fa 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -58,7 +58,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 ff8c4182af2f..7849dd663b61 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -367,6 +367,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 \
@@ -375,6 +376,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..2291944a337e
--- /dev/null
+++ b/vcl/inc/bitmap/ScanlineHalfScaler.hxx
@@ -0,0 +1,91 @@
+/* -*- 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 <vcl/bitmapaccess.hxx>
+#include <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..338ee75f45d2
--- /dev/null
+++ b/vcl/source/bitmap/BitmapComboScaleFilter.cxx
@@ -0,0 +1,367 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <BitmapComboScaleFilter.hxx>
+
+#include <vcl/bitmapaccess.hxx>
+#include <bitmapwriteaccess.hxx>
+#include <BitmapScaleSuperFilter.hxx>
+
+#include <tools/helpers.hxx>
+#include <algorithm>
+#include <memory>
+#include <sal/log.hxx>
+#include <tools/ScopedNanoTimer.hxx>
+#include <tools/cpuid.hxx>
+
+#include <bitmap/ScanlineHalfScaler.hxx>
+
+namespace vcl
+{
+namespace
+{
+constexpr long constScaleThreadStrip = 4;
+
+constexpr bool ALLOW_HORIZONTAL_VERTICAL = false;
+
+typedef void (*ScaleRangeFn)(ScaleContext& rContext, long nStartY, long nEndY);
+
+class ScaleTask : public comphelper::ThreadTask
+{
+    ScaleRangeFn const mpScaleRangeFunction;
+    ScaleContext& mrContext;
+    const long mnStartY;
+    const long mnEndY;
+
+public:
+    explicit ScaleTask(const std::shared_ptr<comphelper::ThreadTaskTag>& pTag,
+                       ScaleRangeFn pScaleRangeFunction, ScaleContext& 
rContext, long nStartY,
+                       long nEndY)
+        : comphelper::ThreadTask(pTag)
+        , mpScaleRangeFunction(pScaleRangeFunction)
+        , mrContext(rContext)
+        , mnStartY(nStartY)
+        , mnEndY(nEndY)
+    {
+    }
+
+    virtual void doWork() override { mpScaleRangeFunction(mrContext, mnStartY, 
mnEndY); }
+};
+
+} // anonymous namespace
+
+BitmapComboScaleFilter::BitmapComboScaleFilter(const double& rScaleX, const 
double& rScaleY)
+    : mrScaleX(rScaleX)
+    , mrScaleY(rScaleY)
+    , mpThreadPoolTag(comphelper::ThreadPool::createThreadTaskTag())
+{
+}
+
+BitmapComboScaleFilter::~BitmapComboScaleFilter() {}
+
+bool BitmapComboScaleFilter::scale(ScaleType eType, Bitmap& rBitmap)
+{
+    if (eType == ScaleType::NONE)
+        return false;
+
+    bool bResult = false;
+
+    const Size aSizePix(rBitmap.GetSizePixel());
+
+    bool bMirrorHorizontal = mrScaleX < 0;
+    bool bMirrorVertical = mrScaleY < 0;
+
+    double nScaleX = 0.0;
+    double nScaleY = 0.0;
+
+    switch (eType)
+    {
+        case ScaleType::OCTAL:
+            nScaleX = 0.125;
+            nScaleY = 0.125;
+            break;
+        case ScaleType::QUARTER:
+            nScaleX = 0.25;
+            nScaleY = 0.25;
+            break;
+        case ScaleType::QUARTER_HORIZONTAL:
+            nScaleX = 0.25;
+            nScaleY = 1.0;
+            break;
+        case ScaleType::QUARTER_VERTICAL:
+            nScaleX = 1.0;
+            nScaleY = 0.25;
+            break;
+        case ScaleType::HALF:
+            nScaleX = 0.5;
+            nScaleY = 0.5;
+            break;
+        case ScaleType::HALF_HORIZONTAL:
+            nScaleX = 0.5;
+            nScaleY = 1.0;
+            break;
+        case ScaleType::HALF_VERTICAL:
+            nScaleX = 1.0;
+            nScaleY = 0.5;
+            break;
+        case ScaleType::NONE:
+            break;
+    }
+
+    const Size aDestinationSize(std::lround(aSizePix.Width() * nScaleX),
+                                std::lround(aSizePix.Height() * nScaleY));
+
+    if (aDestinationSize.Width() == aSizePix.Width()
+        && aDestinationSize.Height() == aSizePix.Height())
+    {
+        return true;
+    }
+
+    if (aDestinationSize.Width() <= 1L || aDestinationSize.Height() <= 1L)
+    {
+        return false;
+    }
+
+    sal_uInt16 nSourceBitcount = rBitmap.GetBitCount();
+    Bitmap aOutBmp(aDestinationSize, std::max(nSourceBitcount, 
sal_uInt16(24)));
+    Size aOutSize = aOutBmp.GetSizePixel();
+
+    const long nStartY = 0;
+    const long nEndY = aDestinationSize.Height() - 1;
+
+    if (!aOutSize.Width() || !aOutSize.Height())
+    {
+        SAL_WARN("vcl.gdi", "bmp creation failed");
+        return false;
+    }
+
+    {
+        Bitmap::ScopedReadAccess pReadAccess(rBitmap);
+        BitmapScopedWriteAccess pWriteAccess(aOutBmp);
+
+        if (pReadAccess && pWriteAccess)
+        {
+            ScaleRangeFn pScaleRangeFn;
+            ScaleContext aContext(pReadAccess.get(), pWriteAccess.get(), 
pReadAccess->Width(),
+                                  pWriteAccess->Width(), pReadAccess->Height(),
+                                  pWriteAccess->Height(), bMirrorVertical, 
bMirrorHorizontal);
+
+            switch (eType)
+            {
+                case ScaleType::OCTAL:
+                {
+                    switch (pReadAccess->GetScanlineFormat())
+                    {
+                        case ScanlineFormat::N24BitTcBgr:
+                        case ScanlineFormat::N24BitTcRgb:
+                            pScaleRangeFn = scaleOctal24;
+                            break;
+                        case ScanlineFormat::N32BitTcRgba:
+                        case ScanlineFormat::N32BitTcBgra:
+                        case ScanlineFormat::N32BitTcArgb:
+                        case ScanlineFormat::N32BitTcAbgr:
+                            pScaleRangeFn = scaleOctal32;
+                            break;
+                        default:
+                            pScaleRangeFn = scaleOctalGeneral;
+                            break;
+                    }
+
+                    break;
+                }
+                case ScaleType::QUARTER:
+                    switch (pReadAccess->GetScanlineFormat())
+                    {
+                        case ScanlineFormat::N24BitTcBgr:
+                        case ScanlineFormat::N24BitTcRgb:
+                            pScaleRangeFn = scaleQuarter24;
+                            break;
+                        case ScanlineFormat::N32BitTcRgba:
+                        case ScanlineFormat::N32BitTcBgra:
+                        case ScanlineFormat::N32BitTcArgb:
+                        case ScanlineFormat::N32BitTcAbgr:
+                            pScaleRangeFn = scaleQuarter32_SSE;
+                            break;
+                        default:
+                            pScaleRangeFn = scaleQuarterGeneral;
+                            break;
+                    }
+
+                    break;
+                case ScaleType::QUARTER_HORIZONTAL:
+                    pScaleRangeFn = scaleQuarterGeneralHorizontal;
+                    break;
+                case ScaleType::QUARTER_VERTICAL:
+                    pScaleRangeFn = scaleQuarterGeneralVertical;
+                    break;
+                case ScaleType::HALF:
+                    switch (pReadAccess->GetScanlineFormat())
+                    {
+                        case ScanlineFormat::N24BitTcBgr:
+                        case ScanlineFormat::N24BitTcRgb:
+                            pScaleRangeFn = scaleHalf24;
+                            break;
+                        case ScanlineFormat::N32BitTcRgba:
+                        case ScanlineFormat::N32BitTcBgra:
+                        case ScanlineFormat::N32BitTcArgb:
+                        case ScanlineFormat::N32BitTcAbgr:
+                            pScaleRangeFn = scaleHalf32_SSE2;
+                            break;
+                        default:
+                            pScaleRangeFn = scaleHalfGeneral;
+                            break;
+                    }
+
+                    break;
+                case ScaleType::HALF_HORIZONTAL:
+                    pScaleRangeFn = scaleHalfGeneralHorizontal;
+                    break;
+                case ScaleType::HALF_VERTICAL:
+                    pScaleRangeFn = scaleHalfGeneralVertical;
+                    break;
+                default:
+                    return false;
+            }
+
+            bool bUseThreads = true;
+
+            static bool bDisableThreadedScaling = 
getenv("VCL_NO_THREAD_SCALE");
+            if (bDisableThreadedScaling)
+            {
+                SAL_INFO("vcl.gdi", "Scale in main thread");
+                bUseThreads = false;
+            }
+
+            if (bUseThreads)
+            {
+                try
+                {
+                    comphelper::ThreadPool& rShared
+                        = comphelper::ThreadPool::getSharedOptimalPool();
+                    // partition and queue work
+                    long nStripYStart = nStartY;
+                    long nStripYEnd = nStripYStart + constScaleThreadStrip - 1;
+
+                    while (nStripYEnd < nEndY)
+                    {
+                        std::unique_ptr<ScaleTask> pTask(new ScaleTask(
+                            mpThreadPoolTag, pScaleRangeFn, aContext, 
nStripYStart, nStripYEnd));
+                        rShared.pushTask(std::move(pTask));
+                        nStripYStart += constScaleThreadStrip;
+                        nStripYEnd += constScaleThreadStrip;
+                    }
+                    if (nStripYStart <= nEndY)
+                    {
+                        std::unique_ptr<ScaleTask> pTask(new ScaleTask(
+                            mpThreadPoolTag, pScaleRangeFn, aContext, 
nStripYStart, nEndY));
+                        rShared.pushTask(std::move(pTask));
+                    }
+                    rShared.waitUntilDone(mpThreadPoolTag);
+                    SAL_INFO("vcl.gdi", "All threaded scaling tasks complete");
+                }
+                catch (...)
+                {
+                    SAL_WARN("vcl.gdi", "threaded bitmap scaling failed");
+                    bUseThreads = false;
+                }
+            }
+
+            if (!bUseThreads)
+                pScaleRangeFn(aContext, nStartY, nEndY);
+
+            bResult = true;
+        }
+    }
+
+    if (bResult)
+    {
+        rBitmap = aOutBmp;
+    }
+    return bResult;
+}
+
+bool BitmapComboScaleFilter::fastPrescale(Bitmap& rBitmap)
+{
+    const Size aSize(rBitmap.GetSizePixel());
+
+    const long nDestinationWidth = std::lround(aSize.Width() * 
std::fabs(mrScaleX));
+    const long nDestinationHeight = std::lround(aSize.Height() * 
std::fabs(mrScaleY));
+
+    bool bResult = false;
+    ScaleType eType = ScaleType::NONE;
+    if (mrScaleX <= 0.125 && mrScaleY <= 0.125)
+    {
+        eType = ScaleType::OCTAL;
+    }
+    else if (mrScaleX <= 0.25 && mrScaleY <= 0.25)
+    {
+        eType = ScaleType::QUARTER;
+    }
+    else if (mrScaleX <= 0.25 && ALLOW_HORIZONTAL_VERTICAL)
+    {
+        eType = ScaleType::QUARTER_HORIZONTAL;
+    }
+    else if (mrScaleY <= 0.25 && ALLOW_HORIZONTAL_VERTICAL)
+    {
+        eType = ScaleType::QUARTER_VERTICAL;
+    }
+    else if (mrScaleX <= 0.5 && mrScaleY <= 0.5)
+    {
+        eType = ScaleType::HALF;
+    }
+    else if (mrScaleX <= 0.5 && ALLOW_HORIZONTAL_VERTICAL)
+    {
+        eType = ScaleType::HALF_HORIZONTAL;
+    }
+    else if (mrScaleY <= 0.5 && ALLOW_HORIZONTAL_VERTICAL)
+    {
+        eType = ScaleType::HALF_VERTICAL;
+    }
+
+    bResult = scale(eType, rBitmap);
+
+    if (bResult)
+    {
+        const Size aNewSize(rBitmap.GetSizePixel());
+        mrScaleX = nDestinationWidth / double(aNewSize.Width());
+        mrScaleY = nDestinationHeight / double(aNewSize.Height());
+        printf("Combo: %ld %ld -> %ld %ld\n", aSize.Width(), aSize.Height(), 
aNewSize.Width(),
+               aNewSize.Height());
+    }
+
+    return bResult;
+}
+
+BitmapEx BitmapComboScaleFilter::execute(BitmapEx const& rBitmapEx) const
+{
+    Bitmap aBitmap(rBitmapEx.GetBitmap());
+
+    while (const_cast<BitmapComboScaleFilter*>(this)->fastPrescale(aBitmap))
+        ;
+
+    BitmapEx aBitmapEx(aBitmap);
+    BitmapScaleSuperFilter aScaleSuper(mrScaleX, mrScaleY);
+    BitmapEx aResult = aScaleSuper.execute(aBitmapEx);
+
+    return aResult;
+}
+
+} // end namespace vcl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/ScanlineHalfScaler.cxx 
b/vcl/source/bitmap/ScanlineHalfScaler.cxx
new file mode 100644
index 000000000000..944559038948
--- /dev/null
+++ b/vcl/source/bitmap/ScanlineHalfScaler.cxx
@@ -0,0 +1,1359 @@
+/* -*- 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 <bitmap/ScanlineHalfScaler.hxx>
+
+#include <vcl/bitmapaccess.hxx>
+#include <bitmapwriteaccess.hxx>
+
+#include <tools/helpers.hxx>
+#include <algorithm>
+#include <memory>
+#include <tools/cpuid.hxx>
+#include <tools/simdsupport.hxx>
+
+#if defined(LO_SSE2_AVAILABLE)
+#include <emmintrin.h>
+#endif
+
+namespace vcl
+{
+namespace
+{
+inline sal_uInt32 Avg2x2(sal_uInt32 a, sal_uInt32 b, sal_uInt32 c, sal_uInt32 
d)
+{
+    // Prepare half-adder work
+    sal_uInt32 sum = a ^ b ^ c;
+    sal_uInt32 carry = (a & b) | (a & c) | (b & c);
+
+    // Before shifting, mask lower order bits of each byte to avoid underflow.
+    sal_uInt32 mask = 0xfefefefe;
+
+    // Add d to sum and divide by 2.
+    sum = (((sum ^ d) & mask) >> 1) + (sum & d);
+
+    // Sum is now shifted into place relative to carry, add them together.
+    return (((sum ^ carry) & mask) >> 1) + (sum & carry);
+}
+}
+
+void scaleHalfGeneralHorizontal(ScaleContext& rContext, long nStartY, long 
nEndY)
+{
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        Scanline pSourceScanline = rContext.getSourceScanline(nY);
+        Scanline pTargetScanline = rContext.getTargetScanline(nY);
+
+        long nTargetX = 0;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            long nSourceX = nX * 2;
+
+            BitmapColor aColor0 = rContext.getSourcePixel(pSourceScanline, 
nSourceX);
+            BitmapColor aColor1 = rContext.getSourcePixel(pSourceScanline, 
nSourceX + 1);
+
+            BitmapColor aColorResult((aColor0.GetRed() + aColor1.GetRed()) / 2,
+                                     (aColor0.GetGreen() + aColor1.GetGreen()) 
/ 2,
+                                     (aColor0.GetBlue() + aColor1.GetBlue()) / 
2);
+
+            rContext.setTargetPixel(pTargetScanline, nTargetX++, aColorResult);
+        }
+    }
+}
+
+void scaleHalfGeneralVertical(ScaleContext& rContext, long nStartY, long nEndY)
+{
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        long nSourceY = nY * 2;
+
+        Scanline pSourceScanline0 = rContext.mpSource->GetScanline(nSourceY);
+        Scanline pSourceScanline1 = rContext.mpSource->GetScanline(nSourceY + 
1);
+
+        Scanline pTargetScanline = rContext.mpTarget->GetScanline(nY);
+
+        long nSourceX = nStartX;
+        long nTargetX = 0;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            BitmapColor aColor0 = 
rContext.mpSource->GetPixelFromData(pSourceScanline0, nSourceX);
+            BitmapColor aColor1 = 
rContext.mpSource->GetPixelFromData(pSourceScanline1, nSourceX);
+
+            BitmapColor aColorResult((aColor0.GetRed() + aColor1.GetRed()) / 2,
+                                     (aColor0.GetGreen() + aColor1.GetGreen()) 
/ 2,
+                                     (aColor0.GetBlue() + aColor1.GetBlue()) / 
2);
+
+            rContext.mpTarget->SetPixelOnData(pTargetScanline, nTargetX++, 
aColorResult);
+        }
+    }
+}
+
+void scaleHalfGeneral(ScaleContext& rContext, long nStartY, long nEndY)
+{
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    long nSourceY = nStartY * 2;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        Scanline pSource0 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource1 = rContext.mpSource->GetScanline(nSourceY++);
+
+        Scanline pScanDest = rContext.mpTarget->GetScanline(nY);
+
+        long nTargetX = 0;
+
+        BitmapColor aColor;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            long nRed = 0;
+            long nGreen = 0;
+            long nBlue = 0;
+            long nAlpha = 0;
+
+            long nSourceX = nX * 2;
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource0, nSourceX);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource0, nSourceX + 
1);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource1, nSourceX);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource1, nSourceX + 
1);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            BitmapColor aColorResult(nRed / 4, nGreen / 4, nBlue / 4, nAlpha / 
4);
+
+            rContext.mpTarget->SetPixelOnData(pScanDest, nTargetX++, 
aColorResult);
+        }
+    }
+}
+
+void scaleQuarterGeneral(ScaleContext& rContext, long nStartY, long nEndY)
+{
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    long nSourceY = nStartY * 4;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        Scanline pSource0 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource1 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource2 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource3 = rContext.mpSource->GetScanline(nSourceY++);
+
+        Scanline pScanDest = rContext.mpTarget->GetScanline(nY);
+
+        long nTargetX = 0;
+
+        BitmapColor aColor;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            long nRed = 0;
+            long nGreen = 0;
+            long nBlue = 0;
+            long nAlpha = 0;
+
+            long nSourceX = nX * 4;
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource0, nSourceX);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource0, nSourceX + 
1);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource0, nSourceX + 
2);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource0, nSourceX + 
3);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource1, nSourceX);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource1, nSourceX + 
1);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource1, nSourceX + 
2);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource1, nSourceX + 
3);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource2, nSourceX);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource2, nSourceX + 
1);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource2, nSourceX + 
2);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource2, nSourceX + 
3);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource3, nSourceX);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource3, nSourceX + 
1);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource3, nSourceX + 
2);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            aColor = rContext.mpSource->GetPixelFromData(pSource3, nSourceX + 
3);
+            nRed += aColor.GetRed();
+            nGreen += aColor.GetGreen();
+            nBlue += aColor.GetBlue();
+            nAlpha += aColor.GetAlpha();
+
+            BitmapColor aColorResult(nRed / 16, nGreen / 16, nBlue / 16, 
nAlpha / 16);
+
+            rContext.mpTarget->SetPixelOnData(pScanDest, nTargetX++, 
aColorResult);
+        }
+    }
+}
+
+void scaleQuarterGeneralHorizontal(ScaleContext& rContext, long nStartY, long 
nEndY)
+{
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        Scanline pSourceScanline = rContext.mpSource->GetScanline(nY);
+        Scanline pTargetScanline = rContext.mpTarget->GetScanline(nY);
+
+        long nTargetX = 0;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            long nSourceX = nX * 4;
+
+            BitmapColor aColor0 = 
rContext.mpSource->GetPixelFromData(pSourceScanline, nSourceX);
+            BitmapColor aColor1
+                = rContext.mpSource->GetPixelFromData(pSourceScanline, 
nSourceX + 1);
+            BitmapColor aColor2
+                = rContext.mpSource->GetPixelFromData(pSourceScanline, 
nSourceX + 2);
+            BitmapColor aColor3
+                = rContext.mpSource->GetPixelFromData(pSourceScanline, 
nSourceX + 3);
+
+            BitmapColor aColorResult(
+                (aColor0.GetRed() + aColor1.GetRed() + aColor2.GetRed() + 
aColor3.GetRed()) / 4,
+                (aColor0.GetGreen() + aColor1.GetGreen() + aColor2.GetGreen() 
+ aColor3.GetGreen())
+                    / 4,
+                (aColor0.GetBlue() + aColor1.GetBlue() + aColor2.GetBlue() + 
aColor3.GetBlue())
+                    / 4);
+
+            rContext.mpTarget->SetPixelOnData(pTargetScanline, nTargetX++, 
aColorResult);
+        }
+    }
+}
+
+void scaleQuarterGeneralVertical(ScaleContext& rContext, long nStartY, long 
nEndY)
+{
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        long nSourceY = nY * 4;
+
+        Scanline pSourceScanline0 = rContext.mpSource->GetScanline(nSourceY);
+        Scanline pSourceScanline1 = rContext.mpSource->GetScanline(nSourceY + 
1);
+        Scanline pSourceScanline2 = rContext.mpSource->GetScanline(nSourceY + 
2);
+        Scanline pSourceScanline3 = rContext.mpSource->GetScanline(nSourceY + 
3);
+
+        Scanline pTargetScanline = rContext.mpTarget->GetScanline(nY);
+
+        long nSourceX = nStartX;
+        long nTargetX = 0;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            BitmapColor aColor0 = 
rContext.mpSource->GetPixelFromData(pSourceScanline0, nSourceX);
+            BitmapColor aColor1 = 
rContext.mpSource->GetPixelFromData(pSourceScanline1, nSourceX);
+            BitmapColor aColor2 = 
rContext.mpSource->GetPixelFromData(pSourceScanline2, nSourceX);
+            BitmapColor aColor3 = 
rContext.mpSource->GetPixelFromData(pSourceScanline3, nSourceX);
+
+            BitmapColor aColorResult(
+                (aColor0.GetRed() + aColor1.GetRed() + aColor2.GetRed() + 
aColor3.GetRed()) / 4,
+                (aColor0.GetGreen() + aColor1.GetGreen() + aColor2.GetGreen() 
+ aColor3.GetGreen())
+                    / 4,
+                (aColor0.GetBlue() + aColor1.GetBlue() + aColor2.GetBlue() + 
aColor3.GetBlue())
+                    / 4);
+
+            rContext.mpTarget->SetPixelOnData(pTargetScanline, nTargetX++, 
aColorResult);
+        }
+    }
+}
+
+void scaleOctalGeneral(ScaleContext& rContext, long nStartY, long nEndY)
+{
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        long nSourceY = nY * 8;
+
+        Scanline pSource0 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource1 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource2 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource3 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource4 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource5 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource6 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource7 = rContext.mpSource->GetScanline(nSourceY);
+
+        Scanline pTargetScanline = rContext.mpTarget->GetScanline(nY);
+
+        long nTargetX = 0;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            long nRed = 0;
+            long nGreen = 0;
+            long nBlue = 0;
+            long nAlpha = 0;
+
+            long nSourceX = nX * 8;
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource0, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource1, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource2, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource3, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource4, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource5, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource6, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            for (long i = 0; i < 8; i++)
+            {
+                BitmapColor aColor = 
rContext.mpSource->GetPixelFromData(pSource7, nSourceX + i);
+                nRed += aColor.GetRed();
+                nGreen += aColor.GetGreen();
+                nBlue += aColor.GetBlue();
+                nAlpha += aColor.GetAlpha();
+            }
+
+            BitmapColor aColorResult(nRed / 64, nGreen / 64, nBlue / 64);
+
+            rContext.mpTarget->SetPixelOnData(pTargetScanline, nTargetX++, 
aColorResult);
+        }
+    }
+}
+
+void scaleOctal32(ScaleContext& rContext, long nStartY, long nEndY)
+{
+    constexpr int constColorComponents = 4;
+    constexpr int constNumberSamples = 4;
+    constexpr int constNumberSamplesSquared = (constNumberSamples * 
constNumberSamples);
+
+    const long nStartX = 0;
+    const long nEndX = rContext.mnTargetW - 1;
+
+    for (long nY = nStartY; nY <= nEndY; nY++)
+    {
+        long nSourceY = nY * constNumberSamples;
+
+        Scanline pSource0 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource1 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource2 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource3 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource4 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource5 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource6 = rContext.mpSource->GetScanline(nSourceY++);
+        Scanline pSource7 = rContext.mpSource->GetScanline(nSourceY);
+
+        Scanline pTargetScanline = rContext.mpTarget->GetScanline(nY);
+
+        Scanline pColorPtr;
+
+        for (long nX = nStartX; nX <= nEndX; nX++)
+        {
+            long nComponent1 = 0;
+            long nComponent2 = 0;
+            long nComponent3 = 0;
+            long nComponent4 = 0;
+
+            long nSourceX = nX * constNumberSamples;
+
+            pColorPtr = pSource0 + constColorComponents * nSourceX;
+            for (long i = 0; i < constNumberSamples; i++)
+            {
+                nComponent1 += *pColorPtr;
+                pColorPtr++;
+                nComponent2 += *pColorPtr;
+                pColorPtr++;
+                nComponent3 += *pColorPtr;
+                pColorPtr++;
+                nComponent4 += *pColorPtr;
+                pColorPtr++;
+            }
+
+            pColorPtr = pSource1 + constColorComponents * nSourceX;
+            for (long i = 0; i < constNumberSamples; i++)
+            {
+                nComponent1 += *pColorPtr;
+                pColorPtr++;
+                nComponent2 += *pColorPtr;
+                pColorPtr++;
+                nComponent3 += *pColorPtr;
+                pColorPtr++;
+                nComponent4 += *pColorPtr;
+                pColorPtr++;
+            }
+
+            pColorPtr = pSource2 + constColorComponents * nSourceX;
+            for (long i = 0; i < constNumberSamples; i++)
+            {
+                nComponent1 += *pColorPtr;
+                pColorPtr++;

... 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