summaryrefslogtreecommitdiff
path: root/svgio/qa/cppunit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 13:49:45 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 15:20:16 +0200
commit41368edc6e2b16d4e0ea89b822064bb75dfadc01 (patch)
tree152c4bbf75b9700a6c016dc46974e1dc329e258a /svgio/qa/cppunit
parenta9f1b705275ef9abbcf17366d8f3713235dd4675 (diff)
tdf#159660: Add support for lighten mode in feBlend
Change-Id: I17471a9c70a38d05de5ad476f817285fb2438e5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166429 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio/qa/cppunit')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx44
-rw-r--r--svgio/qa/cppunit/data/lightenBlend.svg8
2 files changed, 52 insertions, 0 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 87aa04887d2f..abf7f58c848b 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1909,6 +1909,50 @@ CPPUNIT_TEST_FIXTURE(Test, testDarkenBlend)
CPPUNIT_ASSERT_EQUAL(OUString("008000"), aPixels[125]);
}
+CPPUNIT_TEST_FIXTURE(Test, testLightenBlend)
+{
+ xmlDocUniquePtr pDocument = dumpAndParseSvg(u"/svgio/qa/cppunit/data/lightenBlend.svg");
+
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "height"_ostr, "150");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "width"_ostr, "150");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap/data"_ostr, 150);
+
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy11"_ostr, "150");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy12"_ostr, "0");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy13"_ostr, "20");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy21"_ostr, "0");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy22"_ostr, "150");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy23"_ostr, "20");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy31"_ostr, "0");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy32"_ostr, "0");
+ assertXPath(pDocument,
+ "/primitive2D/transform/transform/bitmap"_ostr, "xy33"_ostr, "1");
+
+ // Check the colors in the diagonal
+ OUString sDataRow = getXPath(pDocument, "/primitive2D/transform/transform/bitmap/data[25]"_ostr, "row"_ostr);
+ std::vector<OUString> aPixels = comphelper::string::split(sDataRow, ',');
+ CPPUNIT_ASSERT_EQUAL(OUString("ff0000"), aPixels[25]);
+
+ sDataRow = getXPath(pDocument, "/primitive2D/transform/transform/bitmap/data[75]"_ostr, "row"_ostr);
+ aPixels = comphelper::string::split(sDataRow, ',');
+ CPPUNIT_ASSERT_EQUAL(OUString("ff8000"), aPixels[75]);
+
+ sDataRow = getXPath(pDocument, "/primitive2D/transform/transform/bitmap/data[125]"_ostr, "row"_ostr);
+ aPixels = comphelper::string::split(sDataRow, ',');
+ CPPUNIT_ASSERT_EQUAL(OUString("008000"), aPixels[125]);
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf149880)
{
xmlDocUniquePtr pDocument = dumpAndParseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg");
diff --git a/svgio/qa/cppunit/data/lightenBlend.svg b/svgio/qa/cppunit/data/lightenBlend.svg
new file mode 100644
index 000000000000..62e9254da597
--- /dev/null
+++ b/svgio/qa/cppunit/data/lightenBlend.svg
@@ -0,0 +1,8 @@
+<svg width="100" height="140" viewBox="0 0 200 280" xmlns="http://www.w3.org/2000/svg">
+ <filter id="filter" filterUnits="userSpaceOnUse" x="0" y="0" width="100%" height="100%">
+ <feFlood x="20" y="20" width="100" height="100" flood-color="red" flood-opacity="1" result="img1"></feFlood>
+ <feFlood x="50" y="50" width="100" height="100" flood-color="green" flood-opacity="1" result="img2"></feFlood>
+ <feBlend in="img1" in2="img2" mode="lighten"></feBlend>
+ </filter>
+ <use style="filter: url(#filter)"></use>
+</svg>