[Libreoffice-commits] core.git: vcl/CppunitTest_vcl_bitmap_render_test.mk vcl/qa
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 16 05:20:31 UTC 2019
vcl/CppunitTest_vcl_bitmap_render_test.mk | 5 +++
vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 34 ++++++++++++++++++-----
2 files changed, 33 insertions(+), 6 deletions(-)
New commits:
commit d7263d05bdcbe7e219664e198154e31a986c68fc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Apr 16 13:10:11 2019 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Apr 16 07:20:00 2019 +0200
Test drawing BitmapEx with an alpha channel on a VirtualDevice
This adds a test for drawing a BitmapEx which has an alpha channel
onto a VirtualDevice. Most important is that alpha blending is
done as we expect it (but it is prone to rounding error).
Change-Id: I41a16ca9da98d7a067ada9aafad8c9fc7c6484d5
Reviewed-on: https://gerrit.libreoffice.org/70804
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/CppunitTest_vcl_bitmap_render_test.mk b/vcl/CppunitTest_vcl_bitmap_render_test.mk
index 1d66e6a5aae4..3af9c9fafd51 100644
--- a/vcl/CppunitTest_vcl_bitmap_render_test.mk
+++ b/vcl/CppunitTest_vcl_bitmap_render_test.mk
@@ -13,6 +13,11 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_bitmap_render_test, \
vcl/qa/cppunit/bitmaprender/BitmapRenderTest \
))
+$(eval $(call gb_CppunitTest_set_include,vcl_bitmap_render_test,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/vcl/inc \
+))
+
$(eval $(call gb_CppunitTest_use_libraries,vcl_bitmap_render_test, \
comphelper \
cppu \
diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
index 531494205c14..5fc6c5b7b53c 100644
--- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
+++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
@@ -13,7 +13,7 @@
#include <vcl/virdev.hxx>
#include <vcl/salbtype.hxx>
#include <vcl/bitmapaccess.hxx>
-#include <vcl/wrkwin.hxx>
+#include <vcl/svapp.hxx>
#include <tools/stream.hxx>
#include <vcl/pngwrite.hxx>
@@ -21,6 +21,9 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/filter/PngImageReader.hxx>
+#include <svdata.hxx>
+#include <salinst.hxx>
+
static OUString const gaDataUrl = "/vcl/qa/cppunit/bitmaprender/data/";
class BitmapRenderTest : public test::BootstrapFixture
@@ -38,13 +41,13 @@ public:
void testTdf104141();
void testTdf113918();
- void testDrawBitmap32();
+ void testDrawAlphaBitmapEx();
void testTdf116888();
CPPUNIT_TEST_SUITE(BitmapRenderTest);
CPPUNIT_TEST(testTdf104141);
CPPUNIT_TEST(testTdf113918);
- CPPUNIT_TEST(testDrawBitmap32);
+ CPPUNIT_TEST(testDrawAlphaBitmapEx);
CPPUNIT_TEST(testTdf116888);
CPPUNIT_TEST_SUITE_END();
@@ -101,7 +104,7 @@ void BitmapRenderTest::testTdf113918()
CPPUNIT_ASSERT(aColor.GetGreen() > 100);
}
-void BitmapRenderTest::testDrawBitmap32()
+void BitmapRenderTest::testDrawAlphaBitmapEx()
{
ScopedVclPtrInstance<VirtualDevice> pVDev;
pVDev->SetOutputSizePixel(Size(8, 8));
@@ -117,10 +120,29 @@ void BitmapRenderTest::testDrawBitmap32()
vcl::PngImageReader aPngReader(aFileStream);
BitmapEx aBitmapEx;
aPngReader.read(aBitmapEx);
+
+ // Check backend capabilities, if the backend support 32-bit bitmap
+ auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
+ if (pBackendCapabilities->mbSupportsBitmap32)
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(32), aBitmapEx.GetBitmap().GetBitCount());
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmapEx.GetBitmap().GetBitCount());
+ CPPUNIT_ASSERT_EQUAL(true, aBitmapEx.IsAlpha());
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), aBitmapEx.GetAlpha().GetBitCount());
+ }
+
+ // Check the bitmap has pixels we expect
+ CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0x00, 0x00, 0x00), aBitmapEx.GetPixelColor(0, 0));
+ CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0xFF, 0x00), aBitmapEx.GetPixelColor(1, 1));
+ CPPUNIT_ASSERT_EQUAL(Color(0x7F, 0x00, 0xFF, 0x00), aBitmapEx.GetPixelColor(2, 2));
+
pVDev->DrawBitmapEx(Point(), aBitmapEx);
- CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(0, 0)));
- CPPUNIT_ASSERT_EQUAL(COL_YELLOW, pVDev->GetPixel(Point(1, 1)));
+ CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0xFF, 0xFF), pVDev->GetPixel(Point(0, 0)));
+ CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0xFF, 0x00), pVDev->GetPixel(Point(1, 1)));
// sometimes on Windows we get rounding error in blending so let's ignore this on Windows for now.
#if !defined(_WIN32)
More information about the Libreoffice-commits
mailing list