A game framework written with osu! in mind.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace all usages of HasFlag with HasFlagFast

+116 -91
+5 -4
osu.Framework.Tests/Visual/Containers/TestSceneSafeAreaOverrides.cs
··· 1 1 // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 + using osu.Framework.Extensions.EnumExtensions; 4 5 using osu.Framework.Graphics; 5 6 using osu.Framework.Graphics.Containers; 6 7 using osu.Framework.Graphics.Shapes; ··· 38 39 39 40 private void addBoxAssert(OverrideTestContainer container) 40 41 { 41 - bool leftOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlag(Edges.Left); 42 - bool topOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlag(Edges.Top); 43 - bool rightOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlag(Edges.Right); 44 - bool bottomOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlag(Edges.Bottom); 42 + bool leftOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlagFast(Edges.Left); 43 + bool topOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlagFast(Edges.Top); 44 + bool rightOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlagFast(Edges.Right); 45 + bool bottomOverridden = container.SafeAreaContainer.SafeAreaOverrideEdges.HasFlagFast(Edges.Bottom); 45 46 46 47 AddAssert($"\"{container.Name}\" overrides correctly", () => 47 48 leftOverridden == container.SafeAreaContainer.Padding.Left < 0
+3 -2
osu.Framework.Tests/Visual/Drawables/TestSceneIsMaskedAway.cs
··· 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 4 using NUnit.Framework; 5 + using osu.Framework.Extensions.EnumExtensions; 5 6 using osu.Framework.Graphics; 6 7 using osu.Framework.Graphics.Containers; 7 8 using osu.Framework.Graphics.Shapes; ··· 82 83 Anchor = anchor, 83 84 Origin = anchor, 84 85 Size = new Vector2(10), 85 - Position = new Vector2(anchor.HasFlag(Anchor.x0) ? -5 : 5, anchor.HasFlag(Anchor.y0) ? -5 : 5), 86 + Position = new Vector2(anchor.HasFlagFast(Anchor.x0) ? -5 : 5, anchor.HasFlagFast(Anchor.y0) ? -5 : 5), 86 87 } 87 88 }; 88 89 }); ··· 115 116 Anchor = anchor, 116 117 Origin = anchor, 117 118 Size = new Vector2(10), 118 - Position = new Vector2(anchor.HasFlag(Anchor.x0) ? -20 : 20, anchor.HasFlag(Anchor.y0) ? -20 : 20), 119 + Position = new Vector2(anchor.HasFlagFast(Anchor.x0) ? -20 : 20, anchor.HasFlagFast(Anchor.y0) ? -20 : 20), 119 120 } 120 121 }; 121 122 });
+5 -4
osu.Framework.Tests/Visual/UserInterface/TestSceneContextMenu.cs
··· 4 4 using System; 5 5 using System.Linq; 6 6 using NUnit.Framework; 7 + using osu.Framework.Extensions.EnumExtensions; 7 8 using osu.Framework.Graphics; 8 9 using osu.Framework.Graphics.Containers; 9 10 using osu.Framework.Graphics.Cursor; ··· 152 153 { 153 154 box.Anchor = anchor; 154 155 155 - if (anchor.HasFlag(Anchor.x0)) 156 + if (anchor.HasFlagFast(Anchor.x0)) 156 157 box.X -= contextMenuContainer.CurrentMenu.DrawWidth + 10; 157 - else if (anchor.HasFlag(Anchor.x2)) 158 + else if (anchor.HasFlagFast(Anchor.x2)) 158 159 box.X += 10; 159 160 160 - if (anchor.HasFlag(Anchor.y0)) 161 + if (anchor.HasFlagFast(Anchor.y0)) 161 162 box.Y -= contextMenuContainer.CurrentMenu.DrawHeight + 10; 162 - else if (anchor.HasFlag(Anchor.y2)) 163 + else if (anchor.HasFlagFast(Anchor.y2)) 163 164 box.Y += 10; 164 165 }); 165 166
+2
osu.Framework/Extensions/EnumExtensions/EnumExtensions.cs
··· 53 53 }); 54 54 } 55 55 56 + #pragma warning disable RS0030 // (banned API) 56 57 /// <summary> 57 58 /// A fast alternative functionally equivalent to <see cref="Enum.HasFlag"/>, eliminating boxing in all scenarios. 58 59 /// </summary> 59 60 /// <param name="enumValue">The enum to check.</param> 60 61 /// <param name="flag">The flag to check for.</param> 62 + #pragma warning restore RS0030 61 63 [MethodImpl(MethodImplOptions.AggressiveInlining)] 62 64 public static unsafe bool HasFlagFast<T>(this T enumValue, T flag) where T : unmanaged, Enum 63 65 {
+3 -2
osu.Framework/Graphics/Containers/AudioContainer.cs
··· 5 5 using System.Collections; 6 6 using System.Collections.Generic; 7 7 using osu.Framework.Audio; 8 + using osu.Framework.Extensions.EnumExtensions; 8 9 using osu.Framework.Graphics.Audio; 9 10 using osu.Framework.Graphics.Effects; 10 11 using osuTK; ··· 40 41 set 41 42 { 42 43 base.Size = new Vector2( 43 - RelativeSizeAxes.HasFlag(Axes.X) ? 1 : value.X, 44 - RelativeSizeAxes.HasFlag(Axes.Y) ? 1 : value.Y); 44 + RelativeSizeAxes.HasFlagFast(Axes.X) ? 1 : value.X, 45 + RelativeSizeAxes.HasFlagFast(Axes.Y) ? 1 : value.Y); 45 46 46 47 container.Size = value; 47 48 }
+11 -10
osu.Framework/Graphics/Containers/CompositeDrawable.cs
··· 21 21 using System.Threading.Tasks; 22 22 using JetBrains.Annotations; 23 23 using osu.Framework.Development; 24 + using osu.Framework.Extensions.EnumExtensions; 24 25 using osu.Framework.Extensions.ExceptionExtensions; 25 26 using osu.Framework.Graphics.Effects; 26 27 using osu.Framework.Graphics.Primitives; ··· 666 667 { 667 668 var state = checkChildLife(internalChildren[i]); 668 669 669 - anyAliveChanged |= state.HasFlag(ChildLifeStateChange.MadeAlive) || state.HasFlag(ChildLifeStateChange.MadeDead); 670 + anyAliveChanged |= state.HasFlagFast(ChildLifeStateChange.MadeAlive) || state.HasFlagFast(ChildLifeStateChange.MadeDead); 670 671 671 - if (state.HasFlag(ChildLifeStateChange.Removed)) 672 + if (state.HasFlagFast(ChildLifeStateChange.Removed)) 672 673 i--; 673 674 } 674 675 ··· 1706 1707 { 1707 1708 get 1708 1709 { 1709 - if (!isComputingChildrenSizeDependencies && AutoSizeAxes.HasFlag(Axes.X)) 1710 + if (!isComputingChildrenSizeDependencies && AutoSizeAxes.HasFlagFast(Axes.X)) 1710 1711 updateChildrenSizeDependencies(); 1711 1712 return base.Width; 1712 1713 } ··· 1724 1725 { 1725 1726 get 1726 1727 { 1727 - if (!isComputingChildrenSizeDependencies && AutoSizeAxes.HasFlag(Axes.Y)) 1728 + if (!isComputingChildrenSizeDependencies && AutoSizeAxes.HasFlagFast(Axes.Y)) 1728 1729 updateChildrenSizeDependencies(); 1729 1730 return base.Height; 1730 1731 } ··· 1780 1781 1781 1782 Vector2 cBound = c.RequiredParentSizeToFit; 1782 1783 1783 - if (!c.BypassAutoSizeAxes.HasFlag(Axes.X)) 1784 + if (!c.BypassAutoSizeAxes.HasFlagFast(Axes.X)) 1784 1785 maxBoundSize.X = Math.Max(maxBoundSize.X, cBound.X); 1785 1786 1786 - if (!c.BypassAutoSizeAxes.HasFlag(Axes.Y)) 1787 + if (!c.BypassAutoSizeAxes.HasFlagFast(Axes.Y)) 1787 1788 maxBoundSize.Y = Math.Max(maxBoundSize.Y, cBound.Y); 1788 1789 } 1789 1790 1790 - if (!AutoSizeAxes.HasFlag(Axes.X)) 1791 + if (!AutoSizeAxes.HasFlagFast(Axes.X)) 1791 1792 maxBoundSize.X = DrawSize.X; 1792 - if (!AutoSizeAxes.HasFlag(Axes.Y)) 1793 + if (!AutoSizeAxes.HasFlagFast(Axes.Y)) 1793 1794 maxBoundSize.Y = DrawSize.Y; 1794 1795 1795 1796 return new Vector2(maxBoundSize.X, maxBoundSize.Y); ··· 1809 1810 Vector2 b = computeAutoSize() + Padding.Total; 1810 1811 1811 1812 autoSizeResizeTo(new Vector2( 1812 - AutoSizeAxes.HasFlag(Axes.X) ? b.X : base.Width, 1813 - AutoSizeAxes.HasFlag(Axes.Y) ? b.Y : base.Height 1813 + AutoSizeAxes.HasFlagFast(Axes.X) ? b.X : base.Width, 1814 + AutoSizeAxes.HasFlagFast(Axes.Y) ? b.Y : base.Height 1814 1815 ), AutoSizeDuration, AutoSizeEasing); 1815 1816 1816 1817 //note that this is called before autoSize becomes valid. may be something to consider down the line.
+3 -2
osu.Framework/Graphics/Containers/ContainerExtensions.cs
··· 4 4 using osuTK; 5 5 using System; 6 6 using System.Collections.Generic; 7 + using osu.Framework.Extensions.EnumExtensions; 7 8 8 9 namespace osu.Framework.Graphics.Containers 9 10 { ··· 43 44 44 45 // For anchor/origin positioning to be preserved correctly, 45 46 // relatively sized axes must be lifted to the wrapping container. 46 - if (container.RelativeSizeAxes.HasFlag(Axes.X)) 47 + if (container.RelativeSizeAxes.HasFlagFast(Axes.X)) 47 48 { 48 49 container.Width = drawable.Width; 49 50 drawable.Width = 1; 50 51 } 51 52 52 - if (container.RelativeSizeAxes.HasFlag(Axes.Y)) 53 + if (container.RelativeSizeAxes.HasFlagFast(Axes.Y)) 53 54 { 54 55 container.Height = drawable.Height; 55 56 drawable.Height = 1;
+9 -8
osu.Framework/Graphics/Containers/FillFlowContainer.cs
··· 5 5 using System.Collections.Generic; 6 6 using osuTK; 7 7 using System.Linq; 8 + using osu.Framework.Extensions.EnumExtensions; 8 9 using osu.Framework.Utils; 9 10 10 11 namespace osu.Framework.Graphics.Containers ··· 87 88 private Vector2 spacingFactor(Drawable c) 88 89 { 89 90 Vector2 result = c.RelativeOriginPosition; 90 - if (c.Anchor.HasFlag(Anchor.x2)) 91 + if (c.Anchor.HasFlagFast(Anchor.x2)) 91 92 result.X = 1 - result.X; 92 - if (c.Anchor.HasFlag(Anchor.y2)) 93 + if (c.Anchor.HasFlagFast(Anchor.y2)) 93 94 result.Y = 1 - result.Y; 94 95 return result; 95 96 } ··· 104 105 105 106 // If we are autosize and haven't specified a maximum size, we should allow infinite expansion. 106 107 // If we are inheriting then we need to use the parent size (our ActualSize). 107 - max.X = AutoSizeAxes.HasFlag(Axes.X) ? float.MaxValue : s.X; 108 - max.Y = AutoSizeAxes.HasFlag(Axes.Y) ? float.MaxValue : s.Y; 108 + max.X = AutoSizeAxes.HasFlagFast(Axes.X) ? float.MaxValue : s.X; 109 + max.Y = AutoSizeAxes.HasFlagFast(Axes.Y) ? float.MaxValue : s.Y; 109 110 } 110 111 111 112 var children = FlowingChildren.ToArray(); ··· 262 263 break; 263 264 } 264 265 265 - if (c.Anchor.HasFlag(Anchor.x1)) 266 + if (c.Anchor.HasFlagFast(Anchor.x1)) 266 267 // Begin flow at centre of row 267 268 result[i].X += rowOffsetsToMiddle[rowIndices[i]]; 268 - else if (c.Anchor.HasFlag(Anchor.x2)) 269 + else if (c.Anchor.HasFlagFast(Anchor.x2)) 269 270 // Flow right-to-left 270 271 result[i].X = -result[i].X; 271 272 272 - if (c.Anchor.HasFlag(Anchor.y1)) 273 + if (c.Anchor.HasFlagFast(Anchor.y1)) 273 274 // Begin flow at centre of total height 274 275 result[i].Y -= height / 2; 275 - else if (c.Anchor.HasFlag(Anchor.y2)) 276 + else if (c.Anchor.HasFlagFast(Anchor.y2)) 276 277 // Flow bottom-to-top 277 278 result[i].Y = -result[i].Y; 278 279 }
+2 -1
osu.Framework/Graphics/Containers/Markdown/MarkdownContainer.cs
··· 10 10 using Markdig.Syntax.Inlines; 11 11 using osu.Framework.Allocation; 12 12 using osu.Framework.Caching; 13 + using osu.Framework.Extensions.EnumExtensions; 13 14 using osu.Framework.Graphics.Sprites; 14 15 using osuTK; 15 16 ··· 37 38 get => base.AutoSizeAxes; 38 39 set 39 40 { 40 - if (value.HasFlag(Axes.X)) 41 + if (value.HasFlagFast(Axes.X)) 41 42 throw new ArgumentException($"{nameof(MarkdownContainer)} does not support an {nameof(AutoSizeAxes)} of {value}"); 42 43 43 44 base.AutoSizeAxes = value;
+5 -4
osu.Framework/Graphics/Containers/SafeAreaContainer.cs
··· 4 4 using System; 5 5 using osu.Framework.Allocation; 6 6 using osu.Framework.Bindables; 7 + using osu.Framework.Extensions.EnumExtensions; 7 8 using osu.Framework.Graphics.Primitives; 8 9 using osu.Framework.Layout; 9 10 ··· 76 77 77 78 return new MarginPadding 78 79 { 79 - Left = SafeAreaOverrideEdges.HasFlag(Edges.Left) ? nonSafeLocalSpace.TopLeft.X : Math.Clamp(localTopLeft.X, 0, DrawSize.X), 80 - Right = SafeAreaOverrideEdges.HasFlag(Edges.Right) ? DrawRectangle.BottomRight.X - nonSafeLocalSpace.BottomRight.X : Math.Clamp(DrawSize.X - localBottomRight.X, 0, DrawSize.X), 81 - Top = SafeAreaOverrideEdges.HasFlag(Edges.Top) ? nonSafeLocalSpace.TopLeft.Y : Math.Clamp(localTopLeft.Y, 0, DrawSize.Y), 82 - Bottom = SafeAreaOverrideEdges.HasFlag(Edges.Bottom) ? DrawRectangle.BottomRight.Y - nonSafeLocalSpace.BottomRight.Y : Math.Clamp(DrawSize.Y - localBottomRight.Y, 0, DrawSize.Y) 80 + Left = SafeAreaOverrideEdges.HasFlagFast(Edges.Left) ? nonSafeLocalSpace.TopLeft.X : Math.Clamp(localTopLeft.X, 0, DrawSize.X), 81 + Right = SafeAreaOverrideEdges.HasFlagFast(Edges.Right) ? DrawRectangle.BottomRight.X - nonSafeLocalSpace.BottomRight.X : Math.Clamp(DrawSize.X - localBottomRight.X, 0, DrawSize.X), 82 + Top = SafeAreaOverrideEdges.HasFlagFast(Edges.Top) ? nonSafeLocalSpace.TopLeft.Y : Math.Clamp(localTopLeft.Y, 0, DrawSize.Y), 83 + Bottom = SafeAreaOverrideEdges.HasFlagFast(Edges.Bottom) ? DrawRectangle.BottomRight.Y - nonSafeLocalSpace.BottomRight.Y : Math.Clamp(DrawSize.Y - localBottomRight.Y, 0, DrawSize.Y) 83 84 }; 84 85 } 85 86 }
+2 -1
osu.Framework/Graphics/Containers/TextFlowContainer.cs
··· 7 7 using System.Collections.Generic; 8 8 using System.Linq; 9 9 using System.Text; 10 + using osu.Framework.Extensions.EnumExtensions; 10 11 11 12 namespace osu.Framework.Graphics.Containers 12 13 { ··· 192 193 { 193 194 // FillFlowContainer will reverse the ordering of right-anchored words such that the (previously) first word would be 194 195 // the right-most word, whereas it should still be flowed left-to-right. This is achieved by reversing the comparator. 195 - if (TextAnchor.HasFlag(Anchor.x2)) 196 + if (TextAnchor.HasFlagFast(Anchor.x2)) 196 197 return base.Compare(y, x); 197 198 198 199 return base.Compare(x, y);
+19 -18
osu.Framework/Graphics/Drawable.cs
··· 25 25 using JetBrains.Annotations; 26 26 using osu.Framework.Bindables; 27 27 using osu.Framework.Development; 28 + using osu.Framework.Extensions.EnumExtensions; 28 29 using osu.Framework.Graphics.Cursor; 29 30 using osu.Framework.Graphics.OpenGL; 30 31 using osu.Framework.Input.Bindings; ··· 661 662 { 662 663 offset = Parent.RelativeChildOffset; 663 664 664 - if (!RelativePositionAxes.HasFlag(Axes.X)) 665 + if (!RelativePositionAxes.HasFlagFast(Axes.X)) 665 666 offset.X = 0; 666 667 667 - if (!RelativePositionAxes.HasFlag(Axes.Y)) 668 + if (!RelativePositionAxes.HasFlagFast(Axes.Y)) 668 669 offset.Y = 0; 669 670 } 670 671 ··· 790 791 791 792 relativeSizeAxes = value; 792 793 793 - if (relativeSizeAxes.HasFlag(Axes.X) && Width == 0) Width = 1; 794 - if (relativeSizeAxes.HasFlag(Axes.Y) && Height == 0) Height = 1; 794 + if (relativeSizeAxes.HasFlagFast(Axes.X) && Width == 0) Width = 1; 795 + if (relativeSizeAxes.HasFlagFast(Axes.Y) && Height == 0) Height = 1; 795 796 796 797 updateBypassAutoSizeAxes(); 797 798 ··· 885 886 { 886 887 Vector2 conversion = relativeToAbsoluteFactor; 887 888 888 - if (relativeAxes.HasFlag(Axes.X)) 889 + if (relativeAxes.HasFlagFast(Axes.X)) 889 890 v.X *= conversion.X; 890 - if (relativeAxes.HasFlag(Axes.Y)) 891 + if (relativeAxes.HasFlagFast(Axes.Y)) 891 892 v.Y *= conversion.Y; 892 893 893 894 // FillMode only makes sense if both axes are relatively sized as the general rule ··· 1122 1123 throw new InvalidOperationException(@"Can not obtain relative origin position for custom origins."); 1123 1124 1124 1125 Vector2 result = Vector2.Zero; 1125 - if (origin.HasFlag(Anchor.x1)) 1126 + if (origin.HasFlagFast(Anchor.x1)) 1126 1127 result.X = 0.5f; 1127 - else if (origin.HasFlag(Anchor.x2)) 1128 + else if (origin.HasFlagFast(Anchor.x2)) 1128 1129 result.X = 1; 1129 1130 1130 - if (origin.HasFlag(Anchor.y1)) 1131 + if (origin.HasFlagFast(Anchor.y1)) 1131 1132 result.Y = 0.5f; 1132 - else if (origin.HasFlag(Anchor.y2)) 1133 + else if (origin.HasFlagFast(Anchor.y2)) 1133 1134 result.Y = 1; 1134 1135 1135 1136 return result; ··· 1211 1212 return customRelativeAnchorPosition; 1212 1213 1213 1214 Vector2 result = Vector2.Zero; 1214 - if (anchor.HasFlag(Anchor.x1)) 1215 + if (anchor.HasFlagFast(Anchor.x1)) 1215 1216 result.X = 0.5f; 1216 - else if (anchor.HasFlag(Anchor.x2)) 1217 + else if (anchor.HasFlagFast(Anchor.x2)) 1217 1218 result.X = 1; 1218 1219 1219 - if (anchor.HasFlag(Anchor.y1)) 1220 + if (anchor.HasFlagFast(Anchor.y1)) 1220 1221 result.Y = 0.5f; 1221 - else if (anchor.HasFlag(Anchor.y2)) 1222 + else if (anchor.HasFlagFast(Anchor.y2)) 1222 1223 result.Y = 1; 1223 1224 1224 1225 return result; ··· 1256 1257 { 1257 1258 Vector2 result = Vector2.Zero; 1258 1259 1259 - if (anchor.HasFlag(Anchor.x1)) 1260 + if (anchor.HasFlagFast(Anchor.x1)) 1260 1261 result.X = size.X / 2f; 1261 - else if (anchor.HasFlag(Anchor.x2)) 1262 + else if (anchor.HasFlagFast(Anchor.x2)) 1262 1263 result.X = size.X; 1263 1264 1264 - if (anchor.HasFlag(Anchor.y1)) 1265 + if (anchor.HasFlagFast(Anchor.y1)) 1265 1266 result.Y = size.Y / 2f; 1266 - else if (anchor.HasFlag(Anchor.y2)) 1267 + else if (anchor.HasFlagFast(Anchor.y2)) 1267 1268 result.Y = size.Y; 1268 1269 1269 1270 return result;
+3 -2
osu.Framework/Graphics/Lines/Path.cs
··· 9 9 using osu.Framework.Allocation; 10 10 using System.Collections.Generic; 11 11 using osu.Framework.Caching; 12 + using osu.Framework.Extensions.EnumExtensions; 12 13 using osuTK.Graphics; 13 14 using osuTK.Graphics.ES30; 14 15 ··· 113 114 { 114 115 get 115 116 { 116 - if (AutoSizeAxes.HasFlag(Axes.X)) 117 + if (AutoSizeAxes.HasFlagFast(Axes.X)) 117 118 return base.Width = vertexBounds.Width; 118 119 119 120 return base.Width; ··· 131 132 { 132 133 get 133 134 { 134 - if (AutoSizeAxes.HasFlag(Axes.Y)) 135 + if (AutoSizeAxes.HasFlagFast(Axes.Y)) 135 136 return base.Height = vertexBounds.Height; 136 137 137 138 return base.Height;
+2 -1
osu.Framework/Graphics/Pooling/PoolableDrawable.cs
··· 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 4 using System; 5 + using osu.Framework.Extensions.EnumExtensions; 5 6 using osu.Framework.Graphics.Containers; 6 7 using osu.Framework.Layout; 7 8 using osu.Framework.Threading; ··· 117 118 118 119 protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source) 119 120 { 120 - if (source != InvalidationSource.Child && invalidation.HasFlag(Invalidation.Parent)) 121 + if (source != InvalidationSource.Child && invalidation.HasFlagFast(Invalidation.Parent)) 121 122 { 122 123 if (IsInUse && Parent == null) 123 124 Return();
+3 -2
osu.Framework/Graphics/Textures/Texture.cs
··· 3 3 4 4 using System; 5 5 using System.IO; 6 + using osu.Framework.Extensions.EnumExtensions; 6 7 using osu.Framework.Graphics.Batches; 7 8 using osu.Framework.Graphics.OpenGL.Textures; 8 9 using osu.Framework.Graphics.Primitives; ··· 73 74 if (relativeSizeAxes != Axes.None) 74 75 { 75 76 Vector2 scale = new Vector2( 76 - relativeSizeAxes.HasFlag(Axes.X) ? Width : 1, 77 - relativeSizeAxes.HasFlag(Axes.Y) ? Height : 1 77 + relativeSizeAxes.HasFlagFast(Axes.X) ? Width : 1, 78 + relativeSizeAxes.HasFlagFast(Axes.Y) ? Height : 1 78 79 ); 79 80 cropRectangle *= scale; 80 81 }
+3 -2
osu.Framework/Graphics/UserInterface/Menu.cs
··· 4 4 using System; 5 5 using System.Collections.Generic; 6 6 using System.Linq; 7 + using osu.Framework.Extensions.EnumExtensions; 7 8 using osu.Framework.Extensions.IEnumerableExtensions; 8 9 using osuTK.Graphics; 9 10 using osu.Framework.Graphics.Containers; ··· 362 363 height = Math.Min(MaxHeight, height); 363 364 364 365 // Regardless of the above result, if we are relative-sizing, just use the stored width/height 365 - width = RelativeSizeAxes.HasFlag(Axes.X) ? Width : width; 366 - height = RelativeSizeAxes.HasFlag(Axes.Y) ? Height : height; 366 + width = RelativeSizeAxes.HasFlagFast(Axes.X) ? Width : width; 367 + height = RelativeSizeAxes.HasFlagFast(Axes.Y) ? Height : height; 367 368 368 369 if (State == MenuState.Closed && Direction == Direction.Horizontal) 369 370 width = 0;
+3 -2
osu.Framework/Graphics/UserInterface/TabControl.cs
··· 7 7 using System.Linq; 8 8 using JetBrains.Annotations; 9 9 using osu.Framework.Bindables; 10 + using osu.Framework.Extensions.EnumExtensions; 10 11 using osu.Framework.Graphics.Containers; 11 12 using osu.Framework.Input; 12 13 using osu.Framework.Input.Bindings; ··· 168 169 169 170 AddInternal(Dropdown); 170 171 171 - Trace.Assert(Dropdown.Header.Anchor.HasFlag(Anchor.x2), $@"The {nameof(Dropdown)} implementation should use a right-based anchor inside a TabControl."); 172 - Trace.Assert(!Dropdown.Header.RelativeSizeAxes.HasFlag(Axes.X), $@"The {nameof(Dropdown)} implementation's header should have a specific size."); 172 + Trace.Assert(Dropdown.Header.Anchor.HasFlagFast(Anchor.x2), $@"The {nameof(Dropdown)} implementation should use a right-based anchor inside a TabControl."); 173 + Trace.Assert(!Dropdown.Header.RelativeSizeAxes.HasFlagFast(Axes.X), $@"The {nameof(Dropdown)} implementation's header should have a specific size."); 173 174 } 174 175 175 176 AddInternal(TabContainer = CreateTabFlow());
+2 -1
osu.Framework/Input/Handlers/Mouse/OsuTKMouseState.cs
··· 1 1 // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 + using osu.Framework.Extensions.EnumExtensions; 4 5 using osuTK; 5 6 using osuTK.Input; 6 7 ··· 29 30 } 30 31 31 32 Scroll = new Vector2(-tkState.Scroll.X, tkState.Scroll.Y); 32 - HasPreciseScroll = tkState.Flags.HasFlag(MouseStateFlags.HasPreciseScroll); 33 + HasPreciseScroll = tkState.Flags.HasFlagFast(MouseStateFlags.HasPreciseScroll); 33 34 Position = new Vector2(mappedPosition?.X ?? tkState.X, mappedPosition?.Y ?? tkState.Y); 34 35 } 35 36
+4 -3
osu.Framework/Input/Handlers/Mouse/OsuTKRawMouseHandler.cs
··· 7 7 using System.Linq; 8 8 using osu.Framework.Bindables; 9 9 using osu.Framework.Configuration; 10 + using osu.Framework.Extensions.EnumExtensions; 10 11 using osu.Framework.Platform; 11 12 using osu.Framework.Threading; 12 13 using osuTK; ··· 71 72 72 73 var newState = new OsuTKPollMouseState(rawState, host.IsActive.Value, getUpdatedPosition(rawState, lastState)); 73 74 74 - HandleState(newState, lastState, rawState.Flags.HasFlag(MouseStateFlags.MoveAbsolute)); 75 + HandleState(newState, lastState, rawState.Flags.HasFlagFast(MouseStateFlags.MoveAbsolute)); 75 76 76 77 lastEachDeviceStates[i] = newState; 77 78 lastUnfocusedState = null; ··· 116 117 { 117 118 Vector2 currentPosition; 118 119 119 - if (state.Flags.HasFlag(MouseStateFlags.MoveAbsolute)) 120 + if (state.Flags.HasFlagFast(MouseStateFlags.MoveAbsolute)) 120 121 { 121 122 const int raw_input_resolution = 65536; 122 123 ··· 129 130 } 130 131 else 131 132 { 132 - Rectangle screenRect = state.Flags.HasFlag(MouseStateFlags.VirtualDesktop) 133 + Rectangle screenRect = state.Flags.HasFlagFast(MouseStateFlags.VirtualDesktop) 133 134 ? Platform.Windows.Native.Input.GetVirtualScreenRect() 134 135 : new Rectangle(0, 0, DisplayDevice.Default.Width, DisplayDevice.Default.Height); 135 136
+2 -1
osu.Framework/Input/UserInputManager.cs
··· 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 4 using System.Collections.Immutable; 5 + using osu.Framework.Extensions.EnumExtensions; 5 6 using osu.Framework.Input.Handlers; 6 7 using osu.Framework.Input.StateChanges; 7 8 using osu.Framework.Input.StateChanges.Events; ··· 34 35 var mouse = mousePositionChange.State.Mouse; 35 36 36 37 // confine cursor 37 - if (Host.Window != null && Host.Window.CursorState.HasFlag(CursorState.Confined)) 38 + if (Host.Window != null && Host.Window.CursorState.HasFlagFast(CursorState.Confined)) 38 39 { 39 40 var clientSize = Host.Window.ClientSize; 40 41 mouse.Position = Vector2.Clamp(mouse.Position, Vector2.Zero, new Vector2(clientSize.Width, clientSize.Height));
+11 -10
osu.Framework/Platform/MacOS/OsuTKMacOSWindow.cs
··· 12 12 using osu.Framework.Platform.MacOS.Native; 13 13 using osuTK; 14 14 using System.Diagnostics; 15 + using osu.Framework.Extensions.EnumExtensions; 15 16 16 17 namespace osu.Framework.Platform.MacOS 17 18 { ··· 140 141 private const NSApplicationPresentationOptions default_fullscreen_presentation_options = 141 142 NSApplicationPresentationOptions.AutoHideDock | NSApplicationPresentationOptions.AutoHideMenuBar | NSApplicationPresentationOptions.FullScreen; 142 143 143 - private bool isCursorHidden => CursorState.HasFlag(CursorState.Hidden); 144 + private bool isCursorHidden => CursorState.HasFlagFast(CursorState.Hidden); 144 145 145 146 private NSApplicationPresentationOptions fullscreenPresentationOptions => 146 147 default_fullscreen_presentation_options | (isCursorHidden ? NSApplicationPresentationOptions.DisableCursorLocationAssistance : 0); ··· 164 165 { 165 166 pendingWindowMode = null; 166 167 167 - bool currentFullScreen = styleMask.HasFlag(NSWindowStyleMask.FullScreen); 168 + bool currentFullScreen = styleMask.HasFlagFast(NSWindowStyleMask.FullScreen); 168 169 bool toggleFullScreen = mode.Value == Configuration.WindowMode.Fullscreen ? !currentFullScreen : currentFullScreen; 169 170 170 171 if (toggleFullScreen) ··· 195 196 { 196 197 case MacOSKeyCodes.LShift: 197 198 key = osuTK.Input.Key.LShift; 198 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftShift); 199 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.LeftShift); 199 200 break; 200 201 201 202 case MacOSKeyCodes.RShift: 202 203 key = osuTK.Input.Key.RShift; 203 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightShift); 204 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.RightShift); 204 205 break; 205 206 206 207 case MacOSKeyCodes.LControl: 207 208 key = osuTK.Input.Key.LControl; 208 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftControl); 209 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.LeftControl); 209 210 break; 210 211 211 212 case MacOSKeyCodes.RControl: 212 213 key = osuTK.Input.Key.RControl; 213 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightControl); 214 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.RightControl); 214 215 break; 215 216 216 217 case MacOSKeyCodes.LAlt: 217 218 key = osuTK.Input.Key.LAlt; 218 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftAlt); 219 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.LeftAlt); 219 220 break; 220 221 221 222 case MacOSKeyCodes.RAlt: 222 223 key = osuTK.Input.Key.RAlt; 223 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightAlt); 224 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.RightAlt); 224 225 break; 225 226 226 227 case MacOSKeyCodes.LCommand: 227 228 key = osuTK.Input.Key.LWin; 228 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftCommand); 229 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.LeftCommand); 229 230 break; 230 231 231 232 case MacOSKeyCodes.RCommand: 232 233 key = osuTK.Input.Key.RWin; 233 - keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightCommand); 234 + keyDown = modifierFlags.HasFlagFast(CocoaKeyModifiers.RightCommand); 234 235 break; 235 236 236 237 default:
+3 -2
osu.Framework/Platform/OsuTKWindow.cs
··· 16 16 using JetBrains.Annotations; 17 17 using osu.Framework.Bindables; 18 18 using osu.Framework.Extensions; 19 + using osu.Framework.Extensions.EnumExtensions; 19 20 using osu.Framework.Threading; 20 21 21 22 namespace osu.Framework.Platform ··· 193 194 { 194 195 cursorState = value; 195 196 196 - OsuTKGameWindow.Cursor = cursorState.HasFlag(CursorState.Hidden) ? MouseCursor.Empty : MouseCursor.Default; 197 + OsuTKGameWindow.Cursor = cursorState.HasFlagFast(CursorState.Hidden) ? MouseCursor.Empty : MouseCursor.Default; 197 198 198 199 try 199 200 { 200 - OsuTKGameWindow.CursorGrabbed = cursorState.HasFlag(CursorState.Confined); 201 + OsuTKGameWindow.CursorGrabbed = cursorState.HasFlagFast(CursorState.Confined); 201 202 } 202 203 catch 203 204 {
+8 -7
osu.Framework/Platform/SDL2/SDL2Extensions.cs
··· 1 1 // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2 2 // See the LICENCE file in the repository root for full licence text. 3 3 4 + using osu.Framework.Extensions.EnumExtensions; 4 5 using osu.Framework.Input; 5 6 using osuTK.Input; 6 7 using SDL2; ··· 13 14 { 14 15 // Apple devices don't have the notion of NumLock (they have a Clear key instead). 15 16 // treat them as if they always have NumLock on (the numpad always performs its primary actions). 16 - bool numLockOn = sdlKeysym.mod.HasFlag(SDL.SDL_Keymod.KMOD_NUM) || RuntimeInfo.IsApple; 17 + bool numLockOn = sdlKeysym.mod.HasFlagFast(SDL.SDL_Keymod.KMOD_NUM) || RuntimeInfo.IsApple; 17 18 18 19 switch (sdlKeysym.scancode) 19 20 { ··· 446 447 public static WindowState ToWindowState(this SDL.SDL_WindowFlags windowFlags) 447 448 { 448 449 // NOTE: on macOS, SDL2 does not differentiate between "maximised" and "fullscreen desktop" 449 - if (windowFlags.HasFlag(SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP) || 450 - windowFlags.HasFlag(SDL.SDL_WindowFlags.SDL_WINDOW_BORDERLESS) || 451 - windowFlags.HasFlag(SDL.SDL_WindowFlags.SDL_WINDOW_MAXIMIZED) && RuntimeInfo.OS == RuntimeInfo.Platform.MacOsx) 450 + if (windowFlags.HasFlagFast(SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP) || 451 + windowFlags.HasFlagFast(SDL.SDL_WindowFlags.SDL_WINDOW_BORDERLESS) || 452 + windowFlags.HasFlagFast(SDL.SDL_WindowFlags.SDL_WINDOW_MAXIMIZED) && RuntimeInfo.OS == RuntimeInfo.Platform.MacOsx) 452 453 return WindowState.FullscreenBorderless; 453 454 454 - if (windowFlags.HasFlag(SDL.SDL_WindowFlags.SDL_WINDOW_MINIMIZED)) 455 + if (windowFlags.HasFlagFast(SDL.SDL_WindowFlags.SDL_WINDOW_MINIMIZED)) 455 456 return WindowState.Minimised; 456 457 457 - if (windowFlags.HasFlag(SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN)) 458 + if (windowFlags.HasFlagFast(SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN)) 458 459 return WindowState.Fullscreen; 459 460 460 - if (windowFlags.HasFlag(SDL.SDL_WindowFlags.SDL_WINDOW_MAXIMIZED)) 461 + if (windowFlags.HasFlagFast(SDL.SDL_WindowFlags.SDL_WINDOW_MAXIMIZED)) 461 462 return WindowState.Maximised; 462 463 463 464 return WindowState.Normal;
+3 -2
osu.Framework/Platform/SDL2DesktopWindow.cs
··· 9 9 using JetBrains.Annotations; 10 10 using osu.Framework.Bindables; 11 11 using osu.Framework.Configuration; 12 + using osu.Framework.Extensions.EnumExtensions; 12 13 using osu.Framework.Extensions.ImageExtensions; 13 14 using osu.Framework.Input; 14 15 using osu.Framework.Platform.SDL2; ··· 351 352 352 353 CursorStateBindable.ValueChanged += evt => 353 354 { 354 - CursorVisible = !evt.NewValue.HasFlag(CursorState.Hidden); 355 - CursorConfined = evt.NewValue.HasFlag(CursorState.Confined); 355 + CursorVisible = !evt.NewValue.HasFlagFast(CursorState.Hidden); 356 + CursorConfined = evt.NewValue.HasFlagFast(CursorState.Confined); 356 357 }; 357 358 358 359 cursorInWindow.ValueChanged += evt =>