1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 13:23:05 +08:00

Changes in line with framework refcount changes

This commit is contained in:
Dean Herbert 2018-09-06 13:15:43 +09:00
parent 9b753bb429
commit 29b0d62f21
7 changed files with 20 additions and 26 deletions

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Graphics.Textures;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Storyboards; using osu.Game.Storyboards;
@ -45,6 +44,10 @@ namespace osu.Game.Beatmaps
private string getPathForFile(string filename) => BeatmapSetInfo.Files.First(f => string.Equals(f.Filename, filename, StringComparison.InvariantCultureIgnoreCase)).FileInfo.StoragePath; private string getPathForFile(string filename) => BeatmapSetInfo.Files.First(f => string.Equals(f.Filename, filename, StringComparison.InvariantCultureIgnoreCase)).FileInfo.StoragePath;
private LargeTextureStore textureStore;
protected override bool BackgroundStillValid(Texture b) => false; // bypass lazy logic. we want to return a new background each time for refcounting purposes.
protected override Texture GetBackground() protected override Texture GetBackground()
{ {
if (Metadata?.BackgroundFile == null) if (Metadata?.BackgroundFile == null)
@ -52,7 +55,7 @@ namespace osu.Game.Beatmaps
try try
{ {
return new LargeTextureStore(new RawTextureLoaderStore(store)).Get(getPathForFile(Metadata.BackgroundFile)); return (textureStore ?? (textureStore = new LargeTextureStore(new TextureLoaderStore(store)))).Get(getPathForFile(Metadata.BackgroundFile));
} }
catch catch
{ {
@ -73,6 +76,14 @@ namespace osu.Game.Beatmaps
} }
} }
public override void TransferTo(WorkingBeatmap other)
{
base.TransferTo(other);
if (other is BeatmapManagerWorkingBeatmap owb && textureStore != null && BeatmapInfo.BackgroundEquals(other.BeatmapInfo))
owb.textureStore = textureStore;
}
protected override Waveform GetWaveform() protected override Waveform GetWaveform()
{ {
try try

View File

@ -5,8 +5,8 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Graphics.Textures;
namespace osu.Game.Graphics.Backgrounds namespace osu.Game.Graphics.Backgrounds
{ {

View File

@ -1,18 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
namespace osu.Game.Graphics.Textures
{
/// <summary>
/// A texture store that bypasses atlasing.
/// </summary>
public class LargeTextureStore : TextureStore
{
public LargeTextureStore(IResourceStore<RawTexture> store = null) : base(store, false)
{
}
}
}

View File

@ -24,7 +24,6 @@ using osu.Framework.Input;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics.Textures;
using osu.Game.Input; using osu.Game.Input;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.IO; using osu.Game.IO;
@ -109,7 +108,7 @@ namespace osu.Game
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage));
dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures")))); dependencies.Cache(new LargeTextureStore(new TextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures"))));
dependencies.CacheAs(this); dependencies.CacheAs(this);
dependencies.Cache(LocalConfig); dependencies.Cache(LocalConfig);

View File

@ -59,7 +59,7 @@ namespace osu.Game.Screens.Tournament
TextureStore flagStore = new TextureStore(); TextureStore flagStore = new TextureStore();
// Local flag store // Local flag store
flagStore.AddStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(new StorageBackedResourceStore(storage), "Drawings"))); flagStore.AddStore(new TextureLoaderStore(new NamespacedResourceStore<byte[]>(new StorageBackedResourceStore(storage), "Drawings")));
// Default texture store // Default texture store
flagStore.AddStore(textures); flagStore.AddStore(textures);

View File

@ -37,7 +37,7 @@ namespace osu.Game.Skinning
Configuration = new SkinConfiguration(); Configuration = new SkinConfiguration();
Samples = audioManager.GetSampleManager(storage); Samples = audioManager.GetSampleManager(storage);
Textures = new TextureStore(new RawTextureLoaderStore(storage)); Textures = new TextureStore(new TextureLoaderStore(storage));
} }
public override Drawable GetDrawableComponent(string componentName) public override Drawable GetDrawableComponent(string componentName)

View File

@ -22,6 +22,7 @@ namespace osu.Game.Storyboards.Drawables
public override bool HandleMouseInput => false; public override bool HandleMouseInput => false;
private bool passing = true; private bool passing = true;
public bool Passing public bool Passing
{ {
get { return passing; } get { return passing; }
@ -36,6 +37,7 @@ namespace osu.Game.Storyboards.Drawables
public override bool RemoveCompletedTransforms => false; public override bool RemoveCompletedTransforms => false;
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
@ -57,7 +59,7 @@ namespace osu.Game.Storyboards.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(FileStore fileStore) private void load(FileStore fileStore)
{ {
dependencies.Cache(new TextureStore(new RawTextureLoaderStore(fileStore.Store), false) { ScaleAdjust = 1, }); dependencies.Cache(new TextureStore(new TextureLoaderStore(fileStore.Store), false, scaleAdjust: 1));
foreach (var layer in Storyboard.Layers) foreach (var layer in Storyboard.Layers)
Add(layer.CreateDrawable()); Add(layer.CreateDrawable());