Skip to content

Commit

Permalink
Merge branch 'master' into deferred-renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Jan 10, 2024
2 parents 981ea3d + 382b60f commit 2a810c6
Show file tree
Hide file tree
Showing 131 changed files with 2,899 additions and 716 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PropertyGroup Label="NuGet">
<Authors>ppy Pty Ltd</Authors>
<Company>ppy Pty Ltd</Company>
<Copyright>Copyright (c) 2021 ppy Pty Ltd</Copyright>
<Copyright>Copyright (c) 2024 ppy Pty Ltd</Copyright>
<Product>osu!framework</Product>
<PackageReleaseNotes>Automated release.</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 ppy Pty Ltd <contact@ppy.sh>.
Copyright (c) 2024 ppy Pty Ltd <contact@ppy.sh>.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Android/AndroidGameActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected override void OnCreate(Bundle? savedInstanceState)
// The default current directory on android is '/'.
// On some devices '/' maps to the app data directory. On others it maps to the root of the internal storage.
// In order to have a consistent current directory on all devices the full path of the app data directory is set as the current directory.
System.Environment.CurrentDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
System.Environment.CurrentDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile);

base.OnCreate(savedInstanceState);

Expand Down
3 changes: 3 additions & 0 deletions osu.Framework.Android/Input/AndroidJoystickHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace osu.Framework.Android.Input
{
public class AndroidJoystickHandler : AndroidInputHandler
{
private static readonly GlobalStatistic<ulong> statistic_total_events = GlobalStatistics.Get<ulong>(StatisticGroupFor<AndroidJoystickHandler>(), "Total events");

public BindableFloat DeadzoneThreshold { get; } = new BindableFloat(0.1f)
{
MinValue = 0,
Expand Down Expand Up @@ -223,6 +225,7 @@ private void enqueueInput(IInput input)
{
PendingInputs.Enqueue(input);
FrameStatistics.Increment(StatisticsCounterType.JoystickEvents);
statistic_total_events.Value++;
}
}
}
3 changes: 3 additions & 0 deletions osu.Framework.Android/Input/AndroidKeyboardHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace osu.Framework.Android.Input
{
public class AndroidKeyboardHandler : AndroidInputHandler
{
private static readonly GlobalStatistic<ulong> statistic_total_events = GlobalStatistics.Get<ulong>(StatisticGroupFor<AndroidKeyboardHandler>(), "Total events");

protected override IEnumerable<InputSourceType> HandledEventSources => new[]
{
InputSourceType.Keyboard,
Expand Down Expand Up @@ -209,6 +211,7 @@ private void enqueueInput(IInput input)
{
PendingInputs.Enqueue(input);
FrameStatistics.Increment(StatisticsCounterType.KeyEvents);
statistic_total_events.Value++;
}
}
}
3 changes: 3 additions & 0 deletions osu.Framework.Android/Input/AndroidMouseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace osu.Framework.Android.Input
/// </summary>
public class AndroidMouseHandler : AndroidInputHandler
{
private static readonly GlobalStatistic<ulong> statistic_total_events = GlobalStatistics.Get<ulong>(StatisticGroupFor<AndroidMouseHandler>(), "Total events");

/// <summary>
/// Whether relative mode should be preferred when the window has focus, the cursor is contained and the OS cursor is not visible.
/// </summary>
Expand Down Expand Up @@ -308,6 +310,7 @@ private void enqueueInput(IInput input)
{
PendingInputs.Enqueue(input);
FrameStatistics.Increment(StatisticsCounterType.MouseEvents);
statistic_total_events.Value++;
}
}
}
9 changes: 9 additions & 0 deletions osu.Framework.Android/Input/AndroidTouchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace osu.Framework.Android.Input
{
public class AndroidTouchHandler : AndroidInputHandler
{
private static readonly GlobalStatistic<ulong> statistic_touch_events = GlobalStatistics.Get<ulong>(StatisticGroupFor<AndroidTouchHandler>(), "Touch events");
private static readonly GlobalStatistic<ulong> statistic_hover_events = GlobalStatistics.Get<ulong>(StatisticGroupFor<AndroidTouchHandler>(), "Hover events");

public override bool IsActive => true;

protected override IEnumerable<InputSourceType> HandledEventSources => new[] { InputSourceType.BluetoothStylus, InputSourceType.Stylus, InputSourceType.Touchscreen };
Expand Down Expand Up @@ -87,14 +90,20 @@ protected override bool OnHover(MotionEvent hoverEvent)
void apply(MotionEvent e, int historyPosition)
{
if (tryGetEventPosition(e, historyPosition, 0, out var position))
{
enqueueInput(new MousePositionAbsoluteInput { Position = position });
statistic_hover_events.Value++;
}
}
}

private void applyTouchInput(MotionEvent touchEvent, int historyPosition, int pointerIndex)
{
if (tryGetEventTouch(touchEvent, historyPosition, pointerIndex, out var touch))
{
enqueueInput(new TouchInput(touch, touchEvent.ActionMasked.IsTouchDownAction()));
statistic_touch_events.Value++;
}
}

private bool tryGetEventTouch(MotionEvent motionEvent, int historyPosition, int pointerIndex, out Touch touch)
Expand Down
29 changes: 29 additions & 0 deletions osu.Framework.Benchmarks/BenchmarkBindableNumber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using BenchmarkDotNet.Attributes;
using osu.Framework.Bindables;

namespace osu.Framework.Benchmarks
{
[MemoryDiagnoser]
public class BenchmarkBindableNumber
{
private readonly BindableInt bindableNoPrecision = new BindableInt();
private readonly BindableInt bindableWithPrecision = new BindableInt { Precision = 5 };

[Benchmark]
public void SetValueNoPrecision()
{
for (int i = 0; i < 1000; i++)
bindableNoPrecision.Value = i;
}

[Benchmark]
public void SetValueWithPrecision()
{
for (int i = 0; i < 1000; i++)
bindableWithPrecision.Value = i;
}
}
}
43 changes: 43 additions & 0 deletions osu.Framework.Benchmarks/BenchmarkPiecewiseLinearToBezier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using osu.Framework.Utils;
using osuTK;

namespace osu.Framework.Benchmarks
{
public class BenchmarkPiecewiseLinearToBezier : BenchmarkTest
{
private Vector2[] inputPath = null!;

[Params(5, 25)]
public int NumControlPoints;

[Params(5, 200)]
public int NumTestPoints;

[Params(0, 100, 200)]
public int MaxIterations;

public override void SetUp()
{
base.SetUp();

Vector2[] points = new Vector2[5];
points[0] = new Vector2(50, 250);
points[1] = new Vector2(150, 230);
points[2] = new Vector2(100, 150);
points[3] = new Vector2(200, 80);
points[4] = new Vector2(250, 50);
inputPath = PathApproximator.LagrangePolynomialToPiecewiseLinear(points).ToArray();
}

[Benchmark]
public List<Vector2> PiecewiseLinearToBezier()
{
return PathApproximator.PiecewiseLinearToBezier(inputPath, NumControlPoints, NumTestPoints, MaxIterations);
}
}
}
66 changes: 60 additions & 6 deletions osu.Framework.Benchmarks/BenchmarkTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Timing;
using osuTK;
Expand All @@ -13,7 +13,7 @@ namespace osu.Framework.Benchmarks
{
public partial class BenchmarkTransform : BenchmarkTest
{
private Drawable target = null!;
private Container target = null!;

public override void SetUp()
{
Expand All @@ -25,6 +25,60 @@ public override void SetUp()
[Benchmark]
public Transform CreateSingleBlank() => new TestTransform();

[Benchmark]
public void CreateSequenceThenRewind()
{
target.FadeIn(1000, Easing.OutQuint)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000)
.Then().FadeOut(1000);

for (int i = 0; i < 1000; i++)
{
target.ApplyTransformsAt(50000);
target.ApplyTransformsAt(0);
}

target.ClearTransforms(true);
}

[Benchmark]
public void CreateSequenceThenRewindManyChildren()
{
var nested = target;

for (int i = 0; i < 5; i++)
{
nested.Add(new TestBox());
nested.FadeOutFromOne(1000)
.Then().FadeOutFromOne(1000)
.Then().FadeOutFromOne(1000)
.Then().FadeOutFromOne(1000);

nested.Add(nested = new TestBox());
nested.FadeOutFromOne(1000)
.Then().FadeOutFromOne(1000)
.Then().FadeOutFromOne(1000)
.Then().FadeOutFromOne(1000);
}

for (int i = 0; i < 1000; i++)
{
target.ApplyTransformsAt(50000, true);
target.ApplyTransformsAt(0, true);
}

target.ClearTransforms(true);
target.Clear();
}

[Benchmark]
public void CreateSequenceThenClearAfter()
{
Expand Down Expand Up @@ -117,21 +171,21 @@ private class ReferenceEasingFunction : IEasingFunction
public double ApplyEasing(double time) => 0;
}

private partial class TestBox : Box
private partial class TestBox : Container
{
public override bool RemoveCompletedTransforms => false;
}

private class TestTransform : Transform<float, Box>
private class TestTransform : Transform<float, TestBox>
{
public override string TargetMember => throw new NotImplementedException();

protected override void Apply(Box d, double time)
protected override void Apply(TestBox d, double time)
{
throw new NotImplementedException();
}

protected override void ReadIntoStartValue(Box d)
protected override void ReadIntoStartValue(TestBox d)
{
throw new NotImplementedException();
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/linux-x64/native/libavutil.so
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/linux-x64/native/libswscale.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/osx/native/libavutil.56.dylib
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/osx/native/libswscale.5.dylib
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-arm64/native/avutil-56.dll
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-arm64/native/swscale-5.dll
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x64/native/avcodec-58.dll
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x64/native/avformat-58.dll
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x64/native/avutil-56.dll
Binary file not shown.
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x64/native/swscale-5.dll
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x86/native/avcodec-58.dll
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x86/native/avformat-58.dll
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x86/native/avutil-56.dll
Binary file not shown.
Binary file not shown.
Binary file modified osu.Framework.NativeLibs/runtimes/win-x86/native/swscale-5.dll
Binary file not shown.
13 changes: 9 additions & 4 deletions osu.Framework.NativeLibs/scripts/ffmpeg/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ FFMPEG_FLAGS=(
--enable-avformat
--enable-swscale

# File and video formats
--enable-demuxer='mov,matroska,flv,avi' # mov = mp4, matroska = mkv & webm
--enable-parser='mpeg4video,h264,hevc,vp8,vp9'
--enable-decoder='flv,msmpeg4v1,msmpeg4v2,msmpeg4v3,mpeg4,h264,hevc,vp8,vp9'
# Legacy video formats
--enable-demuxer='avi,flv,asf'
--enable-parser='mpeg4video'
--enable-decoder='flv,msmpeg4v1,msmpeg4v2,msmpeg4v3,mpeg4,vp6,vp6f,wmv2'

# Modern video formats
--enable-demuxer='mov,matroska' # mov = mp4, matroska = mkv & webm
--enable-parser='h264,hevc,vp8,vp9'
--enable-decoder='h264,hevc,vp8,vp9'
--enable-protocol=pipe
)

Expand Down
8 changes: 8 additions & 0 deletions osu.Framework.Tests.Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!--
READ_MEDIA_* permissions are available only on API 33 or greater. Devices with older android versions
don't understand the new permissions, so request the old READ_EXTERNAL_STORAGE permission to get storage access.
Since the old permission has no effect on >= API 33, don't request it.
Care needs to be taken to ensure runtime permission checks target the correct permission for the API level.
-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
</manifest>
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Audio/BassTestComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void Add(params AudioComponent[] component)

internal BassAudioMixer CreateMixer()
{
var mixer = new BassAudioMixer(Mixer, "Test mixer");
var mixer = new BassAudioMixer(null, Mixer, "Test mixer");
mixerComponents.AddItem(mixer);
return mixer;
}
Expand Down
5 changes: 3 additions & 2 deletions osu.Framework.Tests/Bindables/BindableBoolTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Globalization;
using NUnit.Framework;
using osu.Framework.Bindables;

Expand All @@ -26,7 +27,7 @@ public void TestSet(bool value)
public void TestParsingString(string value, bool expected)
{
var bindable = new BindableBool();
bindable.Parse(value);
bindable.Parse(value, CultureInfo.InvariantCulture);

Assert.AreEqual(expected, bindable.Value);
}
Expand All @@ -36,7 +37,7 @@ public void TestParsingString(string value, bool expected)
public void TestParsingBoolean(bool value)
{
var bindable = new BindableBool();
bindable.Parse(value);
bindable.Parse(value, CultureInfo.InvariantCulture);

Assert.AreEqual(value, bindable.Value);
}
Expand Down
3 changes: 2 additions & 1 deletion osu.Framework.Tests/Bindables/BindableColour4Test.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Globalization;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -41,7 +42,7 @@ public void TestSet(byte r, byte g, byte b, byte a)
public void TestParsingString(string value, Colour4 expected)
{
var bindable = new BindableColour4();
bindable.Parse(value);
bindable.Parse(value, CultureInfo.InvariantCulture);

Assert.AreEqual(expected, bindable.Value);
}
Expand Down
Loading

0 comments on commit 2a810c6

Please sign in to comment.