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 b5de4785e0622b84820d1737b20f970b482bd799 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue May 14 12:02:55 2019 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Tue May 14 14:45:11 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.) (cherry picked from commit 93abdf39b01bb7b404dc09ef37369a4350fb0d10) Change-Id: Ie8746ab70f49f7f1080632c39e3a826c4ce509df Reviewed-on: https://gerrit.libreoffice.org/72285 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> 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 e68ec068d3bc..56e947813d99 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -40,6 +40,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/"; @@ -110,6 +111,7 @@ public: void testDeleteNodeRedlineCallback(); void testVisCursorInvalidation(); void testDeselectCustomShape(); + void testSemiTransparent(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -166,6 +168,7 @@ public: CPPUNIT_TEST(testDeleteNodeRedlineCallback); CPPUNIT_TEST(testVisCursorInvalidation); CPPUNIT_TEST(testDeselectCustomShape); + CPPUNIT_TEST(testSemiTransparent); CPPUNIT_TEST_SUITE_END(); private: @@ -2405,6 +2408,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.GetRed())); + CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetGreen())); + CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetBlue())); +} + 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 b9a157d5b313..282256ef06e3 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -104,6 +104,7 @@ #include <o3tl/typed_flags_set.hxx> #include <vcl/BitmapTools.hxx> +#include <comphelper/lok.hxx> #define COL_NOTES_SIDEPANE RGB_COLORDATA(230,230,230) #define COL_NOTES_SIDEPANE_BORDER RGB_COLORDATA(200,200,200) @@ -3415,7 +3416,11 @@ void SwLayoutFrame::Paint(vcl::RenderContext& rRenderContext, SwRect const& rRec } 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