summaryrefslogtreecommitdiff
path: root/vcl/backendtest
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-11-16 12:57:52 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-11-16 14:36:13 +0100
commitae4a9d5cc50d94f3180ce3e5d3793c0a403074cd (patch)
tree24049becd9a6dbc77300c8c883bc39168bae9ca5 /vcl/backendtest
parent5006dfcbc370e80bd159a9e957254b0ce09a6cdd (diff)
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.lunak@collabora.com>
Diffstat (limited to 'vcl/backendtest')
-rw-r--r--vcl/backendtest/GraphicsRenderTests.cxx22
-rw-r--r--vcl/backendtest/VisualBackendTest.cxx7
-rw-r--r--vcl/backendtest/outputdevice/bitmap.cxx73
-rw-r--r--vcl/backendtest/outputdevice/common.cxx81
4 files changed, 132 insertions, 51 deletions
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
@@ -492,6 +492,13 @@ public:
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);
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap), aRectangle, rRenderContext);
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
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: */