vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 10 ++++++++++ vcl/source/gdi/virdev.cxx | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
New commits: commit 72d523f4010647041f7ed95bf3329529e0a48af8 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sun Aug 3 13:05:32 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sun Aug 3 21:58:26 2025 +0200 SetOutputSizePixel(bAlphaMaskTransparent=true) should make.. the background transparent. I initially tried debugging this on both Windwos and macOS. Both quickly descended into nightmare. On macOS we have CGLayer interposing itself with a bunch of extra weirdness. On Windows we have WinSalVirtualDevice sometimes rendering to a GDI bitmap and then inexplicably switching to using a skia surface. I will leave all that alone for now and just use a bigger hammer. Change-Id: I0a485b526af29e841e7267430800bd8ca394d871 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188869 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx index 5a39f97c8d10..b62ba4239de4 100644 --- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx +++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx @@ -45,6 +45,7 @@ public: void testDrawAlphaBitmapEx(); void testAlphaVirtualDevice(); void testTdf116888(); + void testAlphaErase(); CPPUNIT_TEST_SUITE(BitmapRenderTest); CPPUNIT_TEST(testTdf104141); @@ -52,6 +53,7 @@ public: CPPUNIT_TEST(testDrawAlphaBitmapEx); CPPUNIT_TEST(testAlphaVirtualDevice); CPPUNIT_TEST(testTdf116888); + CPPUNIT_TEST(testAlphaErase); CPPUNIT_TEST_SUITE_END(); }; @@ -280,6 +282,14 @@ void BitmapRenderTest::testTdf116888() pAccess->GetColor(pAccess->Height() - 1, pAccess->Width() - 1)); } +void BitmapRenderTest::testAlphaErase() +{ + // verify that SetOutputSizePixel correctly produces a transparent background + ScopedVclPtrInstance<VirtualDevice> xDev(DeviceFormat::WITH_ALPHA); + xDev->SetOutputSizePixel(Size(10, 10), /*bErase*/ true, /*bAlphaMaskTransparent*/ true); + CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0x00, 0x00, 0x00, 0x00), xDev->GetPixel(Point(0, 0))); +} + CPPUNIT_TEST_SUITE_REGISTRATION(BitmapRenderTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 07729bba42f0..c8245a4c4934 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -286,7 +286,15 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra { mnOutWidth = rNewSize.Width(); mnOutHeight = rNewSize.Height(); - Erase(); + // So, in theory, the bAlphaMaskTransparent param to the SetSize() call just above should + // be initialising the data to transparent. But this only works on Linux. On Windows and macOS we + // have two different kinds of problems in the VirtualDevice subclasses, + // which means that it ends up being completely ineffective. + // So just take the heavy handed approach here and force the data to transparent. + if (bAlphaMaskTransparent) + DrawWallpaper(tools::Rectangle(0, 0, mnOutWidth, mnOutHeight), Wallpaper(COL_TRANSPARENT)); + else + Erase(); } } else