mirror of
https://github.com/ppy/osu.git
synced 2024-12-18 04:33:22 +08:00
Merge pull request #29476 from EVAST9919/buffered-editor-grid
Improve draw performance of editor grids
This commit is contained in:
commit
24a0a3c47f
@ -2,15 +2,17 @@
|
|||||||
// 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 osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Layout;
|
using osu.Framework.Layout;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
{
|
{
|
||||||
public abstract partial class PositionSnapGrid : CompositeDrawable
|
public abstract partial class PositionSnapGrid : BufferedContainer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The position of the origin of this <see cref="PositionSnapGrid"/> in local coordinates.
|
/// The position of the origin of this <see cref="PositionSnapGrid"/> in local coordinates.
|
||||||
@ -20,7 +22,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
protected readonly LayoutValue GridCache = new LayoutValue(Invalidation.RequiredParentSizeToFit);
|
protected readonly LayoutValue GridCache = new LayoutValue(Invalidation.RequiredParentSizeToFit);
|
||||||
|
|
||||||
protected PositionSnapGrid()
|
protected PositionSnapGrid()
|
||||||
|
: base(cachedFrameBuffer: true)
|
||||||
{
|
{
|
||||||
|
BackgroundColour = Color4.White.Opacity(0);
|
||||||
|
|
||||||
StartPosition.BindValueChanged(_ => GridCache.Invalidate());
|
StartPosition.BindValueChanged(_ => GridCache.Invalidate());
|
||||||
|
|
||||||
AddLayout(GridCache);
|
AddLayout(GridCache);
|
||||||
@ -30,7 +35,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (GridCache.IsValid) return;
|
if (GridCache.IsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
ClearInternal();
|
ClearInternal();
|
||||||
|
|
||||||
@ -38,6 +44,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
CreateContent();
|
CreateContent();
|
||||||
|
|
||||||
GridCache.Validate();
|
GridCache.Validate();
|
||||||
|
ForceRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void CreateContent();
|
protected abstract void CreateContent();
|
||||||
@ -53,7 +60,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
Colour = Colour4.White,
|
Colour = Colour4.White,
|
||||||
Alpha = 0.3f,
|
Alpha = 0.3f,
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = lineWidth,
|
Height = lineWidth,
|
||||||
Y = 0,
|
Y = 0,
|
||||||
@ -62,28 +68,26 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
Colour = Colour4.White,
|
Colour = Colour4.White,
|
||||||
Alpha = 0.3f,
|
Alpha = 0.3f,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = lineWidth,
|
Height = lineWidth
|
||||||
Y = drawSize.Y,
|
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
Colour = Colour4.White,
|
Colour = Colour4.White,
|
||||||
Alpha = 0.3f,
|
Alpha = 0.3f,
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = lineWidth,
|
Width = lineWidth
|
||||||
X = 0,
|
|
||||||
},
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
Colour = Colour4.White,
|
Colour = Colour4.White,
|
||||||
Alpha = 0.3f,
|
Alpha = 0.3f,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopRight,
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = lineWidth,
|
Width = lineWidth
|
||||||
X = drawSize.X,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user