Browse Source

Updated libs with API changes.

scenegraph-after-breakage
Steven Kirk 10 years ago
parent
commit
458007a106
  1. 2
      src/Gtk/Avalonia.Cairo/Avalonia.Cairo.v2.ncrunchproject
  2. 13
      src/Gtk/Avalonia.Cairo/Media/DrawingContext.cs
  3. 9
      src/Gtk/Avalonia.Cairo/Media/FormattedTextImpl.cs
  4. 2
      src/Gtk/Avalonia.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs
  5. 2
      src/Gtk/Avalonia.Cairo/Media/TileBrushes.cs
  6. 4
      src/Gtk/Avalonia.Cairo/RenderTarget.cs
  7. 8
      src/Skia/Avalonia.Skia.Android/Avalonia.Skia.Android.v2.ncrunchproject
  8. 6
      src/Skia/Avalonia.Skia.Desktop/Avalonia.Skia.Desktop.v2.ncrunchproject
  9. 13
      src/Skia/Avalonia.Skia.Desktop/RenderTarget.cs
  10. 12
      src/Skia/Avalonia.Skia.iOS/RenderTarget.cs
  11. 4
      src/Skia/Avalonia.Skia/BitmapImpl.cs
  12. 15
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  13. 28
      src/Skia/Avalonia.Skia/FormattedTextImpl.cs
  14. 6
      tests/Avalonia.RenderTests/Avalonia.Skia.RenderTests.v2.ncrunchproject

2
src/Gtk/Avalonia.Cairo/Avalonia.Cairo.v2.ncrunchproject

@ -7,7 +7,7 @@
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<AllowCodeAnalysis>false</AllowCodeAnalysis>
<IgnoreThisComponentCompletely>true</IgnoreThisComponentCompletely>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>

13
src/Gtk/Avalonia.Cairo/Media/DrawingContext.cs

@ -12,6 +12,7 @@ using Avalonia.Media;
namespace Avalonia.Cairo.Media
{
using Avalonia.Media.Imaging;
using Platform;
using Cairo = global::Cairo;
/// <summary>
@ -75,9 +76,9 @@ namespace Avalonia.Cairo.Media
/// <param name="opacity">The opacity to draw with.</param>
/// <param name="sourceRect">The rect in the image to draw.</param>
/// <param name="destRect">The rect in the output to draw to.</param>
public void DrawImage(IBitmap bitmap, double opacity, Rect sourceRect, Rect destRect)
public void DrawImage(IBitmapImpl bitmap, double opacity, Rect sourceRect, Rect destRect)
{
var impl = bitmap.PlatformImpl as BitmapImpl;
var impl = bitmap as BitmapImpl;
var size = new Size(impl.PixelWidth, impl.PixelHeight);
var scale = new Vector(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);
@ -137,9 +138,9 @@ namespace Avalonia.Cairo.Media
/// <param name="brush">The fill brush.</param>
/// <param name="pen">The stroke pen.</param>
/// <param name="geometry">The geometry.</param>
public void DrawGeometry(IBrush brush, Pen pen, Geometry geometry)
public void DrawGeometry(IBrush brush, Pen pen, IGeometryImpl geometry)
{
var impl = geometry.PlatformImpl as StreamGeometryImpl;
var impl = geometry as StreamGeometryImpl;
var oldMatrix = Transform;
Transform = impl.Transform * Transform;
@ -192,9 +193,9 @@ namespace Avalonia.Cairo.Media
/// <param name="foreground">The foreground brush.</param>
/// <param name="origin">The upper-left corner of the text.</param>
/// <param name="text">The text.</param>
public void DrawText(IBrush foreground, Point origin, FormattedText text)
public void DrawText(IBrush foreground, Point origin, IFormattedTextImpl text)
{
var layout = ((FormattedTextImpl)text.PlatformImpl).Layout;
var layout = ((FormattedTextImpl)text).Layout;
_context.MoveTo(origin.X, origin.Y);
using (var b = SetBrush(foreground, new Size(0, 0)))

9
src/Gtk/Avalonia.Cairo/Media/FormattedTextImpl.cs

@ -13,7 +13,6 @@ namespace Avalonia.Cairo.Media
public class FormattedTextImpl : IFormattedTextImpl
{
private Size _size;
private readonly string _text;
static double CorrectScale(double input)
{
@ -32,7 +31,7 @@ namespace Avalonia.Cairo.Media
Contract.Requires<ArgumentNullException>(context != null);
Contract.Requires<ArgumentNullException>(text != null);
Layout = new Pango.Layout(context);
_text = text;
Text = text;
Layout.SetText(text);
Layout.FontDescription = new Pango.FontDescription
{
@ -46,6 +45,8 @@ namespace Avalonia.Cairo.Media
Layout.Attributes = new Pango.AttrList();
}
public string Text { get; }
public Size Constraint
{
get
@ -99,7 +100,7 @@ namespace Avalonia.Cairo.Media
int PangoIndexToTextIndex(int pangoIndex)
{
return Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(_text), 0, Math.Min(pangoIndex, _text.Length)).Length;
return Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(Text), 0, Math.Min(pangoIndex, Text.Length)).Length;
}
public Rect HitTestTextPosition(int index)
@ -109,7 +110,7 @@ namespace Avalonia.Cairo.Media
int TextIndexToPangoIndex(int textIndex)
{
return Encoding.UTF8.GetByteCount(textIndex < _text.Length ? _text.Remove(textIndex) : _text);
return Encoding.UTF8.GetByteCount(textIndex < Text.Length ? Text.Remove(textIndex) : Text);
}
public IEnumerable<Rect> HitTestTextRange(int index, int length)

2
src/Gtk/Avalonia.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs

@ -40,7 +40,7 @@ namespace Avalonia.Cairo.Media.Imaging
Surface.WriteToPng(fileName);
}
public Avalonia.Media.DrawingContext CreateDrawingContext()
public IDrawingContextImpl CreateDrawingContext()
{
return _renderTarget.CreateDrawingContext();
}

2
src/Gtk/Avalonia.Cairo/Media/TileBrushes.cs

@ -23,7 +23,7 @@ namespace Avalonia.Cairo.Media
using (var intermediate = new ImageSurface(Format.ARGB32, (int)helper.IntermediateSize.Width, (int)helper.IntermediateSize.Height))
using (var ctx = new RenderTarget(intermediate).CreateDrawingContext())
{
helper.DrawIntermediate(ctx);
helper.DrawIntermediate(new Avalonia.Media.DrawingContext(ctx));
var result = new SurfacePattern(intermediate);

4
src/Gtk/Avalonia.Cairo/RenderTarget.cs

@ -48,9 +48,7 @@ namespace Avalonia.Cairo
/// Creates a cairo surface that targets a platform-specific resource.
/// </summary>
/// <returns>A surface wrapped in an <see cref="Avalonia.Media.DrawingContext"/>.</returns>
public DrawingContext CreateDrawingContext() => new DrawingContext(CreateMediaDrawingContext());
public IDrawingContextImpl CreateMediaDrawingContext()
public IDrawingContextImpl CreateDrawingContext()
{
if (_window != null)
return new Media.DrawingContext(_window.GdkWindow);

8
src/Skia/Avalonia.Skia.Android/Avalonia.Skia.Android.v2.ncrunchproject

@ -7,7 +7,7 @@
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<AllowCodeAnalysis>false</AllowCodeAnalysis>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<IgnoreThisComponentCompletely>true</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
@ -17,9 +17,9 @@
<DetectStackOverflow>true</DetectStackOverflow>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<UseBuildPlatform />
<ProxyProcessPath />
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>

6
src/Skia/Avalonia.Skia.Desktop/Avalonia.Skia.Desktop.v2.ncrunchproject

@ -17,9 +17,9 @@
<DetectStackOverflow>true</DetectStackOverflow>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<UseBuildPlatform />
<ProxyProcessPath />
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>

13
src/Skia/Avalonia.Skia.Desktop/RenderTarget.cs

@ -12,11 +12,9 @@ namespace Avalonia.Skia
{
public SKSurface Surface { get; protected set; }
public virtual DrawingContext CreateDrawingContext()
public virtual IDrawingContextImpl CreateDrawingContext()
{
return
new DrawingContext(
new DrawingContextImpl(Surface.Canvas));
return new DrawingContextImpl(Surface.Canvas);
}
public void Dispose()
@ -102,7 +100,7 @@ namespace Avalonia.Skia
return new Size(96, 96);
}
public override DrawingContext CreateDrawingContext()
public override IDrawingContextImpl CreateDrawingContext()
{
FixSize();
@ -127,9 +125,8 @@ namespace Avalonia.Skia
}
}
var result =
new DrawingContext(
new WindowDrawingContextImpl(this), Matrix.CreateScale(scale, scale));
// TODO: Broken DPI scaling on skia here. Fix this.
var result = new WindowDrawingContextImpl(this);
return result;
}

12
src/Skia/Avalonia.Skia.iOS/RenderTarget.cs

@ -11,11 +11,9 @@ namespace Avalonia.Skia
{
public SKSurface Surface { get; protected set; }
public virtual DrawingContext CreateDrawingContext()
public virtual IDrawingContextImpl CreateDrawingContext()
{
return
new DrawingContext(
new DrawingContextImpl(Surface.Canvas));
return new DrawingContextImpl(Surface.Canvas);
}
public void Dispose()
@ -90,7 +88,7 @@ namespace Avalonia.Skia
h = (int)bounds.Height;
}
public override DrawingContext CreateDrawingContext()
public override IDrawingContextImpl CreateDrawingContext()
{
FixSize();
@ -104,9 +102,7 @@ namespace Avalonia.Skia
canvas.Clear(SKColors.Red);
canvas.ResetMatrix();
return
new DrawingContext(
new WindowDrawingContextImpl(this));
return new WindowDrawingContextImpl(this);
}
public void Present()

4
src/Skia/Avalonia.Skia/BitmapImpl.cs

@ -74,10 +74,10 @@ namespace Avalonia.Skia
}
}
public DrawingContext CreateDrawingContext()
public IDrawingContextImpl CreateDrawingContext()
{
return new DrawingContext(new BitmapDrawingContext(Bitmap));
return new BitmapDrawingContext(Bitmap);
}
public void Save(Stream stream)

15
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@ -5,6 +5,7 @@ using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia.Platform;
namespace Avalonia.Skia
{
@ -20,9 +21,9 @@ namespace Avalonia.Skia
Canvas.Clear();
}
public void DrawImage(IBitmap source, double opacity, Rect sourceRect, Rect destRect)
public void DrawImage(IBitmapImpl source, double opacity, Rect sourceRect, Rect destRect)
{
var impl = (BitmapImpl)source.PlatformImpl;
var impl = (BitmapImpl)source;
var s = sourceRect.ToSKRect();
var d = destRect.ToSKRect();
using (var paint = new SKPaint()
@ -40,9 +41,9 @@ namespace Avalonia.Skia
}
}
public void DrawGeometry(IBrush brush, Pen pen, Geometry geometry)
public void DrawGeometry(IBrush brush, Pen pen, IGeometryImpl geometry)
{
var impl = ((StreamGeometryImpl)geometry.PlatformImpl);
var impl = (StreamGeometryImpl)geometry;
var size = geometry.Bounds.Size;
using (var fill = brush != null ? CreatePaint(brush, size) : default(PaintWrapper))
@ -188,7 +189,7 @@ namespace Avalonia.Skia
var bitmap = new BitmapImpl((int)helper.IntermediateSize.Width, (int)helper.IntermediateSize.Height);
rv.AddDisposable(bitmap);
using (var ctx = bitmap.CreateDrawingContext())
helper.DrawIntermediate(ctx);
helper.DrawIntermediate(new DrawingContext(ctx));
SKMatrix translation = SKMatrix.MakeTranslation(-(float)helper.DestinationRect.X, -(float)helper.DestinationRect.Y);
SKShaderTileMode tileX =
tileBrush.TileMode == TileMode.None
@ -278,11 +279,11 @@ namespace Avalonia.Skia
}
}
public void DrawText(IBrush foreground, Point origin, FormattedText text)
public void DrawText(IBrush foreground, Point origin, IFormattedTextImpl text)
{
using (var paint = CreatePaint(foreground, text.Measure()))
{
var textImpl = text.PlatformImpl as FormattedTextImpl;
var textImpl = text as FormattedTextImpl;
textImpl.Draw(this, Canvas, origin.ToSKPoint(), paint);
}
}

28
src/Skia/Avalonia.Skia/FormattedTextImpl.cs

@ -15,10 +15,10 @@ namespace Avalonia.Skia
public FormattedTextImpl(string text, string fontFamilyName, double fontSize, FontStyle fontStyle,
TextAlignment textAlignment, FontWeight fontWeight, TextWrapping wrapping)
{
_text = text ?? string.Empty;
Text = text ?? string.Empty;
// Replace 0 characters with zero-width spaces (200B)
_text = _text.Replace((char)0, (char)0x200B);
Text = Text.Replace((char)0, (char)0x200B);
var typeface = TypefaceCache.GetTypeface(fontFamilyName, fontStyle, fontWeight);
@ -98,7 +98,7 @@ namespace Avalonia.Skia
{
IsInside = false,
TextPosition = line.Start + offset,
IsTrailing = _text.Length == (line.Start + offset + 1)
IsTrailing = Text.Length == (line.Start + offset + 1)
};
}
@ -108,7 +108,7 @@ namespace Avalonia.Skia
{
IsInside = false,
IsTrailing = end,
TextPosition = end ? _text.Length - 1 : 0
TextPosition = end ? Text.Length - 1 : 0
};
}
@ -182,7 +182,7 @@ namespace Avalonia.Skia
public override string ToString()
{
return _text;
return Text;
}
internal void Draw(DrawingContextImpl context,
@ -231,7 +231,7 @@ namespace Avalonia.Skia
if (!hasCusomFGBrushes)
{
var subString = _text.Substring(line.Start, line.Length);
var subString = Text.Substring(line.Start, line.Length);
canvas.DrawText(subString, x, origin.Y + line.Top + _lineOffset, paint);
}
else
@ -255,7 +255,7 @@ namespace Avalonia.Skia
currentWrapper = foreground;
}
subStr = _text.Substring(i, len);
subStr = Text.Substring(i, len);
if (currFGPaint != currentWrapper.Paint)
{
@ -284,7 +284,7 @@ namespace Avalonia.Skia
private readonly List<FormattedTextLine> _lines = new List<FormattedTextLine>();
private readonly SKPaint _paint;
private readonly List<Rect> _rects = new List<Rect>();
private readonly string _text;
public string Text { get; }
private readonly TextWrapping _wrapping;
private Size _constraint = new Size(double.PositiveInfinity, double.PositiveInfinity);
private float _lineHeight = 0;
@ -434,7 +434,7 @@ namespace Avalonia.Skia
for (int i = line.Start; i < line.Start + line.TextLength; i++)
{
float w = _paint.MeasureText(_text[i].ToString());
float w = _paint.MeasureText(Text[i].ToString());
_rects.Add(new Rect(
prevRight,
@ -490,7 +490,7 @@ namespace Avalonia.Skia
private List<Rect> GetRects()
{
if (_text.Length > _rects.Count)
if (Text.Length > _rects.Count)
{
BuildRects();
}
@ -500,7 +500,7 @@ namespace Avalonia.Skia
private void Rebuild()
{
var length = _text.Length;
var length = Text.Length;
_lines.Clear();
_rects.Clear();
@ -536,7 +536,7 @@ namespace Avalonia.Skia
int measured;
int trailingnumber = 0;
subString = _text.Substring(curOff);
subString = Text.Substring(curOff);
float constraint = -1;
@ -547,12 +547,12 @@ namespace Avalonia.Skia
constraint = MAX_LINE_WIDTH;
}
measured = LineBreak(_text, curOff, length, _paint, constraint, out trailingnumber);
measured = LineBreak(Text, curOff, length, _paint, constraint, out trailingnumber);
AvaloniaFormattedTextLine line = new AvaloniaFormattedTextLine();
line.TextLength = measured;
subString = _text.Substring(line.Start, line.TextLength);
subString = Text.Substring(line.Start, line.TextLength);
lineWidth = _paint.MeasureText(subString);
line.Start = curOff;
line.Length = measured - trailingnumber;

6
tests/Avalonia.RenderTests/Avalonia.Skia.RenderTests.v2.ncrunchproject

@ -17,9 +17,9 @@
<DetectStackOverflow>true</DetectStackOverflow>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<UseBuildPlatform />
<ProxyProcessPath />
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>

Loading…
Cancel
Save