[Libreoffice-commits] core.git: filter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jul 25 16:26:24 UTC 2018


 filter/source/graphicfilter/idxf/dxf2mtf.cxx |   32 +++++++++++++++++----------
 filter/source/graphicfilter/idxf/dxf2mtf.hxx |    3 ++
 2 files changed, 24 insertions(+), 11 deletions(-)

New commits:
commit ad9821c92fdf6dbd39826fb71742f10c41f2155b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jul 25 14:59:51 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 25 18:26:02 2018 +0200

    ofz#8539 share LineInfo to save memory
    
    Change-Id: I6a97d82e55fb91f2c45add4d066522f36fabff6c
    Reviewed-on: https://gerrit.libreoffice.org/57983
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
index 203fc9a7f911..40595574dde3 100644
--- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx
+++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
@@ -20,6 +20,7 @@
 
 #include <string.h>
 #include <vcl/gdimtf.hxx>
+#include <vcl/metaact.hxx>
 #include <vcl/virdev.hxx>
 #include <tools/poly.hxx>
 #include "dxf2mtf.hxx"
@@ -230,9 +231,9 @@ void DXF2GDIMetaFile::DrawLineEntity(const DXFLineEntity & rE, const DXFTransfor
             Point aP2,aP3;
             rTransform.Transform(rE.aP0+DXFVector(0,0,rE.fThickness),aP2);
             rTransform.Transform(rE.aP1+DXFVector(0,0,rE.fThickness),aP3);
-            pVirDev->DrawLine(aP2,aP3);
-            pVirDev->DrawLine(aP0,aP2);
-            pVirDev->DrawLine(aP1,aP3);
+            DrawLine(aP2,aP3);
+            DrawLine(aP0,aP2);
+            DrawLine(aP1,aP3);
         }
     }
 }
@@ -248,7 +249,7 @@ void DXF2GDIMetaFile::DrawPointEntity(const DXFPointEntity & rE, const DXFTransf
         else {
             Point aP1;
             rTransform.Transform(rE.aP0+DXFVector(0,0,rE.fThickness),aP1);
-            pVirDev->DrawLine(aP0,aP1);
+            DrawLine(aP0,aP1);
         }
     }
 }
@@ -290,11 +291,20 @@ void DXF2GDIMetaFile::DrawCircleEntity(const DXFCircleEntity & rE, const DXFTran
 
             }
             pVirDev->DrawPolyLine(aPoly2);
-            for (i=0; i<nPoints-1; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+            for (i=0; i<nPoints-1; i++) DrawLine(aPoly[i],aPoly2[i]);
         }
     }
 }
 
+void DXF2GDIMetaFile::DrawLine(const Point& rA, const Point& rB)
+{
+    GDIMetaFile* pMetaFile = pVirDev->GetConnectMetaFile();
+    assert(pMetaFile);
+    //use AddAction instead of OutputDevice::DrawLine so that we can explicitly share
+    //the aDefaultLineInfo between the MetaLineActions to reduce memory use
+    pMetaFile->AddAction(new MetaLineAction(rA, rB, aDefaultLineInfo));
+}
+
 void DXF2GDIMetaFile::DrawArcEntity(const DXFArcEntity & rE, const DXFTransform & rTransform)
 {
     double frx,fry;
@@ -352,7 +362,8 @@ void DXF2GDIMetaFile::DrawArcEntity(const DXFArcEntity & rE, const DXFTransform
                 );
             }
             pVirDev->DrawPolyLine(aPoly2);
-            for (i=0; i<nPoints; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+            for (i=0; i<nPoints; i++)
+                DrawLine(aPoly[i], aPoly2[i]);
         }
     }
 }
@@ -375,7 +386,7 @@ void DXF2GDIMetaFile::DrawTraceEntity(const DXFTraceEntity & rE, const DXFTransf
             rTransform.Transform(rE.aP3+aVAdd,aPoly2[2]);
             rTransform.Transform(rE.aP2+aVAdd,aPoly2[3]);
             pVirDev->DrawPolygon(aPoly2);
-            for (i=0; i<4; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+            for (i=0; i<4; i++) DrawLine(aPoly[i],aPoly2[i]);
         }
     }
 }
@@ -402,7 +413,7 @@ void DXF2GDIMetaFile::DrawSolidEntity(const DXFSolidEntity & rE, const DXFTransf
             pVirDev->DrawPolygon(aPoly2);
             if (SetLineAttribute(rE)) {
                 sal_uInt16 i;
-                for (i=0; i<nN; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+                for (i=0; i<nN; i++) DrawLine(aPoly[i],aPoly2[i]);
             }
         }
     }
@@ -524,7 +535,7 @@ void DXF2GDIMetaFile::DrawPolyLineEntity(const DXFPolyLineEntity & rE, const DXF
             }
             if ((rE.nFlags&1)!=0) pVirDev->DrawPolygon(aPoly2);
             else pVirDev->DrawPolyLine(aPoly2);
-            for (i=0; i<nPolySize; i++) pVirDev->DrawLine(aPoly[i],aPoly2[i]);
+            for (i=0; i<nPolySize; i++) DrawLine(aPoly[i],aPoly2[i]);
         }
     }
 }
@@ -620,14 +631,13 @@ void DXF2GDIMetaFile::Draw3DFaceEntity(const DXF3DFaceEntity & rE, const DXFTran
         else {
             for (i=0; i<nN; i++) {
                 if ( (rE.nIEFlags & (1<<i)) == 0 ) {
-                    pVirDev->DrawLine(aPoly[i],aPoly[(i+1)%nN]);
+                    DrawLine(aPoly[i],aPoly[(i+1)%nN]);
                 }
             }
         }
     }
 }
 
-
 void DXF2GDIMetaFile::DrawDimensionEntity(const DXFDimensionEntity & rE, const DXFTransform & rTransform)
 {
     const DXFBlock * pB;
diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.hxx b/filter/source/graphicfilter/idxf/dxf2mtf.hxx
index 8492289bf067..ba5cc3ac84c5 100644
--- a/filter/source/graphicfilter/idxf/dxf2mtf.hxx
+++ b/filter/source/graphicfilter/idxf/dxf2mtf.hxx
@@ -51,6 +51,7 @@ private:
     Color       aActLineColor;
     Color       aActFillColor;
     vcl::Font   aActFont;
+    const LineInfo aDefaultLineInfo; // to share between lines to reduce memory
 
     static sal_uLong CountEntities(const DXFEntities & rEntities);
 
@@ -100,6 +101,8 @@ private:
     void DrawEntities(const DXFEntities & rEntities,
                       const DXFTransform & rTransform);
 
+    void DrawLine(const Point& rA, const Point& rB);
+
 public:
 
     DXF2GDIMetaFile();


More information about the Libreoffice-commits mailing list