Skip to content

Commit

Permalink
Merge branch 'master' into InputKey-Character
Browse files Browse the repository at this point in the history
  • Loading branch information
Susko3 committed Feb 1, 2024
2 parents 1ffb0bb + 121d25c commit 7402c7b
Show file tree
Hide file tree
Showing 182 changed files with 4,022 additions and 1,108 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,5 @@ fabric.properties
inspectcodereport.xml
inspectcode

.idea/.idea.osu-framework.Desktop/.idea/misc.xml
.idea/.idea.osu-framework.Desktop/.idea/misc.xml
.idea/.idea.osu-framework.Android/.idea/deploymentTargetDropDown.xml
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 <[email protected]>.
Copyright (c) 2024 ppy Pty Ltd <[email protected]>.

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
21 changes: 19 additions & 2 deletions osu.Framework.Android/AndroidGameView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,25 @@ private void updateSafeArea()
usableScreenArea = usableScreenArea.Shrink(cutout.SafeInsetLeft, cutout.SafeInsetRight, cutout.SafeInsetTop, cutout.SafeInsetBottom);
}

if (OperatingSystem.IsAndroidVersionAtLeast(31) && RootWindowInsets != null)
{
var topLeftCorner = RootWindowInsets.GetRoundedCorner((int)RoundedCornerPosition.TopLeft);
var topRightCorner = RootWindowInsets.GetRoundedCorner((int)RoundedCornerPosition.TopRight);
var bottomLeftCorner = RootWindowInsets.GetRoundedCorner((int)RoundedCornerPosition.BottomLeft);
var bottomRightCorner = RootWindowInsets.GetRoundedCorner((int)RoundedCornerPosition.BottomRight);

int cornerInsetLeft = Math.Max(topLeftCorner?.Radius ?? 0, bottomLeftCorner?.Radius ?? 0);
int cornerInsetRight = Math.Max(topRightCorner?.Radius ?? 0, bottomRightCorner?.Radius ?? 0);
int cornerInsetTop = Math.Max(topLeftCorner?.Radius ?? 0, topRightCorner?.Radius ?? 0);
int cornerInsetBottom = Math.Max(bottomLeftCorner?.Radius ?? 0, bottomRightCorner?.Radius ?? 0);

var radiusInsetArea = screenArea.Width >= screenArea.Height
? screenArea.Shrink(cornerInsetLeft, cornerInsetRight, 0, 0)
: screenArea.Shrink(0, 0, cornerInsetTop, cornerInsetBottom);

usableScreenArea = usableScreenArea.Intersect(radiusInsetArea);
}

if (OperatingSystem.IsAndroidVersionAtLeast(24) && Activity.IsInMultiWindowMode)
{
// if we are in multi-window mode, the status bar is always visible (even if we request to hide it) and could be obstructing our view.
Expand All @@ -257,8 +276,6 @@ private void updateSafeArea()
usableScreenArea = usableScreenArea.Intersect(screenArea.Shrink(0, 0, statusBarHeight, 0));
}

// TODO: add rounded corners support (Android 12): https://developer.android.com/guide/topics/ui/look-and-feel/rounded-corners

// compute the location/area of this view on the screen.

int[] location = new int[2];
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 @@ -15,6 +15,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 @@ -213,6 +215,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
15 changes: 15 additions & 0 deletions osu.Framework.Benchmarks/BenchmarkBindableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace osu.Framework.Benchmarks
public class BenchmarkBindableList
{
private readonly BindableList<int> list = new BindableList<int>();
private IBindableList<int> iList => list;

[GlobalSetup]
public void GlobalSetup()
Expand All @@ -31,5 +32,19 @@ public int Enumerate()

return result;
}

[Benchmark]
public int EnumerateInterface()
{
int result = 0;

for (int i = 0; i < 100; i++)
{
foreach (int val in iList)
result += val;
}

return result;
}
}
}
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 <[email protected]>. 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 <[email protected]>. 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,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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace TemplateGame.Game.Tests.Visual
{
public partial class TemplateGameTestScene : TestScene
public abstract partial class TemplateGameTestScene : TestScene
{
protected override ITestSceneTestRunner CreateRunner() => new TemplateGameTestSceneTestRunner();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace FlappyDon.Game.Tests.Visual
{
public partial class FlappyDonTestScene : TestScene
public abstract partial class FlappyDonTestScene : TestScene
{
protected override ITestSceneTestRunner CreateRunner() => new FlappyDonTestSceneTestRunner();

Expand Down
Loading

0 comments on commit 7402c7b

Please sign in to comment.