cppcanvas/source/mtfrenderer/implrenderer.cxx            |    2 +-
 cppcanvas/source/mtfrenderer/transparencygroupaction.hxx |    4 ++--
 filter/source/svg/svgwriter.cxx                          |   15 ++++++++-------
 filter/source/svg/svgwriter.hxx                          |    2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 6ca077ee7156123ec38a6cfdde7168749589d0ff
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Mar 1 11:51:07 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Mar 1 13:07:33 2023 +0000

    no need to allocate Gradient separately
    
    it is only one pointer big
    
    Change-Id: I21afdeb8015c658c7b9d5db24bceeb8e43694272
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148038
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx 
b/cppcanvas/source/mtfrenderer/implrenderer.cxx
index 1fef9c48cce7..e1b4476b62ee 100644
--- a/cppcanvas/source/mtfrenderer/implrenderer.cxx
+++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx
@@ -2409,7 +2409,7 @@ namespace cppcanvas::internal
 
                         // TODO(P2): Use native canvas gradients here (saves a 
lot of UNO calls)
                         internal::GradientAutoPtr pGradient(
-                            new Gradient( pAct->GetGradient() ) );
+                            pAct->GetGradient() );
 
                         DBG_TESTSOLARMUTEX();
 
diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.hxx 
b/cppcanvas/source/mtfrenderer/transparencygroupaction.hxx
index f863d18ed4c7..eb2419bbf53f 100644
--- a/cppcanvas/source/mtfrenderer/transparencygroupaction.hxx
+++ b/cppcanvas/source/mtfrenderer/transparencygroupaction.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include <cppcanvas/canvas.hxx>
+#include <vcl/gradient.hxx>
 #include <action.hxx>
 
 #include <memory>
@@ -30,7 +31,6 @@ namespace basegfx {
 }
 
 class GDIMetaFile;
-class Gradient;
 
 
 /* Definition of internal::TransparencyGroupActionFactory */
@@ -40,7 +40,7 @@ namespace cppcanvas::internal
         struct OutDevState;
 
         typedef std::unique_ptr< GDIMetaFile >  MtfAutoPtr;
-        typedef std::unique_ptr< Gradient >     GradientAutoPtr;
+        typedef std::optional< Gradient >     GradientAutoPtr;
 
         /** Transparency group action.
 
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index e4420dc27e71..d6909bcdb070 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2119,10 +2119,11 @@ void SVGActionWriter::ImplWriteShape( const 
SVGShapeDescriptor& rShape )
     ImplMap( rShape.maShapePolyPoly, aPolyPoly );
 
     const bool bLineOnly
-        = (rShape.maShapeFillColor == COL_TRANSPARENT) && 
(!rShape.mapShapeGradient);
+        = (rShape.maShapeFillColor == COL_TRANSPARENT) && 
(!rShape.moShapeGradient);
     tools::Rectangle   aBoundRect( aPolyPoly.GetBoundRect() );
 
-    maAttributeWriter.AddPaintAttr( rShape.maShapeLineColor, 
rShape.maShapeFillColor, &aBoundRect, rShape.mapShapeGradient.get() );
+    maAttributeWriter.AddPaintAttr( rShape.maShapeLineColor, 
rShape.maShapeFillColor, &aBoundRect,
+                                   rShape.moShapeGradient ? 
&*rShape.moShapeGradient : nullptr );
 
     if( !rShape.maId.isEmpty() )
         mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, rShape.maId );
@@ -3440,7 +3441,7 @@ void SVGActionWriter::ImplWriteActions( const 
GDIMetaFile& rMtf,
                             if( bGradient )
                             {
                                 // step through following actions until the 
first Gradient/GradientEx action is found
-                                while (!mapCurShape->mapShapeGradient && bSkip
+                                while (!mapCurShape->moShapeGradient && bSkip
                                        && (++nCurAction < nCount))
                                 {
                                     pAction = rMtf.GetAction( nCurAction );
@@ -3453,13 +3454,13 @@ void SVGActionWriter::ImplWriteActions( const 
GDIMetaFile& rMtf,
                                     }
                                     else if( pAction->GetType() == 
MetaActionType::GRADIENTEX )
                                     {
-                                        mapCurShape->mapShapeGradient.reset( 
new Gradient(
-                                            static_cast< const 
MetaGradientExAction* >( pAction )->GetGradient() ) );
+                                        mapCurShape->moShapeGradient.emplace(
+                                            static_cast< const 
MetaGradientExAction* >( pAction )->GetGradient() );
                                     }
                                     else if( pAction->GetType() == 
MetaActionType::GRADIENT )
                                     {
-                                        mapCurShape->mapShapeGradient.reset( 
new Gradient(
-                                            static_cast< const 
MetaGradientAction* >( pAction )->GetGradient() ) );
+                                        mapCurShape->moShapeGradient.emplace(
+                                            static_cast< const 
MetaGradientAction* >( pAction )->GetGradient() );
                                     }
                                 }
                             }
diff --git a/filter/source/svg/svgwriter.hxx b/filter/source/svg/svgwriter.hxx
index 022c2585c5ab..16ac77a20026 100644
--- a/filter/source/svg/svgwriter.hxx
+++ b/filter/source/svg/svgwriter.hxx
@@ -164,7 +164,7 @@ struct SVGShapeDescriptor
     Color                               maShapeLineColor;
     sal_Int32                           mnStrokeWidth;
     SvtGraphicStroke::DashArray         maDashArray;
-    ::std::unique_ptr< Gradient >       mapShapeGradient;
+    ::std::optional< Gradient >         moShapeGradient;
     OUString                            maId;
     basegfx::B2DLineJoin        maLineJoin;
     css::drawing::LineCap       maLineCap;

Reply via email to