This commit is contained in:
Soreepeong 2024-03-05 17:41:27 +09:00
parent 9ba0a297c9
commit 70eecdaaef
30 changed files with 767 additions and 345 deletions

View file

@ -591,7 +591,7 @@ internal sealed partial class FontAtlasFactory
{
ref var texture = ref textureSpan[i];
var name =
$"FontAtlas.{ this.data.Owner?.Name ?? "(no owner or name)"}[0x{(long)this.data.Atlas.NativePtr:X}][{i}]";
$"{nameof(FontAtlasBuiltData)}[{this.data.Owner?.Name ?? "-"}][0x{(long)this.data.Atlas.NativePtr:X}][{i}]";
if (texture.TexID != 0)
{
// Nothing to do
@ -602,6 +602,7 @@ internal sealed partial class FontAtlasFactory
RawImageSpecification.Rgba32(width, height),
new(texture.TexPixelsRGBA32, width * height * 4),
name);
this.factory.TextureManager.Blame(wrap, this.data.Owner?.OwnerPlugin);
this.data.AddExistingTexture(wrap);
texture.TexID = wrap.ImGuiHandle;
}
@ -647,6 +648,7 @@ internal sealed partial class FontAtlasFactory
width * bpp),
buf,
name);
this.factory.TextureManager.Blame(wrap, this.data.Owner?.OwnerPlugin);
this.data.AddExistingTexture(wrap);
texture.TexID = wrap.ImGuiHandle;
continue;

View file

@ -12,6 +12,7 @@ using Dalamud.Interface.GameFonts;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Utility;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Utility;
using ImGuiNET;
@ -256,12 +257,15 @@ internal sealed partial class FontAtlasFactory
/// <param name="atlasName">Name of atlas, for debugging and logging purposes.</param>
/// <param name="autoRebuildMode">Specify how to auto rebuild.</param>
/// <param name="isGlobalScaled">Whether the fonts in the atlas are under the effect of global scale.</param>
/// <param name="ownerPlugin">The owner plugin, if any.</param>
public DalamudFontAtlas(
FontAtlasFactory factory,
string atlasName,
FontAtlasAutoRebuildMode autoRebuildMode,
bool isGlobalScaled)
bool isGlobalScaled,
LocalPlugin? ownerPlugin)
{
this.OwnerPlugin = ownerPlugin;
this.IsGlobalScaled = isGlobalScaled;
try
{
@ -355,6 +359,9 @@ internal sealed partial class FontAtlasFactory
/// <inheritdoc/>
public bool IsGlobalScaled { get; }
/// <summary>Gets the owner plugin, if any.</summary>
public LocalPlugin? OwnerPlugin { get; }
/// <inheritdoc/>
public void Dispose()
{

View file

@ -12,6 +12,7 @@ using Dalamud.Interface.FontIdentifier;
using Dalamud.Interface.GameFonts;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures.Internal;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Storage.Assets;
using Dalamud.Utility;
@ -178,12 +179,14 @@ internal sealed partial class FontAtlasFactory
/// <param name="atlasName">Name of atlas, for debugging and logging purposes.</param>
/// <param name="autoRebuildMode">Specify how to auto rebuild.</param>
/// <param name="isGlobalScaled">Whether the fonts in the atlas is global scaled.</param>
/// <param name="ownerPlugin">The owner plugin, if any.</param>
/// <returns>The new font atlas.</returns>
public IFontAtlas CreateFontAtlas(
string atlasName,
FontAtlasAutoRebuildMode autoRebuildMode,
bool isGlobalScaled = true) =>
new DalamudFontAtlas(this, atlasName, autoRebuildMode, isGlobalScaled);
bool isGlobalScaled = true,
LocalPlugin? ownerPlugin = null) =>
new DalamudFontAtlas(this, atlasName, autoRebuildMode, isGlobalScaled, ownerPlugin);
/// <summary>
/// Adds the font from Dalamud Assets.
@ -363,7 +366,7 @@ internal sealed partial class FontAtlasFactory
: DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM),
texFile.Header.Width * bpp),
buffer,
$"{nameof(FontAtlasFactory)}:{texPathFormat.Format(fileIndex)}:{channelIndex}"));
$"{nameof(FontAtlasFactory)}[{texPathFormat.Format(fileIndex)}][{channelIndex}]"));
}
finally
{