From 106bc74cbb8e8efbcc20d94c456ea0904cc1d9d6 Mon Sep 17 00:00:00 2001 From: Alek-ban Date: Tue, 14 Apr 2026 21:20:49 +0300 Subject: [PATCH] feat: CameraView micro-optimization Do not call render if CameraView is not visible --- GSS2.UI.Core/Views/CameraView.axaml.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/GSS2.UI.Core/Views/CameraView.axaml.cs b/GSS2.UI.Core/Views/CameraView.axaml.cs index 606e423..71c7264 100644 --- a/GSS2.UI.Core/Views/CameraView.axaml.cs +++ b/GSS2.UI.Core/Views/CameraView.axaml.cs @@ -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) {