Browse Source

Merge branch 'master' into fixes/3965-popup-modal-interaction

pull/4099/head
Dariusz Komosiński 6 years ago
committed by GitHub
parent
commit
53d408b70f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      build/HarfBuzzSharp.props
  2. 4
      build/SkiaSharp.props
  3. 9
      src/Avalonia.Controls/Primitives/Track.cs
  4. 18
      src/Avalonia.X11/X11Screens.cs
  5. 10
      src/Shared/PlatformSupport/StandardRuntimePlatform.cs
  6. 6
      src/Skia/Avalonia.Skia/DrawingContextImpl.cs
  7. 1
      src/Skia/Avalonia.Skia/FormattedTextImpl.cs
  8. 4
      src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs
  9. 11
      src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaGpu.cs
  10. 20
      src/Skia/Avalonia.Skia/PlatformRenderInterface.cs
  11. 20
      src/Windows/Avalonia.Win32/FramebufferManager.cs
  12. 2
      src/Windows/Avalonia.Win32/WindowImpl.cs

4
build/HarfBuzzSharp.props

@ -1,6 +1,6 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="HarfBuzzSharp" Version="2.6.1" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.6.1" />
<PackageReference Include="HarfBuzzSharp" Version="2.6.1.5" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.6.1.5" />
</ItemGroup>
</Project>

4
build/SkiaSharp.props

@ -1,6 +1,6 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="SkiaSharp" Version="1.68.2.1" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="1.68.2.1" />
<PackageReference Include="SkiaSharp" Version="2.80.0" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.80.0" />
</ItemGroup>
</Project>

9
src/Avalonia.Controls/Primitives/Track.cs

@ -353,6 +353,15 @@ namespace Avalonia.Controls.Primitives
var trackLength = isVertical ? arrangeSize.Height : arrangeSize.Width;
double thumbMinLength = 10;
StyledProperty<double> minLengthProperty = isVertical ? MinHeightProperty : MinWidthProperty;
var thumb = Thumb;
if (thumb != null && thumb.IsSet(minLengthProperty))
{
thumbMinLength = thumb.GetValue(minLengthProperty);
}
thumbLength = trackLength * viewportSize / extent;
CoerceLength(ref thumbLength, trackLength);
thumbLength = Math.Max(thumbMinLength, thumbLength);

18
src/Avalonia.X11/X11Screens.cs

@ -48,9 +48,13 @@ namespace Avalonia.X11
var pwa = (IntPtr*)prop;
var wa = new PixelRect(pwa[0].ToInt32(), pwa[1].ToInt32(), pwa[2].ToInt32(), pwa[3].ToInt32());
foreach (var s in screens)
foreach (var s in screens)
{
s.WorkingArea = s.Bounds.Intersect(wa);
if (s.WorkingArea.Width <= 0 || s.WorkingArea.Height <= 0)
s.WorkingArea = s.Bounds;
}
XFree(prop);
return screens;
@ -134,8 +138,14 @@ namespace Avalonia.X11
settings.GlobalScaleFactor)
});
}
Screens = new[] {new X11Screen(new PixelRect(0, 0, 1920, 1280), true, "Default", null, settings.GlobalScaleFactor)};
else
{
Screens = new[]
{
new X11Screen(new PixelRect(0, 0, 1920, 1280), true, "Default", null,
settings.GlobalScaleFactor)
};
}
}
public X11Screen[] Screens { get; }

10
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@ -86,11 +86,15 @@ namespace Avalonia.Shared.PlatformSupport
#if DEBUG
if (Thread.CurrentThread.ManagedThreadId == GCThread?.ManagedThreadId)
{
lock(_lock)
lock (_lock)
{
if (!IsDisposed)
{
Console.Error.WriteLine("Native blob disposal from finalizer thread\nBacktrace: "
+ Environment.StackTrace
+ "\n\nBlob created by " + _backtrace);
+ Environment.StackTrace
+ "\n\nBlob created by " + _backtrace);
}
}
}
#endif
DoDispose();

6
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))
{

1
src/Skia/Avalonia.Skia/FormattedTextImpl.cs

@ -35,6 +35,7 @@ namespace Avalonia.Skia
IsAntialias = true,
LcdRenderText = true,
SubpixelText = true,
IsLinearText = true,
Typeface = glyphTypeface.Typeface,
TextSize = (float)fontSize,
TextAlign = textAlignment.ToSKTextAlign()

4
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);

11
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)

20
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();

20
src/Windows/Avalonia.Win32/FramebufferManager.cs

@ -5,7 +5,7 @@ using Avalonia.Win32.Interop;
namespace Avalonia.Win32
{
class FramebufferManager : IFramebufferPlatformSurface
class FramebufferManager : IFramebufferPlatformSurface, IDisposable
{
private readonly IntPtr _hwnd;
private WindowFramebuffer _fb;
@ -17,17 +17,25 @@ namespace Avalonia.Win32
public ILockedFramebuffer Lock()
{
UnmanagedMethods.RECT rc;
UnmanagedMethods.GetClientRect(_hwnd, out rc);
var width = rc.right - rc.left;
var height = rc.bottom - rc.top;
if ((_fb == null || _fb.Size.Width != width || _fb.Size.Height != height) && width > 0 && height > 0)
UnmanagedMethods.GetClientRect(_hwnd, out var rc);
var width = Math.Max(1, rc.right - rc.left);
var height = Math.Max(1, rc.bottom - rc.top);
if ((_fb == null || _fb.Size.Width != width || _fb.Size.Height != height))
{
_fb?.Deallocate();
_fb = null;
_fb = new WindowFramebuffer(_hwnd, new PixelSize(width, height));
}
return _fb;
}
public void Dispose()
{
_fb?.Deallocate();
_fb = null;
}
}
}

2
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -389,6 +389,8 @@ namespace Avalonia.Win32
UnregisterClass(_className, GetModuleHandle(null));
_className = null;
}
_framebuffer.Dispose();
}
public void Invalidate(Rect rect)

Loading…
Cancel
Save