[Libreoffice-commits] core.git: Branch 'private/thb/libo-6-1+backports' - 184 commits - basegfx/Library_basegfx.mk basegfx/source basegfx/test canvas/source chart2/qa chart2/source comphelper/Library_comphelper.mk comphelper/source configure.ac cppcanvas/source cui/source drawinglayer/source filter/source include/basegfx include/comphelper include/drawinglayer include/sot include/tools include/vcl oox/source sax/source sc/source sd/source setup_native/scripts slideshow/source solenv/clang-format sot/source svgio/source svx/source sw/source tools/source vcl/backendtest vcl/CustomTarget_kde5_moc.mk vcl/CustomTarget_qt5_moc.mk vcl/headless vcl/inc vcl/ios vcl/Library_vclplug_kde5.mk vcl/Library_vclplug_qt5.mk vcl/opengl vcl/osx vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win vcl/workben winaccessibility/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 27 13:14:56 UTC 2018


Rebased ref, commits from common ancestor:
commit eb585eaf79d3fbdd3f0d4a7a4038cadfd7eda957
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Tue Nov 27 13:25:50 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:55 2018 +0100

    hack fix: funny moc errors
    
    Change-Id: I96c542fa5ee38a173a164c2099de1c2aeb372fe1

diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 529ec3d2779c..efd7eb767e37 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -52,7 +52,7 @@ private Q_SLOTS:
 
 Q_SIGNALS:
     bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
-    std::unique_ptr<SalMenu> createMenuSignal(bool, Menu*);
+    //std::unique_ptr<SalMenu> createMenuSignal(bool, Menu*);
 
 public:
     explicit Qt5Instance(std::unique_ptr<SalYieldMutex> pMutex, bool bUseCairo = false);
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index cc8ecf4fad7b..6bdce6737026 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -66,8 +66,8 @@ Qt5Instance::Qt5Instance(std::unique_ptr<SalYieldMutex> pMutex, bool bUseCairo)
     // is processed before the thread emitting the signal continues
     connect(this, SIGNAL(ImplYieldSignal(bool, bool)), this, SLOT(ImplYield(bool, bool)),
             Qt::BlockingQueuedConnection);
-    connect(this, &Qt5Instance::createMenuSignal, this, &Qt5Instance::CreateMenu,
-            Qt::BlockingQueuedConnection);
+    // connect(this, &Qt5Instance::createMenuSignal, this, &Qt5Instance::CreateMenu,
+    //         Qt::BlockingQueuedConnection);
 }
 
 Qt5Instance::~Qt5Instance()
@@ -126,7 +126,7 @@ std::unique_ptr<SalMenu> Qt5Instance::CreateMenu(bool bMenuBar, Menu* pVCLMenu)
     if (qApp->thread() != QThread::currentThread())
     {
         SolarMutexReleaser aReleaser;
-        return Q_EMIT createMenuSignal(bMenuBar, pVCLMenu);
+        //return Q_EMIT createMenuSignal(bMenuBar, pVCLMenu);
     }
 
     Qt5Menu* pSalMenu = new Qt5Menu(bMenuBar);
commit 043e7b114ac7703f1801269cc3fa972e2e8c1be8
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Tue Nov 27 12:47:14 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:54 2018 +0100

    kde5: role STATIC not known for 6-1
    
    Change-Id: Ic25630f6f8cffa84b184e1993dac4204b857b88f

diff --git a/vcl/qt5/Qt5AccessibleWidget.cxx b/vcl/qt5/Qt5AccessibleWidget.cxx
index 9773b2875050..a31e13f49e3e 100644
--- a/vcl/qt5/Qt5AccessibleWidget.cxx
+++ b/vcl/qt5/Qt5AccessibleWidget.cxx
@@ -464,9 +464,6 @@ QAccessible::Role Qt5AccessibleWidget::role() const
         case AccessibleRole::DOCUMENT_TEXT:
             return QAccessible::Document;
 
-        case AccessibleRole::STATIC:
-            return QAccessible::StaticText;
-
         /* Ignore window objects for sub-menus, combo- and list boxes,
          *  which are exposed as children of their parents.
          */
commit ee0f88da6ad25f21899c7df9bcc50253e92293c6
Author:     Rene Engelhard <rene at debian.org>
AuthorDate: Mon Oct 8 17:57:18 2018 +0000
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:53 2018 +0100

    make --enable-kde5 imply --enable-qt5
    
    And explicitly fail if --enable-kde5 and --disable-qt5.
    
    Change-Id: Ifa0cef6b065ca0825b1cb42922f6fcf676e457f1
    Reviewed-on: https://gerrit.libreoffice.org/61571
    Tested-by: Jenkins
    Reviewed-by: Rene Engelhard <rene at debian.org>
    Tested-by: Rene Engelhard <rene at debian.org>

diff --git a/configure.ac b/configure.ac
index 4fece12fbb33..6a653e661cf5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -594,7 +594,6 @@ linux-gnu*|k*bsd*-gnu*)
     build_gstreamer_0_10=yes
     test_kde4=yes
     test_kde5=yes
-    test_qt5=yes
     test_gtk3_kde5=yes
     if test "$enable_fuzzers" != yes; then
         test_freetype=yes
@@ -690,7 +689,6 @@ freebsd*)
     build_gstreamer_0_10=yes
     test_kde4=yes
     test_kde5=yes
-    test_qt5=yes
     test_gtk3_kde5=yes
     test_freetype=yes
     AC_MSG_CHECKING([the FreeBSD operating system release])
@@ -721,7 +719,6 @@ freebsd*)
     build_gstreamer_0_10=yes
     test_kde4=yes
     test_kde5=yes
-    test_qt5=yes
     test_gtk3_kde5=yes
     test_freetype=yes
     PTHREAD_LIBS="-pthread -lpthread"
@@ -749,7 +746,6 @@ dragonfly*)
     build_gstreamer_0_10=yes
     test_kde4=yes
     test_kde5=yes
-    test_qt5=yes
     test_gtk3_kde5=yes
     test_freetype=yes
     PTHREAD_LIBS="-pthread"
@@ -775,7 +771,6 @@ linux-android*)
     test_gtk=no
     test_kde4=no
     test_kde5=no
-    test_qt5=no
     test_gtk3_kde5=no
     test_randr=no
     test_xrender=no
@@ -4663,6 +4658,18 @@ if test "$OS" = "HAIKU"; then
     test_qt5=yes
 fi
 
+if test "$test_kde5" = "yes"; then
+    test_qt5=yes
+fi
+
+if test "$test_kde5" = "yes" -a  "$enable_kde5" = "yes"; then
+    if test "$enable_qt5" = "no"; then
+        AC_MSG_ERROR([KDE5 support depends on QT5, so it conflicts with --disable-qt5])
+    else
+        enable_qt5=yes
+    fi
+fi
+
 dnl ===================================================================
 dnl check for cups support
 dnl ===================================================================
commit 09fafc6842f9a6c5fa45b532ef3564b7fa1df3db
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Tue Nov 27 10:21:04 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:53 2018 +0100

    vcl: fix gtk debug code
    
    Change-Id: I940e1ae01ec384069cf2704fdc81b7561e9f8d63
    Reviewed-on: https://gerrit.libreoffice.org/64094
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit 56f276592d477c2201cdc184ce62d7183397f210)

diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx
index 539d8cb5d897..b1f80d5855ab 100644
--- a/vcl/unx/gtk/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx
@@ -3888,15 +3888,15 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
 
 #if OSL_DEBUG_LEVEL > 1
     std::fprintf( stderr, "==\n" );
-    std::fprintf( stderr, "MenuColor = %x (%d)\n", (int)aStyleSet.GetMenuColor().GetColor(), aStyleSet.GetMenuColor().GetLuminance() );
-    std::fprintf( stderr, "MenuTextColor = %x (%d)\n", (int)aStyleSet.GetMenuTextColor().GetColor(), aStyleSet.GetMenuTextColor().GetLuminance() );
-    std::fprintf( stderr, "MenuBarColor = %x (%d)\n", (int)aStyleSet.GetMenuBarColor().GetColor(), aStyleSet.GetMenuBarColor().GetLuminance() );
-    std::fprintf( stderr, "MenuBarRolloverColor = %x (%d)\n", (int)aStyleSet.GetMenuBarRolloverColor().GetColor(), aStyleSet.GetMenuBarRolloverColor().GetLuminance() );
-    std::fprintf( stderr, "MenuBarTextColor = %x (%d)\n", (int)aStyleSet.GetMenuBarTextColor().GetColor(), aStyleSet.GetMenuBarTextColor().GetLuminance() );
-    std::fprintf( stderr, "MenuBarRolloverTextColor = %x (%d)\n", (int)aStyleSet.GetMenuBarRolloverTextColor().GetColor(), aStyleSet.GetMenuBarRolloverTextColor().GetLuminance() );
-    std::fprintf( stderr, "LightColor = %x (%d)\n", (int)aStyleSet.GetLightColor().GetColor(), aStyleSet.GetLightColor().GetLuminance() );
-    std::fprintf( stderr, "ShadowColor = %x (%d)\n", (int)aStyleSet.GetShadowColor().GetColor(), aStyleSet.GetShadowColor().GetLuminance() );
-    std::fprintf( stderr, "DarkShadowColor = %x (%d)\n", (int)aStyleSet.GetDarkShadowColor().GetColor(), aStyleSet.GetDarkShadowColor().GetLuminance() );
+    std::fprintf( stderr, "MenuColor = %x (%d)\n", (int)aStyleSet.GetMenuColor(), aStyleSet.GetMenuColor().GetLuminance() );
+    std::fprintf( stderr, "MenuTextColor = %x (%d)\n", (int)aStyleSet.GetMenuTextColor(), aStyleSet.GetMenuTextColor().GetLuminance() );
+    std::fprintf( stderr, "MenuBarColor = %x (%d)\n", (int)aStyleSet.GetMenuBarColor(), aStyleSet.GetMenuBarColor().GetLuminance() );
+    std::fprintf( stderr, "MenuBarRolloverColor = %x (%d)\n", (int)aStyleSet.GetMenuBarRolloverColor(), aStyleSet.GetMenuBarRolloverColor().GetLuminance() );
+    std::fprintf( stderr, "MenuBarTextColor = %x (%d)\n", (int)aStyleSet.GetMenuBarTextColor(), aStyleSet.GetMenuBarTextColor().GetLuminance() );
+    std::fprintf( stderr, "MenuBarRolloverTextColor = %x (%d)\n", (int)aStyleSet.GetMenuBarRolloverTextColor(), aStyleSet.GetMenuBarRolloverTextColor().GetLuminance() );
+    std::fprintf( stderr, "LightColor = %x (%d)\n", (int)aStyleSet.GetLightColor(), aStyleSet.GetLightColor().GetLuminance() );
+    std::fprintf( stderr, "ShadowColor = %x (%d)\n", (int)aStyleSet.GetShadowColor(), aStyleSet.GetShadowColor().GetLuminance() );
+    std::fprintf( stderr, "DarkShadowColor = %x (%d)\n", (int)aStyleSet.GetDarkShadowColor(), aStyleSet.GetDarkShadowColor().GetLuminance() );
 #endif
 
     aHighlightColor = getColor( pMenuItemStyle->bg[ GTK_STATE_SELECTED ] );
commit 1e030aaff9b86e63de60e3fdffd8c8350e3c92dd
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Tue Nov 27 11:34:18 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:52 2018 +0100

    vcl: need <o3tl/make_unique.hxx>
    
    Change-Id: I02a86aca7dd4780a2349a0d9e6cdc8190efa06be

diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 441eb4371c41..cc8ecf4fad7b 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -44,6 +44,7 @@
 #include <vclpluginapi.h>
 #include <sal/log.hxx>
 #include <osl/process.h>
+#include <o3tl/make_unique.hxx>
 
 #include <headless/svpbmp.hxx>
 
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index ec3dd01d7891..018ddd58f333 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -38,6 +38,7 @@
 
 #include <salwtype.hxx>
 #include <sal/macros.h>
+#include <o3tl/make_unique.hxx>
 
 // plugin factory function
 extern "C"
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 1cda7c3de443..7335c72e5cb3 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -35,6 +35,7 @@
 #include <unx/genpspgraphics.h>
 #include <rtl/strbuf.hxx>
 #include <rtl/uri.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <vcl/settings.hxx>
 
diff --git a/vcl/unx/kde4/main.cxx b/vcl/unx/kde4/main.cxx
index 4d5250ee98e5..a9464b53708b 100644
--- a/vcl/unx/kde4/main.cxx
+++ b/vcl/unx/kde4/main.cxx
@@ -25,6 +25,7 @@
 #include <vclpluginapi.h>
 
 #include <rtl/string.hxx>
+#include <o3tl/make_unique.hxx>
 
 /// entry point for the KDE4 VCL plugin
 extern "C" {
commit b29b38d6c2223f53e7ac8f014610a892e340b4a4
Author:     Armin Le Grand <Armin.Le.Grand at cib.de>
AuthorDate: Thu Nov 8 15:36:37 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:50 2018 +0100

    tdf#120252 use the already transformed PolyPolygon
    
    Change-Id: I38abc73116720b99364c3de9fa4378c730385dc2
    Reviewed-on: https://gerrit.libreoffice.org/63104
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    Tested-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>
    
    Conflicts:
            vcl/quartz/salgdicommon.cxx

diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 93aa22ca97f4..477725636c0d 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -1102,7 +1102,9 @@ bool AquaSalGraphics::drawPolyPolygon(
     SAL_INFO( "vcl.cg", "CGPathCreateMutable() = " << xPath );
     for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
     {
-        const basegfx::B2DPolygon rPolygon = rPolyPolygon.getB2DPolygon( nPolyIdx );
+        // tdf#120252 Use the correct, already transformed PolyPolygon (as long as
+        // the transformation is not used here...)
+        const basegfx::B2DPolygon rPolygon = aPolyPolygon.getB2DPolygon( nPolyIdx );
         AddPolygonToPath( xPath, rPolygon, true, !getAntiAliasB2DDraw(), IsPenVisible() );
     }
 
commit f1becc95890000354df2ccaee4f515f539b711ea
Author:     Armin Le Grand <Armin.Le.Grand at cib.de>
AuthorDate: Wed Oct 3 15:55:29 2018 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:49 2018 +0100

    Support estimateUsageInBytes for SystemDependentData
    
    Change-Id: I6074035ed8f90e452915e9ecffdbe9363375e126
    Reviewed-on: https://gerrit.libreoffice.org/61306
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>
    
    Conflicts:
            vcl/win/gdi/gdiimpl.cxx
            vcl/win/gdi/salbmp.cxx

diff --git a/basegfx/source/tools/systemdependentdata.cxx b/basegfx/source/tools/systemdependentdata.cxx
index 4153d35f7d55..c727462c7191 100755
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -8,6 +8,7 @@
  */
 
 #include <basegfx/utils/systemdependentdata.hxx>
+#include <math.h>
 
 namespace basegfx
 {
@@ -62,7 +63,8 @@ namespace basegfx
 {
     SystemDependentData::SystemDependentData(
         SystemDependentDataManager& rSystemDependentDataManager)
-    :   mrSystemDependentDataManager(rSystemDependentDataManager)
+    :   mrSystemDependentDataManager(rSystemDependentDataManager),
+        mnCalculatedCycles(0)
     {
     }
 
@@ -70,6 +72,49 @@ namespace basegfx
     {
     }
 
+    sal_uInt32 SystemDependentData::calculateCombinedHoldCyclesInSeconds() const
+    {
+        if(0 == mnCalculatedCycles)
+        {
+            const sal_Int64 nBytes(estimateUsageInBytes());
+            const sal_uInt32 nSeconds(getHoldCyclesInSeconds());
+
+            // default is Seconds (minimal is one)
+            sal_uInt32 nResult(0 == nSeconds ? 1 : nSeconds);
+
+            if(0 != nBytes)
+            {
+                // use sqrt to get some curved shape. With a default of 60s we get
+                // a single second at 3600 byte. To get close to 10mb, multiply by
+                // a corresponding scaling factor
+                const double fScaleToMB(3600.0 / (1024.0 * 1024.0 * 10.0));
+
+                // also use a multiplier to move the start point higer
+                const double fMultiplierSeconds(10.0);
+
+                // calculate
+                nResult = static_cast<sal_uInt32>((fMultiplierSeconds * nSeconds) / sqrt(nBytes * fScaleToMB));
+
+                // minimal value is 1
+                if(nResult < 1)
+                {
+                    nResult = 1;
+                }
+
+                // maximal value is nSeconds
+                if(nResult > nSeconds)
+                {
+                    nResult = nSeconds;
+                }
+            }
+
+            // set locally (once, on-demand created, non-zero)
+            const_cast<SystemDependentData*>(this)->mnCalculatedCycles = nResult < 1 ? 1 : nResult;
+        }
+
+        return mnCalculatedCycles;
+    }
+
     sal_uInt32 SystemDependentData::getHoldCyclesInSeconds() const
     {
         // default implementation returns 60(s)
diff --git a/include/basegfx/utils/systemdependentdata.hxx b/include/basegfx/utils/systemdependentdata.hxx
index f06f6d09eee9..d5d9bf1202bf 100755
--- a/include/basegfx/utils/systemdependentdata.hxx
+++ b/include/basegfx/utils/systemdependentdata.hxx
@@ -89,6 +89,12 @@ namespace basegfx
         // a single, globally used one, but not necessarily
         SystemDependentDataManager&     mrSystemDependentDataManager;
 
+        // Buffered CalculatedCycles, result of estimations using
+        // getHoldCyclesInSeconds and estimateUsageInBytes, executed
+        // using getHoldCyclesInSeconds. StartValue is 0 to detect
+        // not-yet-calculated state
+        sal_uInt32                      mnCalculatedCycles;
+
     public:
         SystemDependentData(
             SystemDependentDataManager& rSystemDependentDataManager);
@@ -103,6 +109,12 @@ namespace basegfx
         // using getSystemDependentDataManager()
         SystemDependentDataManager& getSystemDependentDataManager() { return mrSystemDependentDataManager; }
 
+        // Calculate HoldCyclesInSeconds based on using
+        // getHoldCyclesInSeconds and estimateUsageInBytes, the
+        // result is crated once on-demand and buffered in
+        // mnCalculatedCycles
+        sal_uInt32 calculateCombinedHoldCyclesInSeconds() const;
+
         // Number of cycles a SystemDependentDataManager should/might
         // hold this instance in seconds - does not have to be used,
         // but should be. Default implementation returns 60(s). Override to
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 015689013771..0e5a07ec7d61 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1054,6 +1054,8 @@ public:
     cairo_path_t* getCairoPath() { return mpCairoPath; }
     bool getNoJoin() const { return mbNoJoin; }
     bool getAntiAliasB2DDraw() const { return mbAntiAliasB2DDraw; }
+
+    virtual sal_Int64 estimateUsageInBytes() const override;
 };
 
 SystemDependentData_CairoPath::SystemDependentData_CairoPath(
@@ -1077,6 +1079,22 @@ SystemDependentData_CairoPath::~SystemDependentData_CairoPath()
     }
 }
 
+sal_Int64 SystemDependentData_CairoPath::estimateUsageInBytes() const
+{
+    sal_Int64 nRetval(0);
+
+    if(nullptr != mpCairoPath)
+    {
+        // per node
+        // - num_data incarnations of
+        // - sizeof(cairo_path_data_t) which is a union of defines and point data
+        //   thus may 2 x sizeof(double)
+        nRetval = mpCairoPath->num_data * sizeof(cairo_path_data_t);
+    }
+
+    return nRetval;
+}
+
 bool SvpSalGraphics::drawPolyLine(
     const basegfx::B2DHomMatrix& rObjectToDevice,
     const basegfx::B2DPolygon& rPolyLine,
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 11da33eebf18..712c2dee5d99 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -159,7 +159,7 @@ namespace
                     maTimer->Start();
                 }
 
-                maEntries[rData] = rData->getHoldCyclesInSeconds();
+                maEntries[rData] = rData->calculateCombinedHoldCyclesInSeconds();
             }
         }
 
@@ -186,7 +186,7 @@ namespace
 
             if(aFound != maEntries.end())
             {
-                aFound->second = rData->getHoldCyclesInSeconds();
+                aFound->second = rData->calculateCombinedHoldCyclesInSeconds();
             }
         }
 
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index d525b7bc1a4e..0e2436260fd0 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -1674,6 +1674,8 @@ public:
     const basegfx::B2DLineJoin& getJoin() const { return meJoin; }
     const css::drawing::LineCap& getCap() const { return meCap; }
     double getMiterMinimumAngle() const { return mfMiterMinimumAngle; }
+
+    virtual sal_Int64 estimateUsageInBytes() const override;
 };
 
 SystemDependentData_Triangulation::SystemDependentData_Triangulation(
@@ -1692,6 +1694,18 @@ SystemDependentData_Triangulation::SystemDependentData_Triangulation(
 {
 }
 
+sal_Int64 SystemDependentData_Triangulation::estimateUsageInBytes() const
+{
+    sal_Int64 nRetval(0);
+
+    if(!maTriangles.empty())
+    {
+        nRetval = maTriangles.size() * sizeof(basegfx::triangulator::B2DTriangle);
+    }
+
+    return nRetval;
+}
+
 bool X11SalGraphicsImpl::drawPolyLine(
     const basegfx::B2DHomMatrix& rObjectToDevice,
     const basegfx::B2DPolygon& rPolygon,
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 71c5fce6ab0d..69da79a8a4a4 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -1954,31 +1954,34 @@ class SystemDependentData_GraphicsPath : public basegfx::SystemDependentData
 {
 private:
     // the path data itself
-    Gdiplus::GraphicsPath           maGraphicsPath;
+    std::shared_ptr<Gdiplus::GraphicsPath>  mpGraphicsPath;
 
     // all other values the triangulation is based on and
     // need to be compared with to check for data validity
-    bool                            mbNoLineJoin;
+    bool                                    mbNoLineJoin;
 
 public:
     SystemDependentData_GraphicsPath(
         basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+        std::shared_ptr<Gdiplus::GraphicsPath>& rpGraphicsPath,
         bool bNoLineJoin);
     virtual ~SystemDependentData_GraphicsPath() override;
 
-    // non-const getter to allow manipulation. That way, we do not need
-    // to copy it (with unknown costs)
-    Gdiplus::GraphicsPath& getGraphicsPath() { return maGraphicsPath; }
+    // read access to Gdiplus::GraphicsPath
+    std::shared_ptr<Gdiplus::GraphicsPath>& getGraphicsPath() { return mpGraphicsPath; }
 
     // other data-validity access
     bool getNoLineJoin() const { return mbNoLineJoin; }
+
+    virtual sal_Int64 estimateUsageInBytes() const override;
 };
 
 SystemDependentData_GraphicsPath::SystemDependentData_GraphicsPath(
     basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+    std::shared_ptr<Gdiplus::GraphicsPath>& rpGraphicsPath,
     bool bNoLineJoin)
 :   basegfx::SystemDependentData(rSystemDependentDataManager),
-    maGraphicsPath(),
+    mpGraphicsPath(rpGraphicsPath),
     mbNoLineJoin(bNoLineJoin)
 {
 }
@@ -1987,6 +1990,26 @@ SystemDependentData_GraphicsPath::~SystemDependentData_GraphicsPath()
 {
 }
 
+sal_Int64 SystemDependentData_GraphicsPath::estimateUsageInBytes() const
+{
+    sal_Int64 nRetval(0);
+
+    if(mpGraphicsPath)
+    {
+        const INT nPointCount(mpGraphicsPath->GetPointCount());
+
+        if(0 != nPointCount)
+        {
+            // Each point has
+            // - 2 x sizeof(Gdiplus::REAL)
+            // - 1 byte (see GetPathTypes in docu)
+            nRetval = nPointCount * ((2 * sizeof(Gdiplus::REAL)) + 1);
+        }
+    }
+
+    return nRetval;
+}
+
 bool WinSalGraphicsImpl::drawPolyPolygon(
     const basegfx::B2DHomMatrix& rObjectToDevice,
     const basegfx::B2DPolyPolygon& rPolyPolygon,
@@ -2023,17 +2046,20 @@ bool WinSalGraphicsImpl::drawPolyPolygon(
         aGraphics.SetTransform(&aMatrix);
     }
 
+    // prepare local instabce of Gdiplus::GraphicsPath
+    std::shared_ptr<Gdiplus::GraphicsPath> pGraphicsPath;
+
     // try to access buffered data
     std::shared_ptr<SystemDependentData_GraphicsPath> pSystemDependentData_GraphicsPath(
         rPolyPolygon.getSystemDependentData<SystemDependentData_GraphicsPath>());
 
-    if(!pSystemDependentData_GraphicsPath)
+    if(pSystemDependentData_GraphicsPath)
+    {
+        // copy buffered data
+        pGraphicsPath = pSystemDependentData_GraphicsPath->getGraphicsPath();
+    }
+    else
     {
-        // add to buffering mechanism
-        pSystemDependentData_GraphicsPath = rPolyPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
-            ImplGetSystemDependentDataManager(),
-            false);
-
         // Note: In principle we could use the same buffered geometry at line
         // and fill polygons. Checked that in a first try, used
         // GraphicsPath::AddPath from Gdiplus combined with below used
@@ -2061,23 +2087,31 @@ bool WinSalGraphicsImpl::drawPolyPolygon(
         // (at least for now...)
 
         // create data
+        pGraphicsPath.reset(new Gdiplus::GraphicsPath());
+
         for(sal_uInt32 a(0); a < nCount; a++)
         {
             if(0 != a)
             {
                 // #i101491# not needed for first run
-                pSystemDependentData_GraphicsPath->getGraphicsPath().StartFigure();
+                pGraphicsPath->StartFigure();
             }
 
             impAddB2DPolygonToGDIPlusGraphicsPathReal(
-                pSystemDependentData_GraphicsPath->getGraphicsPath(),
+                *pGraphicsPath,
                 rPolyPolygon.getB2DPolygon(a),
                 rObjectToDevice, // not used due to the two 'false' values below, but to not forget later
                 false,
                 false);
 
-            pSystemDependentData_GraphicsPath->getGraphicsPath().CloseFigure();
+            pGraphicsPath->CloseFigure();
         }
+
+        // add to buffering mechanism
+        rPolyPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
+            ImplGetSystemDependentDataManager(),
+            pGraphicsPath,
+            false);
     }
 
     if(mrParent.getAntiAliasB2DDraw())
@@ -2127,7 +2161,7 @@ bool WinSalGraphicsImpl::drawPolyPolygon(
     // use created or buffered data
     aGraphics.FillPath(
         &aSolidBrush,
-        &pSystemDependentData_GraphicsPath->getGraphicsPath());
+        &(*pGraphicsPath));
 
     return true;
 }
@@ -2228,6 +2262,9 @@ bool WinSalGraphicsImpl::drawPolyLine(
         }
     }
 
+    // prepare local instabce of Gdiplus::GraphicsPath
+    std::shared_ptr<Gdiplus::GraphicsPath> pGraphicsPath;
+
     // try to access buffered data
     std::shared_ptr<SystemDependentData_GraphicsPath> pSystemDependentData_GraphicsPath(
         rPolygon.getSystemDependentData<SystemDependentData_GraphicsPath>());
@@ -2242,16 +2279,18 @@ bool WinSalGraphicsImpl::drawPolyLine(
         }
     }
 
-    if(!pSystemDependentData_GraphicsPath)
+    if(pSystemDependentData_GraphicsPath)
+    {
+        // copy buffered data
+        pGraphicsPath = pSystemDependentData_GraphicsPath->getGraphicsPath();
+    }
+    else
     {
-        // add to buffering mechanism
-        pSystemDependentData_GraphicsPath = rPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
-            ImplGetSystemDependentDataManager(),
-            bNoLineJoin);
-
         // fill data of buffered data
+        pGraphicsPath.reset(new Gdiplus::GraphicsPath());
+
         impAddB2DPolygonToGDIPlusGraphicsPathReal(
-            pSystemDependentData_GraphicsPath->getGraphicsPath(),
+            *pGraphicsPath,
             rPolygon,
             rObjectToDevice,
             bNoLineJoin,
@@ -2260,8 +2299,14 @@ bool WinSalGraphicsImpl::drawPolyLine(
         if(rPolygon.isClosed() && !bNoLineJoin)
         {
             // #i101491# needed to create the correct line joins
-            pSystemDependentData_GraphicsPath->getGraphicsPath().CloseFigure();
+            pGraphicsPath->CloseFigure();
         }
+
+        // add to buffering mechanism
+        rPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
+            ImplGetSystemDependentDataManager(),
+            pGraphicsPath,
+            bNoLineJoin);
     }
 
     if(mrParent.getAntiAliasB2DDraw())
@@ -2275,7 +2320,7 @@ bool WinSalGraphicsImpl::drawPolyLine(
 
     aGraphics.DrawPath(
         &aPen,
-        &pSystemDependentData_GraphicsPath->getGraphicsPath());
+        &(*pGraphicsPath));
 
     return true;
 }
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 8539bb847457..8892c597412e 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -97,22 +97,78 @@ private:
 
 public:
     SystemDependentData_GdiPlusBitmap(
-        basegfx::SystemDependentDataManager& rSystemDependentDataManager);
+        basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+        const std::shared_ptr<Gdiplus::Bitmap>& rGdiPlusBitmap,
+        const WinSalBitmap* pAssociatedAlpha);
     virtual ~SystemDependentData_GdiPlusBitmap() override;
 
     const WinSalBitmap* getAssociatedAlpha() const { return mpAssociatedAlpha; }
-    void setAssociatedAlpha(const WinSalBitmap* pNew) { mpAssociatedAlpha = pNew; }
-
     const std::shared_ptr<Gdiplus::Bitmap>& getGdiPlusBitmap() const { return mpGdiPlusBitmap; }
-    void setGdiPlusBitmap(const std::shared_ptr<Gdiplus::Bitmap>& rNew) { mpGdiPlusBitmap = rNew; }
+
+    virtual sal_Int64 estimateUsageInBytes() const override;
 };
 
 SystemDependentData_GdiPlusBitmap::SystemDependentData_GdiPlusBitmap(
-    basegfx::SystemDependentDataManager& rSystemDependentDataManager)
+    basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+    const std::shared_ptr<Gdiplus::Bitmap>& rGdiPlusBitmap,
+    const WinSalBitmap* pAssociatedAlpha)
 :   basegfx::SystemDependentData(rSystemDependentDataManager),
-    mpGdiPlusBitmap(),
-    mpAssociatedAlpha(nullptr)
+    mpGdiPlusBitmap(rGdiPlusBitmap),
+    mpAssociatedAlpha(pAssociatedAlpha)
+{
+}
+
+sal_Int64 SystemDependentData_GdiPlusBitmap::estimateUsageInBytes() const
 {
+    sal_Int64 nRetval(0);
+
+    if(mpGdiPlusBitmap)
+    {
+        const UINT nWidth(mpGdiPlusBitmap->GetWidth());
+        const UINT nHeight(mpGdiPlusBitmap->GetHeight());
+
+        if(0 != nWidth && 0 != nHeight)
+        {
+            nRetval = nWidth * nHeight;
+
+            switch(mpGdiPlusBitmap->GetPixelFormat())
+            {
+                case PixelFormat1bppIndexed:
+                    nRetval /= 8;
+                    break;
+                case PixelFormat4bppIndexed:
+                    nRetval /= 4;
+                    break;
+                case PixelFormat16bppGrayScale:
+                case PixelFormat16bppRGB555:
+                case PixelFormat16bppRGB565:
+                case PixelFormat16bppARGB1555:
+                    nRetval *= 2;
+                    break;
+                case PixelFormat24bppRGB:
+                    nRetval *= 3;
+                    break;
+                case PixelFormat32bppRGB:
+                case PixelFormat32bppARGB:
+                case PixelFormat32bppPARGB:
+                case PixelFormat32bppCMYK:
+                    nRetval *= 4;
+                    break;
+                case PixelFormat48bppRGB:
+                    nRetval *= 6;
+                    break;
+                case PixelFormat64bppARGB:
+                case PixelFormat64bppPARGB:
+                    nRetval *= 8;
+                    break;
+                default:
+                case PixelFormat8bppIndexed:
+                    break;
+            }
+        }
+    }
+
+    return nRetval;
 }
 
 SystemDependentData_GdiPlusBitmap::~SystemDependentData_GdiPlusBitmap()
@@ -148,23 +204,25 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
     }
     else if(maSize.Width() > 0 && maSize.Height() > 0)
     {
-        // add to buffering mechanism
-        pSystemDependentData_GdiPlusBitmap = addOrReplaceSystemDependentData<SystemDependentData_GdiPlusBitmap>(
-            ImplGetSystemDependentDataManager());
-
         // create and set data
+        const WinSalBitmap* pAssociatedAlpha(nullptr);
+
         if(pAlphaSource)
         {
             aRetval.reset(const_cast< WinSalBitmap* >(this)->ImplCreateGdiPlusBitmap(*pAlphaSource));
-            pSystemDependentData_GdiPlusBitmap->setGdiPlusBitmap(aRetval);
-            pSystemDependentData_GdiPlusBitmap->setAssociatedAlpha(pAlphaSource);
+            pAssociatedAlpha = pAlphaSource;
         }
         else
         {
             aRetval.reset(const_cast< WinSalBitmap* >(this)->ImplCreateGdiPlusBitmap());
-            pSystemDependentData_GdiPlusBitmap->setGdiPlusBitmap(aRetval);
-            pSystemDependentData_GdiPlusBitmap->setAssociatedAlpha(nullptr);
+            pAssociatedAlpha = nullptr;
         }
+
+        // add to buffering mechanism
+        addOrReplaceSystemDependentData<SystemDependentData_GdiPlusBitmap>(
+            ImplGetSystemDependentDataManager(),
+            aRetval,
+            pAssociatedAlpha);
     }
 
     return aRetval;
commit 8555645e8782dc18157ae83b16b6a6d89080f861
Author:     Armin Le Grand <Armin.Le.Grand at cib.de>
AuthorDate: Fri Sep 21 16:42:01 2018 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:48 2018 +0100

    Support buffering SystemDependent GraphicData
    
    Started to make the buffering more flexible by adding
    virtual methods
    
            virtual sal_uInt32 getHoldCyclesInSeconds() const;
            virtual sal_Int64 estimateUsageInBytes() const;
    
    to class SystemDependentData. This will allow to add more
    sensitive buffering/caching.
    Also fine-tuned Linux-derived classes actively used for buffering
    to be more sensitive when and where to reuse the buffered data
    
    Change-Id: Ifc69c318ade0209aff071d76001869d9f4eeb10d
    Reviewed-on: https://gerrit.libreoffice.org/60881
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>
    
    Conflicts:
            vcl/win/gdi/gdiimpl.cxx

diff --git a/basegfx/source/tools/systemdependentdata.cxx b/basegfx/source/tools/systemdependentdata.cxx
index 45f2efba5012..4153d35f7d55 100755
--- a/basegfx/source/tools/systemdependentdata.cxx
+++ b/basegfx/source/tools/systemdependentdata.cxx
@@ -61,16 +61,26 @@ namespace basegfx
 namespace basegfx
 {
     SystemDependentData::SystemDependentData(
-        SystemDependentDataManager& rSystemDependentDataManager,
-        sal_uInt32 nHoldCycles)
-    :   mrSystemDependentDataManager(rSystemDependentDataManager),
-        mnHoldCycles(nHoldCycles)
+        SystemDependentDataManager& rSystemDependentDataManager)
+    :   mrSystemDependentDataManager(rSystemDependentDataManager)
     {
     }
 
     SystemDependentData::~SystemDependentData()
     {
     }
+
+    sal_uInt32 SystemDependentData::getHoldCyclesInSeconds() const
+    {
+        // default implementation returns 60(s)
+        return 60;
+    }
+
+    sal_Int64 SystemDependentData::estimateUsageInBytes() const
+    {
+        // default implementation has no idea
+        return 0;
+    }
 } // namespace basegfx
 
 namespace basegfx
diff --git a/include/basegfx/utils/systemdependentdata.hxx b/include/basegfx/utils/systemdependentdata.hxx
index 17a0ce44f815..f06f6d09eee9 100755
--- a/include/basegfx/utils/systemdependentdata.hxx
+++ b/include/basegfx/utils/systemdependentdata.hxx
@@ -89,14 +89,9 @@ namespace basegfx
         // a single, globally used one, but not necessarily
         SystemDependentDataManager&     mrSystemDependentDataManager;
 
-        // number of cycles a SystemDependentDataManager should/might
-        // hold this instance - does not have to be used, but should be
-        sal_uInt32                      mnHoldCycles;
-
     public:
         SystemDependentData(
-            SystemDependentDataManager& rSystemDependentDataManager,
-            sal_uInt32 nHoldCycles = 60);
+            SystemDependentDataManager& rSystemDependentDataManager);
 
         // CAUTION! It is VERY important to keep this base class
         // virtual, else typeid(class).hash_code() from derived classes
@@ -108,8 +103,17 @@ namespace basegfx
         // using getSystemDependentDataManager()
         SystemDependentDataManager& getSystemDependentDataManager() { return mrSystemDependentDataManager; }
 
-        // number of cycles to hold data
-        sal_uInt32 getHoldCycles() const { return mnHoldCycles; }
+        // Number of cycles a SystemDependentDataManager should/might
+        // hold this instance in seconds - does not have to be used,
+        // but should be. Default implementation returns 60(s). Override to
+        // offer useful data if you want to have better caching.
+        virtual sal_uInt32 getHoldCyclesInSeconds() const;
+
+        // Size estimation of the entry in bytes - does not have to
+        // be used, but should be. Default returns zero what
+        // means there is no size estimation available. Override to
+        // offer useful data if you want to have better caching.
+        virtual sal_Int64 estimateUsageInBytes() const;
     };
 } // end of namespace basegfx
 
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 473d52a63fa7..015689013771 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1035,27 +1035,36 @@ void SvpSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
 class SystemDependentData_CairoPath : public basegfx::SystemDependentData
 {
 private:
+    // the path data itself
     cairo_path_t*       mpCairoPath;
-    bool                mbPixelSnapHairline;
+
+    // all other values the path data  is based on and
+    // need to be compared with to check for data validity
+    bool                mbNoJoin;
+    bool                mbAntiAliasB2DDraw;
 
 public:
     SystemDependentData_CairoPath(
         basegfx::SystemDependentDataManager& rSystemDependentDataManager,
-        cairo_path_t* pCairoPath);
+        cairo_path_t* pCairoPath,
+        bool bNoJoin,
+        bool bAntiAliasB2DDraw);
     virtual ~SystemDependentData_CairoPath() override;
 
     cairo_path_t* getCairoPath() { return mpCairoPath; }
-
-    bool getPixelSnapHairline() const { return mbPixelSnapHairline; }
-    void setPixelSnapHairline(bool bNew) { mbPixelSnapHairline = bNew; }
+    bool getNoJoin() const { return mbNoJoin; }
+    bool getAntiAliasB2DDraw() const { return mbAntiAliasB2DDraw; }
 };
 
 SystemDependentData_CairoPath::SystemDependentData_CairoPath(
     basegfx::SystemDependentDataManager& rSystemDependentDataManager,
-    cairo_path_t* pCairoPath)
+    cairo_path_t* pCairoPath,
+    bool bNoJoin,
+    bool bAntiAliasB2DDraw)
 :   basegfx::SystemDependentData(rSystemDependentDataManager),
     mpCairoPath(pCairoPath),
-    mbPixelSnapHairline(false)
+    mbNoJoin(bNoJoin),
+    mbAntiAliasB2DDraw(bAntiAliasB2DDraw)
 {
 }
 
@@ -1245,7 +1254,8 @@ bool SvpSalGraphics::drawPolyLine(
     {
         // check data validity
         if(nullptr == pSystemDependentData_CairoPath->getCairoPath()
-            || pSystemDependentData_CairoPath->getPixelSnapHairline() != bPixelSnapHairline)
+            || pSystemDependentData_CairoPath->getNoJoin() != bNoJoin
+            || pSystemDependentData_CairoPath->getAntiAliasB2DDraw() != bAntiAliasB2DDraw)
         {
             // data invalid, forget
             pSystemDependentData_CairoPath.reset();
@@ -1302,10 +1312,9 @@ bool SvpSalGraphics::drawPolyLine(
         // copy and add to buffering mechanism
         pSystemDependentData_CairoPath = rPolyLine.addOrReplaceSystemDependentData<SystemDependentData_CairoPath>(
             ImplGetSystemDependentDataManager(),
-            cairo_copy_path(cr));
-
-        // fill data of buffered data
-        pSystemDependentData_CairoPath->setPixelSnapHairline(bPixelSnapHairline);
+            cairo_copy_path(cr),
+            bNoJoin,
+            bAntiAliasB2DDraw);
     }
 
     // extract extents
@@ -1415,7 +1424,9 @@ bool SvpSalGraphics::drawPolyPolygon(
         // for decisions how/what to buffer, see Note in WinSalGraphicsImpl::drawPolyPolygon
         pSystemDependentData_CairoPath = rPolyPolygon.addOrReplaceSystemDependentData<SystemDependentData_CairoPath>(
             ImplGetSystemDependentDataManager(),
-            cairo_copy_path(cr));
+            cairo_copy_path(cr),
+            false,
+            false);
     }
 
     // To make releaseCairoContext work, use empty extents
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index ba861f02e497..11da33eebf18 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -159,7 +159,7 @@ namespace
                     maTimer->Start();
                 }
 
-                maEntries[rData] = rData->getHoldCycles();
+                maEntries[rData] = rData->getHoldCyclesInSeconds();
             }
         }
 
@@ -186,7 +186,7 @@ namespace
 
             if(aFound != maEntries.end())
             {
-                aFound->second = rData->getHoldCycles();
+                aFound->second = rData->getHoldCyclesInSeconds();
             }
         }
 
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 04d8709f476d..d525b7bc1a4e 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -1650,26 +1650,45 @@ bool X11SalGraphicsImpl::drawFilledTriangles(
 class SystemDependentData_Triangulation : public basegfx::SystemDependentData
 {
 private:
+    // the triangulation itself
     basegfx::triangulator::B2DTriangleVector    maTriangles;
+
+    // all other values the triangulation is based on and
+    // need to be compared with to check for data validity
     basegfx::B2DVector                          maLineWidth;
+    basegfx::B2DLineJoin                        meJoin;
+    css::drawing::LineCap                       meCap;
+    double                                      mfMiterMinimumAngle;
 
 public:
     SystemDependentData_Triangulation(
         basegfx::SystemDependentDataManager& rSystemDependentDataManager,
         const basegfx::triangulator::B2DTriangleVector& rTriangles,
-        const basegfx::B2DVector& rLineWidth);
+        const basegfx::B2DVector& rLineWidth,
+        basegfx::B2DLineJoin eJoin,
+        css::drawing::LineCap eCap,
+        double fMiterMinimumAngle);
 
     const basegfx::triangulator::B2DTriangleVector& getTriangles() const { return maTriangles; }
     const basegfx::B2DVector& getLineWidth() const { return maLineWidth; }
+    const basegfx::B2DLineJoin& getJoin() const { return meJoin; }
+    const css::drawing::LineCap& getCap() const { return meCap; }
+    double getMiterMinimumAngle() const { return mfMiterMinimumAngle; }
 };
 
 SystemDependentData_Triangulation::SystemDependentData_Triangulation(
     basegfx::SystemDependentDataManager& rSystemDependentDataManager,
     const basegfx::triangulator::B2DTriangleVector& rTriangles,
-    const basegfx::B2DVector& rLineWidth)
+    const basegfx::B2DVector& rLineWidth,
+    basegfx::B2DLineJoin eJoin,
+    css::drawing::LineCap eCap,
+    double fMiterMinimumAngle)
 :   basegfx::SystemDependentData(rSystemDependentDataManager),
     maTriangles(rTriangles),
-    maLineWidth(rLineWidth)
+    maLineWidth(rLineWidth),
+    meJoin(eJoin),
+    meCap(eCap),
+    mfMiterMinimumAngle(fMiterMinimumAngle)
 {
 }
 
@@ -1715,7 +1734,19 @@ bool X11SalGraphicsImpl::drawPolyLine(
 
     if(pSystemDependentData_Triangulation)
     {
-        // check data validity
+        // check data validity (I)
+        if(pSystemDependentData_Triangulation->getJoin() != eLineJoin
+        || pSystemDependentData_Triangulation->getCap() != eLineCap
+        || pSystemDependentData_Triangulation->getMiterMinimumAngle() != fMiterMinimumAngle)
+        {
+            // data invalid, forget
+            pSystemDependentData_Triangulation.reset();
+        }
+    }
+
+    if(pSystemDependentData_Triangulation)
+    {
+        // check data validity (II)
         if(pSystemDependentData_Triangulation->getLineWidth() != aLineWidth)
         {
             // sometimes small inconsistencies, use a percentage tolerance
@@ -1773,11 +1804,16 @@ bool X11SalGraphicsImpl::drawPolyLine(
 
         if(!aTriangles.empty())
         {
-            // add to buffering mechanism
+            // Add to buffering mechanism
+            // Add all values the triangulation is based off, too, to check for
+            // validity (see above)
             pSystemDependentData_Triangulation = rPolygon.addOrReplaceSystemDependentData<SystemDependentData_Triangulation>(
                 ImplGetSystemDependentDataManager(),
                 aTriangles,
-                aLineWidth);
+                aLineWidth,
+                eLineJoin,
+                eLineCap,
+                fMiterMinimumAngle);
         }
     }
 
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index d23adf3f47d8..71c5fce6ab0d 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -1953,25 +1953,33 @@ void impAddB2DPolygonToGDIPlusGraphicsPathReal(
 class SystemDependentData_GraphicsPath : public basegfx::SystemDependentData
 {
 private:
+    // the path data itself
     Gdiplus::GraphicsPath           maGraphicsPath;
-    bool                            mbPixelSnapHairline;
+
+    // all other values the triangulation is based on and
+    // need to be compared with to check for data validity
+    bool                            mbNoLineJoin;
 
 public:
     SystemDependentData_GraphicsPath(
-        basegfx::SystemDependentDataManager& rSystemDependentDataManager);
+        basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+        bool bNoLineJoin);
     virtual ~SystemDependentData_GraphicsPath() override;
 
+    // non-const getter to allow manipulation. That way, we do not need
+    // to copy it (with unknown costs)
     Gdiplus::GraphicsPath& getGraphicsPath() { return maGraphicsPath; }
 
-    bool getPixelSnapHairline() const { return mbPixelSnapHairline; }
-    void setPixelSnapHairline(bool bNew) { mbPixelSnapHairline = bNew; }
+    // other data-validity access
+    bool getNoLineJoin() const { return mbNoLineJoin; }
 };
 
 SystemDependentData_GraphicsPath::SystemDependentData_GraphicsPath(
-    basegfx::SystemDependentDataManager& rSystemDependentDataManager)
+    basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+    bool bNoLineJoin)
 :   basegfx::SystemDependentData(rSystemDependentDataManager),
     maGraphicsPath(),
-    mbPixelSnapHairline(false)
+    mbNoLineJoin(bNoLineJoin)
 {
 }
 
@@ -1979,6 +1987,151 @@ SystemDependentData_GraphicsPath::~SystemDependentData_GraphicsPath()
 {
 }
 
+bool WinSalGraphicsImpl::drawPolyPolygon(
+    const basegfx::B2DHomMatrix& rObjectToDevice,
+    const basegfx::B2DPolyPolygon& rPolyPolygon,
+    double fTransparency)
+{
+    const sal_uInt32 nCount(rPolyPolygon.count());
+
+    if(!mbBrush || 0 == nCount || fTransparency < 0.0 || fTransparency > 1.0)
+    {
+        return true;
+    }
+
+    Gdiplus::Graphics aGraphics(mrParent.getHDC());
+    const sal_uInt8 aTrans(sal_uInt8(255) - static_cast<sal_uInt8>(basegfx::fround(fTransparency * 255.0)));
+    const Gdiplus::Color aTestColor(aTrans, maFillColor.GetRed(), maFillColor.GetGreen(), maFillColor.GetBlue());
+    const Gdiplus::SolidBrush aSolidBrush(aTestColor.GetValue());
+
+    // Set full (Object-to-Device) transformation - if used
+    if(rObjectToDevice.isIdentity())
+    {
+        aGraphics.ResetTransform();
+    }
+    else
+    {
+        Gdiplus::Matrix aMatrix;
+
+        aMatrix.SetElements(
+            rObjectToDevice.get(0, 0),
+            rObjectToDevice.get(1, 0),
+            rObjectToDevice.get(0, 1),
+            rObjectToDevice.get(1, 1),
+            rObjectToDevice.get(0, 2),
+            rObjectToDevice.get(1, 2));
+        aGraphics.SetTransform(&aMatrix);
+    }
+
+    // try to access buffered data
+    std::shared_ptr<SystemDependentData_GraphicsPath> pSystemDependentData_GraphicsPath(
+        rPolyPolygon.getSystemDependentData<SystemDependentData_GraphicsPath>());
+
+    if(!pSystemDependentData_GraphicsPath)
+    {
+        // add to buffering mechanism
+        pSystemDependentData_GraphicsPath = rPolyPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
+            ImplGetSystemDependentDataManager(),
+            false);
+
+        // Note: In principle we could use the same buffered geometry at line
+        // and fill polygons. Checked that in a first try, used
+        // GraphicsPath::AddPath from Gdiplus combined with below used
+        // StartFigure/CloseFigure, worked well (thus the line-draw version
+        // may create non-closed partial Polygon data).
+        //
+        // But in current reality it gets not used due to e.g.
+        // SdrPathPrimitive2D::create2DDecomposition creating transformed
+        // line and fill polygon-primitives (what could be changed).
+        //
+        // There will probably be more hindrances here in other rendering paths
+        // which could all be found - intention to do this would be: Use more
+        // transformations, less modifications of B2DPolygons/B2DPolyPolygons.
+        //
+        // A fix for SdrPathPrimitive2D would be to create the sub-geometry
+        // and embed into a TransformPrimitive2D containing the transformation.
+        //
+        // A 2nd problem is that the NoLineJoin mode (basegfx::B2DLineJoin::NONE
+        // && rLineWidths > 0.0) creates polygon fill infos that are not reusable
+        // for the fill case (see ::drawPolyLine below) - thus we would need a
+        // bool and/or two system-dependent paths buffered - doable, but complicated.
+        //
+        // All in all: Make B2DPolyPolygon a SystemDependentDataProvider and buffer
+        // the whole to-be-filled PolyPolygon independent from evtl. line-polygon
+        // (at least for now...)
+
+        // create data
+        for(sal_uInt32 a(0); a < nCount; a++)
+        {
+            if(0 != a)
+            {
+                // #i101491# not needed for first run
+                pSystemDependentData_GraphicsPath->getGraphicsPath().StartFigure();
+            }
+
+            impAddB2DPolygonToGDIPlusGraphicsPathReal(
+                pSystemDependentData_GraphicsPath->getGraphicsPath(),
+                rPolyPolygon.getB2DPolygon(a),
+                rObjectToDevice, // not used due to the two 'false' values below, but to not forget later
+                false,
+                false);
+
+            pSystemDependentData_GraphicsPath->getGraphicsPath().CloseFigure();
+        }
+    }
+
+    if(mrParent.getAntiAliasB2DDraw())
+    {
+        aGraphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
+    }
+    else
+    {
+        aGraphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
+    }
+
+    if(mrParent.isPrinter())
+    {
+        // #i121591#
+        // Normally GdiPlus should not be used for printing at all since printers cannot
+        // print transparent filled polygon geometry and normally this does not happen
+        // since OutputDevice::RemoveTransparenciesFromMetaFile is used as preparation
+        // and no transparent parts should remain for printing. But this can be overridden
+        // by the user and thus happens. This call can only come (currently) from
+        // OutputDevice::DrawTransparent, see comments there with the same TaskID.
+        // If it is used, the mapping for the printer is wrong and needs to be corrected. I
+        // checked that there is *no* transformation set and estimated that a stable factor
+        // dependent of the printer's DPI is used. Create and set a transformation here to
+        // correct this.
+        const Gdiplus::REAL aDpiX(aGraphics.GetDpiX());
+        const Gdiplus::REAL aDpiY(aGraphics.GetDpiY());
+
+        // Now the transformation maybe/is already used (see above), so do
+        // modify it without resetting to not destroy it.
+        // I double-checked with MS docu that Gdiplus::MatrixOrderAppend does what
+        // we need - in our notation, would be a multiply from left to execute
+        // current transform first and this scale last.
+        // I tried to trigger this code using Print from the menu and various
+        // targets, but got no hit, thus maybe obsolete anyways. If someone knows
+        // more, feel free to remove it.
+        // One more hint: This *may* also be needed now in ::drawPolyLine below
+        // since it also uses transformations now.
+        //
+        // aGraphics.ResetTransform();
+
+        aGraphics.ScaleTransform(
+            Gdiplus::REAL(100.0) / aDpiX,
+            Gdiplus::REAL(100.0) / aDpiY,
+            Gdiplus::MatrixOrderAppend);
+    }
+
+    // use created or buffered data
+    aGraphics.FillPath(
+        &aSolidBrush,
+        &pSystemDependentData_GraphicsPath->getGraphicsPath());
+
+    return true;
+}
+
 bool WinSalGraphicsImpl::drawPolyLine(
     const basegfx::B2DHomMatrix& rObjectToDevice,
     const basegfx::B2DPolygon& rPolygon,
@@ -2082,7 +2235,7 @@ bool WinSalGraphicsImpl::drawPolyLine(
     if(pSystemDependentData_GraphicsPath)
     {
         // check data validity
-        if(pSystemDependentData_GraphicsPath->getPixelSnapHairline() != bPixelSnapHairline)
+        if(pSystemDependentData_GraphicsPath->getNoLineJoin() != bNoLineJoin)
         {
             // data invalid, forget
             pSystemDependentData_GraphicsPath.reset();
@@ -2093,11 +2246,10 @@ bool WinSalGraphicsImpl::drawPolyLine(
     {
         // add to buffering mechanism
         pSystemDependentData_GraphicsPath = rPolygon.addOrReplaceSystemDependentData<SystemDependentData_GraphicsPath>(
-            ImplGetSystemDependentDataManager());
+            ImplGetSystemDependentDataManager(),
+            bNoLineJoin);
 
         // fill data of buffered data
-        pSystemDependentData_GraphicsPath->setPixelSnapHairline(bPixelSnapHairline);
-
         impAddB2DPolygonToGDIPlusGraphicsPathReal(
             pSystemDependentData_GraphicsPath->getGraphicsPath(),
             rPolygon,
commit 9db99326a8227165e19c67f3e10ad71150b4813d
Author:     Armin Le Grand <Armin.Le.Grand at cib.de>
AuthorDate: Sat Sep 15 13:48:12 2018 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:47 2018 +0100

    Support buffering SystemDependent GraphicData (III)
    
    This change is for speedup of fat line drawing when using
    X11. This is a long-term problem which never really progressed,
    but is avoided using Cairo in the future. Still - if used,
    speedup using current state and buffering possibilities.
    
    Two speedup steps will be used:
    (1) The tesselation is no longer done using trapezoids. That
    works (but was done wrong leaving artifacts) but is not fast
    and done every time. It is even not done with FatLines and
    more than 1000 points.
    New version will use triangulation. Dspite using the existing
    triangulator (that works but is slow) extend the FatLine
    geometry creator to directly create triangles.
    This is also necessary since for buffering that data a
    transformation-invariant version is needed (in device coordinates
    the data changes all the time when scrolling). Trapezoids are
    by definition *not* transformation-invariant (e.g. rotation)
    
    (2) Buffer that triangulation - with the needed care and watch.
    It is e.g. necessary to react on 'hairlines' since these change
    their logical LineWidth view-dependent (zoom). In those cases, the
    buffered data *has* to be removed due to the base for buffering is
    the created FatLine geometry based on one stable logical LineWidth
    
    Also took the time to adapt B2DPolygonTriangulator to use an
    own data type (B2DTriangle) and a vector of these for better
    understandability and security. Adapted all usages as needed.
    
    Change-Id: Iedb2932b094a8786fd9c32d0d0ab1ca603a1a7b2
    Reviewed-on: https://gerrit.libreoffice.org/60818
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>

diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx
index ca4b88238383..78f569970df3 100644
--- a/basegfx/source/polygon/b2dlinegeometry.cxx
+++ b/basegfx/source/polygon/b2dlinegeometry.cxx
@@ -30,6 +30,7 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <com/sun/star/drawing/LineCap.hpp>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <basegfx/polygon/b2dpolygontriangulator.hxx>
 
 namespace basegfx
 {
@@ -337,7 +338,8 @@ namespace basegfx
             bool bStartRound,
             bool bEndRound,
             bool bStartSquare,
-            bool bEndSquare)
+            bool bEndSquare,
+            basegfx::triangulator::B2DTriangleVector* pTriangles)
         {
             // create polygon for edge
             // Unfortunately, while it would be geometrically correct to not add
@@ -566,6 +568,15 @@ namespace basegfx
                     }
                 }
 
+                if(nullptr != pTriangles)
+                {
+                    const basegfx::triangulator::B2DTriangleVector aResult(
+                        basegfx::triangulator::triangulate(
+                            aBezierPolygon));
+                    pTriangles->insert(pTriangles->end(), aResult.begin(), aResult.end());
+                    aBezierPolygon.clear();
+                }
+
                 // return
                 return aBezierPolygon;
             }
@@ -664,6 +675,15 @@ namespace basegfx
                 // close and return
                 aEdgePolygon.setClosed(true);
 
+                if(nullptr != pTriangles)
+                {
+                    const basegfx::triangulator::B2DTriangleVector aResult(
+                        basegfx::triangulator::triangulate(
+                            aEdgePolygon));
+                    pTriangles->insert(pTriangles->end(), aResult.begin(), aResult.end());
+                    aEdgePolygon.clear();
+                }
+
                 return aEdgePolygon;
             }
         }
@@ -676,7 +696,8 @@ namespace basegfx
             const B2DPoint& rPoint,
             double fHalfLineWidth,
             B2DLineJoin eJoin,
-            double fMiterMinimumAngle)
+            double fMiterMinimumAngle,
+            basegfx::triangulator::B2DTriangleVector* pTriangles)
         {
             OSL_ENSURE(fHalfLineWidth > 0.0, "createAreaGeometryForJoin: LineWidth too small (!)");
             OSL_ENSURE(eJoin != B2DLineJoin::NONE, "createAreaGeometryForJoin: B2DLineJoin::NONE not allowed (!)");
@@ -703,9 +724,19 @@ namespace basegfx
             {
                 case B2DLineJoin::Miter :
                 {
-                    aEdgePolygon.append(aEndPoint);
-                    aEdgePolygon.append(rPoint);
-                    aEdgePolygon.append(aStartPoint);
+                    if(nullptr != pTriangles)
+                    {
+                        pTriangles->emplace_back(
+                            aEndPoint,
+                            rPoint,
+                            aStartPoint);
+                    }
+                    else
+                    {
+                        aEdgePolygon.append(aEndPoint);
+                        aEdgePolygon.append(rPoint);
+                        aEdgePolygon.append(aStartPoint);
+                    }
 
                     // Look for the cut point between start point along rTangentPrev and
                     // end point along rTangentEdge. -rTangentEdge should be used, but since
@@ -718,7 +749,18 @@ namespace basegfx
                     if(fCutPos != 0.0)
                     {
                         const B2DPoint aCutPoint(aStartPoint + (rTangentPrev * fCutPos));
-                        aEdgePolygon.append(aCutPoint);
+
+                        if(nullptr != pTriangles)
+                        {
+                            pTriangles->emplace_back(
+                                aStartPoint,
+                                aCutPoint,
+                                aEndPoint);
+                        }
+                        else
+                        {
+                            aEdgePolygon.append(aCutPoint);
+                        }
                     }
 
                     break;
@@ -744,14 +786,27 @@ namespace basegfx
 
                     if(aBow.count() > 1)
                     {
-                        // #i101491#
-                        // use the original start/end positions; the ones from bow creation may be numerically
-                        // different due to their different creation. To guarantee good merging quality with edges
-                        // and edge roundings (and to reduce point count)
-                        aEdgePolygon = aBow;
-                        aEdgePolygon.setB2DPoint(0, aStartPoint);
-                        aEdgePolygon.setB2DPoint(aEdgePolygon.count() - 1, aEndPoint);
-                        aEdgePolygon.append(rPoint);
+                        if(nullptr != pTriangles)
+                        {
+                            for(sal_uInt32 a(0); a < aBow.count() - 1; a++)
+                            {
+                                pTriangles->emplace_back(
+                                    0 == a ? aStartPoint : aBow.getB2DPoint(a),
+                                    rPoint,
+                                    aBow.count() - 1 == a + 1 ? aEndPoint : aBow.getB2DPoint(a + 1));
+                            }
+                        }
+                        else
+                        {
+                            // #i101491#
+                            // use the original start/end positions; the ones from bow creation may be numerically
+                            // different due to their different creation. To guarantee good merging quality with edges
+                            // and edge roundings (and to reduce point count)
+                            aEdgePolygon = aBow;
+                            aEdgePolygon.setB2DPoint(0, aStartPoint);
+                            aEdgePolygon.setB2DPoint(aEdgePolygon.count() - 1, aEndPoint);
+                            aEdgePolygon.append(rPoint);
+                        }
 
                         break;
                     }
@@ -762,9 +817,19 @@ namespace basegfx
                 }
                 default: // B2DLineJoin::Bevel
                 {
-                    aEdgePolygon.append(aEndPoint);
-                    aEdgePolygon.append(rPoint);
-                    aEdgePolygon.append(aStartPoint);
+                    if(nullptr != pTriangles)
+                    {
+                        pTriangles->emplace_back(
+                            aEndPoint,
+                            rPoint,
+                            aStartPoint);
+                    }
+                    else
+                    {
+                        aEdgePolygon.append(aEndPoint);
+                        aEdgePolygon.append(rPoint);
+                        aEdgePolygon.append(aStartPoint);
+                    }
 
                     break;
                 }
@@ -786,7 +851,8 @@ namespace basegfx
             css::drawing::LineCap eCap,
             double fMaxAllowedAngle,
             double fMaxPartOfEdge,
-            double fMiterMinimumAngle)
+            double fMiterMinimumAngle,
+            basegfx::triangulator::B2DTriangleVector* pTriangles)
         {
             if(fMaxAllowedAngle > F_PI2)
             {
@@ -895,7 +961,8 @@ namespace basegfx
                                         aEdge.getStartPoint(),
                                         fHalfLineWidth,
                                         eJoin,
-                                        fMiterMinimumAngle));
+                                        fMiterMinimumAngle,
+                                        pTriangles));
                             }
                             else if(aOrientation == B2VectorOrientation::Negative)
                             {
@@ -911,7 +978,8 @@ namespace basegfx
                                         aEdge.getStartPoint(),
                                         fHalfLineWidth,
                                         eJoin,
-                                        fMiterMinimumAngle));
+                                        fMiterMinimumAngle,
+                                        pTriangles));
                             }
                         }
 
@@ -929,7 +997,8 @@ namespace basegfx
                                     bFirst && eCap == css::drawing::LineCap_ROUND,
                                     bLast && eCap == css::drawing::LineCap_ROUND,
                                     bFirst && eCap == css::drawing::LineCap_SQUARE,
-                                    bLast && eCap == css::drawing::LineCap_SQUARE));
+                                    bLast && eCap == css::drawing::LineCap_SQUARE,
+                                    pTriangles));
                         }
                         else
                         {
@@ -940,7 +1009,8 @@ namespace basegfx
                                     false,
                                     false,
                                     false,
-                                    false));
+                                    false,
+                                    pTriangles));
                         }
 
                         // prepare next step
@@ -958,10 +1028,22 @@ namespace basegfx
                 else
                 {
                     // point count, but no edge count -> single point
-                    aRetval.append(
+                    const basegfx::B2DPolygon aCircle(
                         createPolygonFromCircle(
                             aCandidate.getB2DPoint(0),
                             fHalfLineWidth));
+
+                    if(nullptr != pTriangles)
+                    {
+                        const basegfx::triangulator::B2DTriangleVector aResult(
+                            basegfx::triangulator::triangulate(
+                                aCircle));
+                        pTriangles->insert(pTriangles->end(), aResult.begin(), aResult.end());
+                    }
+                    else
+                    {
+                        aRetval.append(aCircle);
+                    }
                 }
 
                 return aRetval;
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index db3365eee313..9b2406074a71 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -2133,7 +2133,9 @@ namespace basegfx
             return ((fCrossA > 0.0) == (fCrossB > 0.0));
         }
 
-        void addTriangleFan(const B2DPolygon& rCandidate, B2DPolygon& rTarget)
+        void addTriangleFan(
+            const B2DPolygon& rCandidate,
+            triangulator::B2DTriangleVector& rTarget)
         {
             const sal_uInt32 nCount(rCandidate.count());
 
@@ -2145,9 +2147,10 @@ namespace basegfx
                 for(sal_uInt32 a(2); a < nCount; a++)
                 {
                     const B2DPoint aCurrent(rCandidate.getB2DPoint(a));
-                    rTarget.append(aStart);
-                    rTarget.append(aLast);
-                    rTarget.append(aCurrent);
+                    rTarget.emplace_back(
+                        aStart,
+                        aLast,
+                        aCurrent);
 
                     // prepare next
                     aLast = aCurrent;
diff --git a/basegfx/source/polygon/b2dpolygontriangulator.cxx b/basegfx/source/polygon/b2dpolygontriangulator.cxx
index ab97419144d4..c24a78f579b8 100644
--- a/basegfx/source/polygon/b2dpolygontriangulator.cxx
+++ b/basegfx/source/polygon/b2dpolygontriangulator.cxx
@@ -110,7 +110,7 @@ namespace basegfx
             EdgeEntry*                                      mpList;
             EdgeEntries                                     maStartEntries;
             std::vector< std::unique_ptr<EdgeEntry> >       maNewEdgeEntries;
-            B2DPolygon                                      maResult;
+            triangulator::B2DTriangleVector                 maResult;
 
             void handleClosingEdge(const B2DPoint& rStart, const B2DPoint& rEnd);
             bool CheckPointInTriangle(EdgeEntry* pEdgeA, EdgeEntry const * pEdgeB, const B2DPoint& rTestPoint);
@@ -119,7 +119,7 @@ namespace basegfx
         public:
             explicit Triangulator(const B2DPolyPolygon& rCandidate);
 
-            const B2DPolygon& getResult() const { return maResult; }
+            const triangulator::B2DTriangleVector& getResult() const { return maResult; }
         };
 
         void Triangulator::handleClosingEdge(const B2DPoint& rStart, const B2DPoint& rEnd)
@@ -203,9 +203,10 @@ namespace basegfx
 
         void Triangulator::createTriangle(const B2DPoint& rA, const B2DPoint& rB, const B2DPoint& rC)
         {
-            maResult.append(rA);
-            maResult.append(rB);
-            maResult.append(rC);
+            maResult.emplace_back(
+                rA,
+                rB,
+                rC);
         }
 
         // consume as long as there are edges
@@ -370,9 +371,9 @@ namespace basegfx
 {
     namespace triangulator
     {
-        B2DPolygon triangulate(const B2DPolygon& rCandidate)
+        B2DTriangleVector triangulate(const B2DPolygon& rCandidate)
         {
-            B2DPolygon aRetval;
+            B2DTriangleVector aRetval;
 
             // subdivide locally (triangulate does not work with beziers), remove double and neutral points
             B2DPolygon aCandidate(rCandidate.areControlPointsUsed() ? utils::adaptiveSubdivideByAngle(rCandidate) : rCandidate);
@@ -382,7 +383,10 @@ namespace basegfx
             if(aCandidate.count() == 2)
             {
                 // candidate IS a triangle, just append
-                aRetval.append(aCandidate);
+                aRetval.emplace_back(
+                    aCandidate.getB2DPoint(0),
+                    aCandidate.getB2DPoint(1),
+                    aCandidate.getB2DPoint(2));
             }
             else if(aCandidate.count() > 2)
             {
@@ -396,6 +400,7 @@ namespace basegfx
                     // polygon is concave.
                     const B2DPolyPolygon aCandPolyPoly(aCandidate);
                     Triangulator aTriangulator(aCandPolyPoly);
+
                     aRetval = aTriangulator.getResult();
                 }
             }
@@ -403,9 +408,9 @@ namespace basegfx
             return aRetval;
         }
 
-        B2DPolygon triangulate(const B2DPolyPolygon& rCandidate)
+        B2DTriangleVector triangulate(const B2DPolyPolygon& rCandidate)
         {
-            B2DPolygon aRetval;
+            B2DTriangleVector aRetval;
 
             // subdivide locally (triangulate does not work with beziers)
             B2DPolyPolygon aCandidate(rCandidate.areControlPointsUsed() ? utils::adaptiveSubdivideByAngle(rCandidate) : rCandidate);
@@ -414,11 +419,13 @@ namespace basegfx
             {
                 // single polygon -> single polygon triangulation
                 const B2DPolygon aSinglePolygon(aCandidate.getB2DPolygon(0));
+
                 aRetval = triangulate(aSinglePolygon);
             }
             else
             {
                 Triangulator aTriangulator(aCandidate);
+
                 aRetval = aTriangulator.getResult();
             }
 
diff --git a/canvas/source/opengl/ogl_canvascustomsprite.cxx b/canvas/source/opengl/ogl_canvascustomsprite.cxx
index 5f53ab4ece46..3cb5ec9fe217 100644
--- a/canvas/source/opengl/ogl_canvascustomsprite.cxx
+++ b/canvas/source/opengl/ogl_canvascustomsprite.cxx
@@ -191,18 +191,35 @@ namespace oglcanvas
                     const double fHeight=maSize.Height;
 
                     // TODO(P3): buffer triangulation
-                    const ::basegfx::B2DPolygon& rTriangulatedPolygon(
+                    const ::basegfx::triangulator::B2DTriangleVector rTriangulatedPolygon(
                         ::basegfx::triangulator::triangulate(
                             ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(mxClip)));
 
                     glBegin(GL_TRIANGLES);
-                    for( sal_uInt32 i=0; i<rTriangulatedPolygon.count(); i++ )
+                    for( size_t i=0; i<rTriangulatedPolygon.size(); i++ )
                     {
-                        const ::basegfx::B2DPoint& rPt( rTriangulatedPolygon.getB2DPoint(i) );
-                        const double s(rPt.getX()/fWidth);
-                        const double t(rPt.getY()/fHeight);
-                        glTexCoord2f(s,t); glVertex2d(rPt.getX(), rPt.getY());
-                    }
+                        const::basegfx::triangulator::B2DTriangle& rCandidate(rTriangulatedPolygon[i]);
+                        glTexCoord2f(
+                            rCandidate.getA().getX()/fWidth,
+                            rCandidate.getA().getY()/fHeight);
+                        glVertex2d(
+                            rCandidate.getA().getX(),
+                            rCandidate.getA().getY());
+
+                        glTexCoord2f(
+                            rCandidate.getB().getX()/fWidth,
+                            rCandidate.getB().getY()/fHeight);
+                        glVertex2d(
+                            rCandidate.getB().getX(),
+                            rCandidate.getB().getY());
+
+                        glTexCoord2f(
+                            rCandidate.getC().getX()/fWidth,
+                            rCandidate.getC().getY()/fHeight);
+                        glVertex2d(
+                            rCandidate.getC().getX(),
+                            rCandidate.getC().getY());
+                     }
                     glEnd();
                 }
                 else
diff --git a/canvas/source/opengl/ogl_canvastools.cxx b/canvas/source/opengl/ogl_canvastools.cxx
index cbf20db3a1e5..56fa47fbf303 100644
--- a/canvas/source/opengl/ogl_canvastools.cxx
+++ b/canvas/source/opengl/ogl_canvastools.cxx
@@ -35,15 +35,32 @@ namespace oglcanvas
         const ::basegfx::B2DRange& rBounds(aPolyPoly.getB2DRange());
         const double nWidth=rBounds.getWidth();
         const double nHeight=rBounds.getHeight();
-        const ::basegfx::B2DPolygon& rTriangulatedPolygon(
+        const ::basegfx::triangulator::B2DTriangleVector rTriangulatedPolygon(
             ::basegfx::triangulator::triangulate(aPolyPoly));
 
-        for( sal_uInt32 i=0; i<rTriangulatedPolygon.count(); i++ )
+        for( size_t i=0; i<rTriangulatedPolygon.size(); i++ )
         {
-            const ::basegfx::B2DPoint& rPt( rTriangulatedPolygon.getB2DPoint(i) );
-            const double s(rPt.getX()/nWidth);
-            const double t(rPt.getY()/nHeight);
-            glTexCoord2f(s,t); glVertex2d(rPt.getX(), rPt.getY());
+            const::basegfx::triangulator::B2DTriangle& rCandidate(rTriangulatedPolygon[i]);
+            glTexCoord2f(
+                rCandidate.getA().getX()/nWidth,
+                rCandidate.getA().getY()/nHeight);
+            glVertex2d(
+                rCandidate.getA().getX(),
+                rCandidate.getA().getY());
+
+            glTexCoord2f(
+                rCandidate.getB().getX()/nWidth,
+                rCandidate.getB().getY()/nHeight);
+            glVertex2d(
+                rCandidate.getB().getX(),
+                rCandidate.getB().getY());
+
+            glTexCoord2f(
+                rCandidate.getC().getX()/nWidth,
+                rCandidate.getC().getY()/nHeight);
+            glVertex2d(
+                rCandidate.getC().getX(),
+                rCandidate.getC().getY());
         }
     }
 
diff --git a/canvas/source/tools/surfaceproxy.cxx b/canvas/source/tools/surfaceproxy.cxx
index 0f4444020360..7ce964ab5770 100644
--- a/canvas/source/tools/surfaceproxy.cxx
+++ b/canvas/source/tools/surfaceproxy.cxx
@@ -110,15 +110,28 @@ namespace canvas
                              const ::basegfx::B2DPolyPolygon& rClipPoly,
                              const ::basegfx::B2DHomMatrix&   rTransform )
     {
-        const ::basegfx::B2DPolygon& rTriangulatedPolygon(
+        const ::basegfx::triangulator::B2DTriangleVector& rTriangulatedVector(
             ::basegfx::triangulator::triangulate(rClipPoly));
 
+        // we have now an explicit ::B2DTriangle and ::B2DTriangleVector,
+        // but I do not know enough about 'drawWithClip' or 'clipTriangleListOnRange'
+        // to adapt to that. Convert back to old three-point-in-polygon convention
+        ::basegfx::B2DPolygon aTriangulatedPolygon;
+        aTriangulatedPolygon.reserve(rTriangulatedVector.size() * 3);
+
+        for(const auto& rCandidate : rTriangulatedVector)
+        {
+            aTriangulatedPolygon.append(rCandidate.getA());
+            aTriangulatedPolygon.append(rCandidate.getB());
+            aTriangulatedPolygon.append(rCandidate.getC());
+        }
+
         // dump polygons
         SAL_INFO("canvas", "Original clip polygon: " <<  basegfx::utils::exportToSvgD( rClipPoly, true, true, false ));
-        SAL_INFO("canvas", "Triangulated polygon: " <<  basegfx::utils::exportToSvgD(basegfx::B2DPolyPolygon(rTriangulatedPolygon), true, true, false ));
+        SAL_INFO("canvas", "Triangulated polygon: " <<  basegfx::utils::exportToSvgD(basegfx::B2DPolyPolygon(aTriangulatedPolygon), true, true, false ));
 
         for( const auto& rSurfacePtr : maSurfaceList )
-            rSurfacePtr->drawWithClip( fAlpha, rPos, rTriangulatedPolygon, rTransform );
+            rSurfacePtr->drawWithClip( fAlpha, rPos, aTriangulatedPolygon, rTransform );
 
         return true;
     }
diff --git a/include/basegfx/polygon/b2dlinegeometry.hxx b/include/basegfx/polygon/b2dlinegeometry.hxx
index 29be9934ede0..cdfad4a0ddc5 100644
--- a/include/basegfx/polygon/b2dlinegeometry.hxx
+++ b/include/basegfx/polygon/b2dlinegeometry.hxx
@@ -26,7 +26,7 @@
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <com/sun/star/drawing/LineCap.hpp>
 #include <basegfx/basegfxdllapi.h>
-
+#include <basegfx/polygon/b2dpolygontriangulator.hxx>
 
 namespace basegfx
 {
@@ -124,6 +124,10 @@ namespace basegfx
             the usual fallback to bevel is used. Allowed range is cropped
             to [F_PI .. 0.01 * F_PI].
 
+            @param pTriangles
+            If given, the methjod will additionally add the created geometry as
+            B2DTriangle's
+
             @return
             The tools::PolyPolygon containing the geometry of the extended line by
             it's line width. Contains bezier segments and edge roundings as
@@ -136,7 +140,8 @@ namespace basegfx
             css::drawing::LineCap eCap,
             double fMaxAllowedAngle = basegfx::deg2rad(12.5),
             double fMaxPartOfEdge = 0.4,
-            double fMiterMinimumAngle = basegfx::deg2rad(15.0));
+            double fMiterMinimumAngle = basegfx::deg2rad(15.0),
+            basegfx::triangulator::B2DTriangleVector* pTriangles = nullptr);
 
     } // end of namespace utils
 } // end of namespace basegfx
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx
index 039000f053d1..62430d323cef 100644
--- a/include/basegfx/polygon/b2dpolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolygontools.hxx
@@ -25,6 +25,7 @@
 #include <basegfx/range/b2drectangle.hxx>
 #include <basegfx/polygon/b2dpolypolygon.hxx>
 #include <basegfx/polygon/b3dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontriangulator.hxx>
 #include <com/sun/star/drawing/PointSequence.hpp>
 #include <com/sun/star/drawing/FlagSequence.hpp>
 #include <vector>
@@ -356,7 +357,9 @@ namespace basegfx
         // add triangles for given rCandidate to rTarget. For each triangle, 3 points will be added to rCandidate.
         // All triangles will go from the start point of rCandidate to two consecutive points, building (rCandidate.count() - 2)
         // triangles.
-        BASEGFX_DLLPUBLIC void addTriangleFan(const B2DPolygon& rCandidate, B2DPolygon& rTarget);
+        BASEGFX_DLLPUBLIC void addTriangleFan(
+            const B2DPolygon& rCandidate,
+            triangulator::B2DTriangleVector& rTarget);
 
         // grow for polygon. Move all geometry in each point in the direction of the normal in that point
         // with the given amount. Value may be negative.
diff --git a/include/basegfx/polygon/b2dpolygontriangulator.hxx b/include/basegfx/polygon/b2dpolygontriangulator.hxx
index d3e92a017d79..7ecb819b3241 100644
--- a/include/basegfx/polygon/b2dpolygontriangulator.hxx
+++ b/include/basegfx/polygon/b2dpolygontriangulator.hxx
@@ -28,11 +28,42 @@ namespace basegfx
 {
     namespace triangulator
     {
+        // Simple B2D-based triangle. Main reason is to
+        // keep the data types separated (before a B2DPolygon
+        // was used with the convention that three points in
+        // a row define a triangle)
+        class BASEGFX_DLLPUBLIC B2DTriangle
+        {
+            // positions
+            basegfx::B2DPoint                       maA;
+            basegfx::B2DPoint                       maB;
+            basegfx::B2DPoint                       maC;
+
+        public:
+            B2DTriangle(
+                const basegfx::B2DPoint& rA,
+                const basegfx::B2DPoint& rB,
+                const basegfx::B2DPoint& rC)
+            :   maA(rA),
+                maB(rB),
+                maC(rC)
+            {
+            }
+
+            // get positions
+            const basegfx::B2DPoint& getA() const { return maA; }
+            const basegfx::B2DPoint& getB() const { return maB; }
+            const basegfx::B2DPoint& getC() const { return maC; }
+        };
+
+        // typedef for a vector of B2DTriangle
+        typedef ::std::vector< B2DTriangle > B2DTriangleVector;
+
         // triangulate given polygon
-        BASEGFX_DLLPUBLIC ::basegfx::B2DPolygon triangulate(const ::basegfx::B2DPolygon& rCandidate);
+        BASEGFX_DLLPUBLIC B2DTriangleVector triangulate(const ::basegfx::B2DPolygon& rCandidate);
 
         // triangulate given PolyPolygon
-        BASEGFX_DLLPUBLIC ::basegfx::B2DPolygon triangulate(const ::basegfx::B2DPolyPolygon& rCandidate);
+        BASEGFX_DLLPUBLIC B2DTriangleVector triangulate(const ::basegfx::B2DPolyPolygon& rCandidate);
 
     } // end of namespace triangulator
 } // end of namespace basegfx
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 6f38718a7daa..04d8709f476d 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -49,6 +49,7 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
 #include <basegfx/polygon/b2dtrapezoid.hxx>
+#include <basegfx/utils/systemdependentdata.hxx>
 #include <ControlCacheKey.hxx>
 
 #undef SALGDI2_TESTTRANS
@@ -1568,6 +1569,110 @@ bool X11SalGraphicsImpl::drawFilledTrapezoids( const basegfx::B2DTrapezoid* pB2D
     return true;
 }
 
+bool X11SalGraphicsImpl::drawFilledTriangles(
+    const basegfx::B2DHomMatrix& rObjectToDevice,
+     const basegfx::triangulator::B2DTriangleVector& rTriangles,
+     double fTransparency,
+     bool bPixelOffset)
+{
+    if(rTriangles.empty())
+        return true;
+
+    Picture aDstPic = GetXRenderPicture();
+    // check xrender support for this drawable
+    if( !aDstPic )
+    {
+        return false;
+    }
+
+    // prepare transformation for ObjectToDevice coordinate system
+    basegfx::B2DHomMatrix aObjectToDevice(rObjectToDevice);
+
+    if(bPixelOffset)
+    {
+        aObjectToDevice = basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5) * aObjectToDevice;
+    }
+
+     // convert the Triangles into XRender-Triangles
+    std::vector<XTriangle> aTriVector(rTriangles.size());
+    sal_uInt32 nIndex(0);
+
+    for(const auto& rCandidate : rTriangles)
+    {
+        const basegfx::B2DPoint aP1(aObjectToDevice * rCandidate.getA());
+        const basegfx::B2DPoint aP2(aObjectToDevice * rCandidate.getB());
+        const basegfx::B2DPoint aP3(aObjectToDevice * rCandidate.getC());
+        XTriangle& rTri(aTriVector[nIndex++]);
+
+        rTri.p1.x = XDoubleToFixed(aP1.getX());
+        rTri.p1.y = XDoubleToFixed(aP1.getY());
+
+        rTri.p2.x = XDoubleToFixed(aP2.getX());
+        rTri.p2.y = XDoubleToFixed(aP2.getY());
+
+        rTri.p3.x = XDoubleToFixed(aP3.getX());
+        rTri.p3.y = XDoubleToFixed(aP3.getY());
+    }
+
+    // get xrender Picture for polygon foreground
+    // TODO: cache it like the target picture which uses GetXRenderPicture()
+    XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
+    SalDisplay::RenderEntry& rEntry = mrParent.GetDisplay()->GetRenderEntries( mrParent.m_nXScreen )[ 32 ];
+    if( !rEntry.m_aPicture )
+    {
+        Display* pXDisplay = mrParent.GetXDisplay();
+
+        rEntry.m_aPixmap = limitXCreatePixmap( pXDisplay, mrParent.hDrawable_, 1, 1, 32 );
+        XRenderPictureAttributes aAttr;
+        aAttr.repeat = int(true);
+
+        XRenderPictFormat* pXRPF = rRenderPeer.FindStandardFormat( PictStandardARGB32 );
+        rEntry.m_aPicture = rRenderPeer.CreatePicture( rEntry.m_aPixmap, pXRPF, CPRepeat, &aAttr );
+    }
+
+    // set polygon foreground color and opacity
+    XRenderColor aRenderColor = GetXRenderColor( mnBrushColor , fTransparency );
+    rRenderPeer.FillRectangle( PictOpSrc, rEntry.m_aPicture, &aRenderColor, 0, 0, 1, 1 );
+
+    // set clipping
+    // TODO: move into GetXRenderPicture?
+    if( mrParent.mpClipRegion && !XEmptyRegion( mrParent.mpClipRegion ) )
+        rRenderPeer.SetPictureClipRegion( aDstPic, mrParent.mpClipRegion );
+
+    // render the trapezoids
+    const XRenderPictFormat* pMaskFormat = rRenderPeer.GetStandardFormatA8();
+    rRenderPeer.CompositeTriangles( PictOpOver,
+        rEntry.m_aPicture, aDstPic, pMaskFormat, 0, 0, &aTriVector[0], aTriVector.size() );
+
+    return true;
+}
+
+class SystemDependentData_Triangulation : public basegfx::SystemDependentData
+{
+private:
+    basegfx::triangulator::B2DTriangleVector    maTriangles;
+    basegfx::B2DVector                          maLineWidth;
+
+public:
+    SystemDependentData_Triangulation(
+        basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+        const basegfx::triangulator::B2DTriangleVector& rTriangles,
+        const basegfx::B2DVector& rLineWidth);
+
+    const basegfx::triangulator::B2DTriangleVector& getTriangles() const { return maTriangles; }
+    const basegfx::B2DVector& getLineWidth() const { return maLineWidth; }
+};
+
+SystemDependentData_Triangulation::SystemDependentData_Triangulation(
+    basegfx::SystemDependentDataManager& rSystemDependentDataManager,
+    const basegfx::triangulator::B2DTriangleVector& rTriangles,
+    const basegfx::B2DVector& rLineWidth)
+:   basegfx::SystemDependentData(rSystemDependentDataManager),
+    maTriangles(rTriangles),
+    maLineWidth(rLineWidth)
+{
+}
+
 bool X11SalGraphicsImpl::drawPolyLine(
     const basegfx::B2DHomMatrix& rObjectToDevice,
     const basegfx::B2DPolygon& rPolygon,
@@ -1578,96 +1683,121 @@ bool X11SalGraphicsImpl::drawPolyLine(
     double fMiterMinimumAngle,
     bool bPixelSnapHairline)
 {
-    // Transform to DeviceCoordinates, get DeviceLineWidth, execute PixelSnapHairline
-    const basegfx::B2DVector aLineWidth(rObjectToDevice * rLineWidth);
-    const bool bIsHairline((aLineWidth.getX() == aLineWidth.getY()) && (aLineWidth.getX() <= 1.2));
-
-    // #i101491#
-    if( !bIsHairline && (rPolygon.count() > 1000) )
+    // short circuit if there is nothing to do
+    if(0 == rPolygon.count() || fTransparency < 0.0 || fTransparency >= 1.0)
     {
-        // the used basegfx::utils::createAreaGeometry is simply too
-        // expensive with very big polygons; fallback to caller (who
-        // should use ImplLineConverter normally)
-        // AW: ImplLineConverter had to be removed since it does not even
-        // know LineJoins, so the fallback will now prepare the line geometry
-        // the same way.
-        return false;
+        return true;
     }
 
-    // Transform to DeviceCoordinates, get DeviceLineWidth, execute PixelSnapHairline
-    basegfx::B2DPolygon aPolyLine(rPolygon);
-    aPolyLine.transform(rObjectToDevice);
-    if(bPixelSnapHairline) { aPolyLine = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyLine); }
+    // need to check/handle LineWidth when ObjectToDevice transformation is used
+    basegfx::B2DVector aLineWidth(rLineWidth);
+    const bool bObjectToDeviceIsIdentity(rObjectToDevice.isIdentity());
+    const basegfx::B2DVector aDeviceLineWidths(bObjectToDeviceIsIdentity ? rLineWidth : rObjectToDevice * rLineWidth);
+    const bool bCorrectLineWidth(!bObjectToDeviceIsIdentity && aDeviceLineWidths.getX() < 1.0 && aLineWidth.getX() >= 1.0);
+    basegfx::B2DHomMatrix aObjectToDeviceInv;
+    basegfx::B2DPolygon aPolygon(rPolygon);
 
-    // temporarily adjust brush color to pen color
-    // since the line is drawn as an area-polygon
-    const Color aKeepBrushColor = mnBrushColor;
-    mnBrushColor = mnPenColor;
+    if(bCorrectLineWidth)
+    {
+        if(aObjectToDeviceInv.isIdentity())
+        {
+            aObjectToDeviceInv = rObjectToDevice;
+            aObjectToDeviceInv.invert();
+        }
 
-    // #i11575#desc5#b adjust B2D tessellation result to raster positions
-    // basegfx::B2DPolygon aPolygon = rPolygon;
-    const double fHalfWidth = 0.5 * aLineWidth.getX();
+        // calculate-back logical LineWidth for a hairline
+        aLineWidth = aObjectToDeviceInv * basegfx::B2DVector(1.0, 1.0);
+    }
 
-    // #i122456# This is probably thought to happen to align hairlines to pixel positions, so
-    // it should be a 0.5 translation, not more. It will definitely go wrong with fat lines
-    aPolyLine.transform( basegfx::utils::createTranslateB2DHomMatrix(0.5, 0.5) );
+    // try to access buffered data
+    std::shared_ptr<SystemDependentData_Triangulation> pSystemDependentData_Triangulation(
+        rPolygon.getSystemDependentData<SystemDependentData_Triangulation>());
 
-    // shortcut for hairline drawing to improve performance
-    bool bDrawnOk = true;
-    if( bIsHairline )
+    if(pSystemDependentData_Triangulation)
     {
-        // hairlines can benefit from a simplified tessellation
-        // e.g. for hairlines the linejoin style can be ignored
-        basegfx::B2DTrapezoidVector aB2DTrapVector;
-        basegfx::utils::createLineTrapezoidFromB2DPolygon( aB2DTrapVector, aPolyLine, aLineWidth.getX() );
-
-        // draw tessellation result
-        const int nTrapCount = aB2DTrapVector.size();
-        if( nTrapCount > 0 )
-            bDrawnOk = drawFilledTrapezoids( &aB2DTrapVector[0], nTrapCount, fTransparency );
-
-        // restore the original brush GC
-        mnBrushColor = aKeepBrushColor;
-        return bDrawnOk;
+        // check data validity
+        if(pSystemDependentData_Triangulation->getLineWidth() != aLineWidth)
+        {
+            // sometimes small inconsistencies, use a percentage tolerance
+            const double fFactorX(basegfx::fTools::equalZero(aLineWidth.getX())
+                ? 0.0
+                : fabs(1.0 - (pSystemDependentData_Triangulation->getLineWidth().getX() / aLineWidth.getX())));
+            const double fFactorY(basegfx::fTools::equalZero(aLineWidth.getY())
+                ? 0.0
+                : fabs(1.0 - (pSystemDependentData_Triangulation->getLineWidth().getY() / aLineWidth.getY())));
+
+            // compare with 5.0% tolerance
+            if(basegfx::fTools::more(fFactorX, 0.05) || basegfx::fTools::more(fFactorY, 0.05))
+            {
+                // data invalid, forget
+                pSystemDependentData_Triangulation.reset();
+            }
+        }
     }
 
-    // get the area polygon for the line polygon
-    if( (aLineWidth.getX() != aLineWidth.getY()) && !basegfx::fTools::equalZero( aLineWidth.getY() ) )
+    if(!pSystemDependentData_Triangulation)
     {
-        // prepare for createAreaGeometry() with anisotropic linewidth
-        aPolyLine.transform( basegfx::utils::createScaleB2DHomMatrix(1.0, aLineWidth.getX() / aLineWidth.getY()));
-    }
+        // try to create data
+        if(bPixelSnapHairline)
+        {
+            if(!bObjectToDeviceIsIdentity)
+            {
+                aPolygon.transform(rObjectToDevice);
+            }
 
-    // create the area-polygon for the line
-    const basegfx::B2DPolyPolygon aAreaPolyPoly(
-        basegfx::utils::createAreaGeometry(
-            aPolyLine,
-            fHalfWidth,
-            eLineJoin,
-            eLineCap,
-            fMiterMinimumAngle));
+            aPolygon = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolygon);
 
-    if( (aLineWidth.getX() != aLineWidth.getY()) && !basegfx::fTools::equalZero( aLineWidth.getX() ) )
-    {
-        // postprocess createAreaGeometry() for anisotropic linewidth
-        aPolyLine.transform(basegfx::utils::createScaleB2DHomMatrix(1.0, aLineWidth.getY() / aLineWidth.getX()));
+            if(!bObjectToDeviceIsIdentity)
+            {
+                if(aObjectToDeviceInv.isIdentity())
+                {
+                    aObjectToDeviceInv = rObjectToDevice;
+                    aObjectToDeviceInv.invert();
+                }
+
+                aPolygon.transform(aObjectToDeviceInv);
+            }
+        }
+
+        basegfx::triangulator::B2DTriangleVector aTriangles;
+        const basegfx::B2DPolyPolygon aAreaPolyPoly(
+            basegfx::utils::createAreaGeometry(
+                aPolygon,
+                0.5 * aLineWidth.getX(),
+                eLineJoin,
+                eLineCap,
+                basegfx::deg2rad(12.5),
+                0.4,
+                fMiterMinimumAngle,
+                &aTriangles));
+
+        if(!aTriangles.empty())
+        {
+            // add to buffering mechanism
+            pSystemDependentData_Triangulation = rPolygon.addOrReplaceSystemDependentData<SystemDependentData_Triangulation>(
+                ImplGetSystemDependentDataManager(),
+                aTriangles,
+                aLineWidth);
+        }
     }
 
-    // draw each area polypolygon component individually
-    // to emulate the polypolygon winding rule "non-zero"
-    const int nPolyCount = aAreaPolyPoly.count();
-    for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
+    if(!pSystemDependentData_Triangulation)
     {
-        const basegfx::B2DPolyPolygon aOnePoly( aAreaPolyPoly.getB2DPolygon( nPolyIdx ) );
+        return false;
+    }
 
-        bDrawnOk = drawPolyPolygon(
-            basegfx::B2DHomMatrix(),
-            aOnePoly,
-            fTransparency);
+    // temporarily adjust brush color to pen color
+    // since the line is drawn as an area-polygon
+    const Color aKeepBrushColor = mnBrushColor;
+    mnBrushColor = mnPenColor;
 
-        if( !bDrawnOk )
-            break;
-    }
+    // create the area-polygon for the line
+    const bool bDrawnOk(
+        drawFilledTriangles(
+            rObjectToDevice,
+            pSystemDependentData_Triangulation->getTriangles(),
+            fTransparency,
+            true));
 
     // restore the original brush GC
     mnBrushColor = aKeepBrushColor;
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index ac80ec6f0c40..db13696c4ffc 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -30,6 +30,7 @@
 #include <salgdiimpl.hxx>
 
 #include <basegfx/polygon/b2dtrapezoid.hxx>
+#include <basegfx/polygon/b2dpolygontriangulator.hxx>
 #include <ControlCacheKey.hxx>
 
 /* From <X11/Intrinsic.h> */
@@ -93,6 +94,11 @@ private:
 
     XID GetXRenderPicture();
     bool drawFilledTrapezoids( const basegfx::B2DTrapezoid*, int nTrapCount, double fTransparency );
+    bool drawFilledTriangles(
+        const basegfx::B2DHomMatrix& rObjectToDevice,
+        const basegfx::triangulator::B2DTriangleVector& rTriangles,
+        double fTransparency,
+        bool bPixelOffset);
 
     long GetGraphicsHeight() const;
 
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 9720670ec3ff..5599fe3fcf83 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -604,9 +604,10 @@ bool X11SalGraphics::drawPolyPolygon(
         return true;
     }
 
-    static bool bUseCairoForPolygons = false;
+    // enable by setting to something
+    static const char* pUseCairoForPolygons(getenv("SAL_ENABLE_USE_CAIRO_FOR_POLYGONS"));
 
-    if (!m_bOpenGL && bUseCairoForPolygons && SupportsCairo())
+    if (!m_bOpenGL && nullptr != pUseCairoForPolygons && SupportsCairo())
     {
         // snap to raster if requested
         const bool bSnapPoints(!getAntiAliasB2DDraw());
@@ -724,9 +725,10 @@ bool X11SalGraphics::drawPolyLine(
     }
 
 #if ENABLE_CAIRO_CANVAS
-    static bool bUseCairoForFatLines = true;
+    // disable by setting to something
+    static const char* pUseCairoForFatLines(getenv("SAL_DISABLE_USE_CAIRO_FOR_FATLINES"));
 
-    if (!m_bOpenGL && bUseCairoForFatLines && SupportsCairo())
+    if (!m_bOpenGL && nullptr == pUseCairoForFatLines && SupportsCairo())
     {
         cairo_t* cr = getCairoContext();
         clipRegion(cr);
diff --git a/vcl/unx/generic/gdi/xrender_peer.hxx b/vcl/unx/generic/gdi/xrender_peer.hxx
index 785292223489..88d9578ac6ab 100644
--- a/vcl/unx/generic/gdi/xrender_peer.hxx
+++ b/vcl/unx/generic/gdi/xrender_peer.hxx
@@ -62,6 +62,9 @@ public:
     void        CompositeTrapezoids( int nOp, Picture aSrc, Picture aDst,
                     const XRenderPictFormat*, int nXSrc, int nYSrc,
                     const XTrapezoid*, int nCount ) const;
+    void        CompositeTriangles( int nOp, Picture aSrc, Picture aDst,
+                    const XRenderPictFormat*, int nXSrc, int nYSrc,
+                    const XTriangle*, int nCount ) const;
 };
 
 inline XRenderPictFormat* XRenderPeer::GetStandardFormatA8() const
@@ -127,6 +130,14 @@ inline void XRenderPeer::CompositeTrapezoids( int nOp,
         nXSrc, nYSrc, pXT, nCount );
 }
 
+inline void XRenderPeer::CompositeTriangles( int nOp,
+    Picture aSrc, Picture aDst, const XRenderPictFormat* pXRPF,
+    int nXSrc, int nYSrc, const XTriangle* pXT, int nCount ) const
+{
+    XRenderCompositeTriangles( mpDisplay, nOp, aSrc, aDst, pXRPF,
+        nXSrc, nYSrc, pXT, nCount );
+}
+
 inline XRenderColor GetXRenderColor( Color rColor, double fTransparency )
 {
     XRenderColor aRetVal;
commit 023ffc1fb8b220232cb78681cf1b4eb55a60a2bb
Author:     Armin Le Grand <Armin.Le.Grand at cib.de>
AuthorDate: Wed Sep 19 15:38:50 2018 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:46 2018 +0100

    tdf#119843 Use transformed polygon data when needed
    
    Change-Id: I33cd8da925b9bf3d5b50a1c6ac43babedbe31d0a
    Reviewed-on: https://gerrit.libreoffice.org/60769
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index 5a9bd599a6ff..98409984da90 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -292,14 +292,27 @@ void OutputDevice::DrawTransparent(
         if( bDrawnOk )
         {
             if( mpMetaFile )
-                mpMetaFile->AddAction( new MetaTransparentAction( tools::PolyPolygon( rB2DPolyPoly ), static_cast< sal_uInt16 >(fTransparency * 100.0)));
+            {
+                // tdf#119843 need transformed Polygon here
+                basegfx::B2DPolyPolygon aB2DPolyPoly(rB2DPolyPoly);
+                aB2DPolyPoly.transform(rObjectTransform);
+                mpMetaFile->AddAction(
+                    new MetaTransparentAction(
+                        tools::PolyPolygon(aB2DPolyPoly),
+                        static_cast< sal_uInt16 >(fTransparency * 100.0)));
+            }
 
             return;
         }
     }
 
     // fallback to old polygon drawing if needed
-    DrawTransparent(toPolyPolygon(rB2DPolyPoly), static_cast<sal_uInt16>(fTransparency * 100.0));
+    // tdf#119843 need transformed Polygon here
+    basegfx::B2DPolyPolygon aB2DPolyPoly(rB2DPolyPoly);
+    aB2DPolyPoly.transform(rObjectTransform);
+    DrawTransparent(
+        toPolyPolygon(aB2DPolyPoly),
+        static_cast<sal_uInt16>(fTransparency * 100.0));
 }
 
 void OutputDevice::DrawInvisiblePolygon( const tools::PolyPolygon& rPolyPoly )
commit 1115161181a82922099f3ff9acf2d506613de682
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Nov 23 18:31:01 2018 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Nov 27 13:55:46 2018 +0100

    loplugin:override
    
    Change-Id: Ia45b5f7c126c082d8f3835c3c3529a34a9e20975

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index b7432a3c11e3..43641f023542 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -77,7 +77,7 @@ class Qt5MenuItem : public SalMenuItem
 {
 public:
     Qt5MenuItem(const SalItemParams*);
-    virtual ~Qt5MenuItem();
+    virtual ~Qt5MenuItem() override;
 
     Qt5Menu* mpParentMenu; // The menu into which this menu item is inserted

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list