Fix Background blur thread-safety (#5362)

Fix Background blur thread-safety
This commit is contained in:
Dean Herbert 2019-07-17 22:01:19 +09:00 committed by GitHub
commit 338f757c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary> /// </summary>
public class Background : CompositeDrawable public class Background : CompositeDrawable
{ {
public Sprite Sprite; public readonly Sprite Sprite;
private readonly string textureName; private readonly string textureName;
@ -51,7 +51,7 @@ namespace osu.Game.Graphics.Backgrounds
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns> /// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public void BlurTo(Vector2 newBlurSigma, double duration = 0, Easing easing = Easing.None) public void BlurTo(Vector2 newBlurSigma, double duration = 0, Easing easing = Easing.None)
{ {
if (bufferedContainer == null) if (bufferedContainer == null && newBlurSigma != Vector2.Zero)
{ {
RemoveInternal(Sprite); RemoveInternal(Sprite);
@ -63,7 +63,7 @@ namespace osu.Game.Graphics.Backgrounds
}); });
} }
bufferedContainer.BlurTo(newBlurSigma, duration, easing); bufferedContainer?.BlurTo(newBlurSigma, duration, easing);
} }
} }
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System; using System;
@ -168,6 +168,12 @@ namespace osu.Game.Screens.Backgrounds
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel); userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
}
protected override void LoadComplete()
{
base.LoadComplete();
userBlurLevel.ValueChanged += _ => UpdateVisuals(); userBlurLevel.ValueChanged += _ => UpdateVisuals();
BlurAmount.ValueChanged += _ => UpdateVisuals(); BlurAmount.ValueChanged += _ => UpdateVisuals();
} }