From 3f138c2600a219cd4892449be6e9c187319ee88a Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Wed, 5 Jun 2024 00:11:33 +0900 Subject: [PATCH] Make IsMainThreadInPresent and CumulativePresentCalls clearer --- Dalamud/Interface/Internal/InterfaceManager.cs | 16 +++++++++------- .../Textures/Internal/TextureManager.cs | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index d62d122e2..26b5c8ce2 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -217,7 +217,7 @@ internal class InterfaceManager : IInternalDisposableService /// Gets a value indicating whether the main thread is executing . /// This still will be true even when queried off the main thread. - public bool IsInPresent { get; private set; } + public bool IsMainThreadInPresent { get; private set; } /// /// Gets a value indicating the native handle of the game main window. @@ -249,9 +249,11 @@ internal class InterfaceManager : IInternalDisposableService /// public Task FontBuildTask => WhenFontsReady().dalamudAtlas!.BuildTask; - /// - /// Gets the number of calls to so far. - /// + /// Gets the number of calls to so far. + /// + /// The value increases even when Dalamud is hidden via "/xlui hide". + /// does not. + /// public long CumulativePresentCalls { get; private set; } /// @@ -657,7 +659,7 @@ internal class InterfaceManager : IInternalDisposableService } this.CumulativePresentCalls++; - this.IsInPresent = true; + this.IsMainThreadInPresent = true; while (this.runBeforeImGuiRender.TryDequeue(out var action)) action.InvokeSafely(); @@ -668,14 +670,14 @@ internal class InterfaceManager : IInternalDisposableService RenderImGui(this.scene!); this.PostImGuiRender(); - this.IsInPresent = false; + this.IsMainThreadInPresent = false; return pRes; } RenderImGui(this.scene!); this.PostImGuiRender(); - this.IsInPresent = false; + this.IsMainThreadInPresent = false; return this.presentHook!.Original(swapChain, syncInterval, presentFlags); } diff --git a/Dalamud/Interface/Textures/Internal/TextureManager.cs b/Dalamud/Interface/Textures/Internal/TextureManager.cs index 9dffc6853..3266190df 100644 --- a/Dalamud/Interface/Textures/Internal/TextureManager.cs +++ b/Dalamud/Interface/Textures/Internal/TextureManager.cs @@ -380,7 +380,7 @@ internal sealed partial class TextureManager // Not sure why this and the below can't be unconditional RunOnFrameworkThread private async Task RunDuringPresent(Action action) { - if (this.interfaceManager.IsInPresent && ThreadSafety.IsMainThread) + if (this.interfaceManager.IsMainThreadInPresent && ThreadSafety.IsMainThread) action(); else await this.interfaceManager.RunBeforeImGuiRender(action); @@ -392,7 +392,7 @@ internal sealed partial class TextureManager /// The return value from the function. private async Task RunDuringPresent(Func func) { - if (this.interfaceManager.IsInPresent && ThreadSafety.IsMainThread) + if (this.interfaceManager.IsMainThreadInPresent && ThreadSafety.IsMainThread) return func(); return await this.interfaceManager.RunBeforeImGuiRender(func); }