Browse Source

Renamed CurrentCanvas back to Canvas.

pull/553/head
Jeremy Koritzinsky 10 years ago
parent
commit
46e04db2ff
  1. 48
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs

48
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -12,12 +12,12 @@ namespace Avalonia.Skia
{ {
private Stack<PaintWrapper> maskStack = new Stack<PaintWrapper>(); private Stack<PaintWrapper> maskStack = new Stack<PaintWrapper>();
public SKCanvas CurrentCanvas { get; private set; } public SKCanvas Canvas { get; private set; }
public DrawingContextImpl(SKCanvas canvas) public DrawingContextImpl(SKCanvas canvas)
{ {
CurrentCanvas = canvas; Canvas = canvas;
CurrentCanvas.Clear(); Canvas.Clear();
} }
public void DrawImage(IBitmap source, double opacity, Rect sourceRect, Rect destRect) public void DrawImage(IBitmap source, double opacity, Rect sourceRect, Rect destRect)
@ -25,14 +25,14 @@ namespace Avalonia.Skia
var impl = (BitmapImpl)source.PlatformImpl; var impl = (BitmapImpl)source.PlatformImpl;
var s = sourceRect.ToSKRect(); var s = sourceRect.ToSKRect();
var d = destRect.ToSKRect(); var d = destRect.ToSKRect();
CurrentCanvas.DrawBitmap(impl.Bitmap, s, d); Canvas.DrawBitmap(impl.Bitmap, s, d);
} }
public void DrawLine(Pen pen, Point p1, Point p2) public void DrawLine(Pen pen, Point p1, Point p2)
{ {
using (var paint = CreatePaint(pen, new Size(Math.Abs(p2.X - p1.X), Math.Abs(p2.Y - p1.Y)))) using (var paint = CreatePaint(pen, new Size(Math.Abs(p2.X - p1.X), Math.Abs(p2.Y - p1.Y))))
{ {
CurrentCanvas.DrawLine((float)p1.X, (float)p1.Y, (float)p2.X, (float)p2.Y, paint.Paint); Canvas.DrawLine((float)p1.X, (float)p1.Y, (float)p2.X, (float)p2.Y, paint.Paint);
} }
} }
@ -46,11 +46,11 @@ namespace Avalonia.Skia
{ {
if (fill.Paint != null) if (fill.Paint != null)
{ {
CurrentCanvas.DrawPath(impl.EffectivePath, fill.Paint); Canvas.DrawPath(impl.EffectivePath, fill.Paint);
} }
if (stroke.Paint != null) if (stroke.Paint != null)
{ {
CurrentCanvas.DrawPath(impl.EffectivePath, stroke.Paint); Canvas.DrawPath(impl.EffectivePath, stroke.Paint);
} }
} }
} }
@ -227,11 +227,11 @@ namespace Avalonia.Skia
var rc = rect.ToSKRect(); var rc = rect.ToSKRect();
if (cornerRadius == 0) if (cornerRadius == 0)
{ {
CurrentCanvas.DrawRect(rc, paint.Paint); Canvas.DrawRect(rc, paint.Paint);
} }
else else
{ {
CurrentCanvas.DrawRoundRect(rc, cornerRadius, cornerRadius, paint.Paint); Canvas.DrawRoundRect(rc, cornerRadius, cornerRadius, paint.Paint);
} }
} }
} }
@ -243,11 +243,11 @@ namespace Avalonia.Skia
var rc = rect.ToSKRect(); var rc = rect.ToSKRect();
if (cornerRadius == 0) if (cornerRadius == 0)
{ {
CurrentCanvas.DrawRect(rc, paint.Paint); Canvas.DrawRect(rc, paint.Paint);
} }
else else
{ {
CurrentCanvas.DrawRoundRect(rc, cornerRadius, cornerRadius, paint.Paint); Canvas.DrawRoundRect(rc, cornerRadius, cornerRadius, paint.Paint);
} }
} }
} }
@ -257,19 +257,19 @@ namespace Avalonia.Skia
using (var paint = CreatePaint(foreground, text.Measure())) using (var paint = CreatePaint(foreground, text.Measure()))
{ {
var textImpl = text.PlatformImpl as FormattedTextImpl; var textImpl = text.PlatformImpl as FormattedTextImpl;
textImpl.Draw(this.CurrentCanvas, origin.ToSKPoint()); textImpl.Draw(this.Canvas, origin.ToSKPoint());
} }
} }
public void PushClip(Rect clip) public void PushClip(Rect clip)
{ {
CurrentCanvas.Save(); Canvas.Save();
CurrentCanvas.ClipRect(clip.ToSKRect()); Canvas.ClipRect(clip.ToSKRect());
} }
public void PopClip() public void PopClip()
{ {
CurrentCanvas.Restore(); Canvas.Restore();
} }
double _currentOpacity = 1.0f; double _currentOpacity = 1.0f;
@ -292,30 +292,30 @@ namespace Avalonia.Skia
public void PushGeometryClip(Geometry clip) public void PushGeometryClip(Geometry clip)
{ {
CurrentCanvas.Save(); Canvas.Save();
CurrentCanvas.ClipPath(((StreamGeometryImpl)clip.PlatformImpl).EffectivePath); Canvas.ClipPath(((StreamGeometryImpl)clip.PlatformImpl).EffectivePath);
} }
public void PopGeometryClip() public void PopGeometryClip()
{ {
CurrentCanvas.Restore(); Canvas.Restore();
} }
public void PushOpacityMask(IBrush mask, Rect bounds) public void PushOpacityMask(IBrush mask, Rect bounds)
{ {
CurrentCanvas.SaveLayer(new SKPaint()); Canvas.SaveLayer(new SKPaint());
maskStack.Push(CreatePaint(mask, bounds.Size)); maskStack.Push(CreatePaint(mask, bounds.Size));
} }
public void PopOpacityMask() public void PopOpacityMask()
{ {
CurrentCanvas.SaveLayer(new SKPaint { XferMode = SKXferMode.DstIn }); Canvas.SaveLayer(new SKPaint { XferMode = SKXferMode.DstIn });
using (var paintWrapper = maskStack.Pop()) using (var paintWrapper = maskStack.Pop())
{ {
CurrentCanvas.DrawPaint(paintWrapper.Paint); Canvas.DrawPaint(paintWrapper.Paint);
} }
CurrentCanvas.Restore(); Canvas.Restore();
CurrentCanvas.Restore(); Canvas.Restore();
} }
private Matrix _currentTransform = Matrix.Identity; private Matrix _currentTransform = Matrix.Identity;
@ -329,7 +329,7 @@ namespace Avalonia.Skia
return; return;
_currentTransform = value; _currentTransform = value;
CurrentCanvas.SetMatrix(value.ToSKMatrix()); Canvas.SetMatrix(value.ToSKMatrix());
} }
} }
} }

Loading…
Cancel
Save