Browse Source
Merge pull request #4254 from MarchingCube/fix-fb-crash-zero-size
Fix NREs that occur when rendering to 0x0 framebuffer
pull/4281/head
Dariusz Komosiński
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
23 additions and
9 deletions
-
src/Shared/PlatformSupport/StandardRuntimePlatform.cs
-
src/Windows/Avalonia.Win32/FramebufferManager.cs
-
src/Windows/Avalonia.Win32/WindowImpl.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(); |
|
|
|
|
|
|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -389,6 +389,8 @@ namespace Avalonia.Win32 |
|
|
|
UnregisterClass(_className, GetModuleHandle(null)); |
|
|
|
_className = null; |
|
|
|
} |
|
|
|
|
|
|
|
_framebuffer.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
public void Invalidate(Rect rect) |
|
|
|
|