BitmapEx->Bitmap in OutputDeviceTestCommon

Change-Id: Id0ba95660869e809f59fc5d74e97d181f759f377
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190605
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin
2025-09-05 09:16:36 +02:00
parent c8d666c1ef
commit 744d6e93b8
7 changed files with 26 additions and 37 deletions
+8 -8
View File
@@ -832,17 +832,17 @@ void GraphicsRenderTests::testDrawBlend24bpp()
OUString aTestName = u"testDrawBlend24bpp"_ustr;
GraphicsTestZone zone(aTestName);
vcl::test::OutputDeviceTestBitmap aOutDevTest;
BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
Bitmap aBitmap = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
if (!SHOULD_ASSERT)
{
appendTestResult(aTestName, u"SKIPPED"_ustr);
return;
}
vcl::test::TestResult eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
vcl::test::TestResult eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmap);
appendTestResult(aTestName, returnTestStatus(eResult),
(m_aStoreResultantBitmap ? aBitmapEx.GetBitmap() : Bitmap()));
(m_aStoreResultantBitmap ? aBitmap.CreateColorBitmap() : Bitmap()));
if (m_aStoreResultantBitmap)
exportBitmapToImage(m_aUserInstallPath + aTestName + ".png", Bitmap(aBitmapEx));
exportBitmapToImage(m_aUserInstallPath + aTestName + ".png", aBitmap);
}
void GraphicsRenderTests::testDrawXor()
@@ -1621,18 +1621,18 @@ void GraphicsRenderTests::testDrawBlend32bpp()
OUString aTestName = u"testDrawBlend32bpp"_ustr;
GraphicsTestZone zone(aTestName);
vcl::test::OutputDeviceTestBitmap aOutDevTest;
BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N32_BPP);
Bitmap aBitmap = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N32_BPP);
if (!SHOULD_ASSERT)
{
appendTestResult(aTestName, u"SKIPPED"_ustr);
return;
}
vcl::test::TestResult eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
vcl::test::TestResult eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmap);
appendTestResult(aTestName, returnTestStatus(eResult),
(m_aStoreResultantBitmap ? aBitmapEx.GetBitmap() : Bitmap()));
(m_aStoreResultantBitmap ? aBitmap.CreateColorBitmap() : Bitmap()));
if (m_aStoreResultantBitmap)
{
exportBitmapToImage(m_aUserInstallPath + aTestName + ".png", Bitmap(aBitmapEx));
exportBitmapToImage(m_aUserInstallPath + aTestName + ".png", aBitmap);
}
}
+2 -2
View File
@@ -510,9 +510,9 @@ public:
aRectangle = aRegions[index++];
{
vcl::test::OutputDeviceTestBitmap aOutDevTest;
BitmapEx aBitmap = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
Bitmap aBitmap = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmap), aRectangle, rRenderContext);
drawBitmapScaledAndCentered(aRectangle, aBitmap.GetBitmap(), rRenderContext);
drawBitmapScaledAndCentered(aRectangle, aBitmap.CreateColorBitmap(), rRenderContext);
}
}
+2 -2
View File
@@ -139,7 +139,7 @@ Bitmap OutputDeviceTestBitmap::setupDrawMask(vcl::PixelFormat aBitmapFormat)
return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
}
BitmapEx OutputDeviceTestBitmap::setupDrawBlend(vcl::PixelFormat aBitmapFormat)
Bitmap OutputDeviceTestBitmap::setupDrawBlend(vcl::PixelFormat aBitmapFormat)
{
Size aBitmapSize(9, 9);
Bitmap aBitmap(aBitmapSize, aBitmapFormat);
@@ -172,7 +172,7 @@ BitmapEx OutputDeviceTestBitmap::setupDrawBlend(vcl::PixelFormat aBitmapFormat)
mpVirtualDevice->DrawBitmapEx(aPoint, Bitmap(aBitmap, aAlpha));
return BitmapEx(mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize()));
return mpVirtualDevice->GetBitmap(maVDRectangle.TopLeft(), maVDRectangle.GetSize());
}
} // end namespace vcl::test
+2 -2
View File
@@ -1650,7 +1650,7 @@ TestResult OutputDeviceTestBitmap::checkMask(Bitmap& rBitmap)
return checkRectangle(rBitmap);
}
TestResult OutputDeviceTestBitmap::checkBlend(const BitmapEx& rBitmapEx)
TestResult OutputDeviceTestBitmap::checkBlend(const Bitmap& rBitmap)
{
const Color aBlendedColor(0xEE, 0xEE, 0x33);
@@ -1659,7 +1659,7 @@ TestResult OutputDeviceTestBitmap::checkBlend(const BitmapEx& rBitmapEx)
COL_BLACK, COL_BLACK, COL_YELLOW, constBackgroundColor,
constBackgroundColor, aBlendedColor, constBackgroundColor
};
Bitmap aBitmap(rBitmapEx.GetBitmap());
Bitmap aBitmap(rBitmap.CreateColorBitmap());
return checkRectangles(aBitmap, aExpected);
}
+2 -2
View File
@@ -116,13 +116,13 @@ public:
Bitmap setupDrawBitmap(vcl::PixelFormat aBitmapFormat, bool isBitmapGreyScale = false);
Bitmap setupDrawBitmapExWithAlpha(vcl::PixelFormat aBitmapFormat);
Bitmap setupDrawMask(vcl::PixelFormat aBitmapFormat);
BitmapEx setupDrawBlend(vcl::PixelFormat aBitmapFormat);
Bitmap 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);
static TestResult checkBlend(const Bitmap& rBitmap);
static TestResult checkTransformedBitmap8bppGreyScale(Bitmap& rBitmap);
};
+6 -17
View File
@@ -29,17 +29,6 @@ class BackendTest : public test::BootstrapFixture
// "xdg-open ./workdir/CppunitTest/vcl_backend_test.test.core/"
static constexpr const bool mbExportBitmap = false;
void exportImage(OUString const& rsFilename, BitmapEx const& rBitmapEx)
{
if (mbExportBitmap)
{
Bitmap aBitmap(rBitmapEx);
aBitmap.Scale(Size(128, 128), BmpScaleFlag::Fast);
SvFileStream aStream(rsFilename, StreamMode::WRITE | StreamMode::TRUNC);
GraphicFilter::GetGraphicFilter().compressAsPNG(aBitmap, aStream);
}
}
void exportImage(OUString const& rsFilename, Bitmap const& rBitmap)
{
if (mbExportBitmap)
@@ -526,9 +515,9 @@ public:
if (getDefaultDeviceBitCount() < 24)
return;
vcl::test::OutputDeviceTestBitmap aOutDevTest;
BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
exportImage(u"08-06_blend_test_24bpp.png"_ustr, aBitmapEx);
Bitmap aBitmap = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N24_BPP);
auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmap);
exportImage(u"08-06_blend_test_24bpp.png"_ustr, aBitmap);
if (SHOULD_ASSERT)
CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
}
@@ -586,9 +575,9 @@ public:
if (getDefaultDeviceBitCount() < 24)
return;
vcl::test::OutputDeviceTestBitmap aOutDevTest;
BitmapEx aBitmapEx = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N32_BPP);
auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmapEx);
exportImage(u"09-05_blend_test_32bpp.png"_ustr, aBitmapEx);
Bitmap aBitmap = aOutDevTest.setupDrawBlend(vcl::PixelFormat::N32_BPP);
auto eResult = vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmap);
exportImage(u"09-05_blend_test_32bpp.png"_ustr, aBitmap);
if (SHOULD_ASSERT)
CPPUNIT_ASSERT(eResult != vcl::test::TestResult::Failed);
}
@@ -191,8 +191,8 @@ void BitmapRenderTest::testAlphaVirtualDevice()
CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0x00, 0x00, 0x00, 0x00),
pAlphaVirtualDevice->GetPixel(Point(1, 1)));
// Get a BitmapEx from the VirDev -> Colors should have alpha
BitmapEx aBitmap(pAlphaVirtualDevice->GetBitmap(Point(), Size(4, 4)));
// Get a Bitmap from the VirDev -> Colors should have alpha
Bitmap aBitmap(pAlphaVirtualDevice->GetBitmap(Point(), Size(4, 4)));
CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Width());
CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Height());
Color aColor = aBitmap.GetPixelColor(1, 1);
@@ -210,7 +210,7 @@ void BitmapRenderTest::testAlphaVirtualDevice()
CPPUNIT_ASSERT_EQUAL(Color(0x0022ff55), aColor);
#endif
// Read back the BitmapEx and check the opaque pixel
// Read back the Bitmap and check the opaque pixel
aBitmap = pAlphaVirtualDevice->GetBitmap(Point(), Size(4, 4));
CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Width());
CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Height());
@@ -233,7 +233,7 @@ void BitmapRenderTest::testAlphaVirtualDevice()
CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x4422FF55), aColor);
#endif
// Read back the BitmapEx and check the semi-transparent pixel
// Read back the Bitmap and check the semi-transparent pixel
aBitmap = pAlphaVirtualDevice->GetBitmap(Point(), Size(4, 4));
CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Width());
CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Height());