mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-01 05:13:40 +01:00
Move all texture loading functionalities from IM to TM
This commit is contained in:
parent
248c7911a0
commit
71b84bcf40
12 changed files with 230 additions and 298 deletions
|
|
@ -10,6 +10,7 @@ using Dalamud.Interface.FontIdentifier;
|
|||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Storage.Assets;
|
||||
using Dalamud.Utility;
|
||||
|
||||
|
|
@ -579,7 +580,7 @@ internal sealed partial class FontAtlasFactory
|
|||
var buf = Array.Empty<byte>();
|
||||
try
|
||||
{
|
||||
var use4 = this.factory.InterfaceManager.SupportsDxgiFormat(Format.B4G4R4A4_UNorm);
|
||||
var use4 = this.factory.TextureManager.SupportsDxgiFormat((int)Format.B4G4R4A4_UNorm);
|
||||
var bpp = use4 ? 2 : 4;
|
||||
var width = this.NewImAtlas.TexWidth;
|
||||
var height = this.NewImAtlas.TexHeight;
|
||||
|
|
@ -591,12 +592,9 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
else if (texture.TexPixelsRGBA32 is not null)
|
||||
{
|
||||
var wrap = this.factory.InterfaceManager.LoadImageFromDxgiFormat(
|
||||
new(texture.TexPixelsRGBA32, width * height * 4),
|
||||
width * 4,
|
||||
width,
|
||||
height,
|
||||
use4 ? Format.B4G4R4A4_UNorm : Format.R8G8B8A8_UNorm);
|
||||
var wrap = this.factory.TextureManager.GetFromRaw(
|
||||
RawImageSpecification.Rgba32(width, height),
|
||||
new(texture.TexPixelsRGBA32, width * height * 4));
|
||||
this.data.AddExistingTexture(wrap);
|
||||
texture.TexID = wrap.ImGuiHandle;
|
||||
}
|
||||
|
|
@ -634,12 +632,13 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
}
|
||||
|
||||
var wrap = this.factory.InterfaceManager.LoadImageFromDxgiFormat(
|
||||
buf,
|
||||
width * bpp,
|
||||
width,
|
||||
height,
|
||||
use4 ? Format.B4G4R4A4_UNorm : Format.B8G8R8A8_UNorm);
|
||||
var wrap = this.factory.TextureManager.GetFromRaw(
|
||||
new(
|
||||
width,
|
||||
height,
|
||||
width * bpp,
|
||||
(int)(use4 ? Format.B4G4R4A4_UNorm : Format.B8G8R8A8_UNorm)),
|
||||
buf);
|
||||
this.data.AddExistingTexture(wrap);
|
||||
texture.TexID = wrap.ImGuiHandle;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -46,11 +46,13 @@ internal sealed partial class FontAtlasFactory
|
|||
DataManager dataManager,
|
||||
Framework framework,
|
||||
InterfaceManager interfaceManager,
|
||||
DalamudAssetManager dalamudAssetManager)
|
||||
DalamudAssetManager dalamudAssetManager,
|
||||
TextureManager textureManager)
|
||||
{
|
||||
this.Framework = framework;
|
||||
this.InterfaceManager = interfaceManager;
|
||||
this.dalamudAssetManager = dalamudAssetManager;
|
||||
this.TextureManager = textureManager;
|
||||
this.SceneTask = Service<InterfaceManager.InterfaceManagerWithScene>
|
||||
.GetAsync()
|
||||
.ContinueWith(r => r.Result.Manager.Scene);
|
||||
|
|
@ -144,6 +146,11 @@ internal sealed partial class FontAtlasFactory
|
|||
/// </summary>
|
||||
public InterfaceManager InterfaceManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service instance of <see cref="TextureManager"/>.
|
||||
/// </summary>
|
||||
public TextureManager TextureManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the async task for <see cref="RawDX11Scene"/> inside <see cref="InterfaceManager"/>.
|
||||
/// </summary>
|
||||
|
|
@ -346,7 +353,7 @@ internal sealed partial class FontAtlasFactory
|
|||
var numPixels = texFile.Header.Width * texFile.Header.Height;
|
||||
|
||||
_ = Service<InterfaceManager.InterfaceManagerWithScene>.Get();
|
||||
var targetIsB4G4R4A4 = this.InterfaceManager.SupportsDxgiFormat(Format.B4G4R4A4_UNorm);
|
||||
var targetIsB4G4R4A4 = this.TextureManager.SupportsDxgiFormat((int)Format.B4G4R4A4_UNorm);
|
||||
var bpp = targetIsB4G4R4A4 ? 2 : 4;
|
||||
var buffer = ArrayPool<byte>.Shared.Rent(numPixels * bpp);
|
||||
try
|
||||
|
|
@ -369,12 +376,13 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
|
||||
return this.scopedFinalizer.Add(
|
||||
this.InterfaceManager.LoadImageFromDxgiFormat(
|
||||
buffer,
|
||||
texFile.Header.Width * bpp,
|
||||
texFile.Header.Width,
|
||||
texFile.Header.Height,
|
||||
targetIsB4G4R4A4 ? Format.B4G4R4A4_UNorm : Format.B8G8R8A8_UNorm));
|
||||
this.TextureManager.GetFromRaw(
|
||||
new(
|
||||
texFile.Header.Width,
|
||||
texFile.Header.Height,
|
||||
texFile.Header.Width * bpp,
|
||||
(int)(targetIsB4G4R4A4 ? Format.B4G4R4A4_UNorm : Format.B8G8R8A8_UNorm)),
|
||||
buffer));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue