From 5b292e878703ebc32e875406f4116cba145a9042 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Wed, 18 Nov 2020 16:30:52 +0100 Subject: avoid Skia floating point position fixups for rectangles (tdf#137329) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid to toSkX()/toSkY() tweaks for rectangular areas, so with AA enabled it leads to fuzzy edges, and rectangles should line up perfectly with all pixels even without tweaks. Change-Id: I45bf5a57a9f2d941eb7ec224992fc452481a2f98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106060 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/qa/cppunit/skia/skia.cxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'vcl/qa') diff --git a/vcl/qa/cppunit/skia/skia.cxx b/vcl/qa/cppunit/skia/skia.cxx index d13e1530f95e..1f04c5825584 100644 --- a/vcl/qa/cppunit/skia/skia.cxx +++ b/vcl/qa/cppunit/skia/skia.cxx @@ -35,6 +35,7 @@ public: void testInterpretAs8Bit(); void testAlphaBlendWith(); void testBitmapCopyOnWrite(); + void testTdf137329(); CPPUNIT_TEST_SUITE(SkiaTest); CPPUNIT_TEST(testBitmapErase); @@ -42,6 +43,7 @@ public: CPPUNIT_TEST(testInterpretAs8Bit); CPPUNIT_TEST(testAlphaBlendWith); CPPUNIT_TEST(testBitmapCopyOnWrite); + CPPUNIT_TEST(testTdf137329); CPPUNIT_TEST_SUITE_END(); private: @@ -303,6 +305,27 @@ void SkiaTest::testBitmapCopyOnWrite() CPPUNIT_ASSERT(bitmap.unittestGetAlphaImage() != oldAlphaImage); } +void SkiaTest::testTdf137329() +{ + // Draw a filled polygon in the entire device, with AA enabled. + // All pixels in the device should be black, even those at edges (i.e. not affected by AA). + ScopedVclPtr device = VclPtr::Create(DeviceFormat::DEFAULT); + device->SetOutputSizePixel(Size(10, 10)); + device->SetBackground(Wallpaper(COL_WHITE)); + device->SetAntialiasing(AntialiasingFlags::Enable); + device->Erase(); + device->SetLineColor(); + device->SetFillColor(COL_BLACK); + device->DrawPolyPolygon( + basegfx::B2DPolyPolygon(basegfx::B2DPolygon{ { 0, 0 }, { 10, 0 }, { 10, 10 }, { 0, 10 } })); + // savePNG("/tmp/tdf137329.png", device); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, device->GetPixel(Point(0, 0))); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, device->GetPixel(Point(9, 0))); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, device->GetPixel(Point(9, 9))); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, device->GetPixel(Point(0, 9))); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, device->GetPixel(Point(4, 4))); +} + } // namespace CPPUNIT_TEST_SUITE_REGISTRATION(SkiaTest); -- cgit