Commit 13132300 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

Merge pull request #97 from articulate/BoundsPerformance

Performance Improvement
parents a653b4a4 1b8cb43f
......@@ -127,7 +127,7 @@ namespace Svg
using (var transform = EffectiveGradientTransform)
{
var bounds = renderer.GetBoundable().Bounds;
var bounds = renderer.GetBoundable().CalculateBounds();
transform.Translate(bounds.X, bounds.Y, MatrixOrder.Prepend);
if (this.GradientUnits == SvgCoordinateUnits.ObjectBoundingBox)
{
......
......@@ -114,10 +114,10 @@ namespace Svg
/// <summary>
/// Gets the bounds of the element.
/// </summary>
/// <value>The bounds.</value>
public override System.Drawing.RectangleF Bounds
/// <returns>The bounds.</returns>
public override RectangleF CalculateBounds()
{
get { return this.Path(null).GetBounds(); }
return this.Path(null).GetBounds();
}
/// <summary>
......
......@@ -18,7 +18,7 @@ namespace Svg
public void SetBoundable(ISvgBoundable boundable)
{
_boundables.Push(boundable);
_boundables.Push(new ImmutableBoundable(boundable));
}
public ISvgBoundable GetBoundable()
{
......
......@@ -109,6 +109,7 @@
<Compile Include="Document Structure\SvgSymbol.cs" />
<Compile Include="Filter Effects\ImageBuffer.cs" />
<Compile Include="Painting\GenericBoundable.cs" />
<Compile Include="Painting\ImmutableBoundable.cs" />
<Compile Include="Painting\SvgFallbackPaintServer .cs" />
<Compile Include="Paths\CoordinateParser.cs" />
<Compile Include="Rendering\IGraphicsProvider.cs" />
......
......@@ -1162,4 +1162,4 @@ namespace Svg
void Render(ISvgRenderer renderer);
}
}
\ No newline at end of file
}
......@@ -91,10 +91,10 @@ namespace Svg
/// <summary>
/// Gets the bounds of the element.
/// </summary>
/// <value>The bounds.</value>
public override System.Drawing.RectangleF Bounds
/// <returns>The bounds.</returns>
public override System.Drawing.RectangleF CalculateBounds()
{
get { return this.Path(null).GetBounds(); }
return this.Path(null).GetBounds();
}
/// <summary>
......
......@@ -227,18 +227,15 @@ namespace Svg
/// <summary>
/// Gets the bounds of the element.
/// </summary>
/// <value>The bounds.</value>
public override System.Drawing.RectangleF Bounds
/// <returns>The bounds.</returns>
public override RectangleF CalculateBounds()
{
get
var path = this.Path(null);
foreach (var elem in this.Children.OfType<SvgVisualElement>())
{
var path = this.Path(null);
foreach (var elem in this.Children.OfType<SvgVisualElement>())
{
path.AddPath(elem.Path(null), false);
}
return path.GetBounds();
path.AddPath(elem.Path(null), false);
}
return path.GetBounds();
}
/// <summary>
......@@ -495,19 +492,9 @@ namespace Svg
_width = width;
}
public PointF Location
{
get { return PointF.Empty; }
}
public SizeF Size
{
get { return new SizeF(_width, _font.Size); }
}
public RectangleF Bounds
public RectangleF CalculateBounds()
{
get { return new RectangleF(this.Location, this.Size); }
return new RectangleF(PointF.Empty, new SizeF(_width, _font.Size));
}
}
......
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