Commit a826856b authored by owaits's avatar owaits
Browse files

Correctly caches the clip path and re-generates if dirty.

parent 898d89e1
...@@ -28,25 +28,27 @@ namespace Svg ...@@ -28,25 +28,27 @@ namespace Svg
this.ClipPathUnits = SvgCoordinateUnits.ObjectBoundingBox; this.ClipPathUnits = SvgCoordinateUnits.ObjectBoundingBox;
} }
private GraphicsPath cachedClipPath = null;
/// <summary> /// <summary>
/// Gets this <see cref="SvgClipPath"/>'s region to be used as a clipping region. /// Gets this <see cref="SvgClipPath"/>'s region to be used as a clipping region.
/// </summary> /// </summary>
/// <returns>A new <see cref="Region"/> containing the <see cref="Region"/> to be used for clipping.</returns> /// <returns>A new <see cref="Region"/> containing the <see cref="Region"/> to be used for clipping.</returns>
public Region GetClipRegion(SvgVisualElement owner) public Region GetClipRegion(SvgVisualElement owner)
{ {
var path = new GraphicsPath(); if (cachedClipPath == null || this._pathDirty)
if (this._pathDirty)
{ {
cachedClipPath = new GraphicsPath();
foreach (SvgElement element in this.Children) foreach (SvgElement element in this.Children)
{ {
this.CombinePaths(path, element); this.CombinePaths(cachedClipPath, element);
} }
this._pathDirty = false; this._pathDirty = false;
} }
return new Region(path); return new Region(cachedClipPath);
} }
/// <summary> /// <summary>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment