diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2022-09-13 13:42:54 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2022-09-14 09:54:18 +0200 |
commit | e735ad1c57cddaf17d6ffc0cf15b5e14fa63c4ad (patch) | |
tree | 194e32decaaf2aa96a12169ea3dacd749b8dffd9 /drawinglayer/source/processor2d | |
parent | 80d3fb7ef721b5aa2de1095249557a19e3697b3b (diff) |
Rework of ShadowPrimitive2D
This is pretty much the same for ShadowPrimitive2D as the
change for GlowPrimitive2D and SoftEdgePrimitive2D, so for
more comments please refer to those commits:
c2d1458723c66c2fd717a112f89f773226adc841
707b0c328a282d993fa33b618083d20b6c521de6
There are some needed differences due to ShadowPrimitive2D
having existed longer and is used for non-blurred shadow
for a long time and is used as unchanged as possible.
Only for active glow of shadow is a buffering and local
decompose used.
Change-Id: I55e6516f59390079356ac16f24743b474e53fb05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139858
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer/source/processor2d')
4 files changed, 0 insertions, 163 deletions
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 926835788383..8e221affe978 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -928,11 +928,6 @@ void VclMetafileProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimi static_cast<const primitive2d::ObjectInfoPrimitive2D&>(rCandidate)); break; } - case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D: - { - processPrimitive2DOnPixelProcessor(rCandidate); - break; - } default: { // process recursively @@ -2368,103 +2363,6 @@ void VclMetafileProcessor2D::processStructureTagPrimitive2D( } } -VclPtr<VirtualDevice> -VclMetafileProcessor2D::CreateBufferDevice(const basegfx::B2DRange& rCandidateRange, - geometry::ViewInformation2D& rViewInfo, - tools::Rectangle& rRectLogic, Size& rSizePixel) const -{ - constexpr double fMaxSquarePixels = 500000; - basegfx::B2DRange aViewRange(rCandidateRange); - aViewRange.transform(maCurrentTransformation); - rRectLogic = tools::Rectangle(static_cast<tools::Long>(std::floor(aViewRange.getMinX())), - static_cast<tools::Long>(std::floor(aViewRange.getMinY())), - static_cast<tools::Long>(std::ceil(aViewRange.getMaxX())), - static_cast<tools::Long>(std::ceil(aViewRange.getMaxY()))); - const tools::Rectangle aRectPixel(mpOutputDevice->LogicToPixel(rRectLogic)); - rSizePixel = aRectPixel.GetSize(); - const double fViewVisibleArea(rSizePixel.getWidth() * rSizePixel.getHeight()); - double fReduceFactor(1.0); - - if (fViewVisibleArea > fMaxSquarePixels) - { - // reduce render size - fReduceFactor = sqrt(fMaxSquarePixels / fViewVisibleArea); - rSizePixel = Size(basegfx::fround(rSizePixel.getWidth() * fReduceFactor), - basegfx::fround(rSizePixel.getHeight() * fReduceFactor)); - } - - VclPtrInstance<VirtualDevice> pBufferDevice(DeviceFormat::DEFAULT, DeviceFormat::DEFAULT); - if (pBufferDevice->SetOutputSizePixel(rSizePixel)) - { - // create and set MapModes for target devices - MapMode aNewMapMode(mpOutputDevice->GetMapMode()); - aNewMapMode.SetOrigin(Point(-rRectLogic.Left(), -rRectLogic.Top())); - pBufferDevice->SetMapMode(aNewMapMode); - - // prepare view transformation for target renderers - // ATTENTION! Need to apply another scaling because of the potential DPI differences - // between Printer and VDev (mpOutputDevice and pBufferDevice here). - // To get the DPI, LogicToPixel from (1,1) from MapUnit::MapInch needs to be used. - basegfx::B2DHomMatrix aViewTransform(pBufferDevice->GetViewTransformation()); - const Size aDPIOld(mpOutputDevice->LogicToPixel(Size(1, 1), MapMode(MapUnit::MapInch))); - const Size aDPINew(pBufferDevice->LogicToPixel(Size(1, 1), MapMode(MapUnit::MapInch))); - const double fDPIXChange(static_cast<double>(aDPIOld.getWidth()) - / static_cast<double>(aDPINew.getWidth())); - const double fDPIYChange(static_cast<double>(aDPIOld.getHeight()) - / static_cast<double>(aDPINew.getHeight())); - - if (!basegfx::fTools::equal(fDPIXChange, 1.0) || !basegfx::fTools::equal(fDPIYChange, 1.0)) - { - aViewTransform.scale(fDPIXChange, fDPIYChange); - } - - // also take scaling from Size reduction into account - if (!basegfx::fTools::equal(fReduceFactor, 1.0)) - { - aViewTransform.scale(fReduceFactor, fReduceFactor); - } - - // create view information and pixel renderer. Reuse known ViewInformation - // except new transformation and range - rViewInfo = geometry::ViewInformation2D( - getViewInformation2D().getObjectTransformation(), aViewTransform, aViewRange, - getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime()); - } - else - pBufferDevice.disposeAndClear(); - -#if HAVE_P1155R3 - return pBufferDevice; -#else - return std::move(pBufferDevice); -#endif -} - -void VclMetafileProcessor2D::processPrimitive2DOnPixelProcessor( - const primitive2d::BasePrimitive2D& rCandidate) -{ - basegfx::B2DRange aViewRange(rCandidate.getB2DRange(getViewInformation2D())); - geometry::ViewInformation2D aViewInfo; - tools::Rectangle aRectLogic; - Size aSizePixel; - auto pBufferDevice(CreateBufferDevice(aViewRange, aViewInfo, aRectLogic, aSizePixel)); - if (pBufferDevice) - { - VclPixelProcessor2D aBufferProcessor(aViewInfo, *pBufferDevice, maBColorModifierStack); - - // draw content using pixel renderer - primitive2d::Primitive2DReference aRef( - &const_cast<primitive2d::BasePrimitive2D&>(rCandidate)); - aBufferProcessor.process({ aRef }); - const BitmapEx aBmContent(pBufferDevice->GetBitmapEx(Point(), aSizePixel)); - mpOutputDevice->DrawBitmapEx(aRectLogic.TopLeft(), aRectLogic.GetSize(), aBmContent); - - // aBufferProcessor dtor pops state off pBufferDevice pushed on by its ctor, let - // pBufferDevice live past aBufferProcessor scope to avoid warnings - } - pBufferDevice.disposeAndClear(); -} - } // end of namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx index 06fd61e18309..0393039f4455 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx @@ -144,10 +144,6 @@ private: const primitive2d::TransparencePrimitive2D& rTransparenceCandidate); void processStructureTagPrimitive2D( const primitive2d::StructureTagPrimitive2D& rStructureTagCandidate); - void processPrimitive2DOnPixelProcessor(const primitive2d::BasePrimitive2D& rCandidate); - VclPtr<VirtualDevice> CreateBufferDevice(const basegfx::B2DRange& rCandidateRange, - geometry::ViewInformation2D& rViewInfo, - tools::Rectangle& rRectLogic, Size& rSizePixel) const; /// Convert the fWidth to the same space as its coordinates. double getTransformedLineWidth(double fWidth) const; diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 12e044959b31..cf8d7dcd3ac0 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -58,7 +58,6 @@ #include <drawinglayer/primitive2d/epsprimitive2d.hxx> #include <drawinglayer/primitive2d/shadowprimitive2d.hxx> #include <drawinglayer/primitive2d/patternfillprimitive2d.hxx> -#include <drawinglayer/primitive2d/GlowSoftEgdeShadowTools.hxx> #include <com/sun/star/awt/XWindow2.hpp> #include <com/sun/star/awt/XControl.hpp> @@ -395,12 +394,6 @@ void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitiv static_cast<const drawinglayer::primitive2d::BorderLinePrimitive2D&>(rCandidate)); break; } - case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D: - { - processShadowPrimitive2D( - static_cast<const drawinglayer::primitive2d::ShadowPrimitive2D&>(rCandidate)); - break; - } case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D: { processFillGradientPrimitive2D( @@ -949,52 +942,6 @@ void VclPixelProcessor2D::processMetaFilePrimitive2D(const primitive2d::BasePrim } } -void VclPixelProcessor2D::processShadowPrimitive2D(const primitive2d::ShadowPrimitive2D& rCandidate) -{ - if (rCandidate.getShadowBlur() == 0) - { - process(rCandidate); - return; - } - - basegfx::B2DRange aRange(rCandidate.getB2DRange(getViewInformation2D())); - aRange.transform(maCurrentTransformation); - basegfx::B2DVector aBlurRadiusVector(rCandidate.getShadowBlur(), 0); - aBlurRadiusVector *= maCurrentTransformation; - const double fBlurRadius = aBlurRadiusVector.getLength(); - - impBufferDevice aBufferDevice(*mpOutputDevice, aRange); - if (aBufferDevice.isVisible() && !aRange.isEmpty()) - { - OutputDevice* pLastOutputDevice = mpOutputDevice; - mpOutputDevice = &aBufferDevice.getContent(); - - process(rCandidate); - - const tools::Rectangle aRect(static_cast<tools::Long>(std::floor(aRange.getMinX())), - static_cast<tools::Long>(std::floor(aRange.getMinY())), - static_cast<tools::Long>(std::ceil(aRange.getMaxX())), - static_cast<tools::Long>(std::ceil(aRange.getMaxY()))); - - BitmapEx bitmapEx = mpOutputDevice->GetBitmapEx(aRect.TopLeft(), aRect.GetSize()); - - AlphaMask mask = drawinglayer::primitive2d::ProcessAndBlurAlphaMask(bitmapEx.GetAlpha(), 0, - fBlurRadius, 0, false); - - const basegfx::BColor aShadowColor( - maBColorModifierStack.getModifiedColor(rCandidate.getShadowColor())); - - Bitmap bitmap = bitmapEx.GetBitmap(); - bitmap.Erase(Color(aShadowColor)); - BitmapEx result(bitmap, mask); - - mpOutputDevice = pLastOutputDevice; - mpOutputDevice->DrawBitmapEx(aRect.TopLeft(), result); - } - else - SAL_WARN("drawinglayer", "Temporary buffered virtual device is not visible"); -} - void VclPixelProcessor2D::processFillGradientPrimitive2D( const primitive2d::FillGradientPrimitive2D& rPrimitive) { diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx index 9f1e11cb9110..c144ba9647eb 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx @@ -39,9 +39,6 @@ class PolygonStrokePrimitive2D; class FillHatchPrimitive2D; class BackgroundColorPrimitive2D; class BorderLinePrimitive2D; -class GlowPrimitive2D; -class ShadowPrimitive2D; -class SoftEdgePrimitive2D; class FillGradientPrimitive2D; class PatternFillPrimitive2D; } @@ -97,7 +94,6 @@ class VclPixelProcessor2D final : public VclProcessor2D processBorderLinePrimitive2D(const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder); void processInvertPrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); void processMetaFilePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); - void processShadowPrimitive2D(const primitive2d::ShadowPrimitive2D& rCandidate); void processFillGradientPrimitive2D(const primitive2d::FillGradientPrimitive2D& rPrimitive); void processPatternFillPrimitive2D(const primitive2d::PatternFillPrimitive2D& rPrimitive); |