[Libreoffice-commits] core.git: canvas/source filter/source include/basegfx include/tools include/vcl vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Sep 26 15:40:16 UTC 2020


 canvas/source/vcl/canvashelper.cxx              |   14 -
 canvas/source/vcl/canvashelper_texturefill.cxx  |   18 -
 canvas/source/vcl/impltools.cxx                 |   14 -
 canvas/source/vcl/impltools.hxx                 |    4 
 canvas/source/vcl/spritehelper.cxx              |    2 
 filter/source/graphicfilter/idxf/dxf2mtf.cxx    |   11 -
 filter/source/graphicfilter/ios2met/ios2met.cxx |  243 +++++++++++-------------
 include/basegfx/polygon/b2dpolygon.hxx          |    1 
 include/basegfx/polygon/b2dpolypolygon.hxx      |    1 
 include/tools/gen.hxx                           |   16 -
 include/vcl/outdev.hxx                          |    2 
 vcl/source/outdev/polyline.cxx                  |   30 --
 12 files changed, 148 insertions(+), 208 deletions(-)

New commits:
commit 5cb62b13ca8fec43fffe3f2000f61c1be7c5616c
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Sep 26 14:41:02 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Sep 26 17:39:33 2020 +0200

    revert recent Polygon commits
    
    This reverts
        commit 0cabffc05f3b40f5ee897df73475e09a3c05fc7
        tools::PolyPolygon -> basegfx in canvas
    and
        commit 2c5d5a6d55a1ebd153f05523972a2c625484bde2
        tools::PolyPolygon -> basegfx in filter
    
    Comment from quikee:
    The interpretation of integer polygons and floating point polygons
    (or any other float vs. int drawing primitives) are different,
    so you have to be really careful when changing, that the result
    after the change is still the same. A big problem is that we still
    have the metafile in OutputDevice, which is completely integer based
    - so there will be conversions that go from int representation to
    float representation to int again and to float (because backend is
    in floating point) and I really fear that because of this there will
    be regressions and even if not, it could make changing later more
    painful. This is the reason I wouldn't change these things without
    having tests that would show when there is a difference in rendering.
    
    Change-Id: I54addca4e5a72196b5f77f6c7689eb716451c1dd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103483
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index a62057ce4a30..5cc5f3c42b73 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -266,7 +266,7 @@ namespace vclcanvas
 
             const ::basegfx::B2DPolyPolygon& rPolyPoly(
                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon) );
-            const ::basegfx::B2DPolyPolygon aPolyPoly( tools::mapPolyPolygon( rPolyPoly, viewState, renderState ) );
+            const ::tools::PolyPolygon aPolyPoly( tools::mapPolyPolygon( rPolyPoly, viewState, renderState ) );
 
             if( rPolyPoly.isClosed() )
             {
@@ -284,9 +284,9 @@ namespace vclcanvas
                 // DrawPolygon(), and open ones via DrawPolyLine():
                 // closed polygons will simply already contain the
                 // closing segment.
-                sal_uInt32 nSize( aPolyPoly.count() );
+                sal_uInt16 nSize( aPolyPoly.Count() );
 
-                for( sal_uInt32 i=0; i<nSize; ++i )
+                for( sal_uInt16 i=0; i<nSize; ++i )
                 {
                     mpOutDevProvider->getOutDev().DrawPolyLine( aPolyPoly[i] );
 
@@ -476,7 +476,7 @@ namespace vclcanvas
             ::basegfx::B2DPolyPolygon aB2DPolyPoly(
                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon));
             aB2DPolyPoly.setClosed(true); // ensure closed poly, otherwise VCL does not fill
-            const ::basegfx::B2DPolyPolygon aPolyPoly( tools::mapPolyPolygon(
+            const ::tools::PolyPolygon aPolyPoly( tools::mapPolyPolygon(
                                              aB2DPolyPoly,
                                              viewState, renderState ) );
             const bool bSourceAlpha( renderState.CompositeOperation == rendering::CompositeOperation::SOURCE );
@@ -486,10 +486,8 @@ namespace vclcanvas
             }
             else
             {
-                const double dTransparency( (nTransparency + 128) / 255.0 );
-                basegfx::B2DHomMatrix aIdentityMatrix;
-                aIdentityMatrix.identity();
-                mpOutDevProvider->getOutDev().DrawTransparent( aIdentityMatrix, aPolyPoly, dTransparency );
+                const int nTransPercent( (nTransparency * 100 + 128) / 255 );  // normal rounding, no truncation here
+                mpOutDevProvider->getOutDev().DrawTransparent( aPolyPoly, static_cast<sal_uInt16>(nTransPercent) );
             }
 
             if( mp2ndOutDevProvider )
diff --git a/canvas/source/vcl/canvashelper_texturefill.cxx b/canvas/source/vcl/canvashelper_texturefill.cxx
index b0b0ef3770d5..9cb8dd8abd99 100644
--- a/canvas/source/vcl/canvashelper_texturefill.cxx
+++ b/canvas/source/vcl/canvashelper_texturefill.cxx
@@ -437,7 +437,7 @@ namespace vclcanvas
                            OutputDevice*                                   p2ndOutDev,
                            const ::canvas::ParametricPolyPolygon::Values&  rValues,
                            const std::vector< ::Color >&                   rColors,
-                           const ::basegfx::B2DPolyPolygon&                rPoly,
+                           const ::tools::PolyPolygon&                     rPoly,
                            const rendering::ViewState&                     viewState,
                            const rendering::RenderState&                   renderState,
                            const rendering::Texture&                       texture,
@@ -466,8 +466,8 @@ namespace vclcanvas
 
             // determine maximal bound rect of texture-filled
             // polygon
-            const ::basegfx::B2DRectangle aPolygonDeviceRectOrig(
-                rPoly.getB2DRange() );
+            const ::tools::Rectangle aPolygonDeviceRectOrig(
+                rPoly.GetBoundRect() );
 
             if( tools::isRectangle( rPoly ) )
             {
@@ -482,7 +482,7 @@ namespace vclcanvas
                 // twice for XOR
 
                 rOutDev.Push( PushFlags::CLIPREGION );
-                rOutDev.IntersectClipRegion( ::tools::Rectangle(aPolygonDeviceRectOrig) );
+                rOutDev.IntersectClipRegion( aPolygonDeviceRectOrig );
                 doGradientFill( rOutDev,
                                 rValues,
                                 rColors,
@@ -570,7 +570,7 @@ namespace vclcanvas
             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider );
 
             const int nTransparency( setupOutDevState( viewState, renderState, IGNORE_COLOR ) );
-            ::basegfx::B2DPolyPolygon aPolyPoly( tools::mapPolyPolygon(
+            ::tools::PolyPolygon aPolyPoly( tools::mapPolyPolygon(
                                        ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon),
                                        viewState, renderState ) );
 
@@ -636,7 +636,7 @@ namespace vclcanvas
                 // determine maximal bound rect of texture-filled
                 // polygon
                 const ::tools::Rectangle aPolygonDeviceRect(
-                    aPolyPoly.getB2DRange() );
+                    aPolyPoly.GetBoundRect() );
 
 
                 // first of all, determine whether we have a
@@ -945,10 +945,8 @@ namespace vclcanvas
 
                             // shift output to origin of VDev
                             const ::Point aOutPos( aPt - aPolygonDeviceRect.TopLeft() );
-                            basegfx::B2DHomMatrix aTranslateMatrix;
-                            aTranslateMatrix.translate( -aPolygonDeviceRect.Left(),
-                                                          -aPolygonDeviceRect.Top() );
-                            aPolyPoly.transform( aTranslateMatrix );
+                            aPolyPoly.Translate( ::Point( -aPolygonDeviceRect.Left(),
+                                                          -aPolygonDeviceRect.Top() ) );
 
                             const vcl::Region aPolyClipRegion( aPolyPoly );
 
diff --git a/canvas/source/vcl/impltools.cxx b/canvas/source/vcl/impltools.cxx
index b8341b401a05..754a34ce0806 100644
--- a/canvas/source/vcl/impltools.cxx
+++ b/canvas/source/vcl/impltools.cxx
@@ -134,20 +134,20 @@ namespace vclcanvas::tools
             return true;
         }
 
-        bool isRectangle( const ::basegfx::B2DPolyPolygon& rPolyPoly )
+        bool isRectangle( const ::tools::PolyPolygon& rPolyPoly )
         {
             // exclude some cheap cases first
-            if( rPolyPoly.count() != 1 )
+            if( rPolyPoly.Count() != 1 )
                 return false;
 
-            const ::basegfx::B2DPolygon& rPoly( rPolyPoly[0] );
+            const ::tools::Polygon& rPoly( rPolyPoly[0] );
 
-            sal_uInt16 nCount( rPoly.count() );
+            sal_uInt16 nCount( rPoly.GetSize() );
             if( nCount < 4 )
                 return false;
 
             // delegate to basegfx
-            return ::basegfx::utils::isRectangle( rPoly );
+            return ::basegfx::utils::isRectangle( rPoly.getB2DPolygon() );
         }
 
 
@@ -168,7 +168,7 @@ namespace vclcanvas::tools
             return vcl::unotools::pointFromB2DPoint( aPoint );
         }
 
-        ::basegfx::B2DPolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon&  rPoly,
+        ::tools::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon&  rPoly,
                                       const rendering::ViewState&       rViewState,
                                       const rendering::RenderState&     rRenderState )
         {
@@ -181,7 +181,7 @@ namespace vclcanvas::tools
 
             aTemp.transform( aMatrix );
 
-            return aTemp;
+            return ::tools::PolyPolygon( aTemp );
         }
 
         ::BitmapEx transformBitmap( const BitmapEx&                 rBitmap,
diff --git a/canvas/source/vcl/impltools.hxx b/canvas/source/vcl/impltools.hxx
index a97211e3e7cb..028ea1174f3c 100644
--- a/canvas/source/vcl/impltools.hxx
+++ b/canvas/source/vcl/impltools.hxx
@@ -92,7 +92,7 @@ namespace vclcanvas
 
             @return true, if the polygon is a rectangle.
          */
-        bool isRectangle( const ::basegfx::B2DPolyPolygon& rPolyPoly );
+        bool isRectangle( const ::tools::PolyPolygon& rPolyPoly );
 
 
         // Little helper to encapsulate locking into policy class
@@ -164,7 +164,7 @@ namespace vclcanvas
                                 const css::rendering::ViewState&   rViewState,
                                 const css::rendering::RenderState& rRenderState );
 
-        ::basegfx::B2DPolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon&                          rPoly,
+        ::tools::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon&                          rPoly,
                                       const css::rendering::ViewState&     rViewState,
                                       const css::rendering::RenderState&   rRenderState );
 
diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index d25d06a49168..e52bb211020c 100644
--- a/canvas/source/vcl/spritehelper.cxx
+++ b/canvas/source/vcl/spritehelper.cxx
@@ -266,7 +266,7 @@ namespace vclcanvas
                     rTargetSurface.SetLineColor( Color( 0,255,0 ) );
                     rTargetSurface.SetFillColor();
 
-                    rTargetSurface.DrawPolyPolygon(aClipPoly); // #i76339#
+                    rTargetSurface.DrawPolyPolygon(::tools::PolyPolygon(aClipPoly)); // #i76339#
                 }
 
                 vcl::Region aClipRegion( aClipPoly );
diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
index 827b37915fd7..898dc6159ecb 100644
--- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx
+++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
@@ -579,7 +579,7 @@ void DXF2GDIMetaFile::DrawHatchEntity(const DXFHatchEntity & rE, const DXFTransf
 
     SetAreaAttribute( rE );
     sal_Int32 j = 0;
-    basegfx::B2DPolyPolygon aPolyPoly;
+    tools::PolyPolygon aPolyPoly;
     for ( j = 0; j < rE.nBoundaryPathCount; j++ )
     {
         std::vector< Point > aPtAry;
@@ -619,14 +619,13 @@ void DXF2GDIMetaFile::DrawHatchEntity(const DXFHatchEntity & rE, const DXFTransf
         sal_uInt16 i, nSize = static_cast<sal_uInt16>(aPtAry.size());
         if ( nSize )
         {
-            basegfx::B2DPolygon aPoly;
-            aPoly.reserve( nSize );
+            tools::Polygon aPoly( nSize );
             for ( i = 0; i < nSize; i++ )
-                aPoly.append(aPtAry[ i ]);
-            aPolyPoly.append( aPoly );
+                aPoly[ i ] = aPtAry[ i ];
+            aPolyPoly.Insert( aPoly );
         }
     }
-    if ( aPolyPoly.count() )
+    if ( aPolyPoly.Count() )
         pVirDev->DrawPolyPolygon( aPolyPoly );
 }
 
diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx
index 6e38ad8716cc..54f56f932f53 100644
--- a/filter/source/graphicfilter/ios2met/ios2met.cxx
+++ b/filter/source/graphicfilter/ios2met/ios2met.cxx
@@ -28,10 +28,6 @@
 #include <vcl/virdev.hxx>
 #include <vcl/lineinfo.hxx>
 #include <vcl/gdimtf.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/curve/b2dcubicbezier.hxx>
 
 #include <math.h>
 #include <memory>
@@ -227,7 +223,7 @@ struct OSPalette {
 struct OSArea {
     OSArea    * pSucc;
     sal_uInt8   nFlags;
-    basegfx::B2DPolyPolygon aPPoly;
+    tools::PolyPolygon aPPoly;
     bool    bClosed;
     Color       aCol;
     Color       aBgCol;
@@ -240,7 +236,7 @@ struct OSPath
 {
     OSPath*     pSucc;
     sal_uInt32  nID;
-    basegfx::B2DPolyPolygon aPPoly;
+    tools::PolyPolygon aPPoly;
     bool    bClosed;
     bool    bStroke;
 };
@@ -369,8 +365,8 @@ private:
 
     std::unique_ptr<SvStream> xOrdFile;
 
-    void AddPointsToPath(const basegfx::B2DPolygon & rPoly);
-    void AddPointsToArea(const basegfx::B2DPolygon & rPoly);
+    void AddPointsToPath(const tools::Polygon & rPoly);
+    void AddPointsToArea(const tools::Polygon & rPoly);
     void CloseFigure();
     void PushAttr(sal_uInt16 nPushOrder);
     void PopAttr();
@@ -387,9 +383,9 @@ private:
 
 
     bool        IsLineInfo() const;
-    void        DrawPolyLine( const basegfx::B2DPolygon& rPolygon );
-    void        DrawPolygon( const basegfx::B2DPolygon& rPolygon );
-    void        DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolygon );
+    void        DrawPolyLine( const tools::Polygon& rPolygon );
+    void        DrawPolygon( const tools::Polygon& rPolygon );
+    void        DrawPolyPolygon( const tools::PolyPolygon& rPolygon );
     sal_uInt16  ReadBigEndianWord();
     sal_uInt32  ReadBigEndian3BytesLong();
     sal_uInt32  ReadLittleEndian3BytesLong();
@@ -505,7 +501,7 @@ bool OS2METReader::IsLineInfo() const
     return ( ! ( aLineInfo.IsDefault() || ( aLineInfo.GetStyle() == LineStyle::NONE ) || ( pVirDev->GetLineColor() == COL_TRANSPARENT ) ) );
 }
 
-void OS2METReader::DrawPolyLine( const basegfx::B2DPolygon& rPolygon )
+void OS2METReader::DrawPolyLine( const tools::Polygon& rPolygon )
 {
     if ( aLineInfo.GetStyle() == LineStyle::Dash || ( aLineInfo.GetWidth() > 1 ) )
         pVirDev->DrawPolyLine( rPolygon, aLineInfo );
@@ -513,7 +509,7 @@ void OS2METReader::DrawPolyLine( const basegfx::B2DPolygon& rPolygon )
         pVirDev->DrawPolyLine( rPolygon );
 }
 
-void OS2METReader::DrawPolygon( const basegfx::B2DPolygon& rPolygon )
+void OS2METReader::DrawPolygon( const tools::Polygon& rPolygon )
 {
     if ( IsLineInfo() )
     {
@@ -527,7 +523,7 @@ void OS2METReader::DrawPolygon( const basegfx::B2DPolygon& rPolygon )
         pVirDev->DrawPolygon( rPolygon );
 }
 
-void OS2METReader::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon )
+void OS2METReader::DrawPolyPolygon( const tools::PolyPolygon& rPolyPolygon )
 {
     if ( IsLineInfo() )
     {
@@ -535,53 +531,53 @@ void OS2METReader::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon
         pVirDev->SetLineColor( COL_TRANSPARENT );
         pVirDev->DrawPolyPolygon( rPolyPolygon );
         pVirDev->Pop();
-        for ( sal_uInt32 i = 0; i < rPolyPolygon.count(); i++ )
-            pVirDev->DrawPolyLine( rPolyPolygon.getB2DPolygon( i ), aLineInfo );
+        for ( sal_uInt16 i = 0; i < rPolyPolygon.Count(); i++ )
+            pVirDev->DrawPolyLine( rPolyPolygon.GetObject( i ), aLineInfo );
     }
     else
         pVirDev->DrawPolyPolygon( rPolyPolygon );
 }
 
-void OS2METReader::AddPointsToArea(const basegfx::B2DPolygon & rPoly)
+void OS2METReader::AddPointsToArea(const tools::Polygon & rPoly)
 {
     sal_uInt16 nOldSize, nNewSize,i;
 
-    if (pAreaStack==nullptr || rPoly.count()==0) return;
-    basegfx::B2DPolyPolygon * pPP=&(pAreaStack->aPPoly);
-    if (pPP->count()==0 || pAreaStack->bClosed) pPP->append(rPoly);
+    if (pAreaStack==nullptr || rPoly.GetSize()==0) return;
+    tools::PolyPolygon * pPP=&(pAreaStack->aPPoly);
+    if (pPP->Count()==0 || pAreaStack->bClosed) pPP->Insert(rPoly);
     else {
-        basegfx::B2DPolygon aLastPoly(pPP->getB2DPolygon(pPP->count()-1));
-        nOldSize=aLastPoly.count();
-        if (nOldSize && aLastPoly.getB2DPoint(nOldSize-1)==rPoly.getB2DPoint(0)) nOldSize--;
-        nNewSize=nOldSize+rPoly.count();
-        aLastPoly.reserve(nNewSize);
+        tools::Polygon aLastPoly(pPP->GetObject(pPP->Count()-1));
+        nOldSize=aLastPoly.GetSize();
+        if (nOldSize && aLastPoly.GetPoint(nOldSize-1)==rPoly.GetPoint(0)) nOldSize--;
+        nNewSize=nOldSize+rPoly.GetSize();
+        aLastPoly.SetSize(nNewSize);
         for (i=nOldSize; i<nNewSize; i++) {
-            aLastPoly.append(rPoly.getB2DPoint(i-nOldSize),i);
+            aLastPoly.SetPoint(rPoly.GetPoint(i-nOldSize),i);
         }
-        pPP->setB2DPolygon(pPP->count()-1, aLastPoly);
+        pPP->Replace(aLastPoly,pPP->Count()-1);
     }
     pAreaStack->bClosed=false;
 }
 
-void OS2METReader::AddPointsToPath(const basegfx::B2DPolygon & rPoly)
+void OS2METReader::AddPointsToPath(const tools::Polygon & rPoly)
 {
     sal_uInt16 nOldSize, nNewSize,i;
 
-    if (pPathStack==nullptr || rPoly.count()==0) return;
-    basegfx::B2DPolyPolygon * pPP=&(pPathStack->aPPoly);
-    if (pPP->count()==0 /*|| pPathStack->bClosed==sal_True*/) pPP->append(rPoly);
+    if (pPathStack==nullptr || rPoly.GetSize()==0) return;
+    tools::PolyPolygon * pPP=&(pPathStack->aPPoly);
+    if (pPP->Count()==0 /*|| pPathStack->bClosed==sal_True*/) pPP->Insert(rPoly);
     else {
-        basegfx::B2DPolygon aLastPoly(pPP->getB2DPolygon(pPP->count()-1));
-        nOldSize=aLastPoly.count();
-        if (nOldSize && aLastPoly.getB2DPoint(nOldSize-1)!=rPoly.getB2DPoint(0)) pPP->append(rPoly);
+        tools::Polygon aLastPoly(pPP->GetObject(pPP->Count()-1));
+        nOldSize=aLastPoly.GetSize();
+        if (nOldSize && aLastPoly.GetPoint(nOldSize-1)!=rPoly.GetPoint(0)) pPP->Insert(rPoly);
         else {
             nOldSize--;
-            nNewSize=nOldSize+rPoly.count();
-            aLastPoly.reserve(nNewSize);
+            nNewSize=nOldSize+rPoly.GetSize();
+            aLastPoly.SetSize(nNewSize);
             for (i=nOldSize; i<nNewSize; i++) {
-                aLastPoly.append(rPoly.getB2DPoint(i-nOldSize),i);
+                aLastPoly.SetPoint(rPoly.GetPoint(i-nOldSize),i);
             }
-            pPP->setB2DPolygon(pPP->count()-1, aLastPoly);
+            pPP->Replace(aLastPoly,pPP->Count()-1);
         }
     }
     pPathStack->bClosed=false;
@@ -873,15 +869,12 @@ void OS2METReader::ReadLine(bool bGivenPos, sal_uInt16 nOrderLen)
     if (bCoord32) nPolySize=nOrderLen/8; else nPolySize=nOrderLen/4;
     if (!bGivenPos) nPolySize++;
     if (nPolySize==0) return;
-    basegfx::B2DPolygon aPolygon;
-    aPolygon.reserve(nPolySize);
+    tools::Polygon aPolygon(nPolySize);
     for (i=0; i<nPolySize; i++) {
-        if (i==0 && !bGivenPos)
-            aPolygon.append(aAttr.aCurPos);
-        else
-            aPolygon.append(ReadPoint());
+        if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
+        else aPolygon.SetPoint(ReadPoint(),i);
     }
-    aAttr.aCurPos=Point(aPolygon.getB2DPoint(nPolySize-1));
+    aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
     if (pAreaStack!=nullptr) AddPointsToArea(aPolygon);
     else if (pPathStack!=nullptr) AddPointsToPath(aPolygon);
     else
@@ -906,16 +899,15 @@ void OS2METReader::ReadRelLine(bool bGivenPos, sal_uInt16 nOrderLen)
         throw css::uno::Exception("attempt to read past end of input", nullptr);
     nPolySize=nOrderLen/2;
     if (nPolySize==0) return;
-    basegfx::B2DPolygon aPolygon;
-    aPolygon.reserve(nPolySize);
+    tools::Polygon aPolygon(nPolySize);
     for (i=0; i<nPolySize; i++) {
         sal_Int8 nsignedbyte;
         pOS2MET->ReadSChar( nsignedbyte ); aP0.AdjustX(static_cast<sal_Int32>(nsignedbyte));
         pOS2MET->ReadSChar( nsignedbyte ); aP0.AdjustY(-static_cast<sal_Int32>(nsignedbyte));
         aCalcBndRect.Union(tools::Rectangle(aP0,Size(1,1)));
-        aPolygon.append(aP0);
+        aPolygon.SetPoint(aP0,i);
     }
-    aAttr.aCurPos=aPolygon.getB2DPoint(nPolySize-1);
+    aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
     if (pAreaStack!=nullptr) AddPointsToArea(aPolygon);
     else if (pPathStack!=nullptr) AddPointsToPath(aPolygon);
     else
@@ -946,9 +938,9 @@ void OS2METReader::ReadBox(bool bGivenPos)
     tools::Rectangle aBoxRect( P0, aAttr.aCurPos );
 
     if ( pAreaStack )
-        AddPointsToArea( basegfx::utils::createPolygonFromRect( aBoxRect ) );
+        AddPointsToArea( tools::Polygon( aBoxRect ) );
     else if ( pPathStack )
-        AddPointsToPath( basegfx::utils::createPolygonFromRect( aBoxRect ) );
+        AddPointsToPath( tools::Polygon( aBoxRect ) );
     else
     {
         if ( nFlags & 0x20 )
@@ -969,7 +961,7 @@ void OS2METReader::ReadBox(bool bGivenPos)
 
         if ( IsLineInfo() )
         {
-            basegfx::B2DPolygon aPolygon = basegfx::utils::createPolygonFromRect( aBoxRect, nHRound, nVRound );
+            tools::Polygon aPolygon( aBoxRect, nHRound, nVRound );
             if ( nFlags & 0x40 )
             {
                 pVirDev->Push( PushFlags::LINECOLOR );
@@ -1219,8 +1211,8 @@ void OS2METReader::ReadPartialArc(bool bGivenPos, sal_uInt16 nOrderSize)
 
 void OS2METReader::ReadPolygons()
 {
-    basegfx::B2DPolyPolygon aPolyPoly;
-    basegfx::B2DPolygon aPoly;
+    tools::PolyPolygon aPolyPoly;
+    tools::Polygon aPoly;
     Point aPoint;
 
     sal_uInt8 nFlags(0);
@@ -1247,15 +1239,15 @@ void OS2METReader::ReadPolygons()
             return;
         }
         if (i==0) ++nNumPoints;
-        aPoly.reserve(static_cast<short>(nNumPoints));
+        aPoly.SetSize(static_cast<short>(nNumPoints));
         for (sal_uInt32 j=0; j<nNumPoints; ++j)
         {
             if (i==0 && j==0) aPoint=aAttr.aCurPos;
             else aPoint=ReadPoint();
-            aPoly.append(aPoint);
+            aPoly.SetPoint(aPoint,static_cast<short>(j));
             if (i==nNumPolys-1 && j==nNumPoints-1) aAttr.aCurPos=aPoint;
         }
-        aPolyPoly.append(aPoly);
+        aPolyPoly.Insert(aPoly);
     }
 
     ChangeBrush(aAttr.aPatCol, aAttr.bFill);
@@ -1277,34 +1269,39 @@ void OS2METReader::ReadBezier(bool bGivenPos, sal_uInt16 nOrderLen)
     if( !nNumPoints )
         return;
 
-    basegfx::B2DPolygon aPolygon;
-    aPolygon.reserve( nNumPoints );
+    tools::Polygon aPolygon( nNumPoints );
 
     for( i=0; i < nNumPoints; i++ )
     {
         if( i==0 && !bGivenPos)
-            aPolygon.append( aAttr.aCurPos );
+            aPolygon.SetPoint( aAttr.aCurPos, i );
         else
-            aPolygon.append( ReadPoint() );
+            aPolygon.SetPoint( ReadPoint(), i );
     }
 
     if( !( nNumPoints % 4 ) )
     {
         // create bezier polygon
         const sal_uInt16 nSegPoints = 25;
-        const sal_uInt16 nSegments = aPolygon.count() >> 2;
-        basegfx::B2DPolygon aBezPoly;
-        aBezPoly.reserve( nSegments * nSegPoints );
+        const sal_uInt16 nSegments = aPolygon.GetSize() >> 2;
+        tools::Polygon aBezPoly( nSegments * nSegPoints );
 
         sal_uInt16 nSeg, nBezPos, nStartPos;
         for( nSeg = 0, nBezPos = 0, nStartPos = 0; nSeg < nSegments; nSeg++, nStartPos += 4 )
         {
-            const basegfx::B2DCubicBezier aSegPoly( aPolygon[ nStartPos ], aPolygon[ nStartPos + 1 ],
-                                           aPolygon[ nStartPos + 3 ], aPolygon[ nStartPos + 2 ] );
-            aSegPoly.adaptiveSubdivideByCount(aBezPoly, 25);
+            const tools::Polygon aSegPoly( aPolygon[ nStartPos ], aPolygon[ nStartPos + 1 ],
+                                           aPolygon[ nStartPos + 3 ], aPolygon[ nStartPos + 2 ],
+                                           nSegPoints );
+
+            for( sal_uInt16 nSegPos = 0; nSegPos < nSegPoints; )
+                aBezPoly[ nBezPos++ ] = aSegPoly[ nSegPos++ ];
         }
 
         nNumPoints = nBezPos;
+
+        if( nNumPoints != aBezPoly.GetSize() )
+            aBezPoly.SetSize( nNumPoints );
+
         aPolygon = aBezPoly;
     }
 
@@ -1329,13 +1326,12 @@ void OS2METReader::ReadFillet(bool bGivenPos, sal_uInt16 nOrderLen)
     if (bCoord32) nNumPoints=nOrderLen/8; else nNumPoints=nOrderLen/4;
     if (!bGivenPos) nNumPoints++;
     if (nNumPoints==0) return;
-    basegfx::B2DPolygon aPolygon;
-    aPolygon.reserve(nNumPoints);
+    tools::Polygon aPolygon(nNumPoints);
     for (i=0; i<nNumPoints; i++) {
-        if (i==0 && !bGivenPos) aPolygon.append(aAttr.aCurPos);
-        else aPolygon.append(ReadPoint());
+        if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
+        else aPolygon.SetPoint(ReadPoint(),i);
     }
-    aAttr.aCurPos=aPolygon[nNumPoints-1];
+    aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
     if (pAreaStack!=nullptr) AddPointsToArea(aPolygon);
     else if (pPathStack!=nullptr) AddPointsToPath(aPolygon);
     else {
@@ -1355,11 +1351,10 @@ void OS2METReader::ReadFilletSharp(bool bGivenPos, sal_uInt16 nOrderLen)
     }
     if (bCoord32) nNumPoints=1+nOrderLen/10;
     else nNumPoints=1+nOrderLen/6;
-    basegfx::B2DPolygon aPolygon;
-    aPolygon.reserve(nNumPoints);
-    aPolygon.append(aAttr.aCurPos);
-    for (i=1; i<nNumPoints; i++) aPolygon.append(ReadPoint());
-    aAttr.aCurPos=aPolygon[nNumPoints-1];
+    tools::Polygon aPolygon(nNumPoints);
+    aPolygon.SetPoint(aAttr.aCurPos,0);
+    for (i=1; i<nNumPoints; i++) aPolygon.SetPoint(ReadPoint(),i);
+    aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
     if (pAreaStack!=nullptr) AddPointsToArea(aPolygon);
     else if (pPathStack!=nullptr) AddPointsToPath(aPolygon);
     else
@@ -1398,59 +1393,59 @@ void OS2METReader::ReadMarker(bool bGivenPos, sal_uInt16 nOrderLen)
                 break;
             case  3:   // DIAMOND
             case  7: { // SOLIDDIAMOND
-                basegfx::B2DPolygon aPoly{
-                    Point(x,y+4),
-                    Point(x+4,y),
-                    Point(x,y-4),
-                    Point(x-4,y) };
+                tools::Polygon aPoly(4);
+                aPoly.SetPoint(Point(x,y+4),0);
+                aPoly.SetPoint(Point(x+4,y),1);
+                aPoly.SetPoint(Point(x,y-4),2);
+                aPoly.SetPoint(Point(x-4,y),3);
                 pVirDev->DrawPolygon(aPoly);
                 break;
             }
             case  4:   // SQUARE
             case  8: { // SOLIDSUARE
-                basegfx::B2DPolygon aPoly {
-                    Point(x+4,y+4),
-                    Point(x+4,y-4),
-                    Point(x-4,y-4),
-                    Point(x-4,y+4) };
+                tools::Polygon aPoly(4);
+                aPoly.SetPoint(Point(x+4,y+4),0);
+                aPoly.SetPoint(Point(x+4,y-4),1);
+                aPoly.SetPoint(Point(x-4,y-4),2);
+                aPoly.SetPoint(Point(x-4,y+4),3);
                 pVirDev->DrawPolygon(aPoly);
                 break;
             }
             case  5: { // SIXPOINTSTAR
-                basegfx::B2DPolygon aPoly {
-                    Point(x  ,y-4),
-                    Point(x+2,y-2),
-                    Point(x+4,y-2),
-                    Point(x+2,y  ),
-                    Point(x+4,y+2),
-                    Point(x+2,y+2),
-                    Point(x  ,y+4),
-                    Point(x-2,y+2),
-                    Point(x-4,y+2),
-                    Point(x-2,y  ),
-                    Point(x-4,y-2),
-                    Point(x-2,y-2) };
+                tools::Polygon aPoly(12);
+                aPoly.SetPoint(Point(x  ,y-4),0);
+                aPoly.SetPoint(Point(x+2,y-2),1);
+                aPoly.SetPoint(Point(x+4,y-2),2);
+                aPoly.SetPoint(Point(x+2,y  ),3);
+                aPoly.SetPoint(Point(x+4,y+2),4);
+                aPoly.SetPoint(Point(x+2,y+2),5);
+                aPoly.SetPoint(Point(x  ,y+4),6);
+                aPoly.SetPoint(Point(x-2,y+2),7);
+                aPoly.SetPoint(Point(x-4,y+2),8);
+                aPoly.SetPoint(Point(x-2,y  ),9);
+                aPoly.SetPoint(Point(x-4,y-2),10);
+                aPoly.SetPoint(Point(x-2,y-2),11);
                 pVirDev->DrawPolygon(aPoly);
                 break;
             }
             case  6: { // EIGHTPOINTSTAR
-                basegfx::B2DPolygon aPoly {
-                    Point(x  ,y-4),
-                    Point(x+1,y-2),
-                    Point(x+3,y-3),
-                    Point(x+2,y-1),
-                    Point(x+4,y  ),
-                    Point(x+2,y+1),
-                    Point(x+3,y+3),
-                    Point(x+1,y+2),
-                    Point(x  ,y+4),
-                    Point(x-1,y+2),
-                    Point(x-3,y+3),
-                    Point(x-2,y+1),
-                    Point(x-4,y  ),
-                    Point(x-2,y-1),
-                    Point(x-3,y-3),
-                    Point(x-1,y-2) };
+                tools::Polygon aPoly(16);
+                aPoly.SetPoint(Point(x  ,y-4),0);
+                aPoly.SetPoint(Point(x+1,y-2),1);
+                aPoly.SetPoint(Point(x+3,y-3),2);
+                aPoly.SetPoint(Point(x+2,y-1),3);
+                aPoly.SetPoint(Point(x+4,y  ),4);
+                aPoly.SetPoint(Point(x+2,y+1),5);
+                aPoly.SetPoint(Point(x+3,y+3),6);
+                aPoly.SetPoint(Point(x+1,y+2),7);
+                aPoly.SetPoint(Point(x  ,y+4),8);
+                aPoly.SetPoint(Point(x-1,y+2),9);
+                aPoly.SetPoint(Point(x-3,y+3),10);
+                aPoly.SetPoint(Point(x-2,y+1),11);
+                aPoly.SetPoint(Point(x-4,y  ),12);
+                aPoly.SetPoint(Point(x-2,y-1),13);
+                aPoly.SetPoint(Point(x-3,y-3),14);
+                aPoly.SetPoint(Point(x-1,y-2),15);
                 pVirDev->DrawPolygon(aPoly);
                 break;
             }
@@ -1540,9 +1535,9 @@ void OS2METReader::ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen)
                 pAreaStack = p->pSucc;
                 if ( pPathStack )
                 {
-                    for ( sal_uInt32 i=0; i<p->aPPoly.count(); i++ )
+                    for ( sal_uInt16 i=0; i<p->aPPoly.Count(); i++ )
                     {
-                        AddPointsToPath( p->aPPoly[ i ] );
+                        AddPointsToPath( p->aPPoly.GetObject( i ) );
                         CloseFigure();
                     }
                 }
@@ -1617,8 +1612,8 @@ void OS2METReader::ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen)
                         SetRasterOp( aAttr.ePatMix );
                         if ( IsLineInfo() )
                         {
-                            for ( sal_uInt32 i = 0; i < p->aPPoly.count(); i++ )
-                                pVirDev->DrawPolyLine( p->aPPoly[ i ], aLineInfo );
+                            for ( sal_uInt16 i = 0; i < p->aPPoly.Count(); i++ )
+                                pVirDev->DrawPolyLine( p->aPPoly.GetObject( i ), aLineInfo );
                         }
                         else
                             pVirDev->DrawPolyPolygon( p->aPPoly );
@@ -1662,13 +1657,13 @@ void OS2METReader::ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen)
                 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
                 SetRasterOp(aAttr.eLinMix);
                 ChangeBrush(COL_TRANSPARENT, false);
-                nC=p->aPPoly.count();
+                nC=p->aPPoly.Count();
                 for (i=0; i<nC; i++)
                 {
                     if (i+1<nC || p->bClosed)
-                        DrawPolygon( p->aPPoly[ i ] );
+                        DrawPolygon( p->aPPoly.GetObject( i ) );
                     else
-                        DrawPolyLine( p->aPPoly[ i ] );
+                        DrawPolyLine( p->aPPoly.GetObject( i ) );
                 }
             }
             break;
diff --git a/include/basegfx/polygon/b2dpolygon.hxx b/include/basegfx/polygon/b2dpolygon.hxx
index 346b4c587693..e74b458ec3af 100644
--- a/include/basegfx/polygon/b2dpolygon.hxx
+++ b/include/basegfx/polygon/b2dpolygon.hxx
@@ -78,7 +78,6 @@ namespace basegfx
         /// Coordinate interface
         basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const;
         void setB2DPoint(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue);
-        basegfx::B2DPoint const & operator[](sal_uInt32 nIndex) const { return getB2DPoint(nIndex); }
 
         /// Coordinate insert/append
         void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount = 1);
diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx b/include/basegfx/polygon/b2dpolypolygon.hxx
index ee8372d0aeb5..010815c8784e 100644
--- a/include/basegfx/polygon/b2dpolypolygon.hxx
+++ b/include/basegfx/polygon/b2dpolypolygon.hxx
@@ -68,7 +68,6 @@ namespace basegfx
 
         B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const;
         void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon);
-        B2DPolygon const & operator[](sal_uInt32 nIndex) const { return getB2DPolygon(nIndex); }
 
         // test for curve
         bool areControlPointsUsed() const;
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 0acef174718c..4f6927c62f0b 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -25,8 +25,6 @@
 #include <algorithm>
 #include <ostream>
 #include <config_options.h>
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/range/b2drectangle.hxx>
 
 class SvStream;
 namespace rtl
@@ -75,7 +73,6 @@ class SAL_WARN_UNUSED UNLESS_MERGELIBS(SAL_DLLPUBLIC_EXPORT) Point final : prote
 public:
                         Point() {}
                         Point( long nX, long nY ) : Pair( nX, nY ) {}
-                        Point(basegfx::B2DPoint const & rPoint) : Pair(rPoint.getX(), rPoint.getY()) {}
 
     long                X() const { return nA; }
     long                Y() const { return nB; }
@@ -106,8 +103,6 @@ public:
     Pair const &        toPair() const { return *this; }
     Pair &              toPair() { return *this; }
 
-    operator basegfx::B2DPoint() const { return basegfx::B2DPoint(nA, nB); }
-
     using Pair::toString;
 };
 
@@ -390,7 +385,6 @@ public:
     /// Constructs an empty Rectangle, with top/left at the specified params
                         Rectangle( long nLeft, long nTop );
                         Rectangle( const Point& rLT, const Size& rSize );
-                        Rectangle( basegfx::B2DRectangle const & );
 
     static Rectangle    Justify( const Point& rLT, const Point& rRB );
 
@@ -486,8 +480,6 @@ public:
     void                SaturatingSetX(long x);
     void                SaturatingSetY(long y);
 
-    operator basegfx::B2DRectangle() const { return basegfx::B2DRectangle(nLeft, nTop, nRight, nBottom); }
-
 private:
     long                nLeft;
     long                nTop;
@@ -534,14 +526,6 @@ inline tools::Rectangle::Rectangle( const Point& rLT, const Size& rSize )
     nBottom = rSize.Height() ? nTop+(rSize.Height()-1) : RECT_EMPTY;
 }
 
-inline tools::Rectangle::Rectangle( const basegfx::B2DRectangle& rRect )
-{
-    nLeft   = rRect.getMinX();
-    nTop    = rRect.getMinY();
-    nRight  = !rRect.isEmpty() ? rRect.getMaxX() : RECT_EMPTY;
-    nBottom = !rRect.isEmpty() ? rRect.getMaxY() : RECT_EMPTY;
-}
-
 inline bool tools::Rectangle::IsEmpty() const
 {
     return (nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY);
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index fcf57bb74beb..14b03507dfe3 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -803,8 +803,6 @@ public:
      */
     void                        DrawPolyLine( const tools::Polygon& rPoly,
                                               const LineInfo& rLineInfo );
-    void                        DrawPolyLine( const basegfx::B2DPolygon& rPoly,
-                                              const LineInfo& rLineInfo );
 
     // #i101491#
     // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool.
diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx
index b69a4e324417..2a405e5eaf5a 100644
--- a/vcl/source/outdev/polyline.cxx
+++ b/vcl/source/outdev/polyline.cxx
@@ -135,36 +135,6 @@ void OutputDevice::DrawPolyLine( const tools::Polygon& rPoly, const LineInfo& rL
     drawPolyLine(rPoly, rLineInfo);
 }
 
-void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rPoly, const LineInfo& rLineInfo )
-{
-    assert(!is_double_buffered_window());
-
-    if ( rLineInfo.IsDefault() )
-    {
-        DrawPolyLine( rPoly );
-        return;
-    }
-
-    // #i101491#
-    // Try direct Fallback to B2D-Version of DrawPolyLine
-    if((mnAntialiasing & AntialiasingFlags::EnableB2dDraw) &&
-       LineStyle::Solid == rLineInfo.GetStyle())
-    {
-        DrawPolyLine(
-            rPoly,
-            static_cast< double >(rLineInfo.GetWidth()),
-            rLineInfo.GetLineJoin(),
-            rLineInfo.GetLineCap(),
-            basegfx::deg2rad(15.0) /* default fMiterMinimumAngle, value not available in LineInfo */);
-        return;
-    }
-
-    if ( mpMetaFile )
-        mpMetaFile->AddAction( new MetaPolyLineAction( tools::Polygon(rPoly), rLineInfo ) );
-
-    drawPolyLine(tools::Polygon(rPoly), rLineInfo);
-}
-
 void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
                                  double fLineWidth,
                                  basegfx::B2DLineJoin eLineJoin,


More information about the Libreoffice-commits mailing list