vcl/source/outdev/hatch.cxx | 78 ++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 39 deletions(-)
New commits: commit 186a020f5eab98f3b97da80d543b7101ffb4232d Author: Christopher Sherlock <chris.sherloc...@gmail.com> AuthorDate: Thu Aug 14 23:50:13 2025 +1000 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 15 10:05:11 2025 +0200 vcl: flatten OutputDevice::DrawHatch() Change-Id: I674ce8cde19486e99609b052a7c47078df3f6d39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189610 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx index ccf148d43b9e..c329a9f89e24 100644 --- a/vcl/source/outdev/hatch.cxx +++ b/vcl/source/outdev/hatch.cxx @@ -168,39 +168,55 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rPolyPoly.AdaptiveSubdivide(aPolyPoly); DrawHatch(aPolyPoly, rHatch, bMtf); + + return; } + + tools::Rectangle aRect( rPolyPoly.GetBoundRect() ); + const tools::Long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 ); + const tools::Long nWidth = ImplDevicePixelToLogicWidth( std::max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), tools::Long(3) ) ); + std::unique_ptr<Point[]> pPtBuffer(new Point[ HATCH_MAXPOINTS ]); + Point aPt1, aPt2, aEndPt1; + Size aInc; + + // Single hatch + aRect.AdjustLeft( -nLogPixelWidth ); aRect.AdjustTop( -nLogPixelWidth ); aRect.AdjustRight(nLogPixelWidth ); aRect.AdjustBottom(nLogPixelWidth ); + CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 ); + if (comphelper::IsFuzzing() && !HasSaneNSteps(aPt1, aEndPt1, aInc)) + return; + + if (aInc.Width() <= 0 && aInc.Height() <= 0) + SAL_WARN("vcl.gdi", "invalid increment"); else { - tools::Rectangle aRect( rPolyPoly.GetBoundRect() ); - const tools::Long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 ); - const tools::Long nWidth = ImplDevicePixelToLogicWidth( std::max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), tools::Long(3) ) ); - std::unique_ptr<Point[]> pPtBuffer(new Point[ HATCH_MAXPOINTS ]); - Point aPt1, aPt2, aEndPt1; - Size aInc; - - // Single hatch - aRect.AdjustLeft( -nLogPixelWidth ); aRect.AdjustTop( -nLogPixelWidth ); aRect.AdjustRight(nLogPixelWidth ); aRect.AdjustBottom(nLogPixelWidth ); - CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 ); + do + { + DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); + aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); + aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); + } + while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); + } + + if( ( rHatch.GetStyle() == HatchStyle::Double ) || ( rHatch.GetStyle() == HatchStyle::Triple ) ) + { + // Double hatch + CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900_deg10, aPt1, aPt2, aInc, aEndPt1 ); if (comphelper::IsFuzzing() && !HasSaneNSteps(aPt1, aEndPt1, aInc)) return; - if (aInc.Width() <= 0 && aInc.Height() <= 0) - SAL_WARN("vcl.gdi", "invalid increment"); - else + do { - do - { - DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); - aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); - aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); - } - while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); + DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); + aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); + aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); } + while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - if( ( rHatch.GetStyle() == HatchStyle::Double ) || ( rHatch.GetStyle() == HatchStyle::Triple ) ) + if( rHatch.GetStyle() == HatchStyle::Triple ) { - // Double hatch - CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900_deg10, aPt1, aPt2, aInc, aEndPt1 ); + // Triple hatch + CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450_deg10, aPt1, aPt2, aInc, aEndPt1 ); if (comphelper::IsFuzzing() && !HasSaneNSteps(aPt1, aEndPt1, aInc)) return; @@ -211,22 +227,6 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); } while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - - if( rHatch.GetStyle() == HatchStyle::Triple ) - { - // Triple hatch - CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450_deg10, aPt1, aPt2, aInc, aEndPt1 ); - if (comphelper::IsFuzzing() && !HasSaneNSteps(aPt1, aEndPt1, aInc)) - return; - - do - { - DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); - aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); - aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); - } - while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - } } } }