diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-03-04 15:35:44 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-03-09 22:10:22 +0100 |
commit | 058b59ae92ca19beed698ad1a2d6ee6f1182213a (patch) | |
tree | 9926c57ca08408eefd498e25ad033b50088dcb6f | |
parent | Improve unit test accuracy (diff) | |
download | core-058b59ae92ca19beed698ad1a2d6ee6f1182213a.tar.gz core-058b59ae92ca19beed698ad1a2d6ee6f1182213a.zip |
make RenderMaskPrimitive2DPixel() clip using clipping (tdf#140797)
The original implementation had this peculiar idea of implementing
clipping using transparency, which slows everything down, because
contents need to be copied and then alpha-blended. Keep that only
for when edges of the clip are to be smoothed.
As a side-effect this also seems to fix tdf#115843 again.
The commit also adjusts the test for tdf#133477 to not rely
on the rounding introduced by the optimization from tdf#115843.
Change-Id: Iebae5996159cf9f17066205985c5b591abdae105
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111966
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit 6b8c157a0b4f37a09fdbf656919b2df06a3abc3e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112217
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | drawinglayer/source/processor2d/vclprocessor2d.cxx | 31 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 4 |
2 files changed, 20 insertions, 15 deletions
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index c2c835e5291d..80c7fbdb6556 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -751,7 +751,7 @@ void VclProcessor2D::RenderPolyPolygonGraphicPrimitive2D( } } -// mask group. Force output to VDev and create mask from given mask +// mask group void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate) { if (rMaskCandidate.getChildren().empty()) @@ -763,6 +763,17 @@ void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive return; aMask.transform(maCurrentTransformation); + + // Unless smooth edges are needed, simply use clipping. + if (basegfx::utils::isRectangle(aMask) || !getOptionsDrawinglayer().IsAntiAliasing()) + { + mpOutputDevice->Push(PushFlags::CLIPREGION); + mpOutputDevice->IntersectClipRegion(vcl::Region(aMask)); + process(rMaskCandidate.getChildren()); + mpOutputDevice->Pop(); + return; + } + const basegfx::B2DRange aRange(basegfx::utils::getRange(aMask)); impBufferDevice aBufferDevice(*mpOutputDevice, aRange); @@ -779,19 +790,11 @@ void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive // back to old OutDev mpOutputDevice = pLastOutputDevice; - // if the mask fills the whole area we can skip - // creating a transparent vd and filling it. - if (!basegfx::utils::isRectangle(aMask)) - { - // draw mask - // with AA, use 8bit AlphaMask to get nice borders; no AA -> use 1bit mask - VirtualDevice& rMask = getOptionsDrawinglayer().IsAntiAliasing() - ? aBufferDevice.getTransparence() - : aBufferDevice.getMask(); - rMask.SetLineColor(); - rMask.SetFillColor(COL_BLACK); - rMask.DrawPolyPolygon(aMask); - } + // draw mask + VirtualDevice& rMask = aBufferDevice.getTransparence(); + rMask.SetLineColor(); + rMask.SetFillColor(COL_BLACK); + rMask.DrawPolyPolygon(aMask); // dump buffer to outdev aBufferDevice.paint(); diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 018a96a78ee6..a2b8c8bc1c38 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -2086,10 +2086,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf133477) aStream.Seek(STREAM_SEEK_TO_BEGIN); // Read it back and check the color of the first pixel. + // (Actually check at one-pixel offset, because imprecise shape positioning may + // result in blending with background for the first pixel). Graphic aGraphic; ReadGraphic(aStream, aGraphic); BitmapEx aBitmap = aGraphic.GetBitmapEx(); - CPPUNIT_ASSERT_EQUAL(Color(0, 102, 204), aBitmap.GetPixelColor(0, 0)); + CPPUNIT_ASSERT_EQUAL(Color(0, 102, 204), aBitmap.GetPixelColor(1, 1)); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf137964) |