Browse Source

Merge pull request #4253 from Gillibald/fixes/SkiaSharpObsolete

Remove obsolete SkiaSharp members
Nikita Tsukanov 5 years ago
parent
commit
b575818e7e

+ 3 - 3
src/Skia/Avalonia.Skia/DrawingContextImpl.cs

@@ -629,8 +629,8 @@ namespace Avalonia.Skia
 
             var tileTransform =
                 tileBrush.TileMode != TileMode.None
-                    ? SKMatrix.MakeTranslation(-(float)calc.DestinationRect.X, -(float)calc.DestinationRect.Y)
-                    : SKMatrix.MakeIdentity();
+                    ? SKMatrix.CreateTranslation(-(float)calc.DestinationRect.X, -(float)calc.DestinationRect.Y)
+                    : SKMatrix.CreateIdentity();
 
             SKShaderTileMode tileX =
                 tileBrush.TileMode == TileMode.None
@@ -655,7 +655,7 @@ namespace Avalonia.Skia
             SKMatrix.Concat(
                 ref paintTransform,
                 tileTransform,
-                SKMatrix.MakeScale((float)(96.0 / _dpi.X), (float)(96.0 / _dpi.Y)));
+                SKMatrix.CreateScale((float)(96.0 / _dpi.X), (float)(96.0 / _dpi.Y)));
 
             using (var shader = image.ToShader(tileX, tileY, paintTransform))
             {

+ 2 - 2
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs

@@ -82,10 +82,10 @@ namespace Avalonia.Skia
 
                     var renderTarget =
                         new GRBackendRenderTarget(size.Width, size.Height, disp.SampleCount, disp.StencilSize,
-                            new GRGlFramebufferInfo((uint)fb, GRPixelConfig.Rgba8888.ToGlSizedFormat()));
+                            new GRGlFramebufferInfo((uint)fb, SKColorType.Rgba8888.ToGlSizedFormat()));
                     var surface = SKSurface.Create(_grContext, renderTarget,
                         glSession.IsYFlipped ? GRSurfaceOrigin.TopLeft : GRSurfaceOrigin.BottomLeft,
-                        GRPixelConfig.Rgba8888.ToColorType());
+                        SKColorType.Rgba8888);
 
                     success = true;
                     return new GlGpuSession(_grContext, renderTarget, surface, glSession);

+ 5 - 6
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaGpu.cs

@@ -15,19 +15,18 @@ namespace Avalonia.Skia
             using (context.MakeCurrent())
             {
                 using (var iface = context.Version.Type == GlProfileType.OpenGL ?
-                    GRGlInterface.AssembleGlInterface((_, proc) => context.GlInterface.GetProcAddress(proc)) :
-                    GRGlInterface.AssembleGlesInterface((_, proc) => context.GlInterface.GetProcAddress(proc)))
+                    GRGlInterface.CreateOpenGl(proc => context.GlInterface.GetProcAddress(proc)) :
+                    GRGlInterface.CreateGles(proc => context.GlInterface.GetProcAddress(proc)))
                 {
-                    _grContext = GRContext.Create(GRBackend.OpenGL, iface);
+                    _grContext = GRContext.CreateGl(iface);
                     if (maxResourceBytes.HasValue)
                     {
-                        _grContext.GetResourceCacheLimits(out var maxResources, out _);
-                        _grContext.SetResourceCacheLimits(maxResources, maxResourceBytes.Value);
+                        _grContext.SetResourceCacheLimit(maxResourceBytes.Value);
                     }
                 }
             }
         }
-        
+
         public ISkiaGpuRenderTarget TryCreateRenderTarget(IEnumerable<object> surfaces)
         {
             foreach (var surface in surfaces)

+ 10 - 10
src/Skia/Avalonia.Skia/PlatformRenderInterface.cs

@@ -157,12 +157,12 @@ namespace Avalonia.Skia
             return new WriteableBitmapImpl(size, dpi, format);
         }
 
-        private static readonly SKPaint s_paint = new SKPaint
+        private static readonly SKFont s_font = new SKFont
         {
-            TextEncoding = SKTextEncoding.GlyphId,
-            IsAntialias = true,
-            IsStroke = false,
-            SubpixelText = true
+            Subpixel = true,
+            Edging = SKFontEdging.Antialias,
+            Hinting = SKFontHinting.Full,
+            LinearMetrics = true
         };
 
         private static readonly SKTextBlobBuilder s_textBlobBuilder = new SKTextBlobBuilder();
@@ -176,8 +176,8 @@ namespace Avalonia.Skia
 
             var typeface = glyphTypeface.Typeface;
 
-            s_paint.TextSize = (float)glyphRun.FontRenderingEmSize;
-            s_paint.Typeface = typeface;
+            s_font.Size = (float)glyphRun.FontRenderingEmSize;
+            s_font.Typeface = typeface;
 
 
             SKTextBlob textBlob;
@@ -190,7 +190,7 @@ namespace Avalonia.Skia
             {
                 if (glyphTypeface.IsFixedPitch)
                 {
-                    s_textBlobBuilder.AddRun(s_paint, 0, 0, glyphRun.GlyphIndices.Buffer.Span);
+                    s_textBlobBuilder.AddRun(glyphRun.GlyphIndices.Buffer.Span, s_font);
 
                     textBlob = s_textBlobBuilder.Build();
 
@@ -198,7 +198,7 @@ namespace Avalonia.Skia
                 }
                 else
                 {
-                    var buffer = s_textBlobBuilder.AllocateHorizontalRun(s_paint, count, 0);
+                    var buffer = s_textBlobBuilder.AllocateHorizontalRun(s_font, count, 0);
 
                     var positions = buffer.GetPositionSpan();
 
@@ -223,7 +223,7 @@ namespace Avalonia.Skia
             }
             else
             {
-                var buffer = s_textBlobBuilder.AllocatePositionedRun(s_paint, count);
+                var buffer = s_textBlobBuilder.AllocatePositionedRun(s_font, count);
 
                 var glyphPositions = buffer.GetPositionSpan();