diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-12-07 18:53:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-23 11:45:33 +0100 |
commit | e3bd776e020723ad8caf0a02d8db0d19e0f0e650 (patch) | |
tree | 8ed999eb97278d2cb7954695f03d0bc3652ee6b0 /svgio | |
parent | be596c0192f059324d06716b625be6a11079f8ea (diff) |
Split BasePrimitive2D UNO interface into separate object
Rather than make all the BasePrimitive2D classes bear the cost of being an UNO
object, we just wrap the top level BasePrimitive2D in this class when we need
to pass them over UNO.
This reduces the locking overhead when doing normal drawinglayer operations,
and reduces the size of drawinglayer objects and the cost of initialising
them, which shaves 5% off the load/display time of a large barchart.
Add new drawinglayer::convertPrimitive2DContainerToBitmapEx utility
method to avoid needing to convert to Sequence<XPrimitive2D>
Change-Id: I553eaa4c16ba016b098cb21f6c55f5008f0d9b53
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126487
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/CppunitTest_svgio.mk | 1 | ||||
-rw-r--r-- | svgio/CppunitTest_svgio_tools.mk | 1 | ||||
-rw-r--r-- | svgio/Library_svgio.mk | 1 | ||||
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 70 | ||||
-rw-r--r-- | svgio/source/svguno/xsvgparser.cxx | 2 |
5 files changed, 41 insertions, 34 deletions
diff --git a/svgio/CppunitTest_svgio.mk b/svgio/CppunitTest_svgio.mk index e6708c916f34..3a828ad036e3 100644 --- a/svgio/CppunitTest_svgio.mk +++ b/svgio/CppunitTest_svgio.mk @@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svgio,\ cppuhelper \ comphelper \ sal \ + salhelper \ sax \ svt \ test \ diff --git a/svgio/CppunitTest_svgio_tools.mk b/svgio/CppunitTest_svgio_tools.mk index 09eb03f659fc..cb48c5eda09d 100644 --- a/svgio/CppunitTest_svgio_tools.mk +++ b/svgio/CppunitTest_svgio_tools.mk @@ -34,6 +34,7 @@ $(eval $(call gb_CppunitTest_use_libraries,svgio_tools,\ cppu \ cppuhelper \ sal \ + salhelper \ sax \ svt \ tk \ diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index e921ddaad939..c5a35405323f 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -39,6 +39,7 @@ $(eval $(call gb_Library_use_libraries,svgio,\ cppu \ cppuhelper \ sal \ + salhelper \ tk \ tl \ sax \ diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 25baf76fdad8..a46285ee7f64 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -20,6 +20,7 @@ #include <drawinglayer/primitive2d/Tools.hxx> #include <drawinglayer/tools/primitive2dxmldump.hxx> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <memory> #include <string_view> @@ -129,7 +130,7 @@ Primitive2DSequence Test::parseSvg(std::u16string_view aSource) void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive) { drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(rPrimitive)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(rPrimitive)); CPPUNIT_ASSERT (pDocument); @@ -149,8 +150,11 @@ void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive) bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB) { return std::equal(rA.begin(), rA.end(), rB.begin(), rB.end(), - [](const Primitive2DReference& a, const Primitive2DReference& b) { - return drawinglayer::primitive2d::arePrimitive2DReferencesEqual(a, b); }); + [](const css::uno::Reference<css::graphic::XPrimitive2D>& a, + const css::uno::Reference<css::graphic::XPrimitive2D>& b) + { + return drawinglayer::primitive2d::arePrimitive2DReferencesEqual(a, b); + }); } // Attributes for an object (like rect as in this case) can be defined @@ -185,7 +189,7 @@ void Test::testTdf87309() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf87309.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf87309)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf87309); CPPUNIT_ASSERT (pDocument); @@ -204,7 +208,7 @@ void Test::testFontsizeKeywords() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceFontsizeKeywords.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceFontsizeKeywords)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeKeywords); CPPUNIT_ASSERT (pDocument); @@ -267,7 +271,7 @@ void Test::testFontsizePercentage() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceFontsizePercentage.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceFontsizePercentage)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizePercentage); CPPUNIT_ASSERT (pDocument); @@ -284,7 +288,7 @@ void Test::testFontsizeRelative() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceFontsizeRelative.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceFontsizeRelative)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceFontsizeRelative); CPPUNIT_ASSERT (pDocument); @@ -306,7 +310,7 @@ void Test::testTdf45771() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf45771.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf45771)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf45771); CPPUNIT_ASSERT (pDocument); @@ -323,7 +327,7 @@ void Test::testTdf97941() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97941.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf97941)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf97941); CPPUNIT_ASSERT (pDocument); @@ -339,7 +343,7 @@ void Test::testTdf104339() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf104339.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf104339)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequenceTdf104339); CPPUNIT_ASSERT (pDocument); assertXPath(pDocument, "/primitive2D/transform/transform/transform/transform/transform/polypolygoncolor", "color", "#000000"); @@ -351,7 +355,7 @@ void Test::testTdf85770() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf85770.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf85770)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf85770)); CPPUNIT_ASSERT (pDocument); @@ -377,7 +381,7 @@ void Test::testTdf79163() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf79163.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf79163)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf79163)); CPPUNIT_ASSERT (pDocument); @@ -390,7 +394,7 @@ void Test::testTdf97542_1() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97542_1.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf97542_1)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_1)); CPPUNIT_ASSERT (pDocument); @@ -406,7 +410,7 @@ void Test::testTdf97542_2() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97542_2.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf97542_2)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97542_2)); CPPUNIT_ASSERT (pDocument); @@ -422,7 +426,7 @@ void Test::testTdf97543() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97543.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf97543)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97543)); CPPUNIT_ASSERT (pDocument); @@ -441,7 +445,7 @@ void Test::testRGBColor() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRGBColor.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceRGBColor)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBColor)); CPPUNIT_ASSERT (pDocument); @@ -460,7 +464,7 @@ void Test::testRGBAColor() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRGBAColor.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceRGBAColor)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor)); CPPUNIT_ASSERT (pDocument); @@ -473,7 +477,7 @@ void Test::testNoneColor() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceRGBAColor.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceRGBAColor)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceRGBAColor)); CPPUNIT_ASSERT (pDocument); @@ -490,7 +494,7 @@ void Test::testTdf97936() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf97936.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf97936)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf97936)); CPPUNIT_ASSERT (pDocument); @@ -518,7 +522,7 @@ void Test::testClipPathAndParentStyle() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndParentStyle.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceClipPathAndParentStyle)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndParentStyle)); CPPUNIT_ASSERT (pDocument); @@ -536,7 +540,7 @@ void Test::testClipPathAndStyle() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndStyle.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceClipPathAndStyle)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle)); CPPUNIT_ASSERT (pDocument); @@ -553,7 +557,7 @@ void Test::testi125329() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequencei125329.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequencei125329)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequencei125329)); CPPUNIT_ASSERT (pDocument); @@ -576,7 +580,7 @@ void Test::testMaskingPath07b() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceMaskingPath07b.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceMaskingPath07b)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskingPath07b)); CPPUNIT_ASSERT (pDocument); @@ -588,7 +592,7 @@ void Test::test123926() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence123926.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence123926)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence123926)); CPPUNIT_ASSERT (pDocument); @@ -602,7 +606,7 @@ void Test::test47446() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence47446.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence47446)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446)); CPPUNIT_ASSERT (pDocument); @@ -617,7 +621,7 @@ void Test::test47446b() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence47446b.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence47446b)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence47446b)); CPPUNIT_ASSERT (pDocument); @@ -632,7 +636,7 @@ void Test::testMaskText() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceMaskText.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceMaskText)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceMaskText)); CPPUNIT_ASSERT (pDocument); @@ -650,7 +654,7 @@ void Test::testTdf99994() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf99994.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf99994)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99994)); CPPUNIT_ASSERT (pDocument); @@ -667,7 +671,7 @@ void Test::testTdf99115() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf99115.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf99115) ); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf99115) ); CPPUNIT_ASSERT (pDocument); @@ -716,7 +720,7 @@ void Test::testTdf101237() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf101237.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf101237)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf101237)); CPPUNIT_ASSERT (pDocument); @@ -731,7 +735,7 @@ void Test::testTdf94765() CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf94765.getLength())); drawinglayer::Primitive2dXmlDump dumper; - xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf94765)); + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceTdf94765)); CPPUNIT_ASSERT (pDocument); @@ -762,7 +766,7 @@ void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet() basegfx::B2DRange aRange; uno::Sequence<beans::PropertyValue> aViewParameters; - for (Primitive2DReference const & xReference : aSequence) + for (css::uno::Reference<css::graphic::XPrimitive2D> const & xReference : aSequence) { if (xReference.is()) { @@ -787,7 +791,7 @@ void Test::testBehaviourWhenWidthAndHeightIsOrIsNotSet() basegfx::B2DRange aRange; uno::Sequence<beans::PropertyValue> aViewParameters; - for (Primitive2DReference const & xReference : aSequence) + for (css::uno::Reference<css::graphic::XPrimitive2D> const & xReference : aSequence) { if (xReference.is()) { diff --git a/svgio/source/svguno/xsvgparser.cxx b/svgio/source/svguno/xsvgparser.cxx index 515c6910beb4..f6e85cdeb964 100644 --- a/svgio/source/svguno/xsvgparser.cxx +++ b/svgio/source/svguno/xsvgparser.cxx @@ -141,7 +141,7 @@ namespace svgio::svgreader OSL_ENSURE(false, "Invalid stream (!)"); } - return comphelper::containerToSequence(aRetval); + return aRetval.toSequence(); } uno::Any SAL_CALL XSvgParser::getDrawCommands( |