Kaydet (Commit) 93abdf39 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/72276Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 7e54baa0
......@@ -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();
......
......@@ -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 ) )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment