A few changes
This commit is contained in:
Родитель
fda999a93b
Коммит
c02beb12b1
|
@ -42,18 +42,26 @@ namespace SkiaSharp.Views.Forms
|
|||
if (!oneShot && !Element.HasRenderLoop)
|
||||
return;
|
||||
|
||||
// if this is a one shot request, don't bother with the display link
|
||||
if (oneShot)
|
||||
{
|
||||
var nativeView = Control;
|
||||
nativeView?.Display();
|
||||
return;
|
||||
}
|
||||
|
||||
// create the loop
|
||||
displayLink = new CVDisplayLink();
|
||||
displayLink.SetOutputCallback(delegate
|
||||
{
|
||||
var formsView = Control;
|
||||
var nativeView = Element;
|
||||
var nativeView = Control;
|
||||
var formsView = Element;
|
||||
|
||||
// redraw the view
|
||||
formsView?.Display();
|
||||
nativeView?.Display();
|
||||
|
||||
// stop the render loop if this was a one-shot, or the views are disposed
|
||||
if (formsView == null || nativeView == null || !nativeView.HasRenderLoop)
|
||||
if (nativeView == null || formsView == null || !formsView.HasRenderLoop)
|
||||
{
|
||||
displayLink.Stop();
|
||||
displayLink.Dispose();
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace SkiaSharp.Views.Forms
|
|||
|
||||
base.OnElementChanged(e);
|
||||
}
|
||||
|
||||
|
||||
#if __ANDROID__
|
||||
protected override TNativeView CreateNativeControl()
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ namespace SkiaSharp.Views.Forms
|
|||
{
|
||||
base.OnElementPropertyChanged(sender, e);
|
||||
|
||||
if (e.PropertyName == nameof(SKFormsView.IgnorePixelScaling))
|
||||
if (e.PropertyName == SKFormsView.IgnorePixelScalingProperty.PropertyName)
|
||||
{
|
||||
Control.IgnorePixelScaling = Element.IgnorePixelScaling;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace SkiaSharp.Views.Forms
|
|||
private void OnPaintSurface(object sender, SKNativePaintGLSurfaceEventArgs e)
|
||||
{
|
||||
var controller = Element as ISKGLViewController;
|
||||
|
||||
|
||||
// the control is being repainted, let the user know
|
||||
controller?.OnPaintSurface(new SKPaintGLSurfaceEventArgs(e.Surface, e.RenderTarget));
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace SkiaSharp.Views.Forms
|
|||
[RenderWith(typeof(SKCanvasViewRenderer))]
|
||||
public class SKCanvasView : View, ISKCanvasViewController
|
||||
{
|
||||
public static readonly BindableProperty IgnorePixelScalingProperty =
|
||||
BindableProperty.Create(nameof(IgnorePixelScaling), typeof(bool), typeof(SKCanvasView), default(bool));
|
||||
public static readonly BindableProperty IgnorePixelScalingProperty =
|
||||
BindableProperty.Create(nameof(IgnorePixelScaling), typeof(bool), typeof(SKCanvasView), false);
|
||||
|
||||
// the user can subscribe to repaint
|
||||
public event EventHandler<SKPaintSurfaceEventArgs> PaintSurface;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace SkiaSharp.Views.Forms
|
|||
public class SKGLView : View, ISKGLViewController
|
||||
{
|
||||
public static readonly BindableProperty HasRenderLoopProperty =
|
||||
BindableProperty.Create("HasRenderLoop", typeof(bool), typeof(SKGLView), default(bool));
|
||||
BindableProperty.Create(nameof(HasRenderLoop), typeof(bool), typeof(SKGLView), false);
|
||||
|
||||
public bool HasRenderLoop
|
||||
{
|
||||
|
|
|
@ -47,17 +47,25 @@ namespace SkiaSharp.Views.Forms
|
|||
if (!oneShot && !Element.HasRenderLoop)
|
||||
return;
|
||||
|
||||
// if this is a one shot request, don't bother with the display link
|
||||
if (oneShot)
|
||||
{
|
||||
var nativeView = Control;
|
||||
nativeView?.Display();
|
||||
return;
|
||||
}
|
||||
|
||||
// create the loop
|
||||
displayLink = CADisplayLink.Create(() =>
|
||||
{
|
||||
var formsView = Control;
|
||||
var nativeView = Element;
|
||||
var nativeView = Control;
|
||||
var formsView = Element;
|
||||
|
||||
// redraw the view
|
||||
formsView?.Display();
|
||||
nativeView?.Display();
|
||||
|
||||
// stop the render loop if this was a one-shot, or the views are disposed
|
||||
if (formsView == null || nativeView == null || !nativeView.HasRenderLoop)
|
||||
if (nativeView == null || formsView == null || !formsView.HasRenderLoop)
|
||||
{
|
||||
displayLink.Invalidate();
|
||||
displayLink.Dispose();
|
||||
|
|
|
@ -49,6 +49,8 @@ namespace SkiaSharp.Views.UWP
|
|||
}
|
||||
}
|
||||
|
||||
public double Dpi => dpi;
|
||||
|
||||
public event EventHandler<SKPaintSurfaceEventArgs> PaintSurface;
|
||||
|
||||
protected virtual void OnPaintSurface(SKPaintSurfaceEventArgs e)
|
||||
|
|
Загрузка…
Ссылка в новой задаче