[Libreoffice-commits] core.git: vcl/source vcl/workben

Caolán McNamara caolanm at redhat.com
Thu Jan 5 20:37:05 UTC 2017


 vcl/source/filter/wmf/winmtf.cxx |   35 +++++++++++++++++++++++++++++++----
 vcl/workben/commonfuzzer.hxx     |    1 +
 vcl/workben/fftester.cxx         |    2 ++
 3 files changed, 34 insertions(+), 4 deletions(-)

New commits:
commit dfe33fcd20d97e34ba7b7926a5a0c9a93e0e9960
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jan 5 16:40:39 2017 +0000

    Related: tdf#45820 polygon clipping during wmf load is ultra slow
    
    For file fuzzing defer actually doing it during load and just set a clipping
    region, which can take a polypolygon argument, instead of setting a basic
    cliping rectangle + complexclip flag to specially clip certain things
    
    for normal use, continue to do the slow thing as it gives different visual
    output, so its either not quite the right thing, or there's bugs elsewhere
    that would need to be fixed to go this way the whole time
    
    Change-Id: Ieac7ab54ed7d7c1ca14afd75b25fe273fd676c5d

diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index a169fce..b383439 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -892,13 +892,40 @@ void WinMtfOutput::UpdateClipRegion()
         if( !aClipPath.isEmpty() )
         {
             const basegfx::B2DPolyPolygon& rClipPoly( aClipPath.getClipPath() );
-            mpGDIMetaFile->AddAction(
-                new MetaISectRectClipRegionAction(
-                    vcl::unotools::rectangleFromB2DRectangle(
-                        rClipPoly.getB2DRange())));
 
             mbComplexClip = rClipPoly.count() > 1
                 || !basegfx::tools::isRectangle(rClipPoly);
+
+            static bool bEnableComplexClipViaRegion = getenv("SAL_WMF_COMPLEXCLIP_VIA_REGION") != nullptr;
+
+            if (bEnableComplexClipViaRegion)
+            {
+                //this makes cases like tdf#45820 work in reasonable time, and I feel in theory should
+                //be just fine. In practice I see the output is different so needs work before its the
+                //default, but for file fuzzing it should good enough
+                if (mbComplexClip)
+                {
+                    mpGDIMetaFile->AddAction(
+                        new MetaISectRegionClipRegionAction(
+                            vcl::Region(rClipPoly)));
+                    mbComplexClip = false;
+                }
+                else
+                {
+                    mpGDIMetaFile->AddAction(
+                        new MetaISectRectClipRegionAction(
+                            vcl::unotools::rectangleFromB2DRectangle(
+                                rClipPoly.getB2DRange())));
+                }
+            }
+            else
+            {
+                //normal case
+                mpGDIMetaFile->AddAction(
+                    new MetaISectRectClipRegionAction(
+                        vcl::unotools::rectangleFromB2DRectangle(
+                            rClipPoly.getB2DRange())));
+            }
         }
     }
 }
diff --git a/vcl/workben/commonfuzzer.hxx b/vcl/workben/commonfuzzer.hxx
index 715d691..969d73b 100644
--- a/vcl/workben/commonfuzzer.hxx
+++ b/vcl/workben/commonfuzzer.hxx
@@ -70,6 +70,7 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
         __lsan_disable();
 
     setenv("SAL_USE_VCLPLUGIN", "svp", 1);
+    setenv("SAL_WMF_COMPLEXCLIP_VIA_REGION", "1", 1);
 
     osl_setCommandArgs(*argc, *argv);
 
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index e6a0ba6..af9f725 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -101,6 +101,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
         utl::ConfigManager::EnableAvoidConfig();
         InitVCL();
 
+        setenv("SAL_WMF_COMPLEXCLIP_VIA_REGION", "1", 1);
+
 try_again:
 
         {


More information about the Libreoffice-commits mailing list