11// Copyright (c) Six Labors.
22// Licensed under the Six Labors Split License.
33
4+ using System . Numerics ;
45using System . Runtime . CompilerServices ;
56using SixLabors . ImageSharp . Memory ;
67
@@ -732,12 +733,14 @@ private static bool TryPrepareFillPath(
732733 out PreparedFillItem prepared )
733734 {
734735 IPath path = command . SourcePath ;
735- bool hasTransform = ! command . Transform . IsIdentity ;
736- Brush sourceBrush = hasTransform ? command . Brush . Transform ( command . Transform ) : command . Brush ;
736+ Matrix4x4 transform = command . Transform ;
737+ bool hasTransform = ! transform . IsIdentity ;
738+ LinearGeometry geometry = path . ToLinearGeometry ( transform ) ;
739+ Brush sourceBrush = hasTransform ? command . Brush . Transform ( transform ) : command . Brush ;
737740
738741 if ( ! TryResolveRasterization (
739742 sourceBrush ,
740- hasTransform ? RectangleF . Transform ( path . Bounds , command . Transform ) : path . Bounds ,
743+ geometry . Info . Bounds ,
741744 command . RasterizerOptions ,
742745 command . DestinationOffset ,
743746 command . TargetBounds ,
@@ -750,7 +753,7 @@ private static bool TryPrepareFillPath(
750753 }
751754
752755 DefaultRasterizer . RasterizableGeometry ? rasterizable = DefaultRasterizer . CreateRasterizableGeometry (
753- hasTransform ? path . ToLinearGeometry ( command . Transform ) : path . ToLinearGeometry ( ) ,
756+ geometry ,
754757 command . DestinationOffset . X ,
755758 command . DestinationOffset . Y ,
756759 rasterizerOptions ,
@@ -772,12 +775,15 @@ private static bool TryPrepareStrokePath(
772775 out PreparedStrokeItem prepared )
773776 {
774777 IPath path = command . SourcePath ;
775- bool hasTransform = ! command . Transform . IsIdentity ;
776- Brush sourceBrush = hasTransform ? command . Brush . Transform ( command . Transform ) : command . Brush ;
778+ Matrix4x4 transform = command . Transform ;
779+ bool hasTransform = ! transform . IsIdentity ;
780+ LinearGeometry geometry = path . ToLinearGeometry ( Matrix4x4 . Identity ) ;
781+ RectangleF strokeBounds = GetStrokeBounds ( geometry . Info . Bounds , command . Pen ) ;
782+ Brush sourceBrush = hasTransform ? command . Brush . Transform ( transform ) : command . Brush ;
777783
778784 if ( ! TryResolveRasterization (
779785 sourceBrush ,
780- hasTransform ? RectangleF . Transform ( GetStrokeBounds ( path . Bounds , command . Pen ) , command . Transform ) : GetStrokeBounds ( path . Bounds , command . Pen ) ,
786+ hasTransform ? RectangleF . Transform ( strokeBounds , transform ) : strokeBounds ,
781787 command . RasterizerOptions ,
782788 command . DestinationOffset ,
783789 command . TargetBounds ,
@@ -792,12 +798,12 @@ private static bool TryPrepareStrokePath(
792798 // Retained-scene preparation preserves the stroke centerline and forwards the drawing
793799 // transform into the CPU stroke rasterizer so expansion still happens before transform.
794800 DefaultRasterizer . StrokeRasterizableGeometry ? rasterizable = DefaultRasterizer . CreatePathStrokeRasterizableGeometry (
795- path ,
801+ geometry ,
796802 command . Pen ,
797803 command . DestinationOffset . X ,
798804 command . DestinationOffset . Y ,
799805 rasterizerOptions ,
800- command . Transform ,
806+ transform ,
801807 allocator ) ;
802808 if ( rasterizable is null )
803809 {
0 commit comments