Skip to content

Commit

Permalink
Merge branch 'master' into text-builder-not-invalidated
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo authored Mar 4, 2021
2 parents 8c1ce03 + dfe45e1 commit b5ec9aa
Show file tree
Hide file tree
Showing 51 changed files with 403 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectReference Include="..\TemplateGame.Game\TemplateGame.Game.csproj" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<ProjectReference Include="..\TemplateGame.Resources\TemplateGame.Resources.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.226.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.226.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.226.0" />
<PackageReference Include="ppy.osu.Framework.NativeLibs" Version="2019.1104.0" ExcludeAssets="all" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectReference Include="..\FlappyDon.Game\FlappyDon.Game.csproj" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.226.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FlappyDon.Resources\FlappyDon.Resources.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.226.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<PackageReference Include="ppy.osu.Framework" Version="2021.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.226.0" />
<PackageReference Include="ppy.osu.Framework.NativeLibs" Version="2019.1104.0" ExcludeAssets="all" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
Expand Down
18 changes: 13 additions & 5 deletions osu.Framework.Tests/Audio/SampleBassTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Setup()

resources = new DllResourceStore(typeof(TrackBassTest).Assembly);
sampleFactory = new SampleBassFactory(resources.Get("Resources.Tracks.sample-track.mp3"));
sample = new SampleBass(sampleFactory);
sample = sampleFactory.CreateSample();

updateSample();
}
Expand Down Expand Up @@ -86,11 +86,19 @@ public void TestStopBeforeLoadFinished()
Assert.IsFalse(channel.Playing);
}

private void updateSample() => runOnAudioThread(() =>
[Test]
public void TestStopsWhenFactoryDisposed()
{
sampleFactory.Update();
channel?.Update();
});
channel = sample.Play();
updateSample();

sampleFactory.Dispose();
updateSample();

Assert.IsFalse(channel.Playing);
}

private void updateSample() => runOnAudioThread(() => sampleFactory.Update());

/// <summary>
/// Certain actions are invoked on the audio thread.
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Tests/osu.Framework.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ProjectReference Include="..\osu.Framework\osu.Framework.csproj" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework.iOS.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
<PackageReference Include="Markdig" Version="0.22.1" />
<PackageReference Include="FFmpeg.AutoGen" Version="4.3.0.1" />
<PackageReference Include="SharpFNT" Version="2.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />
<PackageReference Include="System.Drawing.Common" Version="5.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" />
<PackageReference Include="ppy.osuTK.NS20" Version="1.0.173" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.iOS/osu.Framework.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osuTK.iOS" Version="1.0.173" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />
</ItemGroup>
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)\*.a" />
Expand Down
5 changes: 0 additions & 5 deletions osu.Framework/Allocation/TimedExpiryCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ protected virtual void Dispose(bool disposing)
}
}

~TimedExpiryCache()
{
Dispose(false);
}

public void Dispose()
{
Dispose(true);
Expand Down
17 changes: 6 additions & 11 deletions osu.Framework/Audio/AudioComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,21 @@ public void Update()

#region IDisposable Support

~AudioComponent()
{
Dispose(false);
}

protected volatile bool IsDisposed;

protected virtual void Dispose(bool disposing)
{
IsDisposed = true;
}

public virtual void Dispose()
public void Dispose()
{
acceptingActions = false;
PendingActions.Enqueue(new Task(() => Dispose(true)));

GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
IsDisposed = true;
}

#endregion
}
}
8 changes: 8 additions & 0 deletions osu.Framework/Audio/Sample/SampleBassFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,16 @@ private void onPlay(Sample sample)
AddItem(sample);
}

~SampleBassFactory()
{
Dispose(false);
}

protected override void Dispose(bool disposing)
{
if (IsDisposed)
return;

if (IsLoaded)
{
Bass.SampleFree(SampleId);
Expand Down
7 changes: 5 additions & 2 deletions osu.Framework/Audio/Sample/SampleChannelBass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ private void ensureChannel() => EnqueueAction(() =>
bassAmplitudeProcessor?.SetChannel(channel);
});

public override void Dispose()
protected override void Dispose(bool disposing)
{
base.Dispose();
if (IsDisposed)
return;

if (hasChannel)
{
Expand All @@ -192,6 +193,8 @@ public override void Dispose()
}

playing = false;

base.Dispose(disposing);
}
}
}
8 changes: 8 additions & 0 deletions osu.Framework/Audio/Track/TrackBass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,16 @@ protected override void UpdateState()
bassAmplitudeProcessor?.Update();
}

~TrackBass()
{
Dispose(false);
}

protected override void Dispose(bool disposing)
{
if (IsDisposed)
return;

if (activeStream != 0)
{
isRunning = false;
Expand Down
5 changes: 0 additions & 5 deletions osu.Framework/Audio/Track/Waveform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ public async Task<int> GetChannelsAsync()

#region Disposal

~Waveform()
{
Dispose(false);
}

public void Dispose()
{
Dispose(true);
Expand Down
5 changes: 0 additions & 5 deletions osu.Framework/Configuration/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@ protected virtual void Dispose(bool disposing)
}
}

~ConfigManager()
{
Dispose(false);
}

public void Dispose()
{
Dispose(true);
Expand Down
5 changes: 0 additions & 5 deletions osu.Framework/Graphics/BufferedDrawNodeSharedData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public FrameBuffer GetNextEffectBuffer()
/// </summary>
internal void ResetCurrentEffectBuffer() => currentEffectBuffer = -1;

~BufferedDrawNodeSharedData()
{
GLWrapper.ScheduleDisposal(() => Dispose(false));
}

public void Dispose()
{
GLWrapper.ScheduleDisposal(() => Dispose(true));
Expand Down
3 changes: 3 additions & 0 deletions osu.Framework/Graphics/Containers/CompositeDrawable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ private void loadChild(Drawable child)

protected override void Dispose(bool isDisposing)
{
if (IsDisposed)
return;

disposalCancellationSource?.Cancel();
disposalCancellationSource?.Dispose();

Expand Down
5 changes: 0 additions & 5 deletions osu.Framework/Graphics/DrawNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,6 @@ protected void DrawFrameBuffer(FrameBuffer frameBuffer, Quad vertexQuad, ColourI
/// </remarks>
internal void Reference() => referenceCount.Increment();

~DrawNode()
{
GLWrapper.ScheduleDisposal(() => Dispose(false));
}

protected internal bool IsDisposed { get; private set; }

public void Dispose()
Expand Down
52 changes: 18 additions & 34 deletions osu.Framework/Graphics/Drawable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ protected Drawable()
AddLayout(requiredParentSizeToFitBacking);
}

~Drawable()
{
dispose(false);
finalize_disposals.Value++;
}

private static readonly GlobalStatistic<int> total_count = GlobalStatistics.Get<int>(nameof(Drawable), $"Total {nameof(Drawable)}s");
private static readonly GlobalStatistic<int> finalize_disposals = GlobalStatistics.Get<int>(nameof(Drawable), "Finalizer disposals");
private static readonly GlobalStatistic<int> total_count = GlobalStatistics.Get<int>(nameof(Drawable), "Total constructed");

internal bool IsLongRunning => GetType().GetCustomAttribute<LongRunningLoadAttribute>() != null;

Expand All @@ -82,7 +75,9 @@ protected Drawable()
/// </summary>
public void Dispose()
{
dispose(true);
//we can't dispose if we are mid-load, else our children may get in a bad state.
lock (LoadLock) Dispose(true);

GC.SuppressFinalize(this);
}

Expand All @@ -93,36 +88,25 @@ public void Dispose()
/// </summary>
protected virtual void Dispose(bool isDisposing)
{
}

private void dispose(bool isDisposing)
{
//we can't dispose if we are mid-load, else our children may get in a bad state.
lock (LoadLock)
{
if (IsDisposed)
return;

total_count.Value--;
if (IsDisposed)
return;

Dispose(isDisposing);
UnbindAllBindables();
UnbindAllBindables();

// Bypass expensive operations as a result of setting the Parent property, by setting the field directly.
parent = null;
ChildID = 0;
// Bypass expensive operations as a result of setting the Parent property, by setting the field directly.
parent = null;
ChildID = 0;

OnUpdate = null;
Invalidated = null;
OnUpdate = null;
Invalidated = null;

OnDispose?.Invoke();
OnDispose = null;
OnDispose?.Invoke();
OnDispose = null;

for (int i = 0; i < drawNodes.Length; i++)
drawNodes[i]?.Dispose();
for (int i = 0; i < drawNodes.Length; i++)
drawNodes[i]?.Dispose();

IsDisposed = true;
}
IsDisposed = true;
}

/// <summary>
Expand Down Expand Up @@ -430,7 +414,7 @@ public float Depth
internal event Action<Drawable> Invalidated;

/// <summary>
/// Fired after the <see cref="dispose(bool)"/> method is called.
/// Fired after the <see cref="Dispose(bool)"/> method is called.
/// </summary>
internal event Action OnDispose;

Expand Down
5 changes: 0 additions & 5 deletions osu.Framework/Graphics/OpenGL/Textures/TextureGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ protected TextureGL(WrapMode wrapModeS = WrapMode.None, WrapMode wrapModeT = Wra

#region Disposal

~TextureGL()
{
Dispose(false);
}

internal virtual bool IsQueuedForUpload { get; set; }

/// <summary>
Expand Down
Loading

0 comments on commit b5ec9aa

Please sign in to comment.