Kaydet (Commit) 57998f64 authored tarafından Noel Grandin's avatar Noel Grandin

some small simplifications to decompose methods

Change-Id: I9ad8c68c1f0c72d0f985d6c0a3167a775d481a2c
Reviewed-on: https://gerrit.libreoffice.org/30696Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 85102b0f
......@@ -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())
......
......@@ -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;
......
......@@ -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());
......
......@@ -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
......
......@@ -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);
}
}
}
......
......@@ -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());
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment