Skip to content

Commit

Permalink
Merge branch 'master' into disable-raw-input-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 20, 2025
2 parents 52ed8e7 + b19f2c2 commit e6182cd
Show file tree
Hide file tree
Showing 83 changed files with 1,708 additions and 600 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]
},
"nvika": {
"version": "3.0.0",
"version": "4.0.0",
"commands": [
"nvika"
]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: workflow_dispatch
jobs:
build-macos:
name: Build macOS
runs-on: macos-12
runs-on: macos-13
strategy:
fail-fast: false
matrix:
Expand All @@ -30,7 +30,7 @@ jobs:

combine-macos:
name: Combine macOS libs
runs-on: macos-12
runs-on: macos-13
needs: build-macos
steps:
- name: Checkout
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:

build-iOS:
name: Build iOS
runs-on: macos-12
runs-on: macos-13
strategy:
matrix:
arch: [arm64, simulator-arm64, simulator-x86_64]
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:

combine-iOS:
name: Combine iOS libs
runs-on: macos-12
runs-on: macos-13
needs: build-iOS
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions osu-framework.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ARGB/@EntryIndexedValue">ARGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BPM/@EntryIndexedValue">BPM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CG/@EntryIndexedValue">CG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FBO/@EntryIndexedValue">FBO</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CCL/@EntryIndexedValue">CCL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GC/@EntryIndexedValue">GC</s:String>
Expand Down
1 change: 0 additions & 1 deletion osu.Framework.Android/osu.Framework.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<ProjectReference Include="..\osu.Framework\osu.Framework.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.SDL3-CS.Android" Version="2024.1128.0" />
<PackageReference Include="Xamarin.AndroidX.Window" Version="1.2.0.1" PrivateAssets="compile" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private void scrollTo(float position, float scrollContentHeight, float extension
AddStep($"scroll to {position}", () =>
{
scrollContainer.ScrollTo(position, false);
immediateScrollPosition = scrollContainer.Current;
immediateScrollPosition = (float)scrollContainer.Current;
});

AddAssert($"immediately scrolled to {clampedTarget}", () => Precision.AlmostEquals(clampedTarget, immediateScrollPosition, 1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// 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;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osuTK;
using osuTK.Graphics;

namespace osu.Framework.Tests.Visual.Containers
{
public partial class TestSceneScrollContainerDoublePrecision : ManualInputManagerTestScene
{
private const float item_height = 5000;
private const int item_count = 8000;

private ScrollContainer<Drawable> scrollContainer = null!;

[SetUp]
public void Setup() => Schedule(Clear);

[Test]
public void TestStandard()
{
AddStep("Create scroll container", () =>
{
Add(scrollContainer = new BasicScrollContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
ScrollbarVisible = true,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.7f, 0.9f),
});

for (int i = 0; i < item_count; i++)
{
scrollContainer.Add(new BoxWithDouble
{
Colour = new Color4(RNG.NextSingle(1), RNG.NextSingle(1), RNG.NextSingle(1), 1),
RelativeSizeAxes = Axes.X,
Height = item_height,
Y = i * item_height,
});
}
});

scrollIntoView(item_count - 2);
scrollIntoView(item_count - 1);
}

[Test]
public void TestDoublePrecision()
{
AddStep("Create scroll container", () =>
{
Add(scrollContainer = new DoubleScrollContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
ScrollbarVisible = true,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.7f, 0.9f),
});

for (int i = 0; i < item_count; i++)
{
scrollContainer.Add(new BoxWithDouble
{
Colour = new Color4(RNG.NextSingle(1), RNG.NextSingle(1), RNG.NextSingle(1), 1),
RelativeSizeAxes = Axes.X,
Height = item_height,
DoubleLocation = i * item_height,
});
}
});

scrollIntoView(item_count - 2);
scrollIntoView(item_count - 1);
}

private void scrollIntoView(int index)
{
AddStep($"scroll {index} into view", () => scrollContainer.ScrollIntoView(scrollContainer.ChildrenOfType<BoxWithDouble>().Skip(index).First()));
AddUntilStep($"{index} is visible", () => !scrollContainer.ChildrenOfType<BoxWithDouble>().Skip(index).First().IsMaskedAway);
}

public partial class DoubleScrollContainer : BasicScrollContainer
{
private readonly Container<BoxWithDouble> layoutContent;

public override void Add(Drawable drawable)
{
if (drawable is not BoxWithDouble boxWithDouble)
throw new InvalidOperationException();

Add(boxWithDouble);
}

public void Add(BoxWithDouble drawable)
{
if (drawable is not BoxWithDouble boxWithDouble)
throw new InvalidOperationException();

layoutContent.Height = (float)Math.Max(layoutContent.Height, boxWithDouble.DoubleLocation + boxWithDouble.DrawHeight);
layoutContent.Add(drawable);
}

public DoubleScrollContainer()
{
// Managing our own custom layout within ScrollContent causes feedback with internal ScrollContainer calculations,
// so we must maintain one level of separation from ScrollContent.
base.Add(layoutContent = new Container<BoxWithDouble>
{
RelativeSizeAxes = Axes.X,
});
}

public override double GetChildPosInContent(Drawable d, Vector2 offset)
{
if (d is not BoxWithDouble boxWithDouble)
return base.GetChildPosInContent(d, offset);

return boxWithDouble.DoubleLocation + offset.X;
}

protected override void ApplyCurrentToContent()
{
Debug.Assert(ScrollDirection == Direction.Vertical);

double scrollableExtent = -Current + ScrollableExtent * ScrollContent.RelativeAnchorPosition.Y;

foreach (var d in layoutContent)
d.Y = (float)(d.DoubleLocation + scrollableExtent);
}
}

public partial class BoxWithDouble : Box
{
public double DoubleLocation { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ public void TestManyChildren(bool instant)
AddUntilStep("repeating schedulers removed", () => !scroll.Scheduler.HasPendingTasks);
}

// Fails once in a blue moon due to loose (but maybe-not-loose-enough) timing requirements. If we break things, it will fail every time so this is fine.
[TestCase(false)]
[TestCase(true)]
[FlakyTest]
public void TestManyChildrenFunction(bool instant)
{
AddStep("create children", () =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// 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 System.IO;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osuTK;
using osuTK.Graphics;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace osu.Framework.Tests.Visual.Graphics
{
public partial class TestSceneTexturePremultiplication : FrameworkTestScene
{
private TextureStore textures = null!;

[BackgroundDependencyLoader]
private void load(GameHost host)
{
textures = new TextureStore(host.Renderer, host.CreateTextureLoaderStore(new CustomResourceStore()), false, TextureFilteringMode.Nearest);
}

[Test]
public void TestComparison()
{
AddStep("setup", () =>
{
Child = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(0f, 5f),
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new Container
{
AutoSizeAxes = Axes.Both,
Children = new[]
{
new Box
{
Size = new Vector2(256, 128),
Colour = Color4.Blue,
},
new Sprite
{
Texture = textures.Get("zero-to-red"),
Size = new Vector2(256, 128),
}
},
},
new SpriteText
{
Text = "Rendering of the sprite above should be identical to the one below",
},
new Sprite
{
Texture = textures.Get("blue-to-red"),
Size = new Vector2(256, 128),
},
}
};
});
}

private class CustomResourceStore : IResourceStore<byte[]>
{
public byte[] Get(string name) => throw new System.NotImplementedException();
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = default) => throw new System.NotImplementedException();

public Stream GetStream(string name)
{
switch (name)
{
case "zero-to-red":
{
var memoryStream = new MemoryStream();

Image<Rgba32> image = new Image<Rgba32>(256, 1);

for (int i = 0; i < 256; i++)
image[i, 0] = new Rgba32(255, 0, 0, (byte)i);

image.SaveAsPng(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
}

case "blue-to-red":
{
var memoryStream = new MemoryStream();

Image<Rgba32> image = new Image<Rgba32>(256, 1);

for (int i = 0; i < 256; i++)
image[i, 0] = new Rgba32((byte)i, 0, (byte)(255 - i), 255);

image.SaveAsPng(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
}

default:
return Stream.Null;
}
}

public IEnumerable<string> GetAvailableResources() => new[] { "zero-to-red", "blue-to-red" };

public void Dispose()
{
}
}
}
}
Loading

0 comments on commit e6182cd

Please sign in to comment.