summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-03-06 11:05:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-03-08 07:20:29 +0100
commit5c23459245f566831383934dd64d19e002bfcfcb (patch)
tree27d92a2167c6245c3be7844e2bbe7b6e624f0f9e /drawinglayer
parent4a7771ffa8d98d08dffbba90fd42d1ab75e056fe (diff)
new loplugin constvars
detect static variables that can be made const. Thanks to mike kaganski for suggesting this. Here I introduce a new plugin feature - using markers in nearby comments to disable the plugin for specific vars. Some of this stuff was old debugging code. I removed the stuff that was older than 5 years. Change-Id: I6ec7742a7fdadf28fd128b592fcdf6da8257585c Reviewed-on: https://gerrit.libreoffice.org/68807 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx4
-rw-r--r--drawinglayer/source/primitive2d/polygonprimitive2d.cxx5
-rw-r--r--drawinglayer/source/primitive2d/sceneprimitive2d.cxx4
-rw-r--r--drawinglayer/source/processor2d/vclhelperbufferdevice.cxx2
-rw-r--r--drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx8
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx199
-rw-r--r--drawinglayer/source/processor3d/defaultprocessor3d.cxx17
-rw-r--r--drawinglayer/source/tools/converters.cxx2
8 files changed, 78 insertions, 163 deletions
diff --git a/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx
index 85cf4cd548fb..96b3de031acc 100644
--- a/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx
@@ -283,9 +283,7 @@ namespace drawinglayer
if(!getFillGradient().isDefault())
{
- static bool bOverlapping(true); // allow to test non-overlapping in the debugger
-
- createFill(rContainer, bOverlapping);
+ createFill(rContainer, /*bOverlapping*/true);
}
}
diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
index ea2e9c9aede6..bcf1fc6bbc3b 100644
--- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
@@ -267,10 +267,7 @@ namespace drawinglayer
// to be painted as a single tools::PolyPolygon (XORed as fill rule). Alternatively, a
// melting process may be used here one day.
const basegfx::B2DPolyPolygon aNewPolyPolygon(aAreaPolyPolygon.getB2DPolygon(b));
- static bool bTestByUsingRandomColor(false);
- const basegfx::BColor aColor(bTestByUsingRandomColor
- ? basegfx::BColor(getRandomColorRange(), getRandomColorRange(), getRandomColorRange())
- : getLineAttribute().getColor());
+ const basegfx::BColor aColor(getLineAttribute().getColor());
rContainer.push_back(new PolyPolygonColorPrimitive2D(aNewPolyPolygon, aColor));
}
}
diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
index 400dd0f0310c..a15daa84a464 100644
--- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx
@@ -365,7 +365,7 @@ namespace drawinglayer
nOversampleValue ? nRasterHeight * nOversampleValue : nRasterHeight);
// check for parallel execution possibilities
- static bool bMultithreadAllowed = true;
+ static bool bMultithreadAllowed = true; // loplugin:constvars:ignore
sal_Int32 nThreadCount(0);
comphelper::ThreadPool& rThreadPool(comphelper::ThreadPool::getSharedOptimalPool());
@@ -469,7 +469,7 @@ namespace drawinglayer
rContainer.push_back(new BitmapPrimitive2D(maOldRenderedBitmap, aNew2DTransform));
// test: Allow to add an outline in the debugger when tests are needed
- static bool bAddOutlineToCreated3DSceneRepresentation(false);
+ static bool bAddOutlineToCreated3DSceneRepresentation(false); // loplugin:constvars:ignore
if(bAddOutlineToCreated3DSceneRepresentation)
{
diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
index b22ddabf00a0..e30851d23493 100644
--- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
+++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
@@ -329,7 +329,7 @@ namespace drawinglayer
const Size aSizePixel(maDestPixel.GetSize());
const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled());
#ifdef DBG_UTIL
- static bool bDoSaveForVisualControl(false);
+ static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore
#endif
mrOutDev.EnableMapMode(false);
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index d54d8e1fe1ce..8e9e0db30040 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -922,7 +922,7 @@ namespace drawinglayer
{
bool bUsingPDFExtOutDevData(false);
basegfx::B2DVector aTranslate, aScale;
- static bool bSuppressPDFExtOutDevDataSupport(false);
+ static bool bSuppressPDFExtOutDevDataSupport(false); // loplugin:constvars:ignore
if(mpPDFExtOutDevData && !bSuppressPDFExtOutDevDataSupport)
{
@@ -1247,7 +1247,7 @@ namespace drawinglayer
void VclMetafileProcessor2D::processTextHierarchyParagraphPrimitive2D(const primitive2d::TextHierarchyParagraphPrimitive2D& rParagraphPrimitive)
{
const OString aCommentString("XTEXT_EOP");
- static bool bSuppressPDFExtOutDevDataSupport(false);
+ static bool bSuppressPDFExtOutDevDataSupport(false); // loplugin:constvars:ignore
if(nullptr == mpPDFExtOutDevData || bSuppressPDFExtOutDevDataSupport)
{
@@ -1995,7 +1995,7 @@ namespace drawinglayer
// try to identify a single PolyPolygonColorPrimitive2D in the
// content part of the transparence primitive
const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = nullptr;
- static bool bForceToMetafile(false);
+ static bool bForceToMetafile(false); // loplugin:constvars:ignore
if(!bForceToMetafile && 1 == rContent.size())
{
@@ -2089,7 +2089,7 @@ namespace drawinglayer
// try to identify a single FillGradientPrimitive2D in the
// transparence part of the primitive
const primitive2d::FillGradientPrimitive2D* pFiGradient = nullptr;
- static bool bForceToBigTransparentVDev(false);
+ static bool bForceToBigTransparentVDev(false); // loplugin:constvars:ignore
if(!bForceToBigTransparentVDev && 1 == rTransparence.size())
{
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 741c6762a97f..68d197394a4a 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -422,37 +422,24 @@ namespace drawinglayer
void VclPixelProcessor2D::processWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellPrimitive)
{
- // directdraw of wrong spell primitive; added test possibility to check wrong spell decompose
- static bool bHandleWrongSpellDirectly(true);
-
- if(bHandleWrongSpellDirectly)
- {
- if(!renderWrongSpellPrimitive2D(
- rWrongSpellPrimitive,
- *mpOutputDevice,
- maCurrentTransformation,
- maBColorModifierStack))
- {
- // fallback to decomposition (MetaFile)
- process(rWrongSpellPrimitive);
- }
- }
- else
+ if(!renderWrongSpellPrimitive2D(
+ rWrongSpellPrimitive,
+ *mpOutputDevice,
+ maCurrentTransformation,
+ maBColorModifierStack))
{
+ // fallback to decomposition (MetaFile)
process(rWrongSpellPrimitive);
}
}
void VclPixelProcessor2D::processTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rCandidate)
{
- // directdraw of text simple portion; added test possibility to check text decompose
- static bool bForceSimpleTextDecomposition(false);
-
// Adapt evtl. used special DrawMode
const DrawModeFlags nOriginalDrawMode(mpOutputDevice->GetDrawMode());
adaptTextToFillDrawMode();
- if(!bForceSimpleTextDecomposition && getOptionsDrawinglayer().IsRenderSimpleTextDirect())
+ if(getOptionsDrawinglayer().IsRenderSimpleTextDirect())
{
RenderTextSimpleOrDecoratedPortionPrimitive2D(rCandidate);
}
@@ -467,14 +454,11 @@ namespace drawinglayer
void VclPixelProcessor2D::processTextDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rCandidate)
{
- // directdraw of decorated text portion; added test possibility to check text decompose
- static bool bForceComplexTextDecomposition(false);
-
// Adapt evtl. used special DrawMode
const DrawModeFlags nOriginalDrawMode(mpOutputDevice->GetDrawMode());
adaptTextToFillDrawMode();
- if(!bForceComplexTextDecomposition && getOptionsDrawinglayer().IsRenderDecoratedTextDirect())
+ if(getOptionsDrawinglayer().IsRenderDecoratedTextDirect())
{
RenderTextSimpleOrDecoratedPortionPrimitive2D(rCandidate);
}
@@ -489,10 +473,7 @@ namespace drawinglayer
void VclPixelProcessor2D::processPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D)
{
- // try to use directly
- static bool bAllowed(true);
-
- if(bAllowed && tryDrawPolygonHairlinePrimitive2DDirect(rPolygonHairlinePrimitive2D, 0.0))
+ if(tryDrawPolygonHairlinePrimitive2DDirect(rPolygonHairlinePrimitive2D, 0.0))
{
return;
}
@@ -554,24 +535,9 @@ namespace drawinglayer
{
// try to use directly
basegfx::B2DPolyPolygon aLocalPolyPolygon;
- static bool bAllowed(true);
-
- if(bAllowed)
- {
- tryDrawPolyPolygonColorPrimitive2DDirect(rPolyPolygonColorPrimitive2D, 0.0);
- // okay, done. In this case no gaps should have to be repaired, too
- }
- else
- {
- // direct draw of tools::PolyPolygon with color
- const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
- mpOutputDevice->SetFillColor(Color(aPolygonColor));
- mpOutputDevice->SetLineColor();
- aLocalPolyPolygon = rPolyPolygonColorPrimitive2D.getB2DPolyPolygon();
- aLocalPolyPolygon.transform(maCurrentTransformation);
- mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
- }
+ tryDrawPolyPolygonColorPrimitive2DDirect(rPolyPolygonColorPrimitive2D, 0.0);
+ // okay, done. In this case no gaps should have to be repaired, too
// 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
@@ -617,11 +583,7 @@ namespace drawinglayer
{
bool bDrawTransparentUsed(false);
- // since DEV300 m33 DrawTransparent is supported in VCL (for some targets
- // natively), so i am now enabling this shortcut
- static bool bAllowUsingDrawTransparent(true);
-
- if(bAllowUsingDrawTransparent && 1 == rContent.size())
+ if(1 == rContent.size())
{
const primitive2d::Primitive2DReference xReference(rContent[0]);
const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get());
@@ -648,11 +610,9 @@ namespace drawinglayer
// do no tallow by default - problem is that self-overlapping parts of this geometry will
// not be in a 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 uniformely transparent.
+ // content to be uniformly transparent.
// For hairline the effect is pretty minimal, but still not correct.
- static bool bAllowed(false);
-
- bDrawTransparentUsed = bAllowed && tryDrawPolygonHairlinePrimitive2DDirect(*pPoHair, rUniTransparenceCandidate.getTransparence());
+ bDrawTransparentUsed = false;
break;
}
case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
@@ -664,11 +624,9 @@ namespace drawinglayer
// do no tallow by default - problem is that self-overlapping parts of this geometry will
// not be in a 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 uniformely transparent.
+ // content to be uniformly transparent.
// To check, activate and draw a wide transparent self-crossing line/curve
- static bool bAllowed(false);
-
- bDrawTransparentUsed = bAllowed && tryDrawPolygonStrokePrimitive2DDirect(*pPoStroke, rUniTransparenceCandidate.getTransparence());
+ bDrawTransparentUsed = false;
break;
}
default:
@@ -754,28 +712,12 @@ namespace drawinglayer
adaptLineToFillDrawMode();
// polygon stroke primitive
- static bool bSuppressFatToHairlineCorrection(false);
-
- if(bSuppressFatToHairlineCorrection)
- {
- // remember that we enter a PolygonStrokePrimitive2D decomposition,
- // used for AA thick line drawing
- mnPolygonStrokePrimitive2D++;
- // with AA there is no need to handle thin lines special
- process(rPolygonStrokePrimitive2D);
-
- // leave PolygonStrokePrimitive2D
- mnPolygonStrokePrimitive2D--;
- }
- else
- {
- // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation
- // as filled polygons is geometrically correct but looks wrong since polygon filling avoids
- // the right and bottom pixels. The used method evaluates that and takes the correct action,
- // including calling recursively with decomposition if line is wide enough
- RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive2D);
- }
+ // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation
+ // as filled polygons is geometrically correct but looks wrong since polygon filling avoids
+ // the right and bottom pixels. The used method evaluates that and takes the correct action,
+ // including calling recursively with decomposition if line is wide enough
+ RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive2D);
// restore DrawMode
mpOutputDevice->SetDrawMode(nOriginalDrawMode);
@@ -783,72 +725,61 @@ namespace drawinglayer
void VclPixelProcessor2D::processFillHatchPrimitive2D(const primitive2d::FillHatchPrimitive2D& rFillHatchPrimitive)
{
- static bool bForceIgnoreHatchSmoothing(false);
+ // without AA, use VCL to draw the hatch. It snaps hatch distances to the next pixel
+ // and forces hatch distance to be >= 3 pixels to make the hatch display look smoother.
+ // This is wrong in principle, but looks nicer. This could also be done here directly
+ // without VCL usage if needed
+ const attribute::FillHatchAttribute& rFillHatchAttributes = rFillHatchPrimitive.getFillHatch();
+
+ // create hatch polygon in range size and discrete coordinates
+ basegfx::B2DRange aHatchRange(rFillHatchPrimitive.getOutputRange());
+ aHatchRange.transform(maCurrentTransformation);
+ const basegfx::B2DPolygon aHatchPolygon(basegfx::utils::createPolygonFromRect(aHatchRange));
- if(bForceIgnoreHatchSmoothing || getOptionsDrawinglayer().IsAntiAliasing())
+ if(rFillHatchAttributes.isFillBackground())
{
- // if AA is used (or ignore smoothing is on), there is no need to smooth
- // hatch painting, use decomposition
- process(rFillHatchPrimitive);
+ // #i111846# background fill is active; draw fill polygon
+ const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
+
+ mpOutputDevice->SetFillColor(Color(aPolygonColor));
+ mpOutputDevice->SetLineColor();
+ mpOutputDevice->DrawPolygon(aHatchPolygon);
}
- else
- {
- // without AA, use VCL to draw the hatch. It snaps hatch distances to the next pixel
- // and forces hatch distance to be >= 3 pixels to make the hatch display look smoother.
- // This is wrong in principle, but looks nicer. This could also be done here directly
- // without VCL usage if needed
- const attribute::FillHatchAttribute& rFillHatchAttributes = rFillHatchPrimitive.getFillHatch();
- // create hatch polygon in range size and discrete coordinates
- basegfx::B2DRange aHatchRange(rFillHatchPrimitive.getOutputRange());
- aHatchRange.transform(maCurrentTransformation);
- const basegfx::B2DPolygon aHatchPolygon(basegfx::utils::createPolygonFromRect(aHatchRange));
+ // set hatch line color
+ const basegfx::BColor aHatchColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
+ mpOutputDevice->SetFillColor();
+ mpOutputDevice->SetLineColor(Color(aHatchColor));
- if(rFillHatchAttributes.isFillBackground())
- {
- // #i111846# background fill is active; draw fill polygon
- const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
+ // get hatch style
+ HatchStyle eHatchStyle(HatchStyle::Single);
- mpOutputDevice->SetFillColor(Color(aPolygonColor));
- mpOutputDevice->SetLineColor();
- mpOutputDevice->DrawPolygon(aHatchPolygon);
+ switch(rFillHatchAttributes.getStyle())
+ {
+ default : // HatchStyle::Single
+ {
+ break;
}
-
- // set hatch line color
- const basegfx::BColor aHatchColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
- mpOutputDevice->SetFillColor();
- mpOutputDevice->SetLineColor(Color(aHatchColor));
-
- // get hatch style
- HatchStyle eHatchStyle(HatchStyle::Single);
-
- switch(rFillHatchAttributes.getStyle())
+ case attribute::HatchStyle::Double :
{
- default : // HatchStyle::Single
- {
- break;
- }
- case attribute::HatchStyle::Double :
- {
- eHatchStyle = HatchStyle::Double;
- break;
- }
- case attribute::HatchStyle::Triple :
- {
- eHatchStyle = HatchStyle::Triple;
- break;
- }
+ eHatchStyle = HatchStyle::Double;
+ break;
}
+ case attribute::HatchStyle::Triple :
+ {
+ eHatchStyle = HatchStyle::Triple;
+ break;
+ }
+ }
- // create hatch
- const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0));
- const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength()));
- const sal_uInt16 nAngle10(static_cast<sal_uInt16>(basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800)));
- ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10);
+ // create hatch
+ const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0));
+ const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength()));
+ const sal_uInt16 nAngle10(static_cast<sal_uInt16>(basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800)));
+ ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10);
- // draw hatch using VCL
- mpOutputDevice->DrawHatch(::tools::PolyPolygon(::tools::Polygon(aHatchPolygon)), aVCLHatch);
- }
+ // draw hatch using VCL
+ mpOutputDevice->DrawHatch(::tools::PolyPolygon(::tools::Polygon(aHatchPolygon)), aVCLHatch);
}
void VclPixelProcessor2D::processBackgroundColorPrimitive2D(const primitive2d::BackgroundColorPrimitive2D& rPrimitive)
diff --git a/drawinglayer/source/processor3d/defaultprocessor3d.cxx b/drawinglayer/source/processor3d/defaultprocessor3d.cxx
index 36b6939362d7..ab07e055d894 100644
--- a/drawinglayer/source/processor3d/defaultprocessor3d.cxx
+++ b/drawinglayer/source/processor3d/defaultprocessor3d.cxx
@@ -516,20 +516,9 @@ namespace drawinglayer
}
case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D :
{
- // HatchTexturePrimitive3D
- static bool bDoHatchDecomposition(false);
-
- if(bDoHatchDecomposition)
- {
- // let break down
- process(rBasePrimitive.get3DDecomposition(getViewInformation3D()));
- }
- else
- {
- // hatchTexturePrimitive3D
- const primitive3d::HatchTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::HatchTexturePrimitive3D& >(rBasePrimitive);
- impRenderHatchTexturePrimitive3D(rPrimitive);
- }
+ // hatchTexturePrimitive3D
+ const primitive3d::HatchTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::HatchTexturePrimitive3D& >(rBasePrimitive);
+ impRenderHatchTexturePrimitive3D(rPrimitive);
break;
}
case PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D :
diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx
index a993c1884a0c..55cba173e83b 100644
--- a/drawinglayer/source/tools/converters.cxx
+++ b/drawinglayer/source/tools/converters.cxx
@@ -87,7 +87,7 @@ namespace drawinglayer
if(pContentProcessor)
{
#ifdef DBG_UTIL
- static bool bDoSaveForVisualControl(false);
+ static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore
#endif
// render content
pContentProcessor->process(aSequence);