Skip to content

Commit

Permalink
Some performance improvements for Forms (#1424)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Jul 23, 2020
1 parent b84f667 commit c62ce46
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ public SKCanvasViewRenderer()
: base()
{
}

protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKCanvasViewRenderer)
? new SKNativeView(Context)
: base.CreateNativeControl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ protected override void SetupRenderLoop(bool oneShot)

protected override SKNativeView CreateNativeControl()
{
var view = base.CreateNativeControl();
var view = GetType() == typeof(SKGLViewRenderer)
? new SKNativeView(Context)
: base.CreateNativeControl();

// Force the opacity to false for consistency with the other platforms
view.SetOpaque(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ namespace SkiaSharp.Views.Forms
{
public class SKCanvasViewRenderer : SKCanvasViewRendererBase<SKFormsView, SKNativeView>, IRegisterable
{
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKCanvasViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal class SKGLViewRenderer
{
public SKGLViewRenderer()
{
throw new System.PlatformNotSupportedException("SKGLView is not yet supported on this platform.");
throw new System.PlatformNotSupportedException("SKGLView is not yet supported on GTK.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ namespace SkiaSharp.Views.Forms
{
public class SKCanvasViewRenderer : SKCanvasViewRendererBase<SKFormsView, SKNativeView>
{
protected override SKNativeView CreateNativeControl()
{
var view = base.CreateNativeControl();
return view;
}
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKCanvasViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CoreVideo;
using Foundation;
using Xamarin.Forms;

using SKFormsView = SkiaSharp.Views.Forms.SKGLView;
Expand All @@ -13,11 +12,10 @@ public class SKGLViewRenderer : SKGLViewRendererBase<SKFormsView, SKNativeView>
{
private CVDisplayLink displayLink;

protected override SKNativeView CreateNativeControl()
{
var view = base.CreateNativeControl();
return view;
}
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKGLViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();

protected override void Dispose(bool disposing)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Xamarin.Forms;

using TForms = Xamarin.Forms.Forms;

using SKFormsView = SkiaSharp.Views.Forms.SKCanvasView;
using SKNativeView = SkiaSharp.Views.Tizen.SKCanvasView;

Expand All @@ -9,5 +11,9 @@ namespace SkiaSharp.Views.Forms
{
public class SKCanvasViewRenderer : SKCanvasViewRendererBase<SKFormsView, SKNativeView>, IRegisterable
{
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKCanvasViewRenderer)
? new SKNativeView(TForms.NativeParent)
: base.CreateNativeControl();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using SkiaSharp.Views.Tizen;
using Xamarin.Forms;

using TForms = Xamarin.Forms.Forms;

using SKFormsView = SkiaSharp.Views.Forms.SKGLView;
using SKNativeView = SkiaSharp.Views.Tizen.SKGLSurfaceView;

Expand All @@ -10,6 +12,11 @@ namespace SkiaSharp.Views.Forms
{
public class SKGLViewRenderer : SKGLViewRendererBase<SKFormsView, SKNativeView>
{
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKGLViewRenderer)
? new SKNativeView(TForms.NativeParent)
: base.CreateNativeControl();

protected override void SetupRenderLoop(bool oneShot)
{
if (oneShot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ namespace SkiaSharp.Views.Forms
{
public class SKCanvasViewRenderer : SKCanvasViewRendererBase<SKFormsView, SKNativeView>
{
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKCanvasViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace SkiaSharp.Views.Forms
{
public class SKGLViewRenderer : SKGLViewRendererBase<SKFormsView, SKNativeView>
{
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKGLViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();

protected override void SetupRenderLoop(bool oneShot)
{
if (oneShot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ namespace SkiaSharp.Views.Forms
{
public class SKCanvasViewRenderer : SKCanvasViewRendererBase<SKFormsView, SKNativeView>, IRegisterable
{
protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKCanvasViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public class SKGLViewRenderer : SKGLViewRendererBase<SKFormsView, SKNativeView>
{
private DispatcherTimer renderTimer;

protected override SKNativeView CreateNativeControl() =>
GetType() == typeof(SKGLViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();

protected override void SetupRenderLoop(bool oneShot)
{
// only start if we haven't already
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public SKCanvasViewRenderer()

protected override SKNativeView CreateNativeControl()
{
var view = base.CreateNativeControl();
var view = GetType() == typeof(SKCanvasViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();

// Force the opacity to false for consistency with the other platforms
view.Opaque = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public SKGLViewRenderer()

protected override SKNativeView CreateNativeControl()
{
var view = base.CreateNativeControl();
var view = GetType() == typeof(SKGLViewRenderer)
? new SKNativeView()
: base.CreateNativeControl();

// Force the opacity to false for consistency with the other platforms
view.Opaque = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal class SKGLViewRenderer
{
public SKGLViewRenderer()
{
throw new System.PlatformNotSupportedException("SKGLView is not yet supported on GTK.");
throw new System.PlatformNotSupportedException("SKGLView is not yet supported on this platform.");
}
}
}

0 comments on commit c62ce46

Please sign in to comment.