Browse Source

Merge branch 'master' into pathicon-style-order-fix

pull/7859/head
Max Katz 4 years ago
committed by GitHub
parent
commit
2e1b6b86fe
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs
  2. 11
      src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
  3. 10
      src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs
  4. 26
      src/Avalonia.X11/X11Window.cs
  5. 8
      src/Windows/Avalonia.Win32/WindowImpl.cs

16
src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs

@ -2,18 +2,22 @@ using System;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Avalonia.Android.Platform.SkiaPlatform;
using Avalonia.Platform;
namespace Avalonia.Android
{
public abstract class InvalidationAwareSurfaceView : SurfaceView, ISurfaceHolderCallback, IPlatformHandle
public abstract class InvalidationAwareSurfaceView : SurfaceView, ISurfaceHolderCallback, IPlatformNativeSurfaceHandle
{
bool _invalidateQueued;
readonly object _lock = new object();
private readonly Handler _handler;
IntPtr IPlatformHandle.Handle =>
AndroidFramebuffer.ANativeWindow_fromSurface(JNIEnv.Handle, Holder.Surface.Handle);
public InvalidationAwareSurfaceView(Context context) : base(context)
{
@ -25,7 +29,7 @@ namespace Avalonia.Android
{
lock (_lock)
{
if(_invalidateQueued)
if (_invalidateQueued)
return;
_handler.Post(() =>
{
@ -70,7 +74,7 @@ namespace Avalonia.Android
public void SurfaceDestroyed(ISurfaceHolder holder)
{
Log.Info("AVALONIA", "Surface Destroyed");
}
protected void DoDraw()
@ -83,5 +87,9 @@ namespace Avalonia.Android
}
protected abstract void Draw();
public string HandleDescriptor => "SurfaceView";
public PixelSize Size => new PixelSize(Holder.SurfaceFrame.Width(), Holder.SurfaceFrame.Height());
public double Scaling => Resources.DisplayMetrics.Density;
}
}

11
src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using Android.Content;
using Android.Graphics;
using Android.Runtime;
using Android.Views;
using Android.Views.InputMethods;
using Avalonia.Android.OpenGL;
@ -38,11 +37,10 @@ namespace Avalonia.Android.Platform.SkiaPlatform
_keyboardHelper = new AndroidKeyboardEventsHelper<TopLevelImpl>(this);
_touchHelper = new AndroidTouchEventsHelper<TopLevelImpl>(this, () => InputRoot,
GetAvaloniaPointFromEvent);
_gl = GlPlatformSurface.TryCreate(this);
_framebuffer = new FramebufferManager(this);
RenderScaling = (int)_view.Resources.DisplayMetrics.Density;
RenderScaling = (int)_view.Scaling;
MaxClientSize = new PixelSize(_view.Resources.DisplayMetrics.WidthPixels,
_view.Resources.DisplayMetrics.HeightPixels).ToSize(RenderScaling);
@ -77,7 +75,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform
public IPlatformHandle Handle => _view;
public IEnumerable<object> Surfaces => new object[] { _gl, _framebuffer };
public IEnumerable<object> Surfaces => new object[] { _gl, _framebuffer, Handle };
public IRenderer CreateRenderer(IRenderRoot root) =>
AndroidPlatform.Options.UseDeferredRendering
@ -216,10 +214,9 @@ namespace Avalonia.Android.Platform.SkiaPlatform
public AcrylicPlatformCompensationLevels AcrylicCompensationLevels => new AcrylicPlatformCompensationLevels(1, 1, 1);
IntPtr EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo.Handle =>
AndroidFramebuffer.ANativeWindow_fromSurface(JNIEnv.Handle, _view.Holder.Surface.Handle);
IntPtr EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo.Handle => ((IPlatformHandle)_view).Handle;
public PixelSize Size => new PixelSize(_view.Holder.SurfaceFrame.Width(), _view.Holder.SurfaceFrame.Height());
public PixelSize Size => _view.Size;
public double Scaling => RenderScaling;

10
src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs

@ -0,0 +1,10 @@
using System;
namespace Avalonia.Platform
{
public interface IPlatformNativeSurfaceHandle : IPlatformHandle
{
PixelSize Size { get; }
double Scaling { get; }
}
}

26
src/Avalonia.X11/X11Window.cs

@ -134,8 +134,8 @@ namespace Avalonia.X11
SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
else
_renderHandle = _handle;
Handle = new PlatformHandle(_handle, "XID");
Handle = new SurfacePlatformHandle(this);
_realSize = new PixelSize(defaultWidth, defaultHeight);
platform.Windows[_handle] = OnEvent;
XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
@ -169,7 +169,9 @@ namespace Avalonia.X11
if (glx != null)
surfaces.Insert(0, new GlxGlPlatformSurface(glx.Display, glx.DeferredContext,
new SurfaceInfo(this, _x11.Display, _handle, _renderHandle)));
surfaces.Add(Handle);
Surfaces = surfaces.ToArray();
UpdateMotifHints();
UpdateSizeHints(null);
@ -1142,5 +1144,23 @@ namespace Avalonia.X11
public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 0.8, 0.8);
public bool NeedsManagedDecorations => false;
public class SurfacePlatformHandle : IPlatformNativeSurfaceHandle
{
private readonly X11Window _owner;
public PixelSize Size => _owner.ToPixelSize(_owner.ClientSize);
public double Scaling => _owner.RenderScaling;
public SurfacePlatformHandle(X11Window owner)
{
_owner = owner;
}
public IntPtr Handle => _owner._renderHandle;
public string? HandleDescriptor => "XID";
}
}
}

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

@ -459,7 +459,7 @@ namespace Avalonia.Win32
}
}
public IEnumerable<object> Surfaces => new object[] { Handle, _gl, _framebuffer };
public IEnumerable<object> Surfaces => new object[] { (IPlatformNativeSurfaceHandle)Handle, _gl, _framebuffer };
public PixelPoint Position
{
@ -1383,12 +1383,16 @@ namespace Avalonia.Win32
public ITextInputMethodImpl TextInputMethod => Imm32InputMethod.Current;
private class WindowImplPlatformHandle : IPlatformHandle
private class WindowImplPlatformHandle : IPlatformNativeSurfaceHandle
{
private readonly WindowImpl _owner;
public WindowImplPlatformHandle(WindowImpl owner) => _owner = owner;
public IntPtr Handle => _owner.Hwnd;
public string HandleDescriptor => PlatformConstants.WindowHandleType;
public PixelSize Size => PixelSize.FromSize(_owner.ClientSize, Scaling);
public double Scaling => _owner.RenderScaling;
}
}
}

Loading…
Cancel
Save