summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-11-07 15:09:31 +0100
committerMichael Stahl <mstahl@redhat.com>2016-11-07 18:52:22 +0000
commitf9028f1945e3ad87cda1b3001611632b1b424467 (patch)
treeb73f41f935c72df09e3c395a29dcb6eab50874fb /include
parent04644956e53d81cc4518fdbb22ddfe4fd9b8aaf7 (diff)
vcl: improve accounting of SVG images in graphics cache
The problem is that the graphics cache only counts the size of the SVG text, which is stored in SvgData::maSvgDataArray. However the SvgData::maSequence may use a lot more memory, as it may contain de-compressed bitmaps that are stored as base64-encoded PNGs in the SVG text. For example icon-themes/galaxy/brand/flat_logo.svg is 812 Ko but contains 60 Mo of bitmaps. This may cause excessive memory usage and failure to export documents due to OOM; according to valgrind massif, the bitmap buffers use 90% of the heap. Add a new interface com::sun::star::util::XAccounting, and implement it in drawinglayer BasePrimitive2D. VCL SvgData can't access drawinglayer via C++ directly so this looks like the best approach. Change-Id: I5a7c3147733e23473c1decabed24c1f79d951c7d Reviewed-on: https://gerrit.libreoffice.org/30669 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/drawinglayer/primitive2d/baseprimitive2d.hxx12
-rw-r--r--include/drawinglayer/primitive2d/bitmapprimitive2d.hxx3
-rw-r--r--include/drawinglayer/primitive2d/groupprimitive2d.hxx3
-rw-r--r--include/drawinglayer/primitive2d/patternfillprimitive2d.hxx3
-rw-r--r--include/vcl/svgdata.hxx3
5 files changed, 22 insertions, 2 deletions
diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
index 195de7720423..b6e3ecd0e1ed 100644
--- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
@@ -22,8 +22,9 @@
#include <drawinglayer/drawinglayerdllapi.h>
-#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/compbase.hxx>
#include <com/sun/star/graphic/XPrimitive2D.hpp>
+#include <com/sun/star/util/XAccounting.hpp>
#include <cppuhelper/basemutex.hxx>
#include <basegfx/range/b2drange.hxx>
@@ -49,7 +50,10 @@ namespace drawinglayer { namespace geometry {
namespace drawinglayer { namespace primitive2d {
/// typedefs for basePrimitive2DImplBase, Primitive2DSequence and Primitive2DReference
- typedef cppu::WeakComponentImplHelper1< css::graphic::XPrimitive2D > BasePrimitive2DImplBase;
+ typedef cppu::WeakComponentImplHelper<
+ css::graphic::XPrimitive2D,
+ css::util::XAccounting
+ > BasePrimitive2DImplBase;
typedef css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference;
typedef css::uno::Sequence< Primitive2DReference > Primitive2DSequence;
@@ -200,6 +204,10 @@ namespace drawinglayer
will construct a ViewInformation2D from the ViewParameters for that purpose
*/
virtual css::geometry::RealRectangle2D SAL_CALL getRange( const css::uno::Sequence< css::beans::PropertyValue >& rViewParameters ) throw ( css::uno::RuntimeException, std::exception ) override;
+
+ // XAccounting
+ virtual sal_Int64 SAL_CALL estimateUsage() throw (css::uno::RuntimeException) override;
+
};
} // end of namespace primitive2d
} // end of namespace drawinglayer
diff --git a/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx
index c7eb9e32cf37..a14fa68481f8 100644
--- a/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/bitmapprimitive2d.hxx
@@ -69,6 +69,9 @@ namespace drawinglayer
/// provide unique ID
DeclPrimitive2DIDBlock()
+
+ // XAccounting
+ virtual sal_Int64 SAL_CALL estimateUsage() throw (css::uno::RuntimeException) override;
};
} // end of namespace primitive2d
} // end of namespace drawinglayer
diff --git a/include/drawinglayer/primitive2d/groupprimitive2d.hxx b/include/drawinglayer/primitive2d/groupprimitive2d.hxx
index 67b39edd5072..5f6387417359 100644
--- a/include/drawinglayer/primitive2d/groupprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/groupprimitive2d.hxx
@@ -84,6 +84,9 @@ namespace drawinglayer
/// provide unique ID
DeclPrimitive2DIDBlock()
+
+ // XAccounting
+ virtual sal_Int64 SAL_CALL estimateUsage() throw (css::uno::RuntimeException) override;
};
} // end of namespace primitive2d
} // end of namespace drawinglayer
diff --git a/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx b/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx
index 8e10564251b8..8a64fdf3e71f 100644
--- a/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/patternfillprimitive2d.hxx
@@ -87,6 +87,9 @@ namespace drawinglayer
/// provide unique ID
DeclPrimitive2DIDBlock()
+
+ // XAccounting
+ virtual sal_Int64 SAL_CALL estimateUsage() throw (css::uno::RuntimeException) override;
};
} // end of namespace primitive2d
} // end of namespace drawinglayer
diff --git a/include/vcl/svgdata.hxx b/include/vcl/svgdata.hxx
index 361528843691..740137804d27 100644
--- a/include/vcl/svgdata.hxx
+++ b/include/vcl/svgdata.hxx
@@ -52,6 +52,7 @@ private:
std::vector< css::uno::Reference< css::graphic::XPrimitive2D > >
maSequence;
BitmapEx maReplacement;
+ size_t mNestedBitmapSize;
// on demand creators
void ensureReplacement();
@@ -67,6 +68,8 @@ public:
/// data read
const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
sal_uInt32 getSvgDataArrayLength() const { return maSvgDataArray.getLength(); }
+ enum class State { UNPARSED, PARSED };
+ std::pair<State, size_t> getSizeBytes();
const OUString& getPath() const { return maPath; }
/// data read and evtl. on demand creation