summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-06-24 11:17:16 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-06-24 12:33:12 +0200
commit75399b8aad6c0f0998b9d0a6eddb2e29f8bc114c (patch)
tree02c834bff607acc6a8b5f7ec4c243454fdc5c8ac /basegfx
parent85013c57dd29e32ec0411c159ea72824ebca5aa9 (diff)
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 <xiscofauli@libreoffice.org>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/color/bcolormodifier.cxx19
-rwxr-xr-xbasegfx/test/BColorModifierTest.cxx27
2 files changed, 46 insertions, 0 deletions
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* >(&rCompare) != 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 6be160ce43ae..5a4b941e1c44 100755
--- a/basegfx/test/BColorModifierTest.cxx
+++ b/basegfx/test/BColorModifierTest.cxx
@@ -378,6 +378,32 @@ public:
CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
}
+ void testAlpha()
+ {
+ const basegfx::BColorModifierSharedPtr aBColorModifier
+ = std::make_shared<basegfx::BColorModifier_alpha>();
+
+ 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<basegfx::BColorModifier_invert>();
+ CPPUNIT_ASSERT(*aBColorModifier != *aBColorModifierInvert);
+
+ const basegfx::BColorModifierSharedPtr aBColorModifier2
+ = std::make_shared<basegfx::BColorModifier_alpha>();
+ CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier2));
+ }
+
CPPUNIT_TEST_SUITE(bcolormodifier);
CPPUNIT_TEST(testGray);
CPPUNIT_TEST(testInvert);
@@ -389,6 +415,7 @@ public:
CPPUNIT_TEST(testMatrix);
CPPUNIT_TEST(testIdentityMatrix);
CPPUNIT_TEST(testBlackAndWhite);
+ CPPUNIT_TEST(testAlpha);
CPPUNIT_TEST_SUITE_END();
};