[Libreoffice-commits] core.git: include/vcl vcl/backendtest vcl/inc vcl/qa

homeboy445 (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 27 03:30:08 UTC 2021


 include/vcl/test/GraphicsRenderTests.hxx |   17 +-
 vcl/backendtest/GraphicsRenderTests.cxx  |  195 +++++++++++++++++++++++++++----
 vcl/backendtest/VisualBackendTest.cxx    |   10 -
 vcl/backendtest/outputdevice/bitmap.cxx  |   36 ++++-
 vcl/inc/test/outputdevice.hxx            |   13 +-
 vcl/qa/cppunit/BackendTest.cxx           |  141 +++++++++++++++++++---
 6 files changed, 347 insertions(+), 65 deletions(-)

New commits:
commit c46d2c25ee790d02a97ed6bc7403571a2a0823bd
Author:     homeboy445 <akshitsan13 at gmail.com>
AuthorDate: Thu Jul 22 17:05:33 2021 +0530
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Aug 27 05:29:35 2021 +0200

    backendtest: Test Drawing Bitmap other than 24bpp
    
    This test draws bitmap formats other than 24bpp -
    namely 32bpp and 8bpp greyscale.
    
    Change-Id: I1b21214429be08fc7cf1eb086c2ad8946780f481
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119371
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/vcl/test/GraphicsRenderTests.hxx b/include/vcl/test/GraphicsRenderTests.hxx
index dee521438edc..41cbe561b483 100644
--- a/include/vcl/test/GraphicsRenderTests.hxx
+++ b/include/vcl/test/GraphicsRenderTests.hxx
@@ -81,11 +81,18 @@ class VCL_PLUGIN_PUBLIC GraphicsRenderTests
     void testDrawBezierAAWithPolylineB2D();
     void testDrawDropShapeWithPolygon();
     void testDrawDropShapeAAWithPolygon();
-    void testDrawBitmap();
-    void testDrawTransformedBitmap();
-    void testDrawBitmapExWithAlpha();
-    void testDrawMask();
-    void testDrawBlend();
+    void testDrawBitmap24bpp();
+    void testDrawTransformedBitmap24bpp();
+    void testDrawBitmapExWithAlpha24bpp();
+    void testDrawMask24bpp();
+    void testDrawBlend24bpp();
+    void testDrawBitmap32bpp();
+    void testDrawTransformedBitmap32bpp();
+    void testDrawBitmapExWithAlpha32bpp();
+    void testDrawMask32bpp();
+    void testDrawBlend32bpp();
+    void testDrawBitmap8bppGreyScale();
+    void testDrawTransformedBitmap8bppGreyScale();
     void testDrawXor();
     void testClipRectangle();
     void testClipPolygon();
diff --git a/vcl/backendtest/GraphicsRenderTests.cxx b/vcl/backendtest/GraphicsRenderTests.cxx
index 263d37cf6d3f..ad508ec6d975 100644
--- a/vcl/backendtest/GraphicsRenderTests.cxx
+++ b/vcl/backendtest/GraphicsRenderTests.cxx
@@ -13,6 +13,9 @@
 #include <vcl/test/GraphicsRenderTests.hxx>
 #include <tools/stream.hxx>
 
+#include <svdata.hxx>
+#include <salinst.hxx>
+
 #include <unordered_map>
 
 #define SHOULD_ASSERT                                                                              \
@@ -32,6 +35,7 @@ void exportBitmapExToImage(OUString const& rImageName, const BitmapEx& rBitmapEx
     SvFileStream aStream(rImageName, StreamMode::WRITE | StreamMode::TRUNC);
     GraphicFilter::GetGraphicFilter().compressAsPNG(aBitmapEx, aStream);
 }
+bool is32bppSupported() { return ImplGetSVData()->mpDefInst->supportsBitmap32(); }
 }
 
 OUString GraphicsRenderTests::returnTestStatus(vcl::test::TestResult const result)
@@ -758,11 +762,11 @@ void GraphicsRenderTests::testDrawDropShapeAAWithPolygon()
     }
 }
 
-void GraphicsRenderTests::testDrawBitmap()
+void GraphicsRenderTests::testDrawBitmap24bpp()
 {
     vcl::test::OutputDeviceTestBitmap aOutDevTest;
-    Bitmap aBitmap = aOutDevTest.setupDrawBitmap();
-    OUString aTestName = "testDrawBitmap";
+    Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N24_BPP);
+    OUString aTestName = "testDrawBitmap24bpp";
     if (!SHOULD_ASSERT)
     {
         appendTestResult(aTestName, "SKIPPED");
@@ -779,11 +783,11 @@ void GraphicsRenderTests::testDrawBitmap()
     }
 }
 
-void GraphicsRenderTests::testDrawTransformedBitmap()
+void GraphicsRenderTests::testDrawTransformedBitmap24bpp()
 {
     vcl::test::OutputDeviceTestBitmap aOutDevTest;
-    Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap();
-    OUString aTestName = "testDrawTransformedBitmap";
+    Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
+    OUString aTestName = "testDrawTransformedBitmap24bpp";
     if (!SHOULD_ASSERT)
     {
         appendTestResult(aTestName, "SKIPPED");
@@ -800,11 +804,11 @@ void GraphicsRenderTests::testDrawTransformedBitmap()
     }
 }
 
-void GraphicsRenderTests::testDrawBitmapExWithAlpha()
+void GraphicsRenderTests::testDrawBitmapExWithAlpha24bpp()
 {
     vcl::test::OutputDeviceTestBitmap aOutDevTest;
-    Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha();
-    OUString aTestName = "testDrawBitmapExWithAlpha";
+    Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N24_BPP);
+    OUString aTestName = "testDrawBitmapExWithAlpha24bpp";
     if (!SHOULD_ASSERT)
     {
         appendTestResult(aTestName, "SKIPPED");
@@ -821,11 +825,11 @@ void GraphicsRenderTests::testDrawBitmapExWithAlpha()
     }
 }
 
-void GraphicsRenderTests::testDrawMask()
+void GraphicsRenderTests::testDrawMask24bpp()
 {
     vcl::test::OutputDeviceTestBitmap aOutDevTest;
-    Bitmap aBitmap = aOutDevTest.setupDrawMask();
-    OUString aTestName = "testDrawMask";
+    Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N24_BPP);
+    OUString aTestName = "testDrawMask24bpp";
     if (!SHOULD_ASSERT)
     {
         appendTestResult(aTestName, "SKIPPED");
@@ -841,11 +845,11 @@ void GraphicsRenderTests::testDrawMask()
     }
 }
 
-void GraphicsRenderTests::testDrawBlend()
+void GraphicsRenderTests::testDrawBlend24bpp()
 {
     vcl::test::OutputDeviceTestBitmap aOutDevTest;
-    BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend();
-    OUString aTestName = "testDrawBlend";
+    BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
+    OUString aTestName = "testDrawBlend24bpp";
     if (!SHOULD_ASSERT)
     {
         appendTestResult(aTestName, "SKIPPED");
@@ -1545,6 +1549,150 @@ void GraphicsRenderTests::testEvenOddRuleInIntersectingRectsWithPolyPolygonB2D()
     }
 }
 
+void GraphicsRenderTests::testDrawBitmap8bppGreyScale()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N8_BPP, true);
+    OUString aTestName = "testDrawBitmap8bppGreyScale";
+    if (!SHOULD_ASSERT)
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult
+        = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmap : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        BitmapEx aBitmapEx(aBitmap);
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", aBitmapEx);
+    }
+}
+
+void GraphicsRenderTests::testDrawTransformedBitmap8bppGreyScale()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N8_BPP, true);
+    OUString aTestName = "testDrawTransformedBitmap8bppGreyScale";
+    if (!SHOULD_ASSERT)
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult
+        = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmap : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        BitmapEx aBitmapEx(aBitmap);
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", aBitmapEx);
+    }
+}
+
+void GraphicsRenderTests::testDrawBitmap32bpp()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N32_BPP);
+    OUString aTestName = "testDrawBitmap32bpp";
+    if (!SHOULD_ASSERT || !is32bppSupported())
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult
+        = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmap : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        BitmapEx aBitmapEx(aBitmap);
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", aBitmapEx);
+    }
+}
+
+void GraphicsRenderTests::testDrawTransformedBitmap32bpp()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N32_BPP);
+    OUString aTestName = "testDrawTransformedBitmap32bpp";
+    if (!SHOULD_ASSERT || !is32bppSupported())
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult
+        = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmap : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        BitmapEx aBitmapEx(aBitmap);
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", aBitmapEx);
+    }
+}
+
+void GraphicsRenderTests::testDrawBitmapExWithAlpha32bpp()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N32_BPP);
+    OUString aTestName = "testDrawBitmapExWithAlpha32bpp";
+    if (!SHOULD_ASSERT || !is32bppSupported())
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult
+        = vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmap : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        BitmapEx aBitmapEx(aBitmap);
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", aBitmapEx);
+    }
+}
+
+void GraphicsRenderTests::testDrawMask32bpp()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N32_BPP);
+    OUString aTestName = "testDrawMask32bpp";
+    if (!SHOULD_ASSERT || !is32bppSupported())
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult = vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmap : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        BitmapEx aBitmapEx(aBitmap);
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", aBitmapEx);
+    }
+}
+
+void GraphicsRenderTests::testDrawBlend32bpp()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N32_BPP);
+    OUString aTestName = "testDrawBlend32bpp";
+    if (!SHOULD_ASSERT || !is32bppSupported())
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmapEx.GetBitmap() : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", aBitmapEx);
+    }
+}
+
 void GraphicsRenderTests::runALLTests()
 {
     testDrawRectWithRectangle();
@@ -1576,11 +1724,11 @@ void GraphicsRenderTests::runALLTests()
     testDrawInvertTrackFrameWithRectangle();
     testDrawBezierWithPolylineB2D();
     testDrawBezierAAWithPolylineB2D();
-    testDrawBitmap();
-    testDrawTransformedBitmap();
-    testDrawBitmapExWithAlpha();
-    testDrawMask();
-    testDrawBlend();
+    testDrawBitmap24bpp();
+    testDrawTransformedBitmap24bpp();
+    testDrawBitmapExWithAlpha24bpp();
+    testDrawMask24bpp();
+    testDrawBlend24bpp();
     testDrawXor();
     testClipRectangle();
     testClipPolygon();
@@ -1619,6 +1767,13 @@ void GraphicsRenderTests::runALLTests()
     testTextDrawing();
     testEvenOddRuleInIntersectingRectsWithPolyPolygon();
     testEvenOddRuleInIntersectingRectsWithPolyPolygonB2D();
+    testDrawBitmap8bppGreyScale();
+    testDrawTransformedBitmap8bppGreyScale();
+    testDrawBitmap32bpp();
+    testDrawTransformedBitmap32bpp();
+    testDrawBitmapExWithAlpha32bpp();
+    testDrawMask32bpp();
+    testDrawBlend32bpp();
 }
 
 void GraphicsRenderTests::appendTestResult(OUString aTestName, OUString aTestStatus,
diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx
index 55ec308fb226..5426bf2acdd8 100644
--- a/vcl/backendtest/VisualBackendTest.cxx
+++ b/vcl/backendtest/VisualBackendTest.cxx
@@ -477,35 +477,35 @@ public:
         aRectangle = aRegions[index++];
         {
             vcl::test::OutputDeviceTestBitmap aOutDevTest;
-            Bitmap aBitmap = aOutDevTest.setupDrawBitmap();
+            Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N24_BPP);
             assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap), aRectangle, rRenderContext);
             drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
         }
         aRectangle = aRegions[index++];
         {
             vcl::test::OutputDeviceTestBitmap aOutDevTest;
-            Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap();
+            Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
             assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap), aRectangle, rRenderContext);
             drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
         }
         aRectangle = aRegions[index++];
         {
             vcl::test::OutputDeviceTestBitmap aOutDevTest;
-            Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha();
+            Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N24_BPP);
             assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap), aRectangle, rRenderContext);
             drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
         }
         aRectangle = aRegions[index++];
         {
             vcl::test::OutputDeviceTestBitmap aOutDevTest;
-            Bitmap aBitmap = aOutDevTest.setupDrawMask();
+            Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N24_BPP);
             assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap), aRectangle, rRenderContext);
             drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
         }
         aRectangle = aRegions[index++];
         {
             vcl::test::OutputDeviceTestBitmap aOutDevTest;
-            BitmapEx aBitmap = aOutDevTest.setupDrawBlend();
+            BitmapEx aBitmap = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
             assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmap), aRectangle, rRenderContext);
             drawBitmapScaledAndCentered(aRectangle, aBitmap.GetBitmap(), rRenderContext);
         }
diff --git a/vcl/backendtest/outputdevice/bitmap.cxx b/vcl/backendtest/outputdevice/bitmap.cxx
index 2c7d7569cde6..066355c53f14 100644
--- a/vcl/backendtest/outputdevice/bitmap.cxx
+++ b/vcl/backendtest/outputdevice/bitmap.cxx
@@ -15,10 +15,10 @@
 
 namespace vcl::test {
 
-Bitmap OutputDeviceTestBitmap::setupDrawTransformedBitmap()
+Bitmap OutputDeviceTestBitmap::setupDrawTransformedBitmap(vcl::PixelFormat aBitmapFormat,bool isBitmapGreyScale)
 {
     Size aBitmapSize(9, 9);
-    Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
+    Bitmap aBitmap(aBitmapSize, aBitmapFormat);
     {
         BitmapScopedWriteAccess aWriteAccess(aBitmap);
         aWriteAccess->Erase(constFillColor);
@@ -27,6 +27,9 @@ Bitmap OutputDeviceTestBitmap::setupDrawTransformedBitmap()
         aWriteAccess->DrawRect(tools::Rectangle(2, 2,  6, 6));
     }
 
+    if (isBitmapGreyScale)
+        aBitmap.Convert(BmpConversion::N8BitGreys);
+
     initialSetup(13, 13, constBackgroundColor);
 
     basegfx::B2DHomMatrix aTransform;
@@ -40,10 +43,10 @@ Bitmap OutputDeviceTestBitmap::setupDrawTransformedBitmap()
 }
 
 
-Bitmap OutputDeviceTestBitmap::setupDrawBitmap()
+Bitmap OutputDeviceTestBitmap::setupDrawBitmap(vcl::PixelFormat aBitmapFormat,bool isBitmapGreyScale)
 {
     Size aBitmapSize(9, 9);
-    Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
+    Bitmap aBitmap(aBitmapSize, aBitmapFormat);
     {
         BitmapScopedWriteAccess aWriteAccess(aBitmap);
         aWriteAccess->Erase(constFillColor);
@@ -52,6 +55,9 @@ Bitmap OutputDeviceTestBitmap::setupDrawBitmap()
         aWriteAccess->DrawRect(tools::Rectangle(2, 2,  6, 6));
     }
 
+    if (isBitmapGreyScale)
+        aBitmap.Convert(BmpConversion::N8BitGreys);
+
     initialSetup(13, 13, constBackgroundColor);
 
     Point aPoint((maVDRectangle.GetWidth()  / 2.0) - (aBitmapSize.Width() / 2.0),
@@ -62,10 +68,10 @@ Bitmap OutputDeviceTestBitmap::setupDrawBitmap()
     return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
 }
 
-Bitmap OutputDeviceTestBitmap::setupDrawBitmapExWithAlpha()
+Bitmap OutputDeviceTestBitmap::setupDrawBitmapExWithAlpha(vcl::PixelFormat aBitmapFormat)
 {
     Size aBitmapSize(9, 9);
-    Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
+    Bitmap aBitmap(aBitmapSize, aBitmapFormat);
     {
         BitmapScopedWriteAccess aWriteAccess(aBitmap);
         aWriteAccess->Erase(COL_WHITE);
@@ -92,10 +98,10 @@ Bitmap OutputDeviceTestBitmap::setupDrawBitmapExWithAlpha()
     return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
 }
 
-Bitmap OutputDeviceTestBitmap::setupDrawMask()
+Bitmap OutputDeviceTestBitmap::setupDrawMask(vcl::PixelFormat aBitmapFormat)
 {
     Size aBitmapSize(9, 9);
-    Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
+    Bitmap aBitmap(aBitmapSize, aBitmapFormat);
     {
         BitmapScopedWriteAccess aWriteAccess(aBitmap);
         aWriteAccess->Erase(COL_WHITE);
@@ -111,10 +117,10 @@ Bitmap OutputDeviceTestBitmap::setupDrawMask()
     return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
 }
 
-BitmapEx OutputDeviceTestBitmap::setupDrawBlend()
+BitmapEx OutputDeviceTestBitmap::setupDrawBlend(vcl::PixelFormat aBitmapFormat)
 {
     Size aBitmapSize(9, 9);
-    Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
+    Bitmap aBitmap(aBitmapSize, aBitmapFormat);
     {
         BitmapScopedWriteAccess aWriteAccess(aBitmap);
         aWriteAccess->Erase(COL_WHITE);
@@ -157,6 +163,16 @@ TestResult OutputDeviceTestBitmap::checkTransformedBitmap(Bitmap& rBitmap)
     return checkRectangles(rBitmap, aExpected);
 }
 
+TestResult OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(Bitmap& rBitmap)
+{
+    std::vector<Color> aExpected
+    {
+        Color(0xC0,0xC0,0xC0), Color(0xC0,0xC0,0xC0),
+        Color(0xE2,0xE2,0xE2), Color(0xE,0xE,0xE), Color(0xE2,0xE2,0xE2), Color(0xE,0xE,0xE), Color(0xE,0xE,0xE)
+    };
+    return checkRectangles(rBitmap, aExpected);
+}
+
 TestResult OutputDeviceTestBitmap::checkBitmapExWithAlpha(Bitmap& rBitmap)
 {
     const Color aBlendedColor(0xEE, 0xEE, 0x33);
diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx
index b72206d76cd1..67ae1be876b1 100644
--- a/vcl/inc/test/outputdevice.hxx
+++ b/vcl/inc/test/outputdevice.hxx
@@ -105,16 +105,19 @@ class VCL_DLLPUBLIC OutputDeviceTestBitmap : public OutputDeviceTestCommon
 public:
     OutputDeviceTestBitmap() = default;
 
-    Bitmap setupDrawTransformedBitmap();
-    Bitmap setupDrawBitmap();
-    Bitmap setupDrawBitmapExWithAlpha();
-    Bitmap setupDrawMask();
-    BitmapEx setupDrawBlend();
+    Bitmap setupDrawTransformedBitmap(vcl::PixelFormat aBitmapFormat,
+                                      bool isBitmapGreyScale = false);
+    Bitmap setupDrawBitmap(vcl::PixelFormat aBitmapFormat, bool isBitmapGreyScale = false);
+    Bitmap setupDrawBitmapExWithAlpha(vcl::PixelFormat aBitmapFormat);
+    Bitmap setupDrawMask(vcl::PixelFormat aBitmapFormat);
+    BitmapEx setupDrawBlend(vcl::PixelFormat aBitmapFormat);
 
     static TestResult checkTransformedBitmap(Bitmap& rBitmap);
     static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap);
     static TestResult checkMask(Bitmap& rBitmap);
     static TestResult checkBlend(const BitmapEx& rBitmap);
+
+    static TestResult checkTransformedBitmap8bppGreyScale(Bitmap& rBitmap);
 };
 
 class VCL_DLLPUBLIC OutputDeviceTestAnotherOutDev : public OutputDeviceTestCommon
diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 7bef9b2479d7..c337ad1f0707 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -16,6 +16,9 @@
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <bitmap/BitmapWriteAccess.hxx>
 
+#include <svdata.hxx>
+#include <salinst.hxx>
+
 #include <test/outputdevice.hxx>
 
 // Run tests from visualbackendtest ('bin/run visualbackendtest').
@@ -57,6 +60,8 @@ class BackendTest : public test::BootstrapFixture
         }
     }
 
+    bool is32bppSupported() { return ImplGetSVData()->mpDefInst->supportsBitmap32(); }
+
 public:
     BackendTest()
         : BootstrapFixture(true, false)
@@ -449,62 +454,148 @@ public:
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
 
-    void testDrawBitmap()
+    void testDrawBitmap24bpp()
     {
         if (getDefaultDeviceBitCount() < 24)
             return;
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
-        Bitmap aBitmap = aOutDevTest.setupDrawBitmap();
-        exportImage("08-01_bitmap_test.png", aBitmap);
+        Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N24_BPP);
+        exportImage("08-01_bitmap_test_24bpp.png", aBitmap);
         auto eResult = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
 
-    void testDrawTransformedBitmap()
+    void testDrawTransformedBitmap24bpp()
     {
         if (getDefaultDeviceBitCount() < 24)
             return;
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
-        Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap();
+        Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
         auto eResult = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
-        exportImage("08-02_transformed_bitmap_test.png", aBitmap);
+        exportImage("08-02_transformed_bitmap_test_24bpp.png", aBitmap);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
 
-    void testDrawBitmapExWithAlpha()
+    void testDrawBitmapExWithAlpha24bpp()
     {
         if (getDefaultDeviceBitCount() < 24)
             return;
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
-        Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha();
+        Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N24_BPP);
         auto eResult = vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap);
-        exportImage("08-03_bitmapex_with_alpha_test.png", aBitmap);
+        exportImage("08-03_bitmapex_with_alpha_test_24bpp.png", aBitmap);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
 
-    void testDrawMask()
+    void testDrawMask24bpp()
     {
         if (getDefaultDeviceBitCount() < 24)
             return;
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
-        Bitmap aBitmap = aOutDevTest.setupDrawMask();
+        Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N24_BPP);
         auto eResult = vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap);
-        exportImage("08-04_mask_test.png", aBitmap);
+        exportImage("08-04_mask_test_24bpp.png", aBitmap);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
 
-    void testDrawBlend()
+    void testDrawBlend24bpp()
     {
         if (getDefaultDeviceBitCount() < 24)
             return;
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
-        BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend();
+        BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
         auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
-        exportImage("08-05_blend_test.png", aBitmapEx);
+        exportImage("08-05_blend_test_24bpp.png", aBitmapEx);
+        if (SHOULD_ASSERT)
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
+    void testDrawBitmap32bpp()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N32_BPP);
+        exportImage("09-01_bitmap_test_32bpp.png", aBitmap);
+        auto eResult = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
+        if (SHOULD_ASSERT && is32bppSupported())
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
+    void testDrawTransformedBitmap32bpp()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N32_BPP);
+        auto eResult = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap);
+        exportImage("09-02_transformed_bitmap_test_32bpp.png", aBitmap);
+        if (SHOULD_ASSERT && is32bppSupported())
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
+    void testDrawBitmapExWithAlpha32bpp()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N32_BPP);
+        auto eResult = vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap);
+        exportImage("09-03_bitmapex_with_alpha_test_32bpp.png", aBitmap);
+        if (SHOULD_ASSERT && is32bppSupported())
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
+    void testDrawMask32bpp()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N32_BPP);
+        auto eResult = vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap);
+        exportImage("09-04_mask_test_32bpp.png", aBitmap);
+        if (SHOULD_ASSERT && is32bppSupported())
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
+    void testDrawBlend32bpp()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N32_BPP);
+        auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
+        exportImage("09-05_blend_test_32bpp.png", aBitmapEx);
+        if (SHOULD_ASSERT && is32bppSupported())
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
+    void testDrawBitmap8bppGreyScale()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        Bitmap aBitmap = aOutDevTest.setupDrawBitmap(vcl::PixelFormat::N8_BPP, true);
+        exportImage("010-01_bitmap_test_8bpp_greyscale.png", aBitmap);
+        auto eResult
+            = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap);
+        if (SHOULD_ASSERT)
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
+    void testDrawTransformedBitmap8bppGreyScale()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap(vcl::PixelFormat::N8_BPP, true);
+        auto eResult
+            = vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(aBitmap);
+        exportImage("010-02_transformed_bitmap_test_8bpp_greyscale.png", aBitmap);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
@@ -1251,13 +1342,23 @@ public:
 
     CPPUNIT_TEST(testFilledAsymmetricalDropShape);
 
-    CPPUNIT_TEST(testDrawBitmap);
-    CPPUNIT_TEST(testDrawTransformedBitmap);
-    CPPUNIT_TEST(testDrawBitmapExWithAlpha);
-    CPPUNIT_TEST(testDrawMask);
-    CPPUNIT_TEST(testDrawBlend);
+    CPPUNIT_TEST(testDrawBitmap24bpp);
+    CPPUNIT_TEST(testDrawTransformedBitmap24bpp);
+    CPPUNIT_TEST(testDrawBitmapExWithAlpha24bpp);
+    CPPUNIT_TEST(testDrawMask24bpp);
+    CPPUNIT_TEST(testDrawBlend24bpp);
+
     CPPUNIT_TEST(testDrawXor);
 
+    CPPUNIT_TEST(testDrawBitmap32bpp);
+    CPPUNIT_TEST(testDrawTransformedBitmap32bpp);
+    CPPUNIT_TEST(testDrawBitmapExWithAlpha32bpp);
+    CPPUNIT_TEST(testDrawMask32bpp);
+    CPPUNIT_TEST(testDrawBlend32bpp);
+
+    CPPUNIT_TEST(testDrawTransformedBitmap8bppGreyScale);
+    CPPUNIT_TEST(testDrawBitmap8bppGreyScale);
+
     CPPUNIT_TEST(testDrawTransformedBitmapExAlpha);
 
     CPPUNIT_TEST(testClipRectangle);


More information about the Libreoffice-commits mailing list