mirror of
https://github.com/osukey/osukey.git
synced 2025-04-29 10:47:22 +09:00
Fix GetAsync()
not limiting texture dimensions
This commit is contained in:
parent
7bb6337d2e
commit
fd495e87f7
@ -35,6 +35,25 @@ namespace osu.Game.Skinning
|
|||||||
if (textureUpload == null)
|
if (textureUpload == null)
|
||||||
return null!;
|
return null!;
|
||||||
|
|
||||||
|
return limitTextureUploadSize(textureUpload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TextureUpload> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken())
|
||||||
|
{
|
||||||
|
// NRT not enabled on framework side classes (IResourceStore / TextureLoaderStore), welp.
|
||||||
|
if (textureStore == null)
|
||||||
|
return null!;
|
||||||
|
|
||||||
|
var textureUpload = await textureStore.GetAsync(name, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (textureUpload == null)
|
||||||
|
return null!;
|
||||||
|
|
||||||
|
return await Task.Run(() => limitTextureUploadSize(textureUpload), cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextureUpload limitTextureUploadSize(TextureUpload textureUpload)
|
||||||
|
{
|
||||||
// So there's a thing where some users have taken it upon themselves to create skin elements of insane dimensions.
|
// So there's a thing where some users have taken it upon themselves to create skin elements of insane dimensions.
|
||||||
// To the point where GPUs cannot load the textures (along with most image editor apps).
|
// To the point where GPUs cannot load the textures (along with most image editor apps).
|
||||||
// To work around this, let's look out for any stupid images and shrink them down into a usable size.
|
// To work around this, let's look out for any stupid images and shrink them down into a usable size.
|
||||||
@ -58,10 +77,6 @@ namespace osu.Game.Skinning
|
|||||||
return textureUpload;
|
return textureUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove null-forgiving operator below after texture stores are NRT-annotated framework-side
|
|
||||||
public Task<TextureUpload> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken())
|
|
||||||
=> textureStore?.GetAsync(name, cancellationToken) ?? Task.FromResult<TextureUpload>(null!);
|
|
||||||
|
|
||||||
public Stream? GetStream(string name) => textureStore?.GetStream(name);
|
public Stream? GetStream(string name) => textureStore?.GetStream(name);
|
||||||
|
|
||||||
public IEnumerable<string> GetAvailableResources() => textureStore?.GetAvailableResources() ?? Array.Empty<string>();
|
public IEnumerable<string> GetAvailableResources() => textureStore?.GetAvailableResources() ?? Array.Empty<string>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user