Browse Source

Use GetWidenedBounds in D2D backend.

According to http://stackoverflow.com/questions/32611798, "
Geometry.Bounds (in WPF) is equivalent to
ID2D1Geometry::GetWidenedBounds(0.0f)." so use that. This seems to fix
the problem with D2D reporting an invalid size for
Line/PolylineGeometry, so removed the workaround from there.
pull/387/merge
Steven Kirk 11 years ago
parent
commit
1d8800251c
  1. 3
      src/Perspex.SceneGraph/Media/EllipseGeometry.cs
  2. 5
      src/Perspex.SceneGraph/Media/Geometry.cs
  3. 31
      src/Perspex.SceneGraph/Media/LineGeometry.cs
  4. 32
      src/Perspex.SceneGraph/Media/PolylineGeometry.cs
  5. 3
      src/Perspex.SceneGraph/Media/RectangleGeometry.cs
  6. 3
      src/Perspex.SceneGraph/Media/StreamGeometry.cs
  7. 2
      src/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs

3
src/Perspex.SceneGraph/Media/EllipseGeometry.cs

@ -49,9 +49,6 @@ namespace Perspex.Media
PlatformImpl = impl;
}
/// <inheritdoc/>
public override Rect Bounds => PlatformImpl.Bounds;
/// <inheritdoc/>
public override Geometry Clone()
{

5
src/Perspex.SceneGraph/Media/Geometry.cs

@ -31,10 +31,7 @@ namespace Perspex.Media
/// <summary>
/// Gets the geometry's bounding rectangle.
/// </summary>
public abstract Rect Bounds
{
get;
}
public Rect Bounds => PlatformImpl.Bounds;
/// <summary>
/// Gets the platform-specific implementation of the geometry.

31
src/Perspex.SceneGraph/Media/LineGeometry.cs

@ -35,37 +35,6 @@ namespace Perspex.Media
PlatformImpl = impl;
}
/// <inheritdoc/>
public override Rect Bounds
{
get
{
double xMin, yMin, xMax, yMax;
if (_startPoint.X <= _endPoint.X)
{
xMin = _startPoint.X;
xMax = _endPoint.X;
}
else
{
xMin = _endPoint.X;
xMax = _startPoint.X;
}
if (_startPoint.Y <= _endPoint.Y)
{
yMin = _startPoint.Y;
yMax = _endPoint.Y;
}
else
{
yMin = _endPoint.Y;
yMax = _startPoint.Y;
}
return new Rect(xMin, yMin, xMax - xMin, yMax - yMin);
}
}
/// <inheritdoc/>
public override Geometry Clone()
{

32
src/Perspex.SceneGraph/Media/PolylineGeometry.cs

@ -41,38 +41,6 @@ namespace Perspex.Media
PlatformImpl = impl;
}
/// <inheritdoc/>
public override Rect Bounds
{
get
{
double xMin = double.MaxValue, yMin = double.MaxValue;
double xMax = double.MinValue, yMax = double.MinValue;
foreach (var point in _points)
{
if (point.X < xMin)
{
xMin = point.X;
}
else if (point.X > xMax)
{
xMax = point.X;
}
if (point.Y < yMin)
{
yMin = point.Y;
}
else if (point.Y > yMax)
{
yMax = point.Y;
}
}
return new Rect(xMin, yMin, xMax - xMin, yMax - yMin);
}
}
/// <inheritdoc/>
public override Geometry Clone()
{

3
src/Perspex.SceneGraph/Media/RectangleGeometry.cs

@ -31,9 +31,6 @@ namespace Perspex.Media
PlatformImpl = impl;
}
/// <inheritdoc/>
public override Rect Bounds => PlatformImpl.Bounds;
/// <inheritdoc/>
public override Geometry Clone()
{

3
src/Perspex.SceneGraph/Media/StreamGeometry.cs

@ -28,9 +28,6 @@ namespace Perspex.Media
PlatformImpl = impl;
}
/// <inheritdoc/>
public override Rect Bounds => PlatformImpl.Bounds;
/// <summary>
/// Creates a <see cref="StreamGeometry"/> from a string.
/// </summary>

2
src/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs

@ -34,7 +34,7 @@ namespace Perspex.Direct2D1.Media
}
/// <inheritdoc/>
public override Rect Bounds => _path.GetBounds().ToPerspex();
public override Rect Bounds => _path.GetWidenedBounds(0).ToPerspex();
/// <inheritdoc/>
public override D2DGeometry DefiningGeometry => _path;

Loading…
Cancel
Save