@@ -18,6 +18,9 @@ namespace Windows.UI.Xaml.Shapes
18
18
{
19
19
partial class BorderLayerRenderer
20
20
{
21
+ private static SKPoint [ ] _outerRadiiStore = new SKPoint [ 4 ] ;
22
+ private static SKPoint [ ] _innerRadiiStore = new SKPoint [ 4 ] ;
23
+
21
24
private LayoutState _currentState ;
22
25
23
26
private SerialDisposable _layerDisposable = new SerialDisposable ( ) ;
@@ -120,16 +123,17 @@ private static IDisposable InnerCreateLayer(UIElement owner, LayoutState state)
120
123
. DisposeWith ( disposables ) ;
121
124
}
122
125
123
- var outerRadii = cornerRadius . GetRadii ( new Size ( area . Width , area . Height ) , borderThickness , true ) ;
124
- var innerRadii = cornerRadius . GetRadii ( new Size ( area . Width , area . Height ) , borderThickness , false ) ;
126
+ // This needs to be adjusted if multiple UI threads are used in the future for multi-window
127
+ cornerRadius . GetRadii ( ref _outerRadiiStore , new Size ( area . Width , area . Height ) , borderThickness , true ) ;
128
+ cornerRadius . GetRadii ( ref _innerRadiiStore , new Size ( area . Width , area . Height ) , borderThickness , false ) ;
125
129
126
- var borderPath = GetRoundedRect ( outerRadii , innerRadii , borderThickness , area , adjustedArea ) ;
130
+ var borderPath = GetRoundedRect ( _outerRadiiStore , _innerRadiiStore , borderThickness , area , adjustedArea ) ;
127
131
128
132
var backgroundPath = state . BackgroundSizing == BackgroundSizing . InnerBorderEdge ?
129
- GetRoundedPath ( adjustedArea . ToSKRect ( ) , innerRadii ) :
130
- GetRoundedPath ( adjustedArea . ToSKRect ( ) , outerRadii ) ;
133
+ GetRoundedPath ( adjustedArea . ToSKRect ( ) , _innerRadiiStore ) :
134
+ GetRoundedPath ( adjustedArea . ToSKRect ( ) , _outerRadiiStore ) ;
131
135
132
- var outerPath = GetRoundedPath ( area . ToSKRect ( ) , outerRadii ) ;
136
+ var outerPath = GetRoundedPath ( area . ToSKRect ( ) , _outerRadiiStore ) ;
133
137
134
138
backgroundShape . Geometry = compositor . CreatePathGeometry ( backgroundPath ) ;
135
139
borderShape . Geometry = compositor . CreatePathGeometry ( borderPath ) ;
@@ -319,8 +323,6 @@ private static CompositionPath GetRoundedPath(SKRect area, SKPoint[] radii, Skia
319
323
geometrySource ??= new SkiaGeometrySource2D ( ) ;
320
324
var geometry = geometrySource . Geometry ;
321
325
322
- // How ArcTo works:
323
- // http://www.twistedape.me.uk/blog/2013/09/23/what-arctopointdoes/
324
326
var roundRect = new SKRoundRect ( ) ;
325
327
roundRect . SetRectRadii ( area , radii ) ;
326
328
geometry . AddRoundRect ( roundRect ) ;
0 commit comments