summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 13:32:15 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 14:55:44 +0200
commita9f1b705275ef9abbcf17366d8f3713235dd4675 (patch)
tree5b4d7eb18b1937bcc4c418270212be5778a3d0dc /vcl/qa/cppunit
parentfdf3027a0eb8270d527b3e64c6157917a6718787 (diff)
tdf#159660: Add support for darken mode in feBlend
Change-Id: I56862163b7bf1177120081c95ab7851a5fc4019b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166428 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r--vcl/qa/cppunit/BitmapFilterTest.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx
index fb01bfde0018..dcb7bd587a5e 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -16,6 +16,7 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/BitmapArithmeticBlendFilter.hxx>
+#include <vcl/BitmapDarkenBlendFilter.hxx>
#include <vcl/BitmapMultiplyBlendFilter.hxx>
#include <vcl/BitmapScreenBlendFilter.hxx>
#include <vcl/BitmapBasicMorphologyFilter.hxx>
@@ -43,6 +44,7 @@ public:
void testPerformance();
void testGenerateStripRanges();
void testMultiplyBlendFilter();
+ void testDarkenBlendFilter();
void testScreenBlendFilter();
void testArithmeticBlendFilter();
@@ -52,6 +54,7 @@ public:
CPPUNIT_TEST(testPerformance);
CPPUNIT_TEST(testGenerateStripRanges);
CPPUNIT_TEST(testMultiplyBlendFilter);
+ CPPUNIT_TEST(testDarkenBlendFilter);
CPPUNIT_TEST(testScreenBlendFilter);
CPPUNIT_TEST(testArithmeticBlendFilter);
CPPUNIT_TEST_SUITE_END();
@@ -339,6 +342,60 @@ void BitmapFilterTest::testMultiplyBlendFilter()
}
}
+void BitmapFilterTest::testDarkenBlendFilter()
+{
+ Bitmap aRedBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
+ CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aRedBitmap.getPixelFormat());
+ {
+ BitmapScopedWriteAccess aWriteAccess(aRedBitmap);
+ aWriteAccess->Erase(COL_LIGHTRED);
+ }
+
+ Bitmap aGreenBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
+ CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aGreenBitmap.getPixelFormat());
+ {
+ BitmapScopedWriteAccess aWriteAccess(aGreenBitmap);
+ aWriteAccess->Erase(COL_GREEN);
+ }
+
+ Bitmap aTransparentBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
+ CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aTransparentBitmap.getPixelFormat());
+ {
+ BitmapScopedWriteAccess aWriteAccess(aTransparentBitmap);
+ aWriteAccess->Erase(COL_AUTO);
+ }
+
+ BitmapEx aRedBitmapEx(aRedBitmap);
+ BitmapEx aGreenBitmapEx(aGreenBitmap);
+ BitmapEx aTransparentBitmapEx(aTransparentBitmap);
+
+ // same color
+ {
+ BitmapDarkenBlendFilter* pArithmeticFilter
+ = new BitmapDarkenBlendFilter(aRedBitmapEx, aRedBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aResBitmapEx.GetPixelColor(2, 2));
+ }
+
+ // different color
+ {
+ BitmapDarkenBlendFilter* pArithmeticFilter
+ = new BitmapDarkenBlendFilter(aRedBitmapEx, aGreenBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0xFF, 0x00, 0x00, 0x00),
+ aResBitmapEx.GetPixelColor(2, 2));
+ }
+
+ // transparent
+ {
+ BitmapDarkenBlendFilter* pArithmeticFilter
+ = new BitmapDarkenBlendFilter(aRedBitmapEx, aTransparentBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0xFF, 0xFF, 0x00, 0x00),
+ aResBitmapEx.GetPixelColor(2, 2));
+ }
+}
+
void BitmapFilterTest::testScreenBlendFilter()
{
Bitmap aRedBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);