Added bindings for SkOverdrawCanvas

- also set flags to reduce file sizes
This commit is contained in:
Matthew Leibowitz 2018-07-21 22:35:05 +02:00
Родитель 462d3a126d
Коммит 04883d0fb6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3650EBE4AA155AF9
4 изменённых файлов: 49 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,22 @@
using System;
namespace SkiaSharp
{
public class SKOverdrawCanvas : SKNWayCanvas
{
[Preserve]
internal SKOverdrawCanvas (IntPtr handle, bool owns)
: base (handle, owns)
{
}
public SKOverdrawCanvas (SKCanvas canvas)
: this (IntPtr.Zero, true)
{
if (canvas == null)
throw new ArgumentNullException (nameof (canvas));
Handle = SkiaApi.sk_overdraw_canvas_new (canvas.Handle);
}
}
}

Просмотреть файл

@ -7,6 +7,7 @@ using GRBackendObject = System.IntPtr;
using sk_surface_t = System.IntPtr;
using sk_canvas_t = System.IntPtr;
using sk_nodraw_canvas_t = System.IntPtr;
using sk_overdraw_canvas_t = System.IntPtr;
using sk_nway_canvas_t = System.IntPtr;
using sk_image_t = System.IntPtr;
using sk_paint_t = System.IntPtr;
@ -317,6 +318,12 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_nway_canvas_remove_all(sk_nway_canvas_t t);
// overdraw canvas
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_overdraw_canvas_t sk_overdraw_canvas_new(sk_canvas_t canvas);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_overdraw_canvas_destroy(sk_overdraw_canvas_t canvas);
// paint
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_paint_t sk_paint_new();

2
externals/skia поставляемый

@ -1 +1 @@
Subproject commit 65cfd58f44c312e418a73551850f467a27ab4acf
Subproject commit d42756a5d583b02ee472e8c747a905c31e2c5f2b

Просмотреть файл

@ -91,6 +91,25 @@ namespace SkiaSharp.Tests
}
}
[SkippableFact]
public void OverdrawCanvasDrawsProperly()
{
using (var bitmap = new SKBitmap(new SKImageInfo(100, 100)))
using (var canvas = new SKCanvas(bitmap))
using (var overdraw = new SKOverdrawCanvas(canvas))
{
bitmap.Erase(SKColors.Transparent);
overdraw.DrawRect(SKRect.Create(10, 10, 30, 30), new SKPaint());
overdraw.DrawRect(SKRect.Create(20, 20, 30, 30), new SKPaint());
Assert.Equal(0, bitmap.GetPixel(5, 5).Alpha);
Assert.Equal(1, bitmap.GetPixel(15, 15).Alpha);
Assert.Equal(2, bitmap.GetPixel(25, 25).Alpha);
Assert.Equal(1, bitmap.GetPixel(45, 45).Alpha);
}
}
[SkippableFact]
public void SvgCanvasSavesFile()
{