зеркало из https://github.com/mono/SkiaSharp.git
Added the GL view to the Forms sample xaml, and hooked it up
This commit is contained in:
Родитель
60fe43fb17
Коммит
7dc30232de
|
@ -3,9 +3,16 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms"
|
||||
x:Class="SkiaSharpSample.FormsSample.DetailContentsPage">
|
||||
<views:SKCanvasView x:Name="canvas" PaintSurface="OnPaintSample">
|
||||
<views:SKCanvasView.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="OnTapSample" />
|
||||
</views:SKCanvasView.GestureRecognizers>
|
||||
</views:SKCanvasView>
|
||||
<Grid>
|
||||
<views:SKCanvasView x:Name="canvas" PaintSurface="OnPaintSample">
|
||||
<views:SKCanvasView.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="OnTapSample" />
|
||||
</views:SKCanvasView.GestureRecognizers>
|
||||
</views:SKCanvasView>
|
||||
<views:SKGLView x:Name="glview" PaintSurface="OnPaintGLSample" IsVisible="False" HasRenderLoop="False">
|
||||
<views:SKGLView.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="OnTapSample" />
|
||||
</views:SKGLView.GestureRecognizers>
|
||||
</views:SKGLView>
|
||||
</Grid>
|
||||
</ContentPage>
|
|
@ -24,18 +24,32 @@ namespace SkiaSharpSample.FormsSample
|
|||
{
|
||||
sample = value;
|
||||
|
||||
sample.Init(canvas.InvalidateSurface);
|
||||
sample.Init(RefreshSamples);
|
||||
|
||||
Title = sample.Title;
|
||||
canvas.InvalidateSurface();
|
||||
RefreshSamples();
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchBackend(SampleBackends backend)
|
||||
{
|
||||
// TODO: implement once the Forms GL is working
|
||||
|
||||
DisplayAlert("Configure Backend", "This functionality is not yet implemented.", "OK");
|
||||
switch (backend)
|
||||
{
|
||||
case SampleBackends.Memory:
|
||||
canvas.IsVisible = true;
|
||||
canvas.InvalidateSurface();
|
||||
glview.IsVisible = false;
|
||||
break;
|
||||
case SampleBackends.OpenGL:
|
||||
glview.IsVisible = true;
|
||||
glview.InvalidateSurface();
|
||||
canvas.IsVisible = false;
|
||||
break;
|
||||
case SampleBackends.Vulkan:
|
||||
default:
|
||||
DisplayAlert("Configure Backend", "This functionality is not yet implemented.", "OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTapSample(object sender, EventArgs e)
|
||||
|
@ -47,5 +61,22 @@ namespace SkiaSharpSample.FormsSample
|
|||
{
|
||||
Sample?.DrawSample(e.Surface.Canvas, e.Info.Width, e.Info.Height);
|
||||
}
|
||||
|
||||
private void OnPaintGLSample(object sender, SKPaintGLSurfaceEventArgs e)
|
||||
{
|
||||
Sample?.DrawSample(e.Surface.Canvas, e.RenderTarget.Width, e.RenderTarget.Height);
|
||||
}
|
||||
|
||||
private void RefreshSamples()
|
||||
{
|
||||
if (canvas.IsVisible)
|
||||
{
|
||||
canvas.InvalidateSurface();
|
||||
}
|
||||
if (glview.IsVisible)
|
||||
{
|
||||
glview.InvalidateSurface();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче