Browse Source

avoid passing delegates here and there in rendering code - fixed in FormattedText.Draw

pull/559/head
donandren 10 years ago
parent
commit
6ac363bf47
  1. 4
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  2. 8
      src/Skia/Avalonia.Skia/FormattedTextImpl.cs

4
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -121,7 +121,7 @@ namespace Avalonia.Skia
} }
} }
private PaintWrapper CreatePaint(IBrush brush, Size targetSize) internal PaintWrapper CreatePaint(IBrush brush, Size targetSize)
{ {
SKPaint paint = new SKPaint(); SKPaint paint = new SKPaint();
var rv = new PaintWrapper(paint); var rv = new PaintWrapper(paint);
@ -306,7 +306,7 @@ 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(Canvas, origin.ToSKPoint(), paint, CreatePaint); textImpl.Draw(this, Canvas, origin.ToSKPoint(), paint);
} }
} }

8
src/Skia/Avalonia.Skia/FormattedTextImpl.cs

@ -181,9 +181,9 @@ namespace Avalonia.Skia
return _text; return _text;
} }
internal void Draw(SKCanvas canvas, SKPoint origin, internal void Draw(DrawingContextImpl context,
DrawingContextImpl.PaintWrapper foreground, SKCanvas canvas, SKPoint origin,
Func<IBrush, Size, DrawingContextImpl.PaintWrapper> brushFactory) DrawingContextImpl.PaintWrapper foreground)
{ {
/* TODO: This originated from Native code, it might be useful for debugging character positions as /* TODO: This originated from Native code, it might be useful for debugging character positions as
* we improve the FormattedText support. Will need to port this to C# obviously. Rmove when * we improve the FormattedText support. Will need to port this to C# obviously. Rmove when
@ -243,7 +243,7 @@ namespace Avalonia.Skia
if (fb != null) if (fb != null)
{ {
//TODO: figure out how to get the brush size //TODO: figure out how to get the brush size
currentWrapper = brushFactory(fb, new Size()); currentWrapper = context.CreatePaint(fb, new Size());
} }
else else
{ {

Loading…
Cancel
Save