diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-08 14:06:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-09 06:20:39 +0000 |
commit | 57998f642de65bdcb72742abd8ab94a26840a31d (patch) | |
tree | 807ad6f765679dc7bd0c53d72829fc6ade22530c /drawinglayer/source/primitive2d | |
parent | 85102b0fe499dc0cdcedecb5fe6fdeaabee9bf0a (diff) |
some small simplifications to decompose methods
Change-Id: I9ad8c68c1f0c72d0f985d6c0a3167a775d481a2c
Reviewed-on: https://gerrit.libreoffice.org/30696
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/source/primitive2d')
7 files changed, 77 insertions, 88 deletions
diff --git a/drawinglayer/source/primitive2d/mediaprimitive2d.cxx b/drawinglayer/source/primitive2d/mediaprimitive2d.cxx index 0578907ab340..dd4d5241f3a2 100644 --- a/drawinglayer/source/primitive2d/mediaprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/mediaprimitive2d.cxx @@ -52,8 +52,7 @@ namespace drawinglayer const GraphicObject aGraphicObject(maSnapshot); const GraphicAttr aGraphicAttr; xRetval.resize(2); - xRetval[0] = xRefBackground; - xRetval[1] = Primitive2DReference(new GraphicPrimitive2D(getTransform(), aGraphicObject, aGraphicAttr)); + xRetval[1] = new GraphicPrimitive2D(getTransform(), aGraphicObject, aGraphicAttr); } if(getDiscreteBorder()) diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 00cfdbfe72ea..0784603bcc40 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -3164,7 +3164,7 @@ namespace drawinglayer { void MetafilePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const { - // prepare target and porperties; each will have one default entry + // prepare target and properties; each will have one default entry TargetHolders aTargetHolders; PropertyHolders aPropertyHolders; diff --git a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx index 87bdcb4dc2e5..5494c4f811ac 100644 --- a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx @@ -529,44 +529,44 @@ namespace drawinglayer { void PolyPolygonSelectionPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const { + if(getTransparence() >= 1.0 || !getB2DPolyPolygon().count()) + return; + Primitive2DContainer aRetval; - if(getTransparence() < 1.0 && getB2DPolyPolygon().count()) + if(getFill() && getB2DPolyPolygon().isClosed()) { - if(getFill() && getB2DPolyPolygon().isClosed()) - { - // create fill primitive - const Primitive2DReference aFill( - new PolyPolygonColorPrimitive2D( - getB2DPolyPolygon(), - getColor())); + // create fill primitive + const Primitive2DReference aFill( + new PolyPolygonColorPrimitive2D( + getB2DPolyPolygon(), + getColor())); - aRetval = Primitive2DContainer { aFill }; - } + aRetval = Primitive2DContainer { aFill }; + } - if(getDiscreteGrow() > 0.0) - { - const attribute::LineAttribute aLineAttribute( - getColor(), - getDiscreteGrow() * getDiscreteUnit() * 2.0); - const Primitive2DReference aFatLine( - new PolyPolygonStrokePrimitive2D( - getB2DPolyPolygon(), - aLineAttribute)); - - aRetval.push_back(aFatLine); - } + if(getDiscreteGrow() > 0.0) + { + const attribute::LineAttribute aLineAttribute( + getColor(), + getDiscreteGrow() * getDiscreteUnit() * 2.0); + const Primitive2DReference aFatLine( + new PolyPolygonStrokePrimitive2D( + getB2DPolyPolygon(), + aLineAttribute)); + + aRetval.push_back(aFatLine); + } - // embed filled to transparency (if used) - if(!aRetval.empty() && getTransparence() > 0.0) - { - const Primitive2DReference aTrans( - new UnifiedTransparencePrimitive2D( - aRetval, - getTransparence())); + // embed filled to transparency (if used) + if(!aRetval.empty() && getTransparence() > 0.0) + { + const Primitive2DReference aTrans( + new UnifiedTransparencePrimitive2D( + aRetval, + getTransparence())); - aRetval = Primitive2DContainer { aTrans }; - } + aRetval = Primitive2DContainer { aTrans }; } rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end()); diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index 63d30349c0d4..6470f634c187 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -223,8 +223,6 @@ namespace drawinglayer void ScenePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const { - Primitive2DContainer aRetval; - // create 2D shadows from contained 3D primitives. This creates the shadow primitives on demand and tells if // there are some or not. Do this at start, the shadow might still be visible even when the scene is not if(impGetShadow3D(rViewInformation)) @@ -237,7 +235,7 @@ namespace drawinglayer if(aViewRange.isEmpty() || aShadow2DRange.overlaps(aViewRange)) { // add extracted 2d shadows (before 3d scene creations itself) - aRetval = maShadowPrimitives; + rContainer.insert(rContainer.end(), maShadowPrimitives.begin(), maShadowPrimitives.end()); } } @@ -477,8 +475,7 @@ namespace drawinglayer aNew2DTransform *= aInverseOToV; // create bitmap primitive and add - const Primitive2DReference xRef(new BitmapPrimitive2D(maOldRenderedBitmap, aNew2DTransform)); - aRetval.push_back(xRef); + rContainer.push_back(new BitmapPrimitive2D(maOldRenderedBitmap, aNew2DTransform)); // test: Allow to add an outline in the debugger when tests are needed static bool bAddOutlineToCreated3DSceneRepresentation(false); @@ -487,14 +484,11 @@ namespace drawinglayer { basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon()); aOutline.transform(aNew2DTransform); - const Primitive2DReference xRef2(new PolygonHairlinePrimitive2D(aOutline, basegfx::BColor(1.0, 0.0, 0.0))); - aRetval.push_back(xRef2); + rContainer.push_back(new PolygonHairlinePrimitive2D(aOutline, basegfx::BColor(1.0, 0.0, 0.0))); } } } } - - rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end()); } Primitive2DContainer ScenePrimitive2D::getGeometry2D() const diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index 22efbb16c985..e0fe820c3838 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -237,10 +237,10 @@ namespace drawinglayer fTextShadowOffset, fTextShadowOffset)); // create shadow primitive - aShadow = Primitive2DReference(new ShadowPrimitive2D( + aShadow = new ShadowPrimitive2D( aShadowTransform, aShadowColor, - aRetval)); + aRetval); } if(bHasTextRelief) @@ -297,9 +297,7 @@ namespace drawinglayer { // put shadow in front if there is one to paint timely before // but placed behind content - const Primitive2DContainer aContent(aRetval); - aRetval = Primitive2DContainer { aShadow }; - aRetval.append(aContent); + aRetval.insert(aRetval.begin(), aShadow); } } } diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx index 2b3e85c78e52..bd9fc0ba30ad 100644 --- a/drawinglayer/source/primitive2d/textprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx @@ -166,50 +166,49 @@ namespace drawinglayer void TextSimplePortionPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const { + if(!getTextLength()) + return; + Primitive2DContainer aRetval; + basegfx::B2DPolyPolygonVector aB2DPolyPolyVector; + basegfx::B2DHomMatrix aPolygonTransform; - if(getTextLength()) - { - basegfx::B2DPolyPolygonVector aB2DPolyPolyVector; - basegfx::B2DHomMatrix aPolygonTransform; + // get text outlines and their object transformation + getTextOutlinesAndTransformation(aB2DPolyPolyVector, aPolygonTransform); - // get text outlines and their object transformation - getTextOutlinesAndTransformation(aB2DPolyPolyVector, aPolygonTransform); + // create primitives for the outlines + const sal_uInt32 nCount(aB2DPolyPolyVector.size()); - // create primitives for the outlines - const sal_uInt32 nCount(aB2DPolyPolyVector.size()); + if(!nCount) + return; - if(nCount) - { - // alloc space for the primitives - aRetval.resize(nCount); + // alloc space for the primitives + aRetval.resize(nCount); - // color-filled polypolygons - for(sal_uInt32 a(0L); a < nCount; a++) - { - // prepare polypolygon - basegfx::B2DPolyPolygon& rPolyPolygon = aB2DPolyPolyVector[a]; - rPolyPolygon.transform(aPolygonTransform); - aRetval[a] = new PolyPolygonColorPrimitive2D(rPolyPolygon, getFontColor()); - } + // color-filled polypolygons + for(sal_uInt32 a(0L); a < nCount; a++) + { + // prepare polypolygon + basegfx::B2DPolyPolygon& rPolyPolygon = aB2DPolyPolyVector[a]; + rPolyPolygon.transform(aPolygonTransform); + aRetval[a] = new PolyPolygonColorPrimitive2D(rPolyPolygon, getFontColor()); + } - if(getFontAttribute().getOutline()) - { - // decompose polygon transformation to single values - basegfx::B2DVector aScale, aTranslate; - double fRotate, fShearX; - aPolygonTransform.decompose(aScale, aTranslate, fRotate, fShearX); - - // create outline text effect with current content and replace - Primitive2DReference aNewTextEffect(new TextEffectPrimitive2D( - aRetval, - aTranslate, - fRotate, - TextEffectStyle2D::Outline)); - - aRetval = Primitive2DContainer { aNewTextEffect }; - } - } + if(getFontAttribute().getOutline()) + { + // decompose polygon transformation to single values + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + aPolygonTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + // create outline text effect with current content and replace + Primitive2DReference aNewTextEffect(new TextEffectPrimitive2D( + aRetval, + aTranslate, + fRotate, + TextEffectStyle2D::Outline)); + + aRetval = Primitive2DContainer { aNewTextEffect }; } rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end()); diff --git a/drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx b/drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx index 6ff212425852..37b9c3cd68fd 100644 --- a/drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx @@ -201,7 +201,7 @@ namespace drawinglayer // add primitive const attribute::LineAttribute aLineAttribute(getFontColor(), fStrikeoutHeight, basegfx::B2DLineJoin::NONE); Primitive2DContainer xRetval(1); - xRetval[0] = Primitive2DReference(new PolygonStrokePrimitive2D(aStrikeoutLine, aLineAttribute)); + xRetval[0] = new PolygonStrokePrimitive2D(aStrikeoutLine, aLineAttribute); if(bDoubleLine) { @@ -223,10 +223,9 @@ namespace drawinglayer // add transform primitive xRetval.push_back( - Primitive2DReference( new TransformPrimitive2D( aTransform, - xRetval))); + xRetval)); } rContainer.insert(rContainer.end(), xRetval.begin(), xRetval.end()); |