diff options
23 files changed, 333 insertions, 170 deletions
diff --git a/drawinglayer/Library_drawinglayercore.mk b/drawinglayer/Library_drawinglayercore.mk index 9e089e9a0760..7ec954416a23 100644 --- a/drawinglayer/Library_drawinglayercore.mk +++ b/drawinglayer/Library_drawinglayercore.mk @@ -39,6 +39,10 @@ $(eval $(call gb_Library_use_libraries,drawinglayercore,\ tl \ )) +$(eval $(call gb_Library_use_custom_headers,drawinglayercore,\ + officecfg/registry \ +)) + $(eval $(call gb_Library_add_exception_objects,drawinglayercore,\ drawinglayer/source/primitive2d/baseprimitive2d \ drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D \ diff --git a/drawinglayer/source/geometry/viewinformation2d.cxx b/drawinglayer/source/geometry/viewinformation2d.cxx index 6de309286d9d..d23dda648bed 100644 --- a/drawinglayer/source/geometry/viewinformation2d.cxx +++ b/drawinglayer/source/geometry/viewinformation2d.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/geometry/AffineMatrix2D.hpp> #include <com/sun/star/geometry/RealRectangle2D.hpp> +#include <officecfg/Office/Common.hxx> #include <utility> using namespace com::sun::star; @@ -39,6 +40,15 @@ constexpr OUStringLiteral g_PropertyName_Viewport = u"Viewport"; constexpr OUStringLiteral g_PropertyName_Time = u"Time"; constexpr OUStringLiteral g_PropertyName_VisualizedPage = u"VisualizedPage"; constexpr OUStringLiteral g_PropertyName_ReducedDisplayQuality = u"ReducedDisplayQuality"; +constexpr OUStringLiteral g_PropertyName_UseAntiAliasing = u"UseAntiAliasing"; +constexpr OUStringLiteral g_PropertyName_PixelSnapHairline = u"PixelSnapHairline"; +} + +namespace +{ +bool bForwardsAreInitialized(false); +bool bForwardedAntiAliasing(true); +bool bForwardPixelSnapHairline(true); } class ImpViewInformation2D @@ -74,34 +84,54 @@ protected: // the point in time double mfViewTime; + // allow to reduce DisplayQuality (e.g. sw 3d fallback renderer for interactions) bool mbReducedDisplayQuality : 1; -public: - ImpViewInformation2D(basegfx::B2DHomMatrix aObjectTransformation, - basegfx::B2DHomMatrix aViewTransformation, - const basegfx::B2DRange& rViewport, - uno::Reference<drawing::XDrawPage> xDrawPage, double fViewTime, - bool bReducedDisplayQuality) - : maObjectTransformation(std::move(aObjectTransformation)) - , maViewTransformation(std::move(aViewTransformation)) - , maViewport(rViewport) - , mxVisualizedPage(std::move(xDrawPage)) - , mfViewTime(fViewTime) - , mbReducedDisplayQuality(bReducedDisplayQuality) - { - } + // determine if to use AntiAliasing on target pixel device + bool mbUseAntiAliasing : 1; + // determine if to use PixelSnapHairline on target pixel device + bool mbPixelSnapHairline : 1; + +public: ImpViewInformation2D() - : mfViewTime(0.0) + : maObjectTransformation() + , maViewTransformation() + , maObjectToViewTransformation() + , maInverseObjectToViewTransformation() + , maViewport() + , maDiscreteViewport() + , mxVisualizedPage() + , mfViewTime(0.0) , mbReducedDisplayQuality(false) + , mbUseAntiAliasing(bForwardedAntiAliasing) + , mbPixelSnapHairline(bForwardedAntiAliasing && bForwardPixelSnapHairline) { } const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + void setObjectTransformation(const basegfx::B2DHomMatrix& rNew) + { + maObjectTransformation = rNew; + maObjectToViewTransformation.identity(); + maInverseObjectToViewTransformation.identity(); + } const basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; } + void setViewTransformation(const basegfx::B2DHomMatrix& rNew) + { + maViewTransformation = rNew; + maDiscreteViewport.reset(); + maObjectToViewTransformation.identity(); + maInverseObjectToViewTransformation.identity(); + } const basegfx::B2DRange& getViewport() const { return maViewport; } + void setViewport(const basegfx::B2DRange& rNew) + { + maViewport = rNew; + maDiscreteViewport.reset(); + } const basegfx::B2DRange& getDiscreteViewport() const { @@ -143,10 +173,28 @@ public: } double getViewTime() const { return mfViewTime; } + void setViewTime(double fNew) + { + if (fNew >= 0.0) + { + mfViewTime = fNew; + } + } const uno::Reference<drawing::XDrawPage>& getVisualizedPage() const { return mxVisualizedPage; } + void setVisualizedPage(const uno::Reference<drawing::XDrawPage>& rNew) + { + mxVisualizedPage = rNew; + } bool getReducedDisplayQuality() const { return mbReducedDisplayQuality; } + void setReducedDisplayQuality(bool bNew) { mbReducedDisplayQuality = bNew; } + + bool getUseAntiAliasing() const { return mbUseAntiAliasing; } + void setUseAntiAliasing(bool bNew) { mbUseAntiAliasing = bNew; } + + bool getPixelSnapHairline() const { return mbPixelSnapHairline; } + void setPixelSnapHairline(bool bNew) { mbPixelSnapHairline = bNew; } bool operator==(const ImpViewInformation2D& rCandidate) const { @@ -154,7 +202,10 @@ public: && maViewTransformation == rCandidate.maViewTransformation && maViewport == rCandidate.maViewport && mxVisualizedPage == rCandidate.mxVisualizedPage - && mfViewTime == rCandidate.mfViewTime); + && mfViewTime == rCandidate.mfViewTime + && mbReducedDisplayQuality == rCandidate.mbReducedDisplayQuality + && mbUseAntiAliasing == rCandidate.mbUseAntiAliasing + && mbPixelSnapHairline == rCandidate.mbPixelSnapHairline); } }; @@ -167,20 +218,19 @@ ViewInformation2D::ImplType& theGlobalDefault() } } -ViewInformation2D::ViewInformation2D(const basegfx::B2DHomMatrix& rObjectTransformation, - const basegfx::B2DHomMatrix& rViewTransformation, - const basegfx::B2DRange& rViewport, - const uno::Reference<drawing::XDrawPage>& rxDrawPage, - double fViewTime, bool bReducedDisplayQuality) - : mpViewInformation2D(ImpViewInformation2D(rObjectTransformation, rViewTransformation, - rViewport, rxDrawPage, fViewTime, - bReducedDisplayQuality)) -{ -} - ViewInformation2D::ViewInformation2D() : mpViewInformation2D(theGlobalDefault()) { + if (!bForwardsAreInitialized) + { + bForwardsAreInitialized = true; + bForwardedAntiAliasing = officecfg::Office::Common::Drawinglayer::AntiAliasing::get(); + bForwardPixelSnapHairline + = officecfg::Office::Common::Drawinglayer::SnapHorVerLinesToDiscrete::get(); + } + + setUseAntiAliasing(bForwardedAntiAliasing); + setPixelSnapHairline(bForwardPixelSnapHairline); } ViewInformation2D::ViewInformation2D(const ViewInformation2D&) = default; @@ -203,23 +253,53 @@ const basegfx::B2DHomMatrix& ViewInformation2D::getObjectTransformation() const return mpViewInformation2D->getObjectTransformation(); } +void ViewInformation2D::setObjectTransformation(const basegfx::B2DHomMatrix& rNew) +{ + if (std::as_const(mpViewInformation2D)->getObjectTransformation() != rNew) + mpViewInformation2D->setObjectTransformation(rNew); +} + const basegfx::B2DHomMatrix& ViewInformation2D::getViewTransformation() const { return mpViewInformation2D->getViewTransformation(); } +void ViewInformation2D::setViewTransformation(const basegfx::B2DHomMatrix& rNew) +{ + if (std::as_const(mpViewInformation2D)->getViewTransformation() != rNew) + mpViewInformation2D->setViewTransformation(rNew); +} + const basegfx::B2DRange& ViewInformation2D::getViewport() const { return mpViewInformation2D->getViewport(); } +void ViewInformation2D::setViewport(const basegfx::B2DRange& rNew) +{ + if (rNew != std::as_const(mpViewInformation2D)->getViewport()) + mpViewInformation2D->setViewport(rNew); +} + double ViewInformation2D::getViewTime() const { return mpViewInformation2D->getViewTime(); } +void ViewInformation2D::setViewTime(double fNew) +{ + if (fNew != std::as_const(mpViewInformation2D)->getViewTime()) + mpViewInformation2D->setViewTime(fNew); +} + const uno::Reference<drawing::XDrawPage>& ViewInformation2D::getVisualizedPage() const { return mpViewInformation2D->getVisualizedPage(); } +void ViewInformation2D::setVisualizedPage(const uno::Reference<drawing::XDrawPage>& rNew) +{ + if (rNew != std::as_const(mpViewInformation2D)->getVisualizedPage()) + mpViewInformation2D->setVisualizedPage(rNew); +} + const basegfx::B2DHomMatrix& ViewInformation2D::getObjectToViewTransformation() const { return mpViewInformation2D->getObjectToViewTransformation(); @@ -240,55 +320,112 @@ bool ViewInformation2D::getReducedDisplayQuality() const return mpViewInformation2D->getReducedDisplayQuality(); } +void ViewInformation2D::setReducedDisplayQuality(bool bNew) +{ + if (bNew != std::as_const(mpViewInformation2D)->getReducedDisplayQuality()) + mpViewInformation2D->setReducedDisplayQuality(bNew); +} + +bool ViewInformation2D::getUseAntiAliasing() const +{ + return mpViewInformation2D->getUseAntiAliasing(); +} + +void ViewInformation2D::setUseAntiAliasing(bool bNew) +{ + if (bNew != std::as_const(mpViewInformation2D)->getUseAntiAliasing()) + mpViewInformation2D->setUseAntiAliasing(bNew); +} + +bool ViewInformation2D::getPixelSnapHairline() const +{ + return mpViewInformation2D->getPixelSnapHairline(); +} + +void ViewInformation2D::setPixelSnapHairline(bool bNew) +{ + if (bNew != std::as_const(mpViewInformation2D)->getPixelSnapHairline()) + mpViewInformation2D->setPixelSnapHairline(bNew); +} + +void ViewInformation2D::forwardAntiAliasing(bool bAntiAliasing) +{ + bForwardedAntiAliasing = bAntiAliasing; +} + +void ViewInformation2D::forwardPixelSnapHairline(bool bPixelSnapHairline) +{ + bForwardPixelSnapHairline = bPixelSnapHairline; +} + ViewInformation2D createViewInformation2D(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters) { if (!rViewParameters.hasElements()) return ViewInformation2D(); - bool bReducedDisplayQuality = false; - basegfx::B2DHomMatrix aObjectTransformation; - basegfx::B2DHomMatrix aViewTransformation; - basegfx::B2DRange aViewport; - double fViewTime = 0.0; - uno::Reference<drawing::XDrawPage> xVisualizedPage; + ViewInformation2D aRetval; for (auto const& rPropertyValue : rViewParameters) { if (rPropertyValue.Name == g_PropertyName_ReducedDisplayQuality) { - rPropertyValue.Value >>= bReducedDisplayQuality; + bool bNew(false); + rPropertyValue.Value >>= bNew; + aRetval.setReducedDisplayQuality(bNew); + } + else if (rPropertyValue.Name == g_PropertyName_PixelSnapHairline) + { + bool bNew( + true); //SvtOptionsDrawinglayer::IsAntiAliasing() && SvtOptionsDrawinglayer::IsSnapHorVerLinesToDiscrete()); + rPropertyValue.Value >>= bNew; + aRetval.setPixelSnapHairline(bNew); + } + else if (rPropertyValue.Name == g_PropertyName_UseAntiAliasing) + { + bool bNew(true); //SvtOptionsDrawinglayer::IsAntiAliasing()); + rPropertyValue.Value >>= bNew; + aRetval.setUseAntiAliasing(bNew); } else if (rPropertyValue.Name == g_PropertyName_ObjectTransformation) { css::geometry::AffineMatrix2D aAffineMatrix2D; rPropertyValue.Value >>= aAffineMatrix2D; - basegfx::unotools::homMatrixFromAffineMatrix(aObjectTransformation, aAffineMatrix2D); + basegfx::B2DHomMatrix aTransformation; + basegfx::unotools::homMatrixFromAffineMatrix(aTransformation, aAffineMatrix2D); + aRetval.setObjectTransformation(aTransformation); } else if (rPropertyValue.Name == g_PropertyName_ViewTransformation) { css::geometry::AffineMatrix2D aAffineMatrix2D; rPropertyValue.Value >>= aAffineMatrix2D; - basegfx::unotools::homMatrixFromAffineMatrix(aViewTransformation, aAffineMatrix2D); + basegfx::B2DHomMatrix aTransformation; + basegfx::unotools::homMatrixFromAffineMatrix(aTransformation, aAffineMatrix2D); + aRetval.setViewTransformation(aTransformation); } else if (rPropertyValue.Name == g_PropertyName_Viewport) { css::geometry::RealRectangle2D aUnoViewport; rPropertyValue.Value >>= aUnoViewport; - aViewport = basegfx::unotools::b2DRectangleFromRealRectangle2D(aUnoViewport); + const basegfx::B2DRange aViewport( + basegfx::unotools::b2DRectangleFromRealRectangle2D(aUnoViewport)); + aRetval.setViewport(aViewport); } else if (rPropertyValue.Name == g_PropertyName_Time) { + double fViewTime(0.0); rPropertyValue.Value >>= fViewTime; + aRetval.setViewTime(fViewTime); } else if (rPropertyValue.Name == g_PropertyName_VisualizedPage) { + css::uno::Reference<css::drawing::XDrawPage> xVisualizedPage; rPropertyValue.Value >>= xVisualizedPage; + aRetval.setVisualizedPage(xVisualizedPage); } } - return ViewInformation2D(aObjectTransformation, aViewTransformation, aViewport, xVisualizedPage, - fViewTime, bReducedDisplayQuality); + return aRetval; } } // end of namespace drawinglayer::geometry diff --git a/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx b/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx index 0a3249399a44..3c45fdd030f4 100644 --- a/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx +++ b/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx @@ -79,14 +79,11 @@ drawinglayer::geometry::ViewInformation2D expandB2DRangeAtViewInformation2D(const drawinglayer::geometry::ViewInformation2D& rViewInfo, double nAmount) { + drawinglayer::geometry::ViewInformation2D aRetval(rViewInfo); basegfx::B2DRange viewport(rViewInfo.getViewport()); viewport.grow(nAmount); - return { rViewInfo.getObjectTransformation(), - rViewInfo.getViewTransformation(), - viewport, - rViewInfo.getVisualizedPage(), - rViewInfo.getViewTime(), - rViewInfo.getReducedDisplayQuality() }; + aRetval.setViewport(viewport); + return aRetval; } } // end of namespace drawinglayer::primitive2d diff --git a/drawinglayer/source/processor2d/contourextractor2d.cxx b/drawinglayer/source/processor2d/contourextractor2d.cxx index a1d1200183cc..65e8ef86a29e 100644 --- a/drawinglayer/source/processor2d/contourextractor2d.cxx +++ b/drawinglayer/source/processor2d/contourextractor2d.cxx @@ -123,12 +123,8 @@ namespace drawinglayer::processor2d const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); // create new local ViewInformation2D - const geometry::ViewInformation2D aViewInformation2D( - getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(), - getViewInformation2D().getViewTransformation(), - getViewInformation2D().getViewport(), - getViewInformation2D().getVisualizedPage(), - getViewInformation2D().getViewTime()); + geometry::ViewInformation2D aViewInformation2D(getViewInformation2D()); + aViewInformation2D.setObjectTransformation(getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation()); updateViewInformation(aViewInformation2D); // process content diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx index dc7d6fa7cb3f..1ebc8d541619 100644 --- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx +++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx @@ -233,12 +233,8 @@ namespace drawinglayer::processor2d const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); // create new local ViewInformation2D containing transformation - const geometry::ViewInformation2D aViewInformation2D( - getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(), - getViewInformation2D().getViewTransformation(), - getViewInformation2D().getViewport(), - getViewInformation2D().getVisualizedPage(), - getViewInformation2D().getViewTime()); + geometry::ViewInformation2D aViewInformation2D(getViewInformation2D()); + aViewInformation2D.setObjectTransformation(getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation()); updateViewInformation(aViewInformation2D); // process child content recursively diff --git a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx index 08ec1232d137..11af79725b41 100644 --- a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx +++ b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx @@ -84,12 +84,8 @@ namespace drawinglayer::processor2d const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); // create new transformations for CurrentTransformation and for local ViewInformation2D - const geometry::ViewInformation2D aViewInformation2D( - getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(), - getViewInformation2D().getViewTransformation(), - getViewInformation2D().getViewport(), - getViewInformation2D().getVisualizedPage(), - getViewInformation2D().getViewTime()); + geometry::ViewInformation2D aViewInformation2D(getViewInformation2D()); + aViewInformation2D.setObjectTransformation(getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation()); updateViewInformation(aViewInformation2D); // process content diff --git a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx index fcf15b189ed2..c98fae69d301 100644 --- a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx +++ b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx @@ -177,12 +177,8 @@ namespace drawinglayer::processor2d const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); // create new transformations for CurrentTransformation and for local ViewInformation2D - const geometry::ViewInformation2D aViewInformation2D( - getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(), - getViewInformation2D().getViewTransformation(), - getViewInformation2D().getViewport(), - getViewInformation2D().getVisualizedPage(), - getViewInformation2D().getViewTime()); + geometry::ViewInformation2D aViewInformation2D(getViewInformation2D()); + aViewInformation2D.setObjectTransformation(getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation()); updateViewInformation(aViewInformation2D); // process content diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index a231e20153ef..539e01282a2f 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -2321,9 +2321,9 @@ void VclMetafileProcessor2D::processTransparencePrimitive2D( // create view information and pixel renderer. Reuse known ViewInformation // except new transformation and range - const geometry::ViewInformation2D aViewInfo( - getViewInformation2D().getObjectTransformation(), aViewTransform, aViewRange, - getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime()); + geometry::ViewInformation2D aViewInfo(getViewInformation2D()); + aViewInfo.setViewTransformation(aViewTransform); + aViewInfo.setViewport(aViewRange); VclPixelProcessor2D aBufferProcessor(aViewInfo, *aBufferDevice); diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 564b113d8f86..f701ad9bbeeb 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -83,7 +83,7 @@ VclPixelProcessor2D::VclPixelProcessor2D(const geometry::ViewInformation2D& rVie mpOutputDevice->SetMapMode(); // react on AntiAliasing settings - if (SvtOptionsDrawinglayer::IsAntiAliasing()) + if (rViewInformation.getUseAntiAliasing()) { mpOutputDevice->SetAntialiasing(m_nOrigAntiAliasing | AntialiasingFlags::Enable); } @@ -543,7 +543,7 @@ void VclPixelProcessor2D::processPolyPolygonColorPrimitive2D( // when AA is on and this filled polygons are the result of stroked line geometry, // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons // Caution: This is needed in both cases (!) - if (!(mnPolygonStrokePrimitive2D && SvtOptionsDrawinglayer::IsAntiAliasing() + if (!(mnPolygonStrokePrimitive2D && getViewInformation2D().getUseAntiAliasing() && (mpOutputDevice->GetAntialiasing() & AntialiasingFlags::Enable))) return; @@ -758,7 +758,7 @@ void VclPixelProcessor2D::processPolygonStrokePrimitive2D( void VclPixelProcessor2D::processFillHatchPrimitive2D( const primitive2d::FillHatchPrimitive2D& rFillHatchPrimitive) { - if (SvtOptionsDrawinglayer::IsAntiAliasing()) + if (getViewInformation2D().getUseAntiAliasing()) { // if AA is used (or ignore smoothing is on), there is no need to smooth // hatch painting, use decomposition @@ -925,8 +925,7 @@ void VclPixelProcessor2D::processInvertPrimitive2D(const primitive2d::BasePrimit void VclPixelProcessor2D::processMetaFilePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { // #i98289# - const bool bForceLineSnap(SvtOptionsDrawinglayer::IsAntiAliasing() - && SvtOptionsDrawinglayer::IsSnapHorVerLinesToDiscrete()); + const bool bForceLineSnap(getViewInformation2D().getPixelSnapHairline()); const AntialiasingFlags nOldAntiAliase(mpOutputDevice->GetAntialiasing()); if (bForceLineSnap) @@ -1045,7 +1044,7 @@ void VclPixelProcessor2D::processPatternFillPrimitive2D( tools::Rectangle aMaskRect = vcl::unotools::rectangleFromB2DRectangle(aMaskRange); // Unless smooth edges are needed, simply use clipping. - if (basegfx::utils::isRectangle(aMask) || !SvtOptionsDrawinglayer::IsAntiAliasing()) + if (basegfx::utils::isRectangle(aMask) || !getViewInformation2D().getUseAntiAliasing()) { mpOutputDevice->Push(vcl::PushFlags::CLIPREGION); mpOutputDevice->IntersectClipRegion(vcl::Region(aMask)); diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index a8874453bd4f..77c35caa1e27 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -407,8 +407,7 @@ void VclProcessor2D::RenderPolygonHairlinePrimitive2D( basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon()); aLocalPolygon.transform(maCurrentTransformation); - if (bPixelBased && SvtOptionsDrawinglayer::IsAntiAliasing() - && SvtOptionsDrawinglayer::IsSnapHorVerLinesToDiscrete()) + if (bPixelBased && getViewInformation2D().getPixelSnapHairline()) { // #i98289# // when a Hairline is painted and AntiAliasing is on the option SnapHorVerLinesToDiscrete @@ -818,7 +817,7 @@ void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive aMask.transform(maCurrentTransformation); // Unless smooth edges are needed, simply use clipping. - if (isRectangles(aMask) || !SvtOptionsDrawinglayer::IsAntiAliasing()) + if (isRectangles(aMask) || !getViewInformation2D().getUseAntiAliasing()) { mpOutputDevice->Push(vcl::PushFlags::CLIPREGION); mpOutputDevice->IntersectClipRegion(vcl::Region(aMask)); @@ -954,10 +953,9 @@ void VclProcessor2D::RenderTransformPrimitive2D( // create new transformations for CurrentTransformation // and for local ViewInformation2D maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation(); - const geometry::ViewInformation2D aViewInformation2D( - getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(), - getViewInformation2D().getViewTransformation(), getViewInformation2D().getViewport(), - getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime()); + geometry::ViewInformation2D aViewInformation2D(getViewInformation2D()); + aViewInformation2D.setObjectTransformation(getViewInformation2D().getObjectTransformation() + * rTransformCandidate.getTransformation()); updateViewInformation(aViewInformation2D); // process content @@ -976,10 +974,8 @@ void VclProcessor2D::RenderPagePreviewPrimitive2D( const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); // create new local ViewInformation2D - const geometry::ViewInformation2D aViewInformation2D( - getViewInformation2D().getObjectTransformation(), - getViewInformation2D().getViewTransformation(), getViewInformation2D().getViewport(), - rPagePreviewCandidate.getXDrawPage(), getViewInformation2D().getViewTime()); + geometry::ViewInformation2D aViewInformation2D(getViewInformation2D()); + aViewInformation2D.setVisualizedPage(rPagePreviewCandidate.getXDrawPage()); updateViewInformation(aViewInformation2D); // process decomposed content @@ -1093,7 +1089,7 @@ void VclProcessor2D::RenderPolygonStrokePrimitive2D( if (nCount) { - const bool bAntiAliased(SvtOptionsDrawinglayer::IsAntiAliasing()); + const bool bAntiAliased(getViewInformation2D().getUseAntiAliasing()); aHairlinePolyPolygon.transform(maCurrentTransformation); if (bAntiAliased) diff --git a/include/drawinglayer/geometry/viewinformation2d.hxx b/include/drawinglayer/geometry/viewinformation2d.hxx index 2957b7daf709..e71ab08faead 100644 --- a/include/drawinglayer/geometry/viewinformation2d.hxx +++ b/include/drawinglayer/geometry/viewinformation2d.hxx @@ -91,14 +91,18 @@ public: The time the view is defined for. Default is 0.0. This parameter is used e.g. for animated objects - @param rReducedDisplayQuality - */ - ViewInformation2D(const basegfx::B2DHomMatrix& rObjectTransformation, - const basegfx::B2DHomMatrix& rViewTransformation, - const basegfx::B2DRange& rViewport, - const css::uno::Reference<css::drawing::XDrawPage>& rxDrawPage, - double fViewTime, bool bReducedDisplayQuality = false); + @param bReducedDisplayQuality + Support reduced DisplayQuality, PropertyName is 'ReducedDisplayQuality'. This + is used e.g. to allow to lower display quality for OverlayPrimitives and + may lead to simpler decompositions in the local create2DDecomposition + implementations of the primitives + @param bUseAntiAliasing + Determine if to use AntiAliasing on target pixel device + + @param bPixelSnapHairline + Determine if to use PixelSnapHairline on target pixel device + */ /// default (empty) constructor ViewInformation2D(); @@ -120,11 +124,20 @@ public: /// data access const basegfx::B2DHomMatrix& getObjectTransformation() const; + void setObjectTransformation(const basegfx::B2DHomMatrix& rNew); + const basegfx::B2DHomMatrix& getViewTransformation() const; + void setViewTransformation(const basegfx::B2DHomMatrix& rNew); + /// Empty viewport means everything is visible. const basegfx::B2DRange& getViewport() const; + void setViewport(const basegfx::B2DRange& rNew); + double getViewTime() const; + void setViewTime(double fNew); + const css::uno::Reference<css::drawing::XDrawPage>& getVisualizedPage() const; + void setVisualizedPage(const css::uno::Reference<css::drawing::XDrawPage>& rNew); /// On-demand prepared Object to View transformation and its inverse for convenience const basegfx::B2DHomMatrix& getObjectToViewTransformation() const; @@ -134,12 +147,20 @@ public: /// Empty viewport means everything is visible. const basegfx::B2DRange& getDiscreteViewport() const; - /** support reduced DisplayQuality, PropertyName is 'ReducedDisplayQuality'. This - is used e.g. to allow to lower display quality for OverlayPrimitives and - may lead to simpler decompositions in the local create2DDecomposition - implementations of the primitives - */ + /// Support reduced DisplayQuality, PropertyName is 'ReducedDisplayQuality'. bool getReducedDisplayQuality() const; + void setReducedDisplayQuality(bool bNew); + + /// Determine if to use AntiAliasing on target pixel device, PropertyName is 'UseAntiAliasing' + bool getUseAntiAliasing() const; + void setUseAntiAliasing(bool bNew); + + /// Determine if to use PixelSnapHairline on target pixel device, PropertyName is 'PixelSnapHairline' + bool getPixelSnapHairline() const; + void setPixelSnapHairline(bool bNew); + + static void forwardAntiAliasing(bool bAntiAliasing); + static void forwardPixelSnapHairline(bool bPixelSnapHairline); }; DRAWINGLAYERCORE_DLLPUBLIC ViewInformation2D diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 77bc4810f4a6..664eca6cb999 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -1716,12 +1716,10 @@ std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> ScOutputData::Create basegfx::B2DRange aViewRange; SdrPage *pDrawPage = pDrawLayer->GetPage( static_cast< sal_uInt16 >( nTab ) ); - const drawinglayer::geometry::ViewInformation2D aNewViewInfos( - basegfx::B2DHomMatrix( ), - mpDev->GetViewTransformation(), - aViewRange, - GetXDrawPageForSdrPage( pDrawPage ), - 0.0); + drawinglayer::geometry::ViewInformation2D aNewViewInfos; + aNewViewInfos.setViewTransformation(mpDev->GetViewTransformation()); + aNewViewInfos.setViewport(aViewRange); + aNewViewInfos.setVisualizedPage(GetXDrawPageForSdrPage( pDrawPage )); return drawinglayer::processor2d::createProcessor2DFromOutputDevice( *mpDev, aNewViewInfos ); diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index a2bc1aad7ccf..ec2405d65636 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -44,6 +44,7 @@ $(eval $(call gb_Library_use_libraries,svt,\ comphelper \ cppu \ cppuhelper \ + drawinglayercore \ i18nlangtag \ i18nutil \ $(if $(ENABLE_JAVA), \ diff --git a/svtools/source/config/optionsdrawinglayer.cxx b/svtools/source/config/optionsdrawinglayer.cxx index 54efe4a66326..2fee81139800 100644 --- a/svtools/source/config/optionsdrawinglayer.cxx +++ b/svtools/source/config/optionsdrawinglayer.cxx @@ -22,6 +22,7 @@ #include <vcl/outdev.hxx> #include <vcl/settings.hxx> #include <officecfg/Office/Common.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> #include <mutex> // #i73602# @@ -124,6 +125,12 @@ static bool gbAntiAliasing = false; static bool gbAllowAAInit = false; static bool gbAllowAA = false; +static bool gbAntiAliasingForwardInitial(false); +static bool gbAntiAliasingForwardLast(true); + +static bool gbPixelSnapHairlineForwardInitial(false); +static bool gbPixelSnapHairlineForwardLast(true); + bool IsAAPossibleOnThisSystem() { std::scoped_lock aGuard(gaAntiAliasMutex); @@ -148,7 +155,18 @@ bool IsAntiAliasing() } bAntiAliasing = gbAntiAliasing; } - return bAntiAliasing && IsAAPossibleOnThisSystem(); + + bAntiAliasing = bAntiAliasing && IsAAPossibleOnThisSystem(); + + // + if (!gbAntiAliasingForwardInitial || gbAntiAliasingForwardLast != bAntiAliasing) + { + gbAntiAliasingForwardInitial = true; + gbAntiAliasingForwardLast = bAntiAliasing; + drawinglayer::geometry::ViewInformation2D::forwardAntiAliasing(bAntiAliasing); + } + + return bAntiAliasing; } /** @@ -165,6 +183,13 @@ void SetAntiAliasing( bool bOn, bool bTemporary ) comphelper::ConfigurationChanges::create(); officecfg::Office::Common::Drawinglayer::AntiAliasing::set(bOn, batch); batch->commit(); + + if(!gbAntiAliasingForwardInitial || gbAntiAliasingForwardLast != bOn) + { + gbAntiAliasingForwardInitial = true; + gbAntiAliasingForwardLast = bOn; + drawinglayer::geometry::ViewInformation2D::forwardAntiAliasing(bOn); + } } gbAntiAliasing = bOn; } @@ -172,7 +197,16 @@ void SetAntiAliasing( bool bOn, bool bTemporary ) bool IsSnapHorVerLinesToDiscrete() { - return IsAntiAliasing() && officecfg::Office::Common::Drawinglayer::SnapHorVerLinesToDiscrete::get(); + const bool bRetval(IsAntiAliasing() && officecfg::Office::Common::Drawinglayer::SnapHorVerLinesToDiscrete::get()); + + if (!gbPixelSnapHairlineForwardInitial || gbPixelSnapHairlineForwardLast != bRetval) + { + gbPixelSnapHairlineForwardInitial = true; + gbPixelSnapHairlineForwardLast = bRetval; + drawinglayer::geometry::ViewInformation2D::forwardPixelSnapHairline(bRetval); + } + + return bRetval; } bool IsSolidDragCreate() diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx index a55f6a2577cb..fe44562ff230 100644 --- a/svx/source/dialog/pagectrl.cxx +++ b/svx/source/dialog/pagectrl.cxx @@ -352,8 +352,9 @@ void SvxPageWindow::drawFillAttributes(vcl::RenderContext& rRenderContext, if (aSequence.empty()) return; - const drawinglayer::geometry::ViewInformation2D aViewInformation2D( - basegfx::B2DHomMatrix(), rRenderContext.GetViewTransformation(), aPaintRange, nullptr, 0.0); + drawinglayer::geometry::ViewInformation2D aViewInformation2D; + aViewInformation2D.setViewTransformation(rRenderContext.GetViewTransformation()); + aViewInformation2D.setViewport(aPaintRange); std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor( drawinglayer::processor2d::createProcessor2DFromOutputDevice(rRenderContext, aViewInformation2D)); diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx index 3cfd53d707bb..a87168708ddb 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -231,9 +231,9 @@ void WeldEditView::DoPaint(vcl::RenderContext& rRenderContext, const tools::Rect sdr::overlay::OverlaySelection aCursorOverlay(sdr::overlay::OverlayType::Transparent, aHighlight, std::move(aLogicRanges), true); - const drawinglayer::geometry::ViewInformation2D aViewInformation2D( - basegfx::B2DHomMatrix(), rRenderContext.GetViewTransformation(), - vcl::unotools::b2DRectangleFromRectangle(rRect), nullptr, 0.0); + drawinglayer::geometry::ViewInformation2D aViewInformation2D; + aViewInformation2D.setViewTransformation(rRenderContext.GetViewTransformation()); + aViewInformation2D.setViewport(vcl::unotools::b2DRectangleFromRectangle(rRect)); std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> xProcessor( drawinglayer::processor2d::createProcessor2DFromOutputDevice(rRenderContext, diff --git a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx index ff65e60fcf7c..cef1cbc1f289 100644 --- a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx +++ b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx @@ -96,12 +96,10 @@ void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo) } // update local ViewInformation2D - const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D( - basegfx::B2DHomMatrix(), - pTargetDevice->GetViewTransformation(), - aViewRange, - GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)), - 0.0); + drawinglayer::geometry::ViewInformation2D aNewViewInformation2D; + aNewViewInformation2D.setViewTransformation(pTargetDevice->GetViewTransformation()); + aNewViewInformation2D.setViewport(aViewRange); + aNewViewInformation2D.setVisualizedPage(GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage))); updateViewInformation2D(aNewViewInformation2D); // collect primitive data in a sequence; this will already use the updated ViewInformation2D diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx index fd8cf5b4a1ca..9d0918a5d22a 100644 --- a/svx/source/sdr/contact/objectcontactofpageview.cxx +++ b/svx/source/sdr/contact/objectcontactofpageview.cxx @@ -208,12 +208,11 @@ namespace sdr::contact } // update local ViewInformation2D - const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D( - basegfx::B2DHomMatrix(), - rTargetOutDev.GetViewTransformation(), - aViewRange, - GetXDrawPageForSdrPage(GetSdrPage()), - fCurrentTime); + drawinglayer::geometry::ViewInformation2D aNewViewInformation2D; + aNewViewInformation2D.setViewTransformation(rTargetOutDev.GetViewTransformation()); + aNewViewInformation2D.setViewport(aViewRange); + aNewViewInformation2D.setVisualizedPage(GetXDrawPageForSdrPage(GetSdrPage())); + aNewViewInformation2D.setViewTime(fCurrentTime); updateViewInformation2D(aNewViewInformation2D); // if there is something to show, use a primitive processor to render it. There diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx index d838a13c6eca..fb60e6b55965 100644 --- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx @@ -124,20 +124,21 @@ drawinglayer::primitive2d::Primitive2DContainer PagePrimitiveExtractor::createPr { // update own ViewInformation2D for visualized page const drawinglayer::geometry::ViewInformation2D& rOriginalViewInformation = mrViewObjectContactOfPageObj.GetObjectContact().getViewInformation2D(); - const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D( - rOriginalViewInformation.getObjectTransformation(), - rOriginalViewInformation.getViewTransformation(), - - // #i101075# use empty range for page content here to force - // the content not to be physically clipped in any way. This - // would be possible, but would require the internal transformation - // which maps between the page visualisation object and the page - // content, including the aspect ratios (for details see in - // PagePreviewPrimitive2D::create2DDecomposition) - basegfx::B2DRange(), - - GetXDrawPageForSdrPage(pStartPage), - 0.0); // no time; page previews are not animated + drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(rOriginalViewInformation); + + // #i101075# use empty range for page content here to force + // the content not to be physically clipped in any way. This + // would be possible, but would require the internal transformation + // which maps between the page visualisation object and the page + // content, including the aspect ratios (for details see in + // PagePreviewPrimitive2D::create2DDecomposition) + aNewViewInformation2D.setViewport(basegfx::B2DRange()); + + aNewViewInformation2D.setVisualizedPage(GetXDrawPageForSdrPage(pStartPage)); + + // no time; page previews are not animated + aNewViewInformation2D.setViewTime(0.0); + updateViewInformation2D(aNewViewInformation2D); // create copy of DisplayInfo to set PagePainting diff --git a/svx/source/sdr/overlay/overlaymanager.cxx b/svx/source/sdr/overlay/overlaymanager.cxx index c29138de8b87..21d3a5458cfa 100644 --- a/svx/source/sdr/overlay/overlaymanager.cxx +++ b/svx/source/sdr/overlay/overlaymanager.cxx @@ -46,7 +46,7 @@ namespace sdr::overlay return; const AntialiasingFlags nOriginalAA(rDestinationDevice.GetAntialiasing()); - const bool bIsAntiAliasing(SvtOptionsDrawinglayer::IsAntiAliasing()); + const bool bIsAntiAliasing(getCurrentViewInformation2D().getUseAntiAliasing()); // tdf#150622 for High Contrast we typically force colors to a single pair Fore/Back, // but it seems reasonable to allow overlays to use the selection color // taken from the system High Contrast settings @@ -137,8 +137,8 @@ namespace sdr::overlay mnStripeLengthPixel(5), mfDiscreteOne(0.0) { - // set Property 'ReducedDisplayQuality' to true to allow simpler interaction - // visualisations + // Set Property 'ReducedDisplayQuality' to true to allow simpler interaction + // visualisations. Note: Currently will use reduced quality for 3d scene soft renderer uno::Sequence< beans::PropertyValue > xProperties{ comphelper::makePropertyValue("ReducedDisplayQuality", true) }; @@ -172,12 +172,11 @@ namespace sdr::overlay OverlayManager* pThis = const_cast< OverlayManager* >(this); pThis->maViewTransformation = getOutputDevice().GetViewTransformation(); - pThis->maViewInformation2D = drawinglayer::geometry::ViewInformation2D( - maViewInformation2D.getObjectTransformation(), - maViewTransformation, - aViewRange, - maViewInformation2D.getVisualizedPage(), - maViewInformation2D.getViewTime()); + drawinglayer::geometry::ViewInformation2D aViewInformation(maViewInformation2D); + aViewInformation.setViewTransformation(maViewTransformation); + aViewInformation.setViewport(aViewRange); + pThis->maViewInformation2D = aViewInformation; + pThis->mfDiscreteOne = 0.0; } @@ -296,7 +295,7 @@ namespace sdr::overlay if (rRange.isEmpty()) { return {}; } - if (SvtOptionsDrawinglayer::IsAntiAliasing()) + if (getCurrentViewInformation2D().getUseAntiAliasing()) { // assume AA needs one pixel more and invalidate one pixel more const double fDiscreteOne(getDiscreteOne()); diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx index 19babd089e54..365171757934 100644 --- a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx +++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx @@ -412,7 +412,7 @@ namespace sdr::overlay basegfx::B2DRange aDiscreteRange(rRange); aDiscreteRange.transform(getOutputDevice().GetViewTransformation()); - if(SvtOptionsDrawinglayer::IsAntiAliasing()) + if(getCurrentViewInformation2D().getUseAntiAliasing()) { // assume AA needs one pixel more and invalidate one pixel more const double fDiscreteOne(getDiscreteOne()); diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 7436d235485b..b0e0a92e6aac 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -888,12 +888,10 @@ static bool paintUsingPrimitivesHelper( // embed the primitives to it. Use original TargetRange here so there is also // no need to embed the primitives to a MaskPrimitive for cropping. This works // only in this case where the graphic object cannot be rotated, though. - const drawinglayer::geometry::ViewInformation2D aViewInformation2D( - aMappingTransform, - rOutputDevice.GetViewTransformation(), - rTargetRange, - nullptr, - 0.0); + drawinglayer::geometry::ViewInformation2D aViewInformation2D; + aViewInformation2D.setObjectTransformation(aMappingTransform); + aViewInformation2D.setViewTransformation(rOutputDevice.GetViewTransformation()); + aViewInformation2D.setViewport(rTargetRange); // get a primitive processor for rendering std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D( diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index b42fc48acb37..5127624df73c 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1795,12 +1795,10 @@ bool DrawFillAttributes( } assert(pPrimitives && pPrimitives->size()); - const drawinglayer::geometry::ViewInformation2D aViewInformation2D( - basegfx::B2DHomMatrix(), - rOut.GetViewTransformation(), - aPaintRange, - nullptr, - 0.0); + drawinglayer::geometry::ViewInformation2D aViewInformation2D; + aViewInformation2D.setViewTransformation(rOut.GetViewTransformation()); + aViewInformation2D.setViewport(aPaintRange); + std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(drawinglayer::processor2d::createProcessor2DFromOutputDevice( rOut, aViewInformation2D) ); @@ -5187,12 +5185,10 @@ std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> SwFrame::CreateProce basegfx::B2DRange aViewRange; SdrPage *pDrawPage = getRootFrame()->GetCurrShell()->Imp()->GetPageView()->GetPage(); - const drawinglayer::geometry::ViewInformation2D aNewViewInfos( - basegfx::B2DHomMatrix( ), - getRootFrame()->GetCurrShell()->GetOut()->GetViewTransformation(), - aViewRange, - GetXDrawPageForSdrPage( pDrawPage ), - 0.0); + drawinglayer::geometry::ViewInformation2D aNewViewInfos; + aNewViewInfos.setViewTransformation(getRootFrame()->GetCurrShell()->GetOut()->GetViewTransformation()); + aNewViewInfos.setViewport(aViewRange); + aNewViewInfos.setVisualizedPage(GetXDrawPageForSdrPage( pDrawPage )); return drawinglayer::processor2d::createProcessor2DFromOutputDevice( *getRootFrame()->GetCurrShell()->GetOut(), |