Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL-accelerated Skia drawing for Win32/GTK backends #1935

Merged
merged 11 commits into from
Oct 2, 2018

Conversation

kekekeks
Copy link
Member

@kekekeks kekekeks commented Oct 1, 2018

Differencies from #1917

  • While being platform-agnostic allows calling OpenGL-functions
  • Actual implementations for Win32/GTK via EGL/ANGLE
  • Proper separation of display, context and surface
  • Separate OpenGL-context for UI-thread drawing (RenderTargetBitmap is hw-accelerated)
  • No hardcode for stencil size and sample count

@kekekeks kekekeks requested a review from a team October 1, 2018 10:48
@kekekeks kekekeks changed the title OpenGL-accelerated Skia drawing in Win32/GTK backends OpenGL-accelerated Skia drawing for Win32/GTK backends Oct 1, 2018
@jmacato
Copy link
Member

jmacato commented Oct 1, 2018

This really is a game-changer! It handles animations with ease

I was testing with RenderDemo & ImmediateRenderer and sometimes it crashes whenever i click on Tabs/Menu. this was the stack trace:

WARNING: failed to attach stencil buffer for clip mask. Clip will be ignored.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Avalonia.Controls.Platform.DefaultMenuInteractionHandler.PointerReleased(Object sender, PointerReleasedEventArgs e) in {avaloniaDir}/src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs:line 334
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e) in {avaloniaDir}/src/Avalonia.Interactivity/Interactive.cs:line 199
   at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e) in {avaloniaDir}/src/Avalonia.Interactivity/Interactive.cs:line 158
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in {avaloniaDir}/src/Avalonia.Interactivity/Interactive.cs:line 141
   at Avalonia.Input.MouseDevice.MouseUp(IMouseDevice device, IInputRoot root, Point p, MouseButton button, InputModifiers inputModifiers) in {avaloniaDir}/src/Avalonia.Input/MouseDevice.cs:line 247
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawMouseEventArgs e) in {avaloniaDir}/src/Avalonia.Input/MouseDevice.cs:line 132
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawInputEventArgs e) in {avaloniaDir}/src/Avalonia.Input/MouseDevice.cs:line 104
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in {avaloniaDir}/src/Avalonia.Input/InputManager.cs:line 38
   at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e) in {avaloniaDir}/src/Avalonia.Controls/TopLevel.cs:line 350
   at Avalonia.Gtk3.WindowBaseImpl.<>c__DisplayClass94_0.<OnInput>b__0() in {avaloniaDir}/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs:line 400
   at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run() in {avaloniaDir}/src/Avalonia.Base/Threading/JobRunner.cs:line 169
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in {avaloniaDir}/src/Avalonia.Base/Threading/JobRunner.cs:line 40
   at Avalonia.Gtk3.Gtk3Platform.<>c__DisplayClass28_0.<Signal>b__0() in {avaloniaDir}/src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs:line 108
   at Avalonia.Gtk3.Interop.GlibTimeout.Handler(IntPtr data) in {avaloniaDir}/src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs:line 12
   at Avalonia.Gtk3.Gtk3Platform.RunLoop(CancellationToken cancellationToken) in {avaloniaDir}/src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs:line 81
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in {avaloniaDir}/src/Avalonia.Base/Threading/Dispatcher.cs:line 64
   at Avalonia.Application.Run(Window mainWindow) in {avaloniaDir}/src/Avalonia.Controls/Application.cs:line 259
   at Avalonia.Controls.AppBuilderBase`1.Start[TMainWindow](Func`1 dataContextProvider) in {avaloniaDir}/src/Avalonia.Controls/AppBuilderBase.cs:line 128
   at RenderDemo.App.Main(String[] args) in {avaloniaDir}/samples/RenderDemo/App.xaml.cs:line 19

@kekekeks
Copy link
Member Author

kekekeks commented Oct 1, 2018

I don't think that the crash is related to OpenGL changes. The stencil warning is a bit concerning though.

@jmacato
Copy link
Member

jmacato commented Oct 1, 2018

@kekekeks yeah, it's repeating that warning over and over when the rotating geometry clipped animation is running

Copy link
Member

@danwalmsley danwalmsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits, let me know if you want me to do the fixes

src/Avalonia.OpenGL/EglDisplay.cs Show resolved Hide resolved
src/Avalonia.OpenGL/EglGlPlatformSurface.cs Show resolved Hide resolved
OpenGLES2
}

public interface IGlContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: 1 class / interface per file

namespace Avalonia.OpenGL
{
public interface IGlPlatformSurface
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: 1 interface per file

src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs Show resolved Hide resolved
src/Gtk/Avalonia.Gtk3/Interop/Native.cs Show resolved Hide resolved
src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs Show resolved Hide resolved
src/Gtk/Avalonia.Gtk3/Interop/Signal.cs Show resolved Hide resolved
src/Gtk/Avalonia.Gtk3/SystemDialogs.cs Show resolved Hide resolved
src/Gtk/Avalonia.Gtk3/WindowImpl.cs Show resolved Hide resolved
@danwalmsley
Copy link
Member

I think the only functional change required now is to make it disabled by default, so that we can add this to 0.7 release and people who want to test it can, but existing code wont potentially be exposed to any issues in gpu rendering we don't yet know about.

Copy link
Member

@danwalmsley danwalmsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM great work :)

@danwalmsley danwalmsley merged commit dbe9bc8 into AvaloniaUI:master Oct 2, 2018
@grokys grokys added this to the 0.7.0 milestone Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants