include/vcl/test/GraphicsRenderTests.hxx |    1 
 vcl/backendtest/GraphicsRenderTests.cxx  |   22 ++++++++
 vcl/backendtest/VisualBackendTest.cxx    |    7 ++
 vcl/backendtest/outputdevice/bitmap.cxx  |   73 ++++++++-------------------
 vcl/backendtest/outputdevice/common.cxx  |   81 +++++++++++++++++++++++++++++++
 vcl/inc/test/outputdevice.hxx            |    3 +
 vcl/qa/cppunit/BackendTest.cxx           |   19 ++++++-
 7 files changed, 152 insertions(+), 54 deletions(-)

New commits:
commit ae4a9d5cc50d94f3180ce3e5d3793c0a403074cd
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Nov 16 12:57:52 2021 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Nov 16 14:36:13 2021 +0100

    add a vcl backend test that draws a sheared bitmap
    
    Change-Id: I06838e01ed41ac41c8b578fd6c7d984f1c073e31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125298
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/include/vcl/test/GraphicsRenderTests.hxx 
b/include/vcl/test/GraphicsRenderTests.hxx
index 86266eebe317..480cd73f5358 100644
--- a/include/vcl/test/GraphicsRenderTests.hxx
+++ b/include/vcl/test/GraphicsRenderTests.hxx
@@ -83,6 +83,7 @@ class VCL_PLUGIN_PUBLIC GraphicsRenderTests
     void testDrawDropShapeAAWithPolygon();
     void testDrawBitmap24bpp();
     void testDrawTransformedBitmap24bpp();
+    void testComplexDrawTransformedBitmap24bpp();
     void testDrawBitmapExWithAlpha24bpp();
     void testDrawMask24bpp();
     void testDrawBlend24bpp();
diff --git a/vcl/backendtest/GraphicsRenderTests.cxx 
b/vcl/backendtest/GraphicsRenderTests.cxx
index 794910b0f045..1c794b246669 100644
--- a/vcl/backendtest/GraphicsRenderTests.cxx
+++ b/vcl/backendtest/GraphicsRenderTests.cxx
@@ -804,6 +804,27 @@ void GraphicsRenderTests::testDrawTransformedBitmap24bpp()
     }
 }
 
+void GraphicsRenderTests::testComplexDrawTransformedBitmap24bpp()
+{
+    vcl::test::OutputDeviceTestBitmap aOutDevTest;
+    Bitmap aBitmap = 
aOutDevTest.setupComplexDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
+    OUString aTestName = "testComplexDrawTransformedBitmap24bpp";
+    if (!SHOULD_ASSERT)
+    {
+        appendTestResult(aTestName, "SKIPPED");
+        return;
+    }
+    vcl::test::TestResult eResult
+        = 
vcl::test::OutputDeviceTestBitmap::checkComplexTransformedBitmap(aBitmap);
+    appendTestResult(aTestName, returnTestStatus(eResult),
+                     (m_aStoreResultantBitmap ? aBitmap : Bitmap()));
+    if (m_aStoreResultantBitmap)
+    {
+        BitmapEx aBitmapEx(aBitmap);
+        exportBitmapExToImage(m_aUserInstallPath + aTestName + ".png", 
aBitmapEx);
+    }
+}
+
 void GraphicsRenderTests::testDrawBitmapExWithAlpha24bpp()
 {
     vcl::test::OutputDeviceTestBitmap aOutDevTest;
@@ -2230,6 +2251,7 @@ void GraphicsRenderTests::runALLTests()
     testDrawBezierAAWithPolylineB2D();
     testDrawBitmap24bpp();
     testDrawTransformedBitmap24bpp();
+    testComplexDrawTransformedBitmap24bpp();
     testDrawBitmapExWithAlpha24bpp();
     testDrawMask24bpp();
     testDrawBlend24bpp();
diff --git a/vcl/backendtest/VisualBackendTest.cxx 
b/vcl/backendtest/VisualBackendTest.cxx
index 4ba2cf63897b..f7da5e182d57 100644
--- a/vcl/backendtest/VisualBackendTest.cxx
+++ b/vcl/backendtest/VisualBackendTest.cxx
@@ -490,6 +490,13 @@ public:
             drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
         }
         aRectangle = aRegions[index++];
+        {
+            vcl::test::OutputDeviceTestBitmap aOutDevTest;
+            Bitmap aBitmap = 
aOutDevTest.setupComplexDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
+            
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkComplexTransformedBitmap(aBitmap),
 aRectangle, rRenderContext);
+            drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
+        }
+        aRectangle = aRegions[index++];
         {
             vcl::test::OutputDeviceTestBitmap aOutDevTest;
             Bitmap aBitmap = 
aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N24_BPP);
diff --git a/vcl/backendtest/outputdevice/bitmap.cxx 
b/vcl/backendtest/outputdevice/bitmap.cxx
index 066355c53f14..5b491badf587 100644
--- a/vcl/backendtest/outputdevice/bitmap.cxx
+++ b/vcl/backendtest/outputdevice/bitmap.cxx
@@ -43,6 +43,28 @@ Bitmap 
OutputDeviceTestBitmap::setupDrawTransformedBitmap(vcl::PixelFormat aBitm
 }
 
 
+Bitmap 
OutputDeviceTestBitmap::setupComplexDrawTransformedBitmap(vcl::PixelFormat 
aBitmapFormat,bool isBitmapGreyScale)
+{
+    Size aBitmapSize(6, 6);
+    Bitmap aBitmap(aBitmapSize, aBitmapFormat);
+    aBitmap.Erase(constFillColor);
+
+    if (isBitmapGreyScale)
+        aBitmap.Convert(BmpConversion::N8BitGreys);
+
+    initialSetup(17, 14, constBackgroundColor);
+
+    basegfx::B2DHomMatrix aTransform;
+    aTransform.shearX(0.25);
+    aTransform.scale(aBitmapSize.Width() * 2, aBitmapSize.Height() * 2);
+    aTransform.translate(1, 1);
+
+    mpVirtualDevice->DrawTransformedBitmapEx(aTransform, BitmapEx(aBitmap));
+
+    return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), 
maVDRectangle.GetSize());
+}
+
+
 Bitmap OutputDeviceTestBitmap::setupDrawBitmap(vcl::PixelFormat 
aBitmapFormat,bool isBitmapGreyScale)
 {
     Size aBitmapSize(9, 9);
@@ -153,57 +175,6 @@ BitmapEx 
OutputDeviceTestBitmap::setupDrawBlend(vcl::PixelFormat aBitmapFormat)
     return mpVirtualDevice->GetBitmapEx(maVDRectangle.TopLeft(), 
maVDRectangle.GetSize());
 }
 
-TestResult OutputDeviceTestBitmap::checkTransformedBitmap(Bitmap& rBitmap)
-{
-    std::vector<Color> aExpected
-    {
-        constBackgroundColor, constBackgroundColor,
-        COL_YELLOW, constFillColor, COL_YELLOW, constFillColor, constFillColor
-    };
-    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);
-
-    std::vector<Color> aExpected
-    {
-        constBackgroundColor, constBackgroundColor,
-        aBlendedColor, constBackgroundColor, constBackgroundColor,
-        aBlendedColor, constBackgroundColor
-    };
-    return checkRectangles(rBitmap, aExpected);
-}
-
-TestResult OutputDeviceTestBitmap::checkMask(Bitmap& rBitmap)
-{
-    return checkRectangle(rBitmap);
-}
-
-TestResult OutputDeviceTestBitmap::checkBlend(const BitmapEx& rBitmapEx)
-{
-    const Color aBlendedColor(0xEE, 0xEE, 0x33);
-
-    std::vector<Color> aExpected
-    {
-        COL_WHITE, COL_WHITE, COL_YELLOW, constBackgroundColor,
-        constBackgroundColor, aBlendedColor, constBackgroundColor
-    };
-    Bitmap aBitmap(rBitmapEx.GetBitmap());
-    return checkRectangles(aBitmap, aExpected);
-}
-
 } // end namespace vcl::test
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/backendtest/outputdevice/common.cxx 
b/vcl/backendtest/outputdevice/common.cxx
index 80408fac70fe..adbae9599e0f 100644
--- a/vcl/backendtest/outputdevice/common.cxx
+++ b/vcl/backendtest/outputdevice/common.cxx
@@ -1580,6 +1580,87 @@ TestResult 
OutputDeviceTestAnotherOutDev::checkXOR(Bitmap& rBitmap)
 }
 
 
+TestResult OutputDeviceTestBitmap::checkTransformedBitmap(Bitmap& rBitmap)
+{
+    std::vector<Color> aExpected
+    {
+        constBackgroundColor, constBackgroundColor,
+        COL_YELLOW, constFillColor, COL_YELLOW, constFillColor, constFillColor
+    };
+    return checkRectangles(rBitmap, aExpected);
+}
+
+TestResult OutputDeviceTestBitmap::checkComplexTransformedBitmap(Bitmap& 
rBitmap)
+{
+    TestResult aReturnValue = TestResult::Passed;
+    TestResult eResult;
+    eResult = checkRectangle(rBitmap, 0, constBackgroundColor); // outer line 
not affected
+    checkResult(eResult, aReturnValue);
+    // empty "corners" should not be affected
+    eResult = checkFilled(rBitmap, tools::Rectangle(Point(1, 11), Size(2, 2)), 
constBackgroundColor);
+    checkResult(eResult, aReturnValue);
+    eResult = checkFilled(rBitmap, tools::Rectangle(Point(14, 1), Size(2, 2)), 
constBackgroundColor);
+    // check the middle
+    eResult = checkFilled(rBitmap, tools::Rectangle(Point(4, 3), Size(9, 8)), 
constFillColor);
+    checkResult(eResult, aReturnValue);
+    checkResult(eResult, aReturnValue);
+    int nNumberOfQuirks = 0;
+    int nNumberOfErrors = 0;
+    BitmapScopedWriteAccess pAccess(rBitmap);
+    // starting and ending corner, headless draws with AA, so be lenient
+    checkValue(pAccess, 1, 1, constFillColor, nNumberOfQuirks, 
nNumberOfErrors, 0, 192);
+    checkValue(pAccess, 2, 2, constFillColor, nNumberOfQuirks, 
nNumberOfErrors, 0, 16);
+    checkValue(pAccess, 14, 11, constFillColor, nNumberOfQuirks, 
nNumberOfErrors, 0, 16);
+    checkValue(pAccess, 15, 12, constFillColor, nNumberOfQuirks, 
nNumberOfErrors, 0, 192);
+    if (nNumberOfQuirks > 0)
+        checkResult(TestResult::PassedWithQuirks, aReturnValue);
+    if (nNumberOfErrors > 0)
+        checkResult(TestResult::Failed, aReturnValue);
+    return aReturnValue;
+}
+
+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);
+
+    std::vector<Color> aExpected
+    {
+        constBackgroundColor, constBackgroundColor,
+        aBlendedColor, constBackgroundColor, constBackgroundColor,
+        aBlendedColor, constBackgroundColor
+    };
+    return checkRectangles(rBitmap, aExpected);
+}
+
+TestResult OutputDeviceTestBitmap::checkMask(Bitmap& rBitmap)
+{
+    return checkRectangle(rBitmap);
+}
+
+TestResult OutputDeviceTestBitmap::checkBlend(const BitmapEx& rBitmapEx)
+{
+    const Color aBlendedColor(0xEE, 0xEE, 0x33);
+
+    std::vector<Color> aExpected
+    {
+        COL_WHITE, COL_WHITE, COL_YELLOW, constBackgroundColor,
+        constBackgroundColor, aBlendedColor, constBackgroundColor
+    };
+    Bitmap aBitmap(rBitmapEx.GetBitmap());
+    return checkRectangles(aBitmap, aExpected);
+}
+
+
 } // end namespace vcl::test
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/test/outputdevice.hxx b/vcl/inc/test/outputdevice.hxx
index f92e8d8fe13f..8412dbaf8a7b 100644
--- a/vcl/inc/test/outputdevice.hxx
+++ b/vcl/inc/test/outputdevice.hxx
@@ -112,12 +112,15 @@ public:
 
     Bitmap setupDrawTransformedBitmap(vcl::PixelFormat aBitmapFormat,
                                       bool isBitmapGreyScale = false);
+    Bitmap setupComplexDrawTransformedBitmap(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 checkComplexTransformedBitmap(Bitmap& rBitmap);
     static TestResult checkBitmapExWithAlpha(Bitmap& rBitmap);
     static TestResult checkMask(Bitmap& rBitmap);
     static TestResult checkBlend(const BitmapEx& rBitmap);
diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 209c280d07c6..7badb40464be 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -478,6 +478,18 @@ public:
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
 
+    void testComplexDrawTransformedBitmap24bpp()
+    {
+        if (getDefaultDeviceBitCount() < 24)
+            return;
+        vcl::test::OutputDeviceTestBitmap aOutDevTest;
+        Bitmap aBitmap = 
aOutDevTest.setupComplexDrawTransformedBitmap(vcl::PixelFormat::N24_BPP);
+        auto eResult = 
vcl::test::OutputDeviceTestBitmap::checkComplexTransformedBitmap(aBitmap);
+        exportImage("08-03_transformed_bitmap_test_24bpp.png", aBitmap);
+        if (SHOULD_ASSERT)
+            CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
+    }
+
     void testDrawBitmapExWithAlpha24bpp()
     {
         if (getDefaultDeviceBitCount() < 24)
@@ -485,7 +497,7 @@ public:
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
         Bitmap aBitmap = 
aOutDevTest.setupDrawBitmapExWithAlpha(vcl::PixelFormat::N24_BPP);
         auto eResult = 
vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap);
-        exportImage("08-03_bitmapex_with_alpha_test_24bpp.png", aBitmap);
+        exportImage("08-04_bitmapex_with_alpha_test_24bpp.png", aBitmap);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
@@ -497,7 +509,7 @@ public:
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
         Bitmap aBitmap = aOutDevTest.setupDrawMask(vcl::PixelFormat::N24_BPP);
         auto eResult = vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap);
-        exportImage("08-04_mask_test_24bpp.png", aBitmap);
+        exportImage("08-05_mask_test_24bpp.png", aBitmap);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
@@ -509,7 +521,7 @@ public:
         vcl::test::OutputDeviceTestBitmap aOutDevTest;
         BitmapEx aBitmapEx = 
aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
         auto eResult = 
vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
-        exportImage("08-05_blend_test_24bpp.png", aBitmapEx);
+        exportImage("08-06_blend_test_24bpp.png", aBitmapEx);
         if (SHOULD_ASSERT)
             CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
     }
@@ -1439,6 +1451,7 @@ public:
 
     CPPUNIT_TEST(testDrawBitmap24bpp);
     CPPUNIT_TEST(testDrawTransformedBitmap24bpp);
+    CPPUNIT_TEST(testComplexDrawTransformedBitmap24bpp);
     CPPUNIT_TEST(testDrawBitmapExWithAlpha24bpp);
     CPPUNIT_TEST(testDrawMask24bpp);
     CPPUNIT_TEST(testDrawBlend24bpp);

Reply via email to