Skip to content

Commit 11be122

Browse files
committed
Performance improvement
1 parent 41097fb commit 11be122

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Myra/Graphics2D/UI/Widget.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -850,19 +850,24 @@ public void Render(RenderContext context)
850850
context.Transform = Transform;
851851

852852
Rectangle? oldScissorRectangle = null;
853-
if (ClipToBounds && context.Transform.Rotation == 0)
853+
if (context.Transform.Rotation.IsZero())
854854
{
855-
oldScissorRectangle = context.Scissor;
856855
var absoluteBounds = context.Transform.Apply(Bounds);
857-
var newScissorRectangle = Rectangle.Intersect(context.Scissor, absoluteBounds);
856+
var scissorBounds = Rectangle.Intersect(context.Scissor, absoluteBounds);
858857

859-
if (newScissorRectangle.Width == 0 || newScissorRectangle.Height == 0)
858+
if (scissorBounds.Width == 0 || scissorBounds.Height == 0)
860859
{
860+
// Culled by scissor
861861
context.Transform = oldTransform;
862862
return;
863863
}
864864

865-
context.Scissor = newScissorRectangle;
865+
if (ClipToBounds)
866+
{
867+
oldScissorRectangle = context.Scissor;
868+
869+
context.Scissor = scissorBounds;
870+
}
866871
}
867872

868873
var oldOpacity = context.Opacity;
@@ -1431,7 +1436,7 @@ public Widget Clone()
14311436
result.CopyFrom(this);
14321437

14331438
// Copy attached properties
1434-
foreach(var pair in AttachedPropertiesValues)
1439+
foreach (var pair in AttachedPropertiesValues)
14351440
{
14361441
result.AttachedPropertiesValues[pair.Key] = pair.Value;
14371442
}

0 commit comments

Comments
 (0)