drawinglayer/source/primitive2d/Tools.cxx | 28 - drawinglayer/source/primitive3d/baseprimitive3d.cxx | 25 drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx | 333 +++++------- drawinglayer/source/processor2d/baseprocessor2d.cxx | 16 drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 106 +-- drawinglayer/source/processor2d/vclprocessor2d.cxx | 6 drawinglayer/source/processor3d/baseprocessor3d.cxx | 15 drawinglayer/source/tools/primitive2dxmldump.cxx | 4 filter/source/svg/svgfilter.cxx | 6 svx/source/sdr/animation/animationstate.cxx | 26 svx/source/svdraw/svdview.cxx | 8 11 files changed, 248 insertions(+), 325 deletions(-)
New commits: commit fa01f5a1feeb93a88a330daeec8177a39916e6a3 Author: Noel Grandin <n...@peralex.com> AuthorDate: Fri Aug 13 09:05:04 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 13 12:49:00 2021 +0200 tdf#105575 Slow rendering when using a Logo command Remove dynamic_cast'ing to Primitive2D, expensive and unnecessary <quikee[m]> noelgrandin: nobody is using XPrimtive that is not derived from BasePrimitive2D in an extension ... mainly as it is not even possible Change-Id: I68224021f0fbc35fe2a973198ba78d2b41ea172d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120417 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/drawinglayer/source/primitive2d/Tools.cxx b/drawinglayer/source/primitive2d/Tools.cxx index a6321cac1a89..45b2a993b3a7 100644 --- a/drawinglayer/source/primitive2d/Tools.cxx +++ b/drawinglayer/source/primitive2d/Tools.cxx @@ -36,22 +36,9 @@ getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate, if (rCandidate.is()) { - // try to get C++ implementation base - const BasePrimitive2D* pCandidate(dynamic_cast<BasePrimitive2D*>(rCandidate.get())); - - if (pCandidate) - { - // use it if possible - aRetval.expand(pCandidate->getB2DRange(aViewInformation)); - } - else - { - // use UNO API call instead - auto aViewParameters = geometry::createPropertyValues(aViewInformation); - - aRetval.expand(basegfx::unotools::b2DRectangleFromRealRectangle2D( - rCandidate->getRange(aViewParameters))); - } + // get C++ implementation base + const BasePrimitive2D* pCandidate(static_cast<BasePrimitive2D*>(rCandidate.get())); + aRetval.expand(pCandidate->getB2DRange(aViewInformation)); } return aRetval; @@ -71,13 +58,8 @@ bool arePrimitive2DReferencesEqual(const Primitive2DReference& rxA, const Primit return true; } - const BasePrimitive2D* pA(dynamic_cast<const BasePrimitive2D*>(rxA.get())); - const BasePrimitive2D* pB(dynamic_cast<const BasePrimitive2D*>(rxB.get())); - - if (!pA || !pB) - { - return false; - } + const BasePrimitive2D* pA(static_cast<const BasePrimitive2D*>(rxA.get())); + const BasePrimitive2D* pB(static_cast<const BasePrimitive2D*>(rxB.get())); return pA->operator==(*pB); } diff --git a/drawinglayer/source/primitive3d/baseprimitive3d.cxx b/drawinglayer/source/primitive3d/baseprimitive3d.cxx index 4a69c7cc0a73..796f37888e8e 100644 --- a/drawinglayer/source/primitive3d/baseprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/baseprimitive3d.cxx @@ -98,20 +98,8 @@ namespace drawinglayer::primitive3d if(rCandidate.is()) { - // try to get C++ implementation base - const BasePrimitive3D* pCandidate(dynamic_cast< BasePrimitive3D* >(rCandidate.get())); - - if(pCandidate) - { - // use it if possible - aRetval.expand(pCandidate->getB3DRange(aViewInformation)); - } - else - { - // use UNO API call instead - const uno::Sequence< beans::PropertyValue >& rViewParameters(aViewInformation.getViewInformationSequence()); - aRetval.expand(basegfx::unotools::b3DRectangleFromRealRectangle3D(rCandidate->getRange(rViewParameters))); - } + const BasePrimitive3D* pCandidate(static_cast< BasePrimitive3D* >(rCandidate.get())); + aRetval.expand(pCandidate->getB3DRange(aViewInformation)); } return aRetval; @@ -149,13 +137,8 @@ namespace drawinglayer::primitive3d return true; } - const BasePrimitive3D* pA(dynamic_cast< const BasePrimitive3D* >(rxA.get())); - const BasePrimitive3D* pB(dynamic_cast< const BasePrimitive3D* >(rxB.get())); - - if(!pA || !pB) - { - return false; - } + const BasePrimitive3D* pA(static_cast< const BasePrimitive3D* >(rxA.get())); + const BasePrimitive3D* pB(static_cast< const BasePrimitive3D* >(rxB.get())); return pA->operator==(*pB); } diff --git a/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx index 2ea280b68be1..a6a63edf4789 100644 --- a/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx @@ -53,211 +53,202 @@ namespace drawinglayer::primitive3d if(xReference.is()) { - // try to cast to BasePrimitive2D implementation - const BasePrimitive3D* pBasePrimitive = dynamic_cast< const BasePrimitive3D* >(xReference.get()); + const BasePrimitive3D* pBasePrimitive = static_cast< const BasePrimitive3D* >(xReference.get()); - if(pBasePrimitive) + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch + // not all content is needed, remove transparencies and ModifiedColorPrimitives + switch(pBasePrimitive->getPrimitive3DID()) { - // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch - // not all content is needed, remove transparencies and ModifiedColorPrimitives - switch(pBasePrimitive->getPrimitive3DID()) + case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D : { - case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D : + // polyPolygonMaterialPrimitive3D, check texturing and hatching + const PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const PolyPolygonMaterialPrimitive3D& >(*pBasePrimitive); + const basegfx::B3DPolyPolygon& aFillPolyPolygon(rPrimitive.getB3DPolyPolygon()); + + if(maHatch.isFillBackground()) { - // polyPolygonMaterialPrimitive3D, check texturing and hatching - const PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const PolyPolygonMaterialPrimitive3D& >(*pBasePrimitive); - const basegfx::B3DPolyPolygon& aFillPolyPolygon(rPrimitive.getB3DPolyPolygon()); + // add original primitive for background + aDestination.push_back(xReference); + } - if(maHatch.isFillBackground()) + if(aFillPolyPolygon.areTextureCoordinatesUsed()) + { + const sal_uInt32 nPolyCount(aFillPolyPolygon.count()); + basegfx::B2DPolyPolygon aTexPolyPolygon; + basegfx::B2DPoint a2N; + basegfx::B2DVector a2X, a2Y; + basegfx::B3DPoint a3N; + basegfx::B3DVector a3X, a3Y; + bool b2N(false), b2X(false), b2Y(false); + + for(sal_uInt32 b(0); b < nPolyCount; b++) { - // add original primitive for background - aDestination.push_back(xReference); - } + const basegfx::B3DPolygon& aPartPoly(aFillPolyPolygon.getB3DPolygon(b)); + const sal_uInt32 nPointCount(aPartPoly.count()); + basegfx::B2DPolygon aTexPolygon; - if(aFillPolyPolygon.areTextureCoordinatesUsed()) - { - const sal_uInt32 nPolyCount(aFillPolyPolygon.count()); - basegfx::B2DPolyPolygon aTexPolyPolygon; - basegfx::B2DPoint a2N; - basegfx::B2DVector a2X, a2Y; - basegfx::B3DPoint a3N; - basegfx::B3DVector a3X, a3Y; - bool b2N(false), b2X(false), b2Y(false); - - for(sal_uInt32 b(0); b < nPolyCount; b++) + for(sal_uInt32 c(0); c < nPointCount; c++) { - const basegfx::B3DPolygon& aPartPoly(aFillPolyPolygon.getB3DPolygon(b)); - const sal_uInt32 nPointCount(aPartPoly.count()); - basegfx::B2DPolygon aTexPolygon; + const basegfx::B2DPoint a2Candidate(aPartPoly.getTextureCoordinate(c)); - for(sal_uInt32 c(0); c < nPointCount; c++) + if(!b2N) { - const basegfx::B2DPoint a2Candidate(aPartPoly.getTextureCoordinate(c)); - - if(!b2N) - { - a2N = a2Candidate; - a3N = aPartPoly.getB3DPoint(c); - b2N = true; - } - else if(!b2X && !a2N.equal(a2Candidate)) - { - a2X = a2Candidate - a2N; - a3X = aPartPoly.getB3DPoint(c) - a3N; - b2X = true; - } - else if(!b2Y && !a2N.equal(a2Candidate) && !a2X.equal(a2Candidate)) - { - a2Y = a2Candidate - a2N; + a2N = a2Candidate; + a3N = aPartPoly.getB3DPoint(c); + b2N = true; + } + else if(!b2X && !a2N.equal(a2Candidate)) + { + a2X = a2Candidate - a2N; + a3X = aPartPoly.getB3DPoint(c) - a3N; + b2X = true; + } + else if(!b2Y && !a2N.equal(a2Candidate) && !a2X.equal(a2Candidate)) + { + a2Y = a2Candidate - a2N; - const double fCross(a2X.cross(a2Y)); + const double fCross(a2X.cross(a2Y)); - if(!basegfx::fTools::equalZero(fCross)) - { - a3Y = aPartPoly.getB3DPoint(c) - a3N; - b2Y = true; - } + if(!basegfx::fTools::equalZero(fCross)) + { + a3Y = aPartPoly.getB3DPoint(c) - a3N; + b2Y = true; } - - aTexPolygon.append(a2Candidate); } - aTexPolygon.setClosed(true); - aTexPolyPolygon.append(aTexPolygon); + aTexPolygon.append(a2Candidate); } - if(b2N && b2X && b2Y) + aTexPolygon.setClosed(true); + aTexPolyPolygon.append(aTexPolygon); + } + + if(b2N && b2X && b2Y) + { + // found two linearly independent 2D vectors + // get 2d range of texture coordinates + const basegfx::B2DRange aOutlineRange(basegfx::utils::getRange(aTexPolyPolygon)); + const basegfx::BColor aHatchColor(getHatch().getColor()); + const double fAngle(getHatch().getAngle()); + std::vector< basegfx::B2DHomMatrix > aMatrices; + + // get hatch transformations + switch(getHatch().getStyle()) { - // found two linearly independent 2D vectors - // get 2d range of texture coordinates - const basegfx::B2DRange aOutlineRange(basegfx::utils::getRange(aTexPolyPolygon)); - const basegfx::BColor aHatchColor(getHatch().getColor()); - const double fAngle(getHatch().getAngle()); - std::vector< basegfx::B2DHomMatrix > aMatrices; - - // get hatch transformations - switch(getHatch().getStyle()) + case attribute::HatchStyle::Triple: { - case attribute::HatchStyle::Triple: - { - // rotated 45 degrees - texture::GeoTexSvxHatch aHatch( - aOutlineRange, - aOutlineRange, - getHatch().getDistance(), - fAngle - F_PI4); - - aHatch.appendTransformations(aMatrices); - - [[fallthrough]]; - } - case attribute::HatchStyle::Double: - { - // rotated 90 degrees - texture::GeoTexSvxHatch aHatch( - aOutlineRange, - aOutlineRange, - getHatch().getDistance(), - fAngle - F_PI2); + // rotated 45 degrees + texture::GeoTexSvxHatch aHatch( + aOutlineRange, + aOutlineRange, + getHatch().getDistance(), + fAngle - F_PI4); - aHatch.appendTransformations(aMatrices); + aHatch.appendTransformations(aMatrices); - [[fallthrough]]; - } - case attribute::HatchStyle::Single: - { - // angle as given - texture::GeoTexSvxHatch aHatch( - aOutlineRange, - aOutlineRange, - getHatch().getDistance(), - fAngle); - - aHatch.appendTransformations(aMatrices); - } + [[fallthrough]]; } + case attribute::HatchStyle::Double: + { + // rotated 90 degrees + texture::GeoTexSvxHatch aHatch( + aOutlineRange, + aOutlineRange, + getHatch().getDistance(), + fAngle - F_PI2); - // create geometry from unit line - basegfx::B2DPolyPolygon a2DHatchLines; - basegfx::B2DPolygon a2DUnitLine; - a2DUnitLine.append(basegfx::B2DPoint(0.0, 0.0)); - a2DUnitLine.append(basegfx::B2DPoint(1.0, 0.0)); + aHatch.appendTransformations(aMatrices); - for(const basegfx::B2DHomMatrix & rMatrix : aMatrices) - { - basegfx::B2DPolygon aNewLine(a2DUnitLine); - aNewLine.transform(rMatrix); - a2DHatchLines.append(aNewLine); + [[fallthrough]]; } - - if(a2DHatchLines.count()) + case attribute::HatchStyle::Single: { - // clip against texture polygon - a2DHatchLines = basegfx::utils::clipPolyPolygonOnPolyPolygon(a2DHatchLines, aTexPolyPolygon, true, true); + // angle as given + texture::GeoTexSvxHatch aHatch( + aOutlineRange, + aOutlineRange, + getHatch().getDistance(), + fAngle); + + aHatch.appendTransformations(aMatrices); } + } + + // create geometry from unit line + basegfx::B2DPolyPolygon a2DHatchLines; + basegfx::B2DPolygon a2DUnitLine; + a2DUnitLine.append(basegfx::B2DPoint(0.0, 0.0)); + a2DUnitLine.append(basegfx::B2DPoint(1.0, 0.0)); + + for(const basegfx::B2DHomMatrix & rMatrix : aMatrices) + { + basegfx::B2DPolygon aNewLine(a2DUnitLine); + aNewLine.transform(rMatrix); + a2DHatchLines.append(aNewLine); + } + + if(a2DHatchLines.count()) + { + // clip against texture polygon + a2DHatchLines = basegfx::utils::clipPolyPolygonOnPolyPolygon(a2DHatchLines, aTexPolyPolygon, true, true); + } - if(a2DHatchLines.count()) + if(a2DHatchLines.count()) + { + // create 2d matrix with 2d vectors as column vectors and 2d point as offset, this represents + // a coordinate system transformation from unit coordinates to the new coordinate system + basegfx::B2DHomMatrix a2D; + a2D.set(0, 0, a2X.getX()); + a2D.set(1, 0, a2X.getY()); + a2D.set(0, 1, a2Y.getX()); + a2D.set(1, 1, a2Y.getY()); + a2D.set(0, 2, a2N.getX()); + a2D.set(1, 2, a2N.getY()); + + // invert that transformation, so we have a back-transformation from texture coordinates + // to unit coordinates + a2D.invert(); + a2DHatchLines.transform(a2D); + + // expand back-transformed geometry to 3D + basegfx::B3DPolyPolygon a3DHatchLines(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(a2DHatchLines, 0.0)); + + // create 3d matrix with 3d vectors as column vectors (0,0,1 as Z) and 3d point as offset, this represents + // a coordinate system transformation from unit coordinates to the object's 3d coordinate system + basegfx::B3DHomMatrix a3D; + a3D.set(0, 0, a3X.getX()); + a3D.set(1, 0, a3X.getY()); + a3D.set(2, 0, a3X.getZ()); + a3D.set(0, 1, a3Y.getX()); + a3D.set(1, 1, a3Y.getY()); + a3D.set(2, 1, a3Y.getZ()); + a3D.set(0, 3, a3N.getX()); + a3D.set(1, 3, a3N.getY()); + a3D.set(2, 3, a3N.getZ()); + + // transform hatch lines to 3D object coordinates + a3DHatchLines.transform(a3D); + + // build primitives from this geometry + const sal_uInt32 nHatchLines(a3DHatchLines.count()); + + for(sal_uInt32 d(0); d < nHatchLines; d++) { - // create 2d matrix with 2d vectors as column vectors and 2d point as offset, this represents - // a coordinate system transformation from unit coordinates to the new coordinate system - basegfx::B2DHomMatrix a2D; - a2D.set(0, 0, a2X.getX()); - a2D.set(1, 0, a2X.getY()); - a2D.set(0, 1, a2Y.getX()); - a2D.set(1, 1, a2Y.getY()); - a2D.set(0, 2, a2N.getX()); - a2D.set(1, 2, a2N.getY()); - - // invert that transformation, so we have a back-transformation from texture coordinates - // to unit coordinates - a2D.invert(); - a2DHatchLines.transform(a2D); - - // expand back-transformed geometry to 3D - basegfx::B3DPolyPolygon a3DHatchLines(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(a2DHatchLines, 0.0)); - - // create 3d matrix with 3d vectors as column vectors (0,0,1 as Z) and 3d point as offset, this represents - // a coordinate system transformation from unit coordinates to the object's 3d coordinate system - basegfx::B3DHomMatrix a3D; - a3D.set(0, 0, a3X.getX()); - a3D.set(1, 0, a3X.getY()); - a3D.set(2, 0, a3X.getZ()); - a3D.set(0, 1, a3Y.getX()); - a3D.set(1, 1, a3Y.getY()); - a3D.set(2, 1, a3Y.getZ()); - a3D.set(0, 3, a3N.getX()); - a3D.set(1, 3, a3N.getY()); - a3D.set(2, 3, a3N.getZ()); - - // transform hatch lines to 3D object coordinates - a3DHatchLines.transform(a3D); - - // build primitives from this geometry - const sal_uInt32 nHatchLines(a3DHatchLines.count()); - - for(sal_uInt32 d(0); d < nHatchLines; d++) - { - const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(a3DHatchLines.getB3DPolygon(d), aHatchColor)); - aDestination.push_back(xRef); - } + const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(a3DHatchLines.getB3DPolygon(d), aHatchColor)); + aDestination.push_back(xRef); } } } - - break; - } - default : - { - // add reference to result - aDestination.push_back(xReference); - break; } + + break; + } + default : + { + // add reference to result + aDestination.push_back(xReference); + break; } - } - else - { - // unknown implementation, add to result - aDestination.push_back(xReference); } } } diff --git a/drawinglayer/source/processor2d/baseprocessor2d.cxx b/drawinglayer/source/processor2d/baseprocessor2d.cxx index a7b079016747..00d71151e887 100644 --- a/drawinglayer/source/processor2d/baseprocessor2d.cxx +++ b/drawinglayer/source/processor2d/baseprocessor2d.cxx @@ -60,20 +60,8 @@ namespace drawinglayer::processor2d if(xReference.is()) { - // try to cast to BasePrimitive2D implementation - const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get()); - - if(pBasePrimitive) - { - // it is a BasePrimitive2D implementation, use local processor - processBasePrimitive2D(*pBasePrimitive); - } - else - { - // unknown implementation, use UNO API call instead and process recursively - auto aViewParameters = geometry::createPropertyValues(getViewInformation2D()); - process(comphelper::sequenceToContainer<primitive2d::Primitive2DContainer>(xReference->getDecomposition(aViewParameters))); - } + const primitive2d::BasePrimitive2D* pBasePrimitive = static_cast< const primitive2d::BasePrimitive2D* >(xReference.get()); + processBasePrimitive2D(*pBasePrimitive); } } } diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index a0990edf7645..4e9e963ef065 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -612,65 +612,61 @@ void VclPixelProcessor2D::processUnifiedTransparencePrimitive2D( { const primitive2d::Primitive2DReference xReference(rContent[0]); const primitive2d::BasePrimitive2D* pBasePrimitive - = dynamic_cast<const primitive2d::BasePrimitive2D*>(xReference.get()); + = static_cast<const primitive2d::BasePrimitive2D*>(xReference.get()); - if (pBasePrimitive) + switch (pBasePrimitive->getPrimitive2DID()) { - switch (pBasePrimitive->getPrimitive2DID()) + case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D: { - case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D: - { - // single transparent tools::PolyPolygon identified, use directly - const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor - = static_cast<const primitive2d::PolyPolygonColorPrimitive2D*>( - pBasePrimitive); - SAL_WARN_IF(!pPoPoColor, "drawinglayer", - "OOps, PrimitiveID and PrimitiveType do not match (!)"); - bDrawTransparentUsed = true; - tryDrawPolyPolygonColorPrimitive2DDirect( - *pPoPoColor, rUniTransparenceCandidate.getTransparence()); - break; - } - case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D: - { - // single transparent PolygonHairlinePrimitive2D identified, use directly - const primitive2d::PolygonHairlinePrimitive2D* pPoHair - = static_cast<const primitive2d::PolygonHairlinePrimitive2D*>( - pBasePrimitive); - SAL_WARN_IF(!pPoHair, "drawinglayer", - "OOps, PrimitiveID and PrimitiveType do not match (!)"); - - // do no tallow by default - problem is that self-overlapping parts of this geometry will - // not be in an all-same transparency but will already alpha-cover themselves with blending. - // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its - // content to be uniformly transparent. - // For hairline the effect is pretty minimal, but still not correct. - bDrawTransparentUsed = false; - break; - } - case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D: - { - // single transparent PolygonStrokePrimitive2D identified, use directly - const primitive2d::PolygonStrokePrimitive2D* pPoStroke - = static_cast<const primitive2d::PolygonStrokePrimitive2D*>( - pBasePrimitive); - SAL_WARN_IF(!pPoStroke, "drawinglayer", - "OOps, PrimitiveID and PrimitiveType do not match (!)"); - - // do no tallow by default - problem is that self-overlapping parts of this geometry will - // not be in an all-same transparency but will already alpha-cover themselves with blending. - // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its - // content to be uniformly transparent. - // To check, activate and draw a wide transparent self-crossing line/curve - bDrawTransparentUsed = false; - break; - } - default: - SAL_INFO("drawinglayer", - "default case for " << drawinglayer::primitive2d::idToString( - rUniTransparenceCandidate.getPrimitive2DID())); - break; + // single transparent tools::PolyPolygon identified, use directly + const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor + = static_cast<const primitive2d::PolyPolygonColorPrimitive2D*>( + pBasePrimitive); + SAL_WARN_IF(!pPoPoColor, "drawinglayer", + "OOps, PrimitiveID and PrimitiveType do not match (!)"); + bDrawTransparentUsed = true; + tryDrawPolyPolygonColorPrimitive2DDirect( + *pPoPoColor, rUniTransparenceCandidate.getTransparence()); + break; } + case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D: + { + // single transparent PolygonHairlinePrimitive2D identified, use directly + const primitive2d::PolygonHairlinePrimitive2D* pPoHair + = static_cast<const primitive2d::PolygonHairlinePrimitive2D*>( + pBasePrimitive); + SAL_WARN_IF(!pPoHair, "drawinglayer", + "OOps, PrimitiveID and PrimitiveType do not match (!)"); + + // do no tallow by default - problem is that self-overlapping parts of this geometry will + // not be in an all-same transparency but will already alpha-cover themselves with blending. + // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its + // content to be uniformly transparent. + // For hairline the effect is pretty minimal, but still not correct. + bDrawTransparentUsed = false; + break; + } + case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D: + { + // single transparent PolygonStrokePrimitive2D identified, use directly + const primitive2d::PolygonStrokePrimitive2D* pPoStroke + = static_cast<const primitive2d::PolygonStrokePrimitive2D*>(pBasePrimitive); + SAL_WARN_IF(!pPoStroke, "drawinglayer", + "OOps, PrimitiveID and PrimitiveType do not match (!)"); + + // do no tallow by default - problem is that self-overlapping parts of this geometry will + // not be in an all-same transparency but will already alpha-cover themselves with blending. + // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its + // content to be uniformly transparent. + // To check, activate and draw a wide transparent self-crossing line/curve + bDrawTransparentUsed = false; + break; + } + default: + SAL_INFO("drawinglayer", + "default case for " << drawinglayer::primitive2d::idToString( + rUniTransparenceCandidate.getPrimitive2DID())); + break; } } diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index ed40fdb4ee23..0beb31c3a354 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -35,6 +35,7 @@ #include <basegfx/polygon/b2dpolygonclipper.hxx> #include <basegfx/color/bcolor.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> @@ -142,8 +143,9 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( } // handle additional font attributes - const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP - = dynamic_cast<const primitive2d::TextDecoratedPortionPrimitive2D*>( + const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP = nullptr; + if (rTextCandidate.getPrimitive2DID() == PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D) + pTCPP = static_cast<const primitive2d::TextDecoratedPortionPrimitive2D*>( &rTextCandidate); if (pTCPP != nullptr) diff --git a/drawinglayer/source/processor3d/baseprocessor3d.cxx b/drawinglayer/source/processor3d/baseprocessor3d.cxx index 508ee553f31c..0420f02ca37d 100644 --- a/drawinglayer/source/processor3d/baseprocessor3d.cxx +++ b/drawinglayer/source/processor3d/baseprocessor3d.cxx @@ -53,19 +53,8 @@ namespace drawinglayer::processor3d if(xReference.is()) { - // try to cast to BasePrimitive3D implementation - const primitive3d::BasePrimitive3D* pBasePrimitive = dynamic_cast< const primitive3d::BasePrimitive3D* >(xReference.get()); - - if(pBasePrimitive) - { - processBasePrimitive3D(*pBasePrimitive); - } - else - { - // unknown implementation, use UNO API call instead and process recursively - const uno::Sequence< beans::PropertyValue >& rViewParameters(getViewInformation3D().getViewInformationSequence()); - process(comphelper::sequenceToContainer<primitive3d::Primitive3DContainer>(xReference->getDecomposition(rViewParameters))); - } + const primitive3d::BasePrimitive3D* pBasePrimitive = static_cast< const primitive3d::BasePrimitive3D* >(xReference.get()); + processBasePrimitive3D(*pBasePrimitive); } } } diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index a78b4a894e7a..d126b7100c3b 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -213,9 +213,7 @@ void Primitive2dXmlDump::decomposeAndWrite( drawinglayer::primitive2d::Primitive2DReference xPrimitive2DReference = rPrimitive2DSequence[i]; const BasePrimitive2D* pBasePrimitive - = dynamic_cast<const BasePrimitive2D*>(xPrimitive2DReference.get()); - if (!pBasePrimitive) - continue; + = static_cast<const BasePrimitive2D*>(xPrimitive2DReference.get()); sal_uInt32 nId = pBasePrimitive->getPrimitive2DID(); if (nId < maFilter.size() && maFilter[nId]) continue; diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index cc4120dbf428..d8a40437040c 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -267,11 +267,9 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto { if(rCandidate.is()) { - // try to cast to BasePrimitive2D implementation - const drawinglayer::primitive2d::BasePrimitive2D* pBasePrimitive( - dynamic_cast< const drawinglayer::primitive2d::BasePrimitive2D* >(rCandidate.get())); + auto pBasePrimitive = static_cast< const drawinglayer::primitive2d::BasePrimitive2D* >(rCandidate.get()); - if(pBasePrimitive && PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D != pBasePrimitive->getPrimitive2DID()) + if(PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D != pBasePrimitive->getPrimitive2DID()) { bAllAreHiddenGeometry = false; break; diff --git a/svx/source/sdr/animation/animationstate.cxx b/svx/source/sdr/animation/animationstate.cxx index 17db39768aa7..009c0b5fbd69 100644 --- a/svx/source/sdr/animation/animationstate.cxx +++ b/svx/source/sdr/animation/animationstate.cxx @@ -39,24 +39,20 @@ namespace sdr::animation for(sal_Int32 a(0); a < nCount; a++) { const drawinglayer::primitive2d::Primitive2DReference xRef(maAnimatedPrimitives[a]); - const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* pCandidate = dynamic_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* >(xRef.get()); - OSL_ENSURE(pCandidate, "PrimitiveAnimation::getSmallestNextTime: wrong primitive in animated list (!)"); + const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* pCandidate = static_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* >(xRef.get()); - if(pCandidate) - { - const drawinglayer::animation::AnimationEntry& rAnimEntry = pCandidate->getAnimationEntry(); - const double fNextTime(rAnimEntry.getNextEventTime(fCurrentTime)); + const drawinglayer::animation::AnimationEntry& rAnimEntry = pCandidate->getAnimationEntry(); + const double fNextTime(rAnimEntry.getNextEventTime(fCurrentTime)); - if(!::basegfx::fTools::equalZero(fNextTime)) + if(!::basegfx::fTools::equalZero(fNextTime)) + { + if(::basegfx::fTools::equalZero(fRetval)) + { + fRetval = fNextTime; + } + else if(::basegfx::fTools::less(fNextTime, fRetval)) { - if(::basegfx::fTools::equalZero(fRetval)) - { - fRetval = fNextTime; - } - else if(::basegfx::fTools::less(fNextTime, fRetval)) - { - fRetval = fNextTime; - } + fRetval = fNextTime; } } } diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx index ba25ea976b0a..f61c1cb7c852 100644 --- a/svx/source/svdraw/svdview.cxx +++ b/svx/source/svdraw/svdview.cxx @@ -43,6 +43,7 @@ #include <svx/sdrpaintwindow.hxx> #include <svx/sdrpagewindow.hxx> #include <svx/sdrhittesthelper.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> #include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx> #include <svx/sdr/contact/objectcontactofpageview.hxx> #include <sal/log.hxx> @@ -457,11 +458,10 @@ SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) co { if (xReference.is()) { - // try to cast to drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D implementation - pTextHierarchyFieldPrimitive2D = dynamic_cast<const drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D*>(xReference.get()); - - if (pTextHierarchyFieldPrimitive2D) + auto pBasePrimitive = static_cast<const drawinglayer::primitive2d::BasePrimitive2D*>(xReference.get()); + if (pBasePrimitive->getPrimitive2DID() == PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D) { + pTextHierarchyFieldPrimitive2D = static_cast<const drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D*>(xReference.get()); break; } }