This commit is contained in:
Matthew Leibowitz 2018-09-28 19:43:23 +02:00
Родитель aa0ce80fb6
Коммит 310ebdd626
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3650EBE4AA155AF9
17 изменённых файлов: 39 добавлений и 39 удалений

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

@ -8,7 +8,8 @@ namespace SkiaSharpSample
Memory = 1 << 0,
OpenGL = 1 << 1,
Vulkan = 1 << 2,
Metal = 1 << 3,
All = Memory | OpenGL | Vulkan,
All = Memory | OpenGL | Vulkan | Metal,
}
}

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

@ -36,8 +36,7 @@ namespace SkiaSharpSample.Samples
// decode the image
using (var bitmap = new SKBitmap(info.Width, info.Height, info.ColorType, info.IsOpaque ? SKAlphaType.Opaque : SKAlphaType.Premul))
{
IntPtr length;
var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(out length));
var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels());
if (result == SKCodecResult.Success || result == SKCodecResult.IncompleteInput)
{
var x = 25;

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

@ -7,6 +7,7 @@ using System.Linq;
namespace SkiaSharpSample.Samples
{
[Preserve(AllMembers = true)]
[Obsolete]
public class BitmapScalerSample : SampleBase
{
private List<SKBitmapResizeMethod> methods;

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

@ -41,9 +41,7 @@ namespace SkiaSharpSample.Samples
var options = new SKCodecOptions(subset);
using (var bitmap = new SKBitmap(subset.Width, subset.Height, info.ColorType, SKAlphaType.Premul))
{
IntPtr length;
int count = 0;
var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(out length), options, null, ref count);
var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(), options);
if (result == SKCodecResult.Success || result == SKCodecResult.IncompleteInput)
{
canvas.DrawBitmap(bitmap, info.Width + 20, subset.Top + 10);

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

@ -19,7 +19,7 @@ namespace SkiaSharpSample.Samples
canvas.DrawColor(SKColors.White);
using (var paint = new SKPaint())
using (var filter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 5.0f, SKBlurMaskFilterFlags.HighQuality))
using (var filter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 5.0f))
{
paint.IsAntialias = true;
paint.TextSize = 120;
@ -41,7 +41,7 @@ namespace SkiaSharpSample.Samples
{
// create the rounded rectangle
var roundedRect = new SKPath();
roundedRect.AddRoundedRect(rect, 10, 10);
roundedRect.AddRoundRect(rect, 10, 10);
// draw the white background
var p = new SKPaint
@ -61,13 +61,13 @@ namespace SkiaSharpSample.Samples
p.Color = SKColors.Black;
p.Style = SKPaintStyle.Stroke;
p.StrokeWidth = 2;
p.MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 2, SKBlurMaskFilterFlags.HighQuality);
p.MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 2);
canvas.Translate(0.5f, 1.5f);
canvas.DrawPath(roundedRect, p);
// draw the narrow blur at the top
p.StrokeWidth = 1;
p.MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 1, SKBlurMaskFilterFlags.HighQuality);
p.MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 1);
canvas.DrawPath(roundedRect, p);
}

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

@ -94,9 +94,9 @@ namespace SkiaSharpSample.Samples
var w = (float)width / cols;
var h = (float)height / rows;
for (int y = 0; y < rows; y++)
for (var y = 0; y < rows; y++)
{
for (int x = 0; x < cols; x++)
for (var x = 0; x < cols; x++)
{
f(SKRect.Create(x * w, y * h, w, h), matices[y * cols + x]);
}

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

@ -19,7 +19,7 @@ namespace SkiaSharpSample.Samples
canvas.Clear(SKColors.White);
var ct = new byte[256];
for (int i = 0; i < 256; ++i)
for (var i = 0; i < 256; ++i)
{
var x = (i - 96) * 255 / 64;
ct[i] = x < 0 ? (byte)0 : x > 255 ? (byte)255 : (byte)x;

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

@ -18,7 +18,7 @@ namespace SkiaSharpSample.Samples
protected override void OnDrawSample(SKCanvas canvas, int width, int height)
{
string text = "\u03A3 and \u0750";
var text = "\u03A3 and \u0750";
canvas.Clear(SKColors.White);

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

@ -36,8 +36,7 @@ namespace SkiaSharpSample.Samples
// decode the image
using (var bitmap = new SKBitmap(info.Width, info.Height, info.ColorType, info.IsOpaque ? SKAlphaType.Opaque : SKAlphaType.Premul))
{
IntPtr length;
var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(out length));
var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels());
if (result == SKCodecResult.Success || result == SKCodecResult.IncompleteInput)
{
var x = 25;

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

@ -25,7 +25,7 @@ namespace SkiaSharpSample.Samples
using (var path = new SKPath())
{
path.MoveTo(R, 0.0f);
for (int i = 1; i < 7; ++i)
for (var i = 1; i < 7; ++i)
{
var theta = 3f * i * TAU / 7f;
path.LineTo(R * (float)Math.Cos(theta), R * (float)Math.Sin(theta));

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

@ -22,7 +22,7 @@ namespace SkiaSharpSample.Samples
{
// invert the pixels
var pixels = source.Pixels;
for (int i = 0; i < pixels.Length; i++)
for (var i = 0; i < pixels.Length; i++)
{
pixels[i] = new SKColor(
(byte)(255 - pixels[i].Red),

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

@ -19,8 +19,8 @@ namespace SkiaSharpSample.Samples
canvas.Clear(SKColors.White);
canvas.Scale(2, 2);
using (SKPaint paint = new SKPaint())
using (SKPaint textPaint = new SKPaint())
using (var paint = new SKPaint())
using (var textPaint = new SKPaint())
{
paint.Style = SKPaintStyle.Stroke;
paint.StrokeWidth = 1;
@ -29,7 +29,7 @@ namespace SkiaSharpSample.Samples
textPaint.IsAntialias = true;
using (SKPath path = new SKPath())
using (var path = new SKPath())
{
path.MoveTo(-6.2157825e-7f, -25.814698f);
path.RCubicTo(-34.64102137842175f, 19.9999998f, 0f, 40f, 0f, 40f);
@ -39,8 +39,7 @@ namespace SkiaSharpSample.Samples
paint.Color = SampleMedia.Colors.XamarinLightBlue;
canvas.DrawPath(path, paint);
SKRect rect;
path.GetBounds(out rect);
path.GetBounds(out var rect);
paint.Color = SampleMedia.Colors.XamarinDarkBlue;
canvas.DrawRect(rect, paint);

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

@ -26,8 +26,8 @@ namespace SkiaSharpSample.Samples
new SKPoint(100, 150)
};
using (SKPaint paint = new SKPaint())
using (SKPaint textPaint = new SKPaint())
using (var paint = new SKPaint())
using (var textPaint = new SKPaint())
{
paint.Style = SKPaintStyle.Stroke;
paint.StrokeWidth = 5;
@ -36,7 +36,7 @@ namespace SkiaSharpSample.Samples
textPaint.IsAntialias = true;
using (SKPath path = new SKPath())
using (var path = new SKPath())
{
// create a conic path
path.MoveTo(points[0]);
@ -47,16 +47,16 @@ namespace SkiaSharpSample.Samples
canvas.DrawPath(path, paint);
// get the quads from the conic points
SKPoint[] pts;
var quads = SKPath.ConvertConicToQuads(points[0], points[1], points[2], 10, out pts, 2);
var quads = SKPath.ConvertConicToQuads(points[0], points[1], points[2], 10, out var pts, 2);
// move the points on a bit
for (int i = 0; i < pts.Length; i++) pts[i].Offset(120, 0);
for (var i = 0; i < pts.Length; i++)
pts[i].Offset(120, 0);
// draw the quad-based path
using (var quadsPath = new SKPath())
{
quadsPath.MoveTo(pts[0].X, pts[0].Y);
for (int i = 0; i < quads; i++)
for (var i = 0; i < quads; i++)
{
var idx = i * 2;
quadsPath.CubicTo(
@ -70,7 +70,8 @@ namespace SkiaSharpSample.Samples
}
// move the points on a bit
for (int i = 0; i < pts.Length; i++) pts[i].Offset(120, 0);
for (var i = 0; i < pts.Length; i++)
pts[i].Offset(120, 0);
// draw the dots
paint.Color = SampleMedia.Colors.XamarinGreen;
canvas.DrawPoints(SKPointMode.Points, pts, paint);

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

@ -32,9 +32,11 @@ namespace SkiaSharpSample.Samples
SKMatrix.PreConcat(ref offsetMatrix, SKMatrix.MakeSkew(0.5f, 0));
// create the paint
var paint = new SKPaint();
paint.PathEffect = SKPathEffect.Create2DPath(offsetMatrix, path);
paint.Color = SKColors.LightGray;
var paint = new SKPaint
{
PathEffect = SKPathEffect.Create2DPath(offsetMatrix, path),
Color = SKColors.LightGray
};
// draw a rectangle
canvas.DrawRect(SKRect.Create(width + blockSize, height + blockSize), paint);

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

@ -18,8 +18,8 @@ namespace SkiaSharpSample.Samples
{
canvas.Clear(SKColors.White);
using (SKPaint paint = new SKPaint())
using (SKPath path = new SKPath())
using (var paint = new SKPaint())
using (var path = new SKPath())
{
paint.Style = SKPaintStyle.Stroke;
paint.StrokeWidth = 10;

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

@ -62,6 +62,7 @@ namespace SkiaSharpSample
canvas.IsVisible = false;
break;
case SampleBackends.Vulkan:
case SampleBackends.Metal:
default:
DisplayAlert("Configure Backend", "This functionality is not yet implemented.", "OK");
break;
@ -124,7 +125,7 @@ namespace SkiaSharpSample
private void OnPaintGLSample(object sender, SKPaintGLSurfaceEventArgs e)
{
Sample?.DrawSample(e.Surface.Canvas, e.RenderTarget.Width, e.RenderTarget.Height);
Sample?.DrawSample(e.Surface.Canvas, e.BackendRenderTarget.Width, e.BackendRenderTarget.Height);
//lastImage?.Dispose();
//lastImage = e.Surface.Snapshot();

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

@ -58,8 +58,7 @@ namespace SkiaSharpSample
var items = Enum.GetNames(typeof(SampleBackends)).Except(new[] { nameof(SampleBackends.All) });
var backendString = await DisplayActionSheet("Select Backend:", "Close", null, items.ToArray());
SampleBackends backend;
if (Enum.TryParse(backendString, out backend))
if (Enum.TryParse(backendString, out SampleBackends backend))
{
((DetailContentsPage)CurrentPage).SwitchBackend(backend);
}