tdf#101181: use buffer device with alpha in glow effect
Change-Id: Iddc94a5cfdee03befdf245ee086a872f0bfaf7a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95051
Tested-by: Jenkins
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/drawinglayer/source/primitive2d/glowprimitive2d.cxx b/drawinglayer/source/primitive2d/glowprimitive2d.cxx
index bf49b8e..fb6a599 100644
--- a/drawinglayer/source/primitive2d/glowprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/glowprimitive2d.cxx
@@ -60,22 +60,6 @@ GlowPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation
return aRetval;
}
void GlowPrimitive2D::get2DDecomposition(
Primitive2DDecompositionVisitor& rVisitor,
const geometry::ViewInformation2D& /*rViewInformation*/) const
{
if (getChildren().empty())
return;
// create a modifiedColorPrimitive containing the *black* color and the content. Using black
// on white allows creating useful mask in VclPixelProcessor2D::processGlowPrimitive2D.
basegfx::BColorModifierSharedPtr aBColorModifier
= std::make_shared<basegfx::BColorModifier_replace>(basegfx::BColor());
const Primitive2DReference xRef(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier));
rVisitor.append(xRef);
}
// provide unique ID
ImplPrimitive2DIDBlock(GlowPrimitive2D, PRIMITIVE2D_ID_GLOWPRIMITIVE2D)
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 3c1a108..d4ee5f3 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -983,30 +983,29 @@ void VclPixelProcessor2D::processGlowPrimitive2D(const primitive2d::GlowPrimitiv
// Consider glow transparency (initial transparency near the object edge)
const sal_uInt8 nTransparency = rCandidate.getGlowColor().GetTransparency();
impBufferDevice aBufferDevice(*mpOutputDevice, aRange);
impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
if (aBufferDevice.isVisible())
{
// remember last OutDev and set to content
OutputDevice* pLastOutputDevice = mpOutputDevice;
mpOutputDevice = &aBufferDevice.getContent();
// Processing will draw whatever geometry on white background, applying *black*
// replacement color. The black color replacement is added in 2d decomposition of
// glow primitive.
mpOutputDevice->Erase();
process(rCandidate);
const tools::Rectangle aRect(static_cast<long>(std::floor(aRange.getMinX())),
static_cast<long>(std::floor(aRange.getMinY())),
static_cast<long>(std::ceil(aRange.getMaxX())),
static_cast<long>(std::ceil(aRange.getMaxY())));
Bitmap bitmap = mpOutputDevice->GetBitmap(aRect.TopLeft(), aRect.GetSize());
BitmapEx bmpEx = mpOutputDevice->GetBitmapEx(aRect.TopLeft(), aRect.GetSize());
AlphaMask mask = ProcessAndBlurAlphaMask(bitmap, fBlurRadius, fBlurRadius, nTransparency);
AlphaMask mask
= ProcessAndBlurAlphaMask(bmpEx.GetAlpha(), fBlurRadius, fBlurRadius, nTransparency);
// The end result is the bitmap filled with glow color and blurred 8-bit alpha mask
const basegfx::BColor aGlowColor(
maBColorModifierStack.getModifiedColor(rCandidate.getGlowColor().getBColor()));
bitmap.Erase(Color(aGlowColor));
BitmapEx result(bitmap, mask);
Bitmap bmp = bmpEx.GetBitmap();
bmp.Erase(Color(aGlowColor));
BitmapEx result(bmp, mask);
// back to old OutDev
mpOutputDevice = pLastOutputDevice;
diff --git a/include/drawinglayer/primitive2d/glowprimitive2d.hxx b/include/drawinglayer/primitive2d/glowprimitive2d.hxx
index 5c30298..62a5852 100644
--- a/include/drawinglayer/primitive2d/glowprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/glowprimitive2d.hxx
@@ -52,11 +52,6 @@ public:
virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
/// create decomposition
virtual void
get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
const geometry::ViewInformation2D& rViewInformation) const override;
/// provide unique ID
virtual sal_uInt32 getPrimitive2DID() const override;
};