sw/qa/extras/tiledrendering/data/semi-transparent.odt |binary sw/qa/extras/tiledrendering/tiledrendering.cxx | 33 ++++++++++++++++++ sw/source/core/layout/paintfrm.cxx | 7 +++ 3 files changed, 39 insertions(+), 1 deletion(-)
New commits: commit 93abdf39b01bb7b404dc09ef37369a4350fb0d10 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue May 14 12:02:55 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue May 14 13:00:42 2019 +0200 sw lok: assume no windows in SwLayoutFrame::PaintSwFrame() The high-level problem was that a watermark shape in the background was rendered with lighter and darker gray as the user typed. The reason for this was that depending on what larger combined tile was rendered we did or did not repaint the layout frame. Handle the situation similar to when we have no vcl::Window at all, which ensures that we always paint only once. The rgb value matches the desktop rendering result this way. (Just assert that we render the gray light enough, the actual color channel value may be 190 or 191.) Change-Id: Ie8746ab70f49f7f1080632c39e3a826c4ce509df Reviewed-on: https://gerrit.libreoffice.org/72276 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/tiledrendering/data/semi-transparent.odt b/sw/qa/extras/tiledrendering/data/semi-transparent.odt new file mode 100644 index 000000000000..eb76980e7406 Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/semi-transparent.odt differ diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 27e84046050c..777f325e8f78 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -42,6 +42,7 @@ #include <IDocumentRedlineAccess.hxx> #include <vcl/scheduler.hxx> #include <vcl/vclevent.hxx> +#include <vcl/bitmapaccess.hxx> #include <flddat.hxx> static char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/"; @@ -113,6 +114,7 @@ public: void testDeleteNodeRedlineCallback(); void testVisCursorInvalidation(); void testDeselectCustomShape(); + void testSemiTransparent(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -170,6 +172,7 @@ public: CPPUNIT_TEST(testDeleteNodeRedlineCallback); CPPUNIT_TEST(testVisCursorInvalidation); CPPUNIT_TEST(testDeselectCustomShape); + CPPUNIT_TEST(testSemiTransparent); CPPUNIT_TEST_SUITE_END(); private: @@ -2444,6 +2447,36 @@ void SwTiledRenderingTest::testDeselectCustomShape() CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount()); } +void SwTiledRenderingTest::testSemiTransparent() +{ + // Load a document where the top left tile contains a semi-transparent rectangle shape. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("semi-transparent.odt"); + + // Render a larger area, and then get the color of the bottom right corner of our tile. + size_t nCanvasWidth = 1024; + size_t nCanvasHeight = 512; + size_t nTileSize = 256; + std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0); + ScopedVclPtrInstance<VirtualDevice> pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT); + pDevice->SetBackground(Wallpaper(COL_TRANSPARENT)); + pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), + Fraction(1.0), Point(), aPixmap.data()); + pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, + /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); + pDevice->EnableMapMode(false); + Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); + Bitmap::ScopedReadAccess pAccess(aBitmap); + Color aColor(pAccess->GetPixel(255, 255)); + + // Without the accompanying fix in place, this test would have failed with 'Expected greater or + // equal than: 190; Actual: 159'. This means the semi-transparent gray rectangle was darker than + // expected, as it was painted twice. + CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.R)); + CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.G)); + CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.B)); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index ad7530657e4e..559142577009 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -112,6 +112,7 @@ #include <o3tl/typed_flags_set.hxx> #include <vcl/BitmapTools.hxx> +#include <comphelper/lok.hxx> #define COL_NOTES_SIDEPANE Color(230,230,230) #define COL_NOTES_SIDEPANE_BORDER Color(200,200,200) @@ -3330,7 +3331,11 @@ void SwLayoutFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect cons } const SwPageFrame *pPage = nullptr; - const bool bWin = gProp.pSGlobalShell->GetWin() != nullptr; + bool bWin = gProp.pSGlobalShell->GetWin() != nullptr; + if (comphelper::LibreOfficeKit::isTiledPainting()) + // Tiled rendering is similar to printing in this case: painting transparently multiple + // times will result in darker colors: avoid that. + bWin = false; while ( IsAnLower( pFrame ) ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits