Browse Source

Restored clip + Don't crash when something is zero or null

pull/310/head
Nikita Tsukanov 11 years ago
parent
commit
3fa46bda9f
  1. 6
      src/Skia/Perspex.Skia/DrawingContextImpl.cs
  2. 11
      src/Skia/Perspex.Skia/FormattedTextImpl.cs

6
src/Skia/Perspex.Skia/DrawingContextImpl.cs

@ -123,7 +123,7 @@ namespace Perspex.Skia
brush.Brush->StrokeLineCap = pen.StartLineCap;
brush.Brush->StrokeMiterLimit = (float)pen.MiterLimit;
if (pen.DashStyle != null)
if (pen.DashStyle?.Dashes != null)
{
var dashes = pen.DashStyle.Dashes;
if (dashes.Count > NativeBrush.MaxDashCount)
@ -168,12 +168,12 @@ namespace Perspex.Skia
public void PushClip(Rect clip)
{
var rc = SkRect.FromRect(clip);
//MethodTable.Instance.PushClip(Handle, ref rc);
MethodTable.Instance.PushClip(Handle, ref rc);
}
public void PopClip()
{
//MethodTable.Instance.PopClip(Handle);
MethodTable.Instance.PopClip(Handle);
}
private readonly Stack<double> _opacityStack = new Stack<double>();

11
src/Skia/Perspex.Skia/FormattedTextImpl.cs

@ -56,6 +56,8 @@ namespace Perspex.Skia
public Rect HitTestTextPosition(int index)
{
if (index < 0 || index >= _rects.Count)
return new Rect();
return _rects[index];
}
@ -89,8 +91,13 @@ namespace Perspex.Skia
}
for (var c = 0; c < _text.Length; c++)
_rects.Add(_shared->Bounds[c].ToRect());
var lastLine = _shared->Lines[_shared->LineCount - 1];
_size = new Size(maxX, lastLine.Top + lastLine.Height);
if (_shared->LineCount == 0)
_size = new Size();
else
{
var lastLine = _shared->Lines[_shared->LineCount - 1];
_size = new Size(maxX, lastLine.Top + lastLine.Height);
}
}
void Rebuild()

Loading…
Cancel
Save