diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-16 11:50:57 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-22 17:19:27 +0200 |
commit | e121f7b37c48b6d843dfdd1d774d2a40567c46c7 (patch) | |
tree | f512af867d5653469713613df0b3b12a718ea40f /basegfx/test | |
parent | cdce0b615a0bd599cd90dfd145d8270287045619 (diff) |
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 <xiscofauli@libreoffice.org>
Diffstat (limited to 'basegfx/test')
-rwxr-xr-x | basegfx/test/BColorModifierTest.cxx | 85 |
1 files changed, 85 insertions, 0 deletions
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<basegfx::BColorModifier_matrix>(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<basegfx::BColorModifier_invert>(); + CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert); + + const basegfx::BColorModifierSharedPtr aBColorModifier2 + = std::make_shared<basegfx::BColorModifier_matrix>(aMatrix); + CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); + } + + void testIdentityMatrix() + { + basegfx::B3DHomMatrix aMatrix; + aMatrix.set(0, 0, 1.0); + aMatrix.set(0, 1, 0.0); + aMatrix.set(0, 2, 0.0); + aMatrix.set(1, 0, 0.0); + aMatrix.set(1, 1, 1.0); + aMatrix.set(1, 2, 0.0); + aMatrix.set(2, 0, 0.0); + aMatrix.set(2, 1, 0.0); + aMatrix.set(2, 2, 1.0); + + const basegfx::BColorModifierSharedPtr aBColorModifier + = std::make_shared<basegfx::BColorModifier_matrix>(aMatrix); + + CPPUNIT_ASSERT_EQUAL(maWhite, aBColorModifier->getModifiedColor(maWhite)); + CPPUNIT_ASSERT_EQUAL(maGray, aBColorModifier->getModifiedColor(maGray)); + CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlack)); + + CPPUNIT_ASSERT_EQUAL(maRed, aBColorModifier->getModifiedColor(maRed)); + CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maGreen)); + CPPUNIT_ASSERT_EQUAL(maBlue, aBColorModifier->getModifiedColor(maBlue)); + CPPUNIT_ASSERT_EQUAL(maYellow, aBColorModifier->getModifiedColor(maYellow)); + CPPUNIT_ASSERT_EQUAL(maMagenta, aBColorModifier->getModifiedColor(maMagenta)); + CPPUNIT_ASSERT_EQUAL(maCyan, aBColorModifier->getModifiedColor(maCyan)); + + CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier)); + const basegfx::BColorModifierSharedPtr aBColorModifierInvert + = std::make_shared<basegfx::BColorModifier_invert>(); + CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert); + + const basegfx::BColorModifierSharedPtr aBColorModifier2 + = std::make_shared<basegfx::BColorModifier_matrix>(aMatrix); + CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2)); + } + CPPUNIT_TEST_SUITE(bcolormodifier); CPPUNIT_TEST(testGray); CPPUNIT_TEST(testInvert); @@ -277,6 +360,8 @@ public: CPPUNIT_TEST(testSaturate); CPPUNIT_TEST(testLuminanceToAlpha); CPPUNIT_TEST(testHueRotate); + CPPUNIT_TEST(testMatrix); + CPPUNIT_TEST(testIdentityMatrix); CPPUNIT_TEST_SUITE_END(); }; |