[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - basegfx/source basegfx/test include/basegfx svgio/inc svgio/source

2023-07-10 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |   40 +---
 basegfx/test/BColorModifierTest.cxx |   77 +++-
 include/basegfx/color/bcolormodifier.hxx|6 -
 svgio/inc/svgtools.hxx  |3 
 svgio/source/svgreader/svgfecolormatrixnode.cxx |4 -
 svgio/source/svgreader/svgtools.cxx |   26 ++--
 6 files changed, 92 insertions(+), 64 deletions(-)

New commits:
commit a74e4ebdfc2e85bf4fec6e8ac7aa2980473e81f3
Author: Xisco Fauli 
AuthorDate: Mon Jul 10 11:52:30 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 10 14:44:27 2023 +0200

tdf#99562: Do not ignore last column from matrix

Change-Id: I1dff65963e2c414d1771a1592159930150c513e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154241
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154245

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 4d3f277c6cc5..75c06f5cb8f3 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -155,23 +155,41 @@ namespace basegfx
 return false;
 }
 
-return maMatrix == pCompare->maMatrix;
+return maVector == pCompare->maVector;
 }
 
 ::basegfx::BColor BColorModifier_matrix::getModifiedColor(const 
::basegfx::BColor& aSourceColor) const
 {
-basegfx::B3DHomMatrix aColorMatrix;
-aColorMatrix.set(0, 0, aSourceColor.getRed());
-aColorMatrix.set(1, 0, aSourceColor.getGreen());
-aColorMatrix.set(2, 0, aSourceColor.getBlue());
-aColorMatrix.set(3, 0, 1.0);
-// TODO: add support for alpha
+if (maVector.size() != 20)
+return aSourceColor;
+
+const double aRed = maVector[0] * aSourceColor.getRed()
++ maVector[1] * aSourceColor.getGreen()
++ maVector[2] * aSourceColor.getBlue()
++ maVector[3] * 1.0
++ maVector[4];
+const double aGreen = maVector[5] * aSourceColor.getRed()
++ maVector[6] * aSourceColor.getGreen()
++ maVector[7] * aSourceColor.getBlue()
++ maVector[8] * 1.0
++ maVector[9];
+const double aBlue = maVector[10] * aSourceColor.getRed()
++ maVector[11] * aSourceColor.getGreen()
++ maVector[12] * aSourceColor.getBlue()
++ maVector[13] * 1.0
++ maVector[14];
+/*TODO: add support for alpha
+const double aAlpha = maVector[15] * aSourceColor.getRed()
++ maVector[16] * aSourceColor.getGreen()
++ maVector[17] * aSourceColor.getBlue()
++ maVector[18] * 1.0
++ maVector[19]);
+*/
 
-aColorMatrix = maMatrix * aColorMatrix;
 return ::basegfx::BColor(
-std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0),
-std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0),
-std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0));
+std::clamp(aRed, 0.0, 1.0),
+std::clamp(aGreen, 0.0, 1.0),
+std::clamp(aBlue, 0.0, 1.0));
 }
 
 OUString BColorModifier_matrix::getModifierName() const
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index f8a05900d195..82725f441a9c 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -272,22 +272,15 @@ public:
 void testMatrix()
 {
 // green matrix
-basegfx::B3DHomMatrix aMatrix;
-aMatrix.set(0, 0, 0.0);
-aMatrix.set(0, 1, 0.0);
-aMatrix.set(0, 2, 0.0);
-aMatrix.set(0, 3, 0.0);
-aMatrix.set(1, 0, 1.0);
-aMatrix.set(1, 1, 1.0);
-aMatrix.set(1, 2, 1.0);
-aMatrix.set(1, 3, 1.0);
-aMatrix.set(2, 0, 0.0);
-aMatrix.set(2, 1, 0.0);
-aMatrix.set(2, 2, 0.0);
-aMatrix.set(2, 3, 0.0);
+// clang-format off
+std::vector aVector = {0.0, 0.0, 0.0, 0.0, 0.0,
+   1.0, 1.0, 1.0, 1.0, 0.0,
+   0.0, 0.0, 0.0, 0.0, 0.0,
+   0.0, 0.0, 0.0, 1.0, 0.0};
+// clang-format on
 
 const basegfx::BColorModifierSharedPtr aBColorModifier
-= std::make_shared(aMatrix);
+= std::make_shared(aVector);
 
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maWhite));
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGray));
@@ -306,25 +299,54 @@ public:
 CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
 
 const basegfx::BColorModifierSharedPtr aBColorModifier2
-= std::make_shared(aMatrix);
+= std::make_shared(aVector);
+

[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - basegfx/source basegfx/test

2023-07-07 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |7 ++-
 basegfx/test/BColorModifierTest.cxx |   17 ++---
 2 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 9111a6154e40f5c9a7d5d5470f76597b1cbaa8ec
Author: Xisco Fauli 
AuthorDate: Fri Jul 7 14:44:00 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 7 17:35:15 2023 +0200

related: tdf#155735: clamp RGB values

So when a green matrix is used, everything becomes green.
Also set alpha to 1.0 so at least a green matrix on black returns
green and not black

Change-Id: I9104c7511545fb244750b066bb1e996b6ce229f2
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154168
Tested-by: Jenkins

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 829b0abda659..4d3f277c6cc5 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -164,9 +164,14 @@ namespace basegfx
 aColorMatrix.set(0, 0, aSourceColor.getRed());
 aColorMatrix.set(1, 0, aSourceColor.getGreen());
 aColorMatrix.set(2, 0, aSourceColor.getBlue());
+aColorMatrix.set(3, 0, 1.0);
+// TODO: add support for alpha
 
 aColorMatrix = maMatrix * aColorMatrix;
-return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 
0), aColorMatrix.get(2, 0));
+return ::basegfx::BColor(
+std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0));
 }
 
 OUString BColorModifier_matrix::getModifierName() const
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 17b6a0c22257..f8a05900d195 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -289,21 +289,16 @@ public:
 const basegfx::BColorModifierSharedPtr aBColorModifier
 = std::make_shared(aMatrix);
 
-BColor aExpectedWhite(0.0, 3.0, 0.0);
-CPPUNIT_ASSERT_EQUAL(aExpectedWhite, 
aBColorModifier->getModifiedColor(maWhite));
-BColor aExpectedGray(0.0, 1.5, 0.0);
-CPPUNIT_ASSERT_EQUAL(aExpectedGray, 
aBColorModifier->getModifiedColor(maGray));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maWhite));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maBlack));
 
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maRed));
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGreen));
 CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maBlue));
-BColor aExpectedYellow(0.0, 2.0, 0.0);
-CPPUNIT_ASSERT_EQUAL(aExpectedYellow, 
aBColorModifier->getModifiedColor(maYellow));
-BColor aExpectedMagenta = aExpectedYellow;
-CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, 
aBColorModifier->getModifiedColor(maMagenta));
-BColor aExpectedCyan = aExpectedYellow;
-CPPUNIT_ASSERT_EQUAL(aExpectedCyan, 
aBColorModifier->getModifiedColor(maCyan));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maYellow));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maMagenta));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maCyan));
 
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
 const basegfx::BColorModifierSharedPtr aBColorModifierInvert


[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source

2023-06-27 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx  |   19 ---
 basegfx/test/BColorModifierTest.cxx  |   27 
 include/basegfx/color/bcolormodifier.hxx |   20 
 svgio/inc/svgfecolormatrixnode.hxx   |2 -
 svgio/inc/svgfegaussianblurnode.hxx  |2 -
 svgio/inc/svgfilternode.hxx  |6 ---
 svgio/qa/cppunit/SvgImportTest.cxx   |3 -
 svgio/qa/cppunit/data/filterFeGaussianBlur.svg   |2 -
 svgio/source/svgreader/svgfecolormatrixnode.cxx  |   21 -
 svgio/source/svgreader/svgfegaussianblurnode.cxx |   37 ++-
 10 files changed, 6 insertions(+), 133 deletions(-)

New commits:
commit 5e713ba80fcc7a4157cb7a7e7c3c3476c91f59d4
Author: Xisco Fauli 
AuthorDate: Mon Jun 26 22:16:12 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jun 27 13:39:38 2023 +0200

Revert "tdf#132246, tdf#155735: Add support for SourceAlpha"

This reverts commit 75399b8aad6c0f0998b9d0a6eddb2e29f8bc114c.

it was incomplete.
While at it, do not parse 'in' attribute for now, so only
in="SourceGraphic" is used.
Implementing the 'in' attribute is not trivial

Change-Id: I66c721c1144638f5e3759e0aa3a1c2c062499a90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153627
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153632

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 52f34a69f205..829b0abda659 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -69,25 +69,6 @@ namespace basegfx
 return "invert";
 }
 
-BColorModifier_alpha::~BColorModifier_alpha()
-{
-}
-
-bool BColorModifier_alpha::operator==(const BColorModifier& rCompare) const
-{
-return dynamic_cast< const BColorModifier_alpha* >() != 
nullptr;
-}
-
-::basegfx::BColor BColorModifier_alpha::getModifiedColor(const 
::basegfx::BColor& /*aSourceColor*/) const
-{
-return ::basegfx::BColor(0.0, 0.0, 0.0);
-}
-
-OUString BColorModifier_alpha::getModifierName() const
-{
-return "alpha";
-}
-
 BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha()
 {
 }
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index ca811f67bd8a..17b6a0c22257 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -352,32 +352,6 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
-void testAlpha()
-{
-const basegfx::BColorModifierSharedPtr aBColorModifier
-= std::make_shared();
-
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maWhite));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGray));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
-
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maRed));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGreen));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlue));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maYellow));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maMagenta));
-CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maCyan));
-
-CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
-const basegfx::BColorModifierSharedPtr aBColorModifierInvert
-= std::make_shared();
-CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
-
-const basegfx::BColorModifierSharedPtr aBColorModifier2
-= std::make_shared();
-CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
-}
-
 CPPUNIT_TEST_SUITE(bcolormodifier);
 CPPUNIT_TEST(testGray);
 CPPUNIT_TEST(testInvert);
@@ -388,7 +362,6 @@ public:
 CPPUNIT_TEST(testHueRotate);
 CPPUNIT_TEST(testMatrix);
 CPPUNIT_TEST(testIdentityMatrix);
-CPPUNIT_TEST(testAlpha);
 CPPUNIT_TEST_SUITE_END();
 };
 
diff --git a/include/basegfx/color/bcolormodifier.hxx 
b/include/basegfx/color/bcolormodifier.hxx
index a553ad18311f..ceffae841847 100644
--- a/include/basegfx/color/bcolormodifier.hxx
+++ b/include/basegfx/color/bcolormodifier.hxx
@@ -127,26 +127,6 @@ namespace basegfx
 SAL_DLLPRIVATE virtual OUString getModifierName() const override;
 };
 
-/**
- * convert to alpha
-*/
-class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC BColorModifier_alpha final : 
public BColorModifier
-{
-public:
-BColorModifier_alpha()
-{
-}
-
-virtual ~BColorModifier_alpha() override;
-
-// 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source

2023-06-24 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx  |   19 
 basegfx/test/BColorModifierTest.cxx  |   27 +++
 include/basegfx/color/bcolormodifier.hxx |   20 +
 svgio/inc/svgfecolormatrixnode.hxx   |2 +
 svgio/inc/svgfegaussianblurnode.hxx  |   14 ---
 svgio/inc/svgfilternode.hxx  |6 +
 svgio/qa/cppunit/SvgImportTest.cxx   |3 +-
 svgio/qa/cppunit/data/filterFeGaussianBlur.svg   |2 -
 svgio/source/svgreader/svgfecolormatrixnode.cxx  |   21 +
 svgio/source/svgreader/svgfegaussianblurnode.cxx |   18 +--
 10 files changed, 115 insertions(+), 17 deletions(-)

New commits:
commit 31a66dab1e7d39e2d2062442f41090c583466cc1
Author: Xisco Fauli 
AuthorDate: Sat Jun 24 11:17:16 2023 +0200
Commit: Xisco Fauli 
CommitDate: Sat Jun 24 14:37:35 2023 +0200

tdf#132246, tdf#155735: Add support for SourceAlpha

Change-Id: I8feae2447b17e15113ca45fe46c0d68cb6b6ab71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153550
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153554

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 829b0abda659..52f34a69f205 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -69,6 +69,25 @@ namespace basegfx
 return "invert";
 }
 
+BColorModifier_alpha::~BColorModifier_alpha()
+{
+}
+
+bool BColorModifier_alpha::operator==(const BColorModifier& rCompare) const
+{
+return dynamic_cast< const BColorModifier_alpha* >() != 
nullptr;
+}
+
+::basegfx::BColor BColorModifier_alpha::getModifiedColor(const 
::basegfx::BColor& /*aSourceColor*/) const
+{
+return ::basegfx::BColor(0.0, 0.0, 0.0);
+}
+
+OUString BColorModifier_alpha::getModifierName() const
+{
+return "alpha";
+}
+
 BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha()
 {
 }
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 17b6a0c22257..ca811f67bd8a 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -352,6 +352,32 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
+void testAlpha()
+{
+const basegfx::BColorModifierSharedPtr aBColorModifier
+= std::make_shared();
+
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maWhite));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maRed));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maGreen));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlue));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maYellow));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maMagenta));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maCyan));
+
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
+const basegfx::BColorModifierSharedPtr aBColorModifierInvert
+= std::make_shared();
+CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
+
+const basegfx::BColorModifierSharedPtr aBColorModifier2
+= std::make_shared();
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
+}
+
 CPPUNIT_TEST_SUITE(bcolormodifier);
 CPPUNIT_TEST(testGray);
 CPPUNIT_TEST(testInvert);
@@ -362,6 +388,7 @@ public:
 CPPUNIT_TEST(testHueRotate);
 CPPUNIT_TEST(testMatrix);
 CPPUNIT_TEST(testIdentityMatrix);
+CPPUNIT_TEST(testAlpha);
 CPPUNIT_TEST_SUITE_END();
 };
 
diff --git a/include/basegfx/color/bcolormodifier.hxx 
b/include/basegfx/color/bcolormodifier.hxx
index ceffae841847..a553ad18311f 100644
--- a/include/basegfx/color/bcolormodifier.hxx
+++ b/include/basegfx/color/bcolormodifier.hxx
@@ -127,6 +127,26 @@ namespace basegfx
 SAL_DLLPRIVATE virtual OUString getModifierName() const override;
 };
 
+/**
+ * convert to alpha
+*/
+class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC BColorModifier_alpha final : 
public BColorModifier
+{
+public:
+BColorModifier_alpha()
+{
+}
+
+virtual ~BColorModifier_alpha() override;
+
+// compare operator
+SAL_DLLPRIVATE virtual bool operator==(const BColorModifier& rCompare) 
const override;
+
+// compute modified color
+SAL_DLLPRIVATE virtual ::basegfx::BColor getModifiedColor(const 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source

2023-06-22 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |   32 +
 basegfx/test/BColorModifierTest.cxx |   85 
 include/basegfx/color/bcolormodifier.hxx|   28 +++
 svgio/inc/svgfecolormatrixnode.hxx  |3 
 svgio/inc/svgtools.hxx  |2 
 svgio/qa/cppunit/SvgImportTest.cxx  |8 +-
 svgio/source/svgreader/svgfecolormatrixnode.cxx |   13 +++
 svgio/source/svgreader/svgtools.cxx |   34 +
 8 files changed, 200 insertions(+), 5 deletions(-)

New commits:
commit 8395acfec900ea23d25632909eb22e02763bbe37
Author: Xisco Fauli 
AuthorDate: Fri Jun 16 11:50:57 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 22 20:58:09 2023 +0200

tdf#155735: Add support for matrix type

Change-Id: Icc172c5f47731ddcf0beca64c72c2022313e74a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153177
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit 40371d9fe99d9588e2717b24e44b1ff846e6fe7e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153425

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 8d6f99a3faf5..829b0abda659 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -142,6 +142,38 @@ namespace basegfx
 return "interpolate";
 }
 
+BColorModifier_matrix::~BColorModifier_matrix()
+{
+}
+
+bool BColorModifier_matrix::operator==(const BColorModifier& rCompare) 
const
+{
+const BColorModifier_matrix* pCompare = dynamic_cast< const 
BColorModifier_matrix* >();
+
+if(!pCompare)
+{
+return false;
+}
+
+return maMatrix == pCompare->maMatrix;
+}
+
+::basegfx::BColor BColorModifier_matrix::getModifiedColor(const 
::basegfx::BColor& aSourceColor) const
+{
+basegfx::B3DHomMatrix aColorMatrix;
+aColorMatrix.set(0, 0, aSourceColor.getRed());
+aColorMatrix.set(1, 0, aSourceColor.getGreen());
+aColorMatrix.set(2, 0, aSourceColor.getBlue());
+
+aColorMatrix = maMatrix * aColorMatrix;
+return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 
0), aColorMatrix.get(2, 0));
+}
+
+OUString BColorModifier_matrix::getModifierName() const
+{
+return "matrix";
+}
+
 BColorModifier_saturate::BColorModifier_saturate(double fValue)
 {
 maSatMatrix.set(0, 0, 0.213 + 0.787 * fValue);
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index d6e0648d2c17..17b6a0c22257 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -269,6 +269,89 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
+void testMatrix()
+{
+// green matrix
+basegfx::B3DHomMatrix aMatrix;
+aMatrix.set(0, 0, 0.0);
+aMatrix.set(0, 1, 0.0);
+aMatrix.set(0, 2, 0.0);
+aMatrix.set(0, 3, 0.0);
+aMatrix.set(1, 0, 1.0);
+aMatrix.set(1, 1, 1.0);
+aMatrix.set(1, 2, 1.0);
+aMatrix.set(1, 3, 1.0);
+aMatrix.set(2, 0, 0.0);
+aMatrix.set(2, 1, 0.0);
+aMatrix.set(2, 2, 0.0);
+aMatrix.set(2, 3, 0.0);
+
+const basegfx::BColorModifierSharedPtr aBColorModifier
+= std::make_shared(aMatrix);
+
+BColor aExpectedWhite(0.0, 3.0, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedWhite, 
aBColorModifier->getModifiedColor(maWhite));
+BColor aExpectedGray(0.0, 1.5, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedGray, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maRed));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maGreen));
+CPPUNIT_ASSERT_EQUAL(maGreen, 
aBColorModifier->getModifiedColor(maBlue));
+BColor aExpectedYellow(0.0, 2.0, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedYellow, 
aBColorModifier->getModifiedColor(maYellow));
+BColor aExpectedMagenta = aExpectedYellow;
+CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, 
aBColorModifier->getModifiedColor(maMagenta));
+BColor aExpectedCyan = aExpectedYellow;
+CPPUNIT_ASSERT_EQUAL(aExpectedCyan, 
aBColorModifier->getModifiedColor(maCyan));
+
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
+const basegfx::BColorModifierSharedPtr aBColorModifierInvert
+= std::make_shared();
+CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
+
+const basegfx::BColorModifierSharedPtr aBColorModifier2
+= std::make_shared(aMatrix);
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
+}
+
+void testIdentityMatrix()
+{

[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - basegfx/source basegfx/test include/basegfx svgio/inc svgio/qa svgio/source

2023-06-22 Thread Xisco Fauli (via logerrit)
 basegfx/source/color/bcolormodifier.cxx |   51 
 basegfx/test/BColorModifierTest.cxx |   33 +++
 include/basegfx/color/bcolormodifier.hxx|   25 +++
 svgio/inc/svgfecolormatrixnode.hxx  |3 -
 svgio/qa/cppunit/SvgImportTest.cxx  |4 -
 svgio/source/svgreader/svgfecolormatrixnode.cxx |   27 
 6 files changed, 132 insertions(+), 11 deletions(-)

New commits:
commit cd3c376da36acf76327290b83eac8563f3bf562e
Author: Xisco Fauli 
AuthorDate: Thu Jun 15 12:19:39 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 22 09:47:19 2023 +0200

tdf#155735: Add support for hueRotate type

Change-Id: I9c7ada2908c0739708fbc9e28ac58430350da7a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153112
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit a62513e1e80e39f9928e9e1815a84761403a4f2b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153420

diff --git a/basegfx/source/color/bcolormodifier.cxx 
b/basegfx/source/color/bcolormodifier.cxx
index 480af66e7588..8d6f99a3faf5 100644
--- a/basegfx/source/color/bcolormodifier.cxx
+++ b/basegfx/source/color/bcolormodifier.cxx
@@ -187,6 +187,57 @@ namespace basegfx
 return "saturate";
 }
 
+BColorModifier_hueRotate::BColorModifier_hueRotate(double fRad)
+{
+const double fCos = cos(fRad);
+const double fSin = sin(fRad);
+
+maHueMatrix.set(0, 0, 0.213 + fCos * 0.787 - fSin * 0.213);
+maHueMatrix.set(0, 1, 0.715 - fCos * 0.715 - fSin * 0.715);
+maHueMatrix.set(0, 2, 0.072 - fCos * 0.072 + fSin * 0.928);
+maHueMatrix.set(1, 0, 0.213 - fCos * 0.213 + fSin * 0.143);
+maHueMatrix.set(1, 1, 0.715 + fCos * 0.285 + fSin * 0.140);
+maHueMatrix.set(1, 2, 0.072 - fCos * 0.072 - fSin * 0.283);
+maHueMatrix.set(2, 0, 0.213 - fCos * 0.213 - fSin * 0.787);
+maHueMatrix.set(2, 1, 0.715 - fCos * 0.715 + fSin * 0.715);
+maHueMatrix.set(2, 2, 0.072 + fCos * 0.928 + fSin * 0.072);
+}
+
+BColorModifier_hueRotate::~BColorModifier_hueRotate()
+{
+}
+
+bool BColorModifier_hueRotate::operator==(const BColorModifier& rCompare) 
const
+{
+const BColorModifier_hueRotate* pCompare = dynamic_cast< const 
BColorModifier_hueRotate* >();
+
+if(!pCompare)
+{
+return false;
+}
+
+return maHueMatrix == pCompare->maHueMatrix;
+}
+
+::basegfx::BColor BColorModifier_hueRotate::getModifiedColor(const 
::basegfx::BColor& aSourceColor) const
+{
+basegfx::B3DHomMatrix aColorMatrix;
+aColorMatrix.set(0, 0, aSourceColor.getRed());
+aColorMatrix.set(1, 0, aSourceColor.getGreen());
+aColorMatrix.set(2, 0, aSourceColor.getBlue());
+
+aColorMatrix = maHueMatrix * aColorMatrix;
+return ::basegfx::BColor(
+std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0),
+std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0));
+}
+
+OUString BColorModifier_hueRotate::getModifierName() const
+{
+return "hueRotate";
+}
+
 BColorModifier_black_and_white::~BColorModifier_black_and_white()
 {
 }
diff --git a/basegfx/test/BColorModifierTest.cxx 
b/basegfx/test/BColorModifierTest.cxx
index 053540018206..d6e0648d2c17 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -237,6 +237,38 @@ public:
 CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
 }
 
+void testHueRotate()
+{
+const basegfx::BColorModifierSharedPtr aBColorModifier
+= 
std::make_shared(basegfx::deg2rad(180.0));
+
+CPPUNIT_ASSERT_EQUAL(maWhite, 
aBColorModifier->getModifiedColor(maWhite));
+CPPUNIT_ASSERT_EQUAL(maGray, 
aBColorModifier->getModifiedColor(maGray));
+CPPUNIT_ASSERT_EQUAL(maBlack, 
aBColorModifier->getModifiedColor(maBlack));
+
+BColor aExpectedRed(0.0, 0.426, 0.426);
+CPPUNIT_ASSERT_EQUAL(aExpectedRed, 
aBColorModifier->getModifiedColor(maRed));
+BColor aExpectedGreen(1.0, 0.43, 1.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedGreen, 
aBColorModifier->getModifiedColor(maGreen));
+BColor aExpectedBlue(0.144, 0.144, 0);
+CPPUNIT_ASSERT_EQUAL(aExpectedBlue, 
aBColorModifier->getModifiedColor(maBlue));
+BColor aExpectedYellow(0.856, 0.856, 1.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedYellow, 
aBColorModifier->getModifiedColor(maYellow));
+BColor aExpectedMagenta(0.0, 0.57, 0.0);
+CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, 
aBColorModifier->getModifiedColor(maMagenta));
+BColor aExpectedCyan(1.0, 0.574, 0.574);
+CPPUNIT_ASSERT_EQUAL(aExpectedCyan, 
aBColorModifier->getModifiedColor(maCyan));
+
+CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));