forked from amkovkov/GranuSightSoftware2
feat: CameraView micro-optimization
Do not call render if CameraView is not visible
This commit is contained in:
@@ -15,6 +15,7 @@ using Avalonia.Input;
|
||||
using GSS2.UI.Core.ViewModels;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using GSS2.Core.UI.Extensions;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace GSS2.UI.Core.Views;
|
||||
|
||||
@@ -427,7 +428,19 @@ public partial class CameraView : OpenGlControlBase
|
||||
context.FillRectangle(new SolidColorBrush(Background), new Rect(0, 0, Bounds.Width, Bounds.Height));
|
||||
base.Render(context);
|
||||
}
|
||||
private void RenderRequested(object? sender, EventArgs ea) => Dispatcher.UIThread.Invoke(() => RequestNextFrameRendering());
|
||||
private void RenderRequested(object? sender, EventArgs ea)
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
var transformBounds = this.GetTransformedBounds();
|
||||
if (transformBounds is not null &&
|
||||
(transformBounds.Value.Clip.Bottom != 0 ||
|
||||
transformBounds.Value.Clip.Top != 0 ||
|
||||
transformBounds.Value.Clip.Left != 0 ||
|
||||
transformBounds.Value.Clip.Right != 0))
|
||||
RequestNextFrameRendering();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnOpenGlInit(GlInterface gl)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user