Merge remote-tracking branch 'origin/patch/v2.80.4'
This commit is contained in:
Коммит
f8dbe84f96
|
@ -14,6 +14,7 @@ namespace SkiaSharp
|
|||
public unsafe class SKPaint : SKObject, ISKSkipObjectRegistration
|
||||
{
|
||||
private SKFont font;
|
||||
private bool lcdRenderText;
|
||||
|
||||
internal SKPaint (IntPtr handle, bool owns)
|
||||
: base (handle, owns)
|
||||
|
@ -38,6 +39,8 @@ namespace SkiaSharp
|
|||
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new InvalidOperationException ("Unable to create a new SKPaint instance.");
|
||||
|
||||
LcdRenderText = font.Edging == SKFontEdging.SubpixelAntialias;
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing) =>
|
||||
|
@ -55,7 +58,10 @@ namespace SkiaSharp
|
|||
|
||||
public bool IsAntialias {
|
||||
get => SkiaApi.sk_paint_is_antialias (Handle);
|
||||
set => SkiaApi.sk_paint_set_antialias (Handle, value);
|
||||
set {
|
||||
SkiaApi.sk_paint_set_antialias (Handle, value);
|
||||
UpdateFontEdging (value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDither {
|
||||
|
@ -81,8 +87,11 @@ namespace SkiaSharp
|
|||
}
|
||||
|
||||
public bool LcdRenderText {
|
||||
get => GetFont ().Edging == SKFontEdging.SubpixelAntialias;
|
||||
set => GetFont ().Edging = value ? SKFontEdging.SubpixelAntialias : SKFontEdging.Antialias;
|
||||
get => lcdRenderText;
|
||||
set {
|
||||
lcdRenderText = value;
|
||||
UpdateFontEdging (IsAntialias);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEmbeddedBitmapText {
|
||||
|
@ -701,6 +710,17 @@ namespace SkiaSharp
|
|||
internal SKFont GetFont () =>
|
||||
font ??= OwnedBy (SKFont.GetObject (SkiaApi.sk_compatpaint_get_font (Handle), false), this);
|
||||
|
||||
private void UpdateFontEdging (bool antialias)
|
||||
{
|
||||
var edging = SKFontEdging.Alias;
|
||||
if (antialias) {
|
||||
edging = lcdRenderText
|
||||
? SKFontEdging.SubpixelAntialias
|
||||
: SKFontEdging.Antialias;
|
||||
}
|
||||
GetFont ().Edging = edging;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
internal static SKPaint GetObject (IntPtr handle) =>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit afebb8307c05be3e11bc3cf71cb2270da771ed88
|
||||
Subproject commit b2c81806f30929802d755eab1e49ee1024a950dc
|
|
@ -831,7 +831,7 @@ stages:
|
|||
notifyAlwaysV2: false
|
||||
instanceUrlForTsaV2: 'DEVDIV'
|
||||
projectNameDEVDIV: 'DevDiv'
|
||||
areaPath: 'DevDiv\Xamarin SDK\SkiaSharp'
|
||||
areaPath: 'DevDiv\VS Client - Runtime SDKs\SkiaSharp'
|
||||
iterationPath: 'DevDiv\OneVS'
|
||||
uploadAPIScan: false
|
||||
uploadBinSkim: false
|
||||
|
|
|
@ -46,5 +46,19 @@ namespace SkiaSharp.Views.UWP
|
|||
// draw the surface to the context
|
||||
drawable.DrawSurface(ctx, Bounds, info, surface);
|
||||
}
|
||||
|
||||
public override void WillMoveToWindow(UIWindow window)
|
||||
{
|
||||
if (drawable != null)
|
||||
{
|
||||
// release the memory if we are leaving the window
|
||||
if (window == null)
|
||||
drawable?.Dispose();
|
||||
else
|
||||
SetNeedsDisplay();
|
||||
}
|
||||
|
||||
base.WillMoveToWindow(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,15 @@ namespace SkiaSharp.Views.Mac
|
|||
if (bitmapData == null)
|
||||
{
|
||||
bitmapData = NSMutableData.FromLength(info.BytesSize);
|
||||
|
||||
// in case allocation has failed
|
||||
if (bitmapData == null)
|
||||
{
|
||||
Dispose();
|
||||
info = Info;
|
||||
return null;
|
||||
}
|
||||
|
||||
dataProvider = new CGDataProvider(bitmapData.MutableBytes, info.BytesSize, Dummy);
|
||||
|
||||
void Dummy(IntPtr data)
|
||||
|
|
|
@ -105,6 +105,20 @@ namespace SkiaSharp.Views.iOS
|
|||
}
|
||||
}
|
||||
|
||||
public override void WillMoveToWindow(UIWindow window)
|
||||
{
|
||||
if (drawable != null)
|
||||
{
|
||||
// release the memory if we are leaving the window
|
||||
if (window == null)
|
||||
drawable?.Dispose();
|
||||
else
|
||||
SetNeedsDisplay();
|
||||
}
|
||||
|
||||
base.WillMoveToWindow(window);
|
||||
}
|
||||
|
||||
public event EventHandler<SKPaintSurfaceEventArgs> PaintSurface;
|
||||
|
||||
protected virtual void OnPaintSurface(SKPaintSurfaceEventArgs e)
|
||||
|
|
|
@ -554,5 +554,92 @@ namespace SkiaSharp.Tests
|
|||
|
||||
Assert.NotNull(paint.GetTextPath("", 0, 0));
|
||||
}
|
||||
|
||||
[SkippableTheory]
|
||||
[InlineData(true, true, SKFontEdging.SubpixelAntialias)]
|
||||
[InlineData(false, true, SKFontEdging.Alias)]
|
||||
[InlineData(true, false, SKFontEdging.Antialias)]
|
||||
[InlineData(false, false, SKFontEdging.Alias)]
|
||||
public void UpdatingPropertiesIsAntialiasLcdRenderText(bool isAntialias, bool lcd, SKFontEdging newEdging)
|
||||
{
|
||||
var paint = new SKPaint();
|
||||
|
||||
paint.IsAntialias = isAntialias;
|
||||
paint.LcdRenderText = lcd;
|
||||
|
||||
Assert.Equal(newEdging, paint.GetFont().Edging);
|
||||
}
|
||||
|
||||
[SkippableTheory]
|
||||
[InlineData(true, true, SKFontEdging.SubpixelAntialias)]
|
||||
[InlineData(false, true, SKFontEdging.Alias)]
|
||||
[InlineData(true, false, SKFontEdging.Antialias)]
|
||||
[InlineData(false, false, SKFontEdging.Alias)]
|
||||
public void UpdatingPropertiesLcdRenderTextIsAntialias(bool isAntialias, bool lcd, SKFontEdging newEdging)
|
||||
{
|
||||
var paint = new SKPaint();
|
||||
|
||||
paint.LcdRenderText = lcd;
|
||||
paint.IsAntialias = isAntialias;
|
||||
|
||||
Assert.Equal(newEdging, paint.GetFont().Edging);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void PaintWithSubpixelEdgingIsPreserved()
|
||||
{
|
||||
var font = new SKFont();
|
||||
font.Edging = SKFontEdging.SubpixelAntialias;
|
||||
|
||||
var paint = new SKPaint(font);
|
||||
|
||||
Assert.True(paint.LcdRenderText);
|
||||
Assert.False(paint.IsAntialias);
|
||||
Assert.Equal(SKFontEdging.Alias, paint.GetFont().Edging);
|
||||
|
||||
paint.IsAntialias = true;
|
||||
|
||||
Assert.True(paint.LcdRenderText);
|
||||
Assert.True(paint.IsAntialias);
|
||||
Assert.Equal(SKFontEdging.SubpixelAntialias, paint.GetFont().Edging);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void PaintWithAntialiasEdgingIsPreserved()
|
||||
{
|
||||
var font = new SKFont();
|
||||
font.Edging = SKFontEdging.Antialias;
|
||||
|
||||
var paint = new SKPaint(font);
|
||||
|
||||
Assert.False(paint.LcdRenderText);
|
||||
Assert.False(paint.IsAntialias);
|
||||
Assert.Equal(SKFontEdging.Alias, paint.GetFont().Edging);
|
||||
|
||||
paint.IsAntialias = true;
|
||||
|
||||
Assert.False(paint.LcdRenderText);
|
||||
Assert.True(paint.IsAntialias);
|
||||
Assert.Equal(SKFontEdging.Antialias, paint.GetFont().Edging);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void PaintWithAliasEdgingIsPreserved()
|
||||
{
|
||||
var font = new SKFont();
|
||||
font.Edging = SKFontEdging.Alias;
|
||||
|
||||
var paint = new SKPaint(font);
|
||||
|
||||
Assert.False(paint.LcdRenderText);
|
||||
Assert.False(paint.IsAntialias);
|
||||
Assert.Equal(SKFontEdging.Alias, paint.GetFont().Edging);
|
||||
|
||||
paint.IsAntialias = true;
|
||||
|
||||
Assert.False(paint.LcdRenderText);
|
||||
Assert.True(paint.IsAntialias);
|
||||
Assert.Equal(SKFontEdging.Antialias, paint.GetFont().Edging);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче