diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-07-16 19:31:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 19:31:14 +0200 |
commit | 326749498bed4360e5a4b11fc67d5ec7cb9a3076 (patch) | |
tree | ae21fb26f99b401ca4e9efaab72b679a81c22369 /src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs | |
parent | fec8291c17fa106c28f58b56419e90d49a41a1ea (diff) |
[Ryujinx.HLE] Address dotnet-format issues (#5380)1.1.962
* dotnet format style --severity info
Some changes were manually reverted.
* dotnet format analyzers --serverity info
Some changes have been minimally adapted.
* Restore a few unused methods and variables
* Silence dotnet format IDE0060 warnings
* Silence dotnet format IDE0052 warnings
* Address or silence dotnet format IDE1006 warnings
* Address dotnet format CA1816 warnings
* Address or silence dotnet format CA2208 warnings
* Address or silence dotnet format CA1806 and a few CA1854 warnings
* Address dotnet format CA2211 warnings
* Address dotnet format CA1822 warnings
* Address or silence dotnet format CA1069 warnings
* Make dotnet format succeed in style mode
* Address or silence dotnet format CA2211 warnings
* Address review comments
* Address dotnet format CA2208 warnings properly
* Make ProcessResult readonly
* Address most dotnet format whitespace warnings
* Apply dotnet format whitespace formatting
A few of them have been manually reverted and the corresponding warning was silenced
* Add previously silenced warnings back
I have no clue how these disappeared
* Revert formatting changes for while and for-loops
* Format if-blocks correctly
* Run dotnet format style after rebase
* Run dotnet format whitespace after rebase
* Run dotnet format style after rebase
* Run dotnet format analyzers after rebase
* Run dotnet format after rebase and remove unused usings
- analyzers
- style
- whitespace
* Disable 'prefer switch expression' rule
* Add comments to disabled warnings
* Fix a few disabled warnings
* Fix naming rule violation, Convert shader properties to auto-property and convert values to const
* Simplify properties and array initialization, Use const when possible, Remove trailing commas
* Start working on disabled warnings
* Fix and silence a few dotnet-format warnings again
* Run dotnet format after rebase
* Use using declaration instead of block syntax
* Address IDE0251 warnings
* Address a few disabled IDE0060 warnings
* Silence IDE0060 in .editorconfig
* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"
This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.
* dotnet format whitespace after rebase
* First dotnet format pass
* Fix naming rule violations
* Fix typo
* Add trailing commas, use targeted new and use array initializer
* Fix build issues
* Fix remaining build issues
* Remove SuppressMessage for CA1069 where possible
* Address dotnet format issues
* Address formatting issues
Co-authored-by: Ac_K <acoustik666@gmail.com>
* Add GetHashCode implementation for RenderingSurfaceInfo
* Explicitly silence CA1822 for every affected method in Syscall
* Address formatting issues in Demangler.cs
* Address review feedback
Co-authored-by: Ac_K <acoustik666@gmail.com>
* Revert marking service methods as static
* Next dotnet format pass
* Address review feedback
---------
Co-authored-by: Ac_K <acoustik666@gmail.com>
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs')
-rw-r--r-- | src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs | 100 |
1 files changed, 49 insertions, 51 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs index 0c1cea51..d3d9dc03 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs @@ -11,49 +11,47 @@ using System.Threading; namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { - using ResultCode = Ryujinx.HLE.HOS.Services.Vi.ResultCode; - class SurfaceFlinger : IConsumerListener, IDisposable { private const int TargetFps = 60; - private Switch _device; + private readonly Switch _device; - private Dictionary<long, Layer> _layers; + private readonly Dictionary<long, Layer> _layers; private bool _isRunning; - private Thread _composerThread; + private readonly Thread _composerThread; - private Stopwatch _chrono; + private readonly Stopwatch _chrono; - private ManualResetEvent _event = new ManualResetEvent(false); - private AutoResetEvent _nextFrameEvent = new AutoResetEvent(true); + private readonly ManualResetEvent _event = new(false); + private readonly AutoResetEvent _nextFrameEvent = new(true); private long _ticks; private long _ticksPerFrame; - private long _spinTicks; - private long _1msTicks; + private readonly long _spinTicks; + private readonly long _1msTicks; private int _swapInterval; private int _swapIntervalDelay; - private readonly object Lock = new(); + private readonly object _lock = new(); public long RenderLayerId { get; private set; } private class Layer { - public int ProducerBinderId; + public int ProducerBinderId; public IGraphicBufferProducer Producer; - public BufferItemConsumer Consumer; - public BufferQueueCore Core; - public ulong Owner; - public LayerState State; + public BufferItemConsumer Consumer; + public BufferQueueCore Core; + public ulong Owner; + public LayerState State; } private class TextureCallbackInformation { - public Layer Layer; + public Layer Layer; public BufferItem Item; } @@ -65,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger _composerThread = new Thread(HandleComposition) { - Name = "SurfaceFlinger.Composer" + Name = "SurfaceFlinger.Composer", }; _chrono = new Stopwatch(); @@ -100,7 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { layerId = 1; - lock (Lock) + lock (_lock) { foreach (KeyValuePair<long, Layer> pair in _layers) { @@ -118,7 +116,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private void CreateLayerFromId(ulong pid, long layerId, LayerState initialState) { - lock (Lock) + lock (_lock) { Logger.Info?.Print(LogClass.SurfaceFlinger, $"Creating layer {layerId}"); @@ -132,16 +130,16 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger _layers.Add(layerId, new Layer { ProducerBinderId = HOSBinderDriverServer.RegisterBinderObject(producer), - Producer = producer, - Consumer = new BufferItemConsumer(_device, consumer, 0, -1, false, this), - Core = core, - Owner = pid, - State = initialState + Producer = producer, + Consumer = new BufferItemConsumer(_device, consumer, 0, -1, false, this), + Core = core, + Owner = pid, + State = initialState, }); } } - public ResultCode OpenLayer(ulong pid, long layerId, out IBinder producer) + public Vi.ResultCode OpenLayer(ulong pid, long layerId, out IBinder producer) { Layer layer = GetLayerByIdLocked(layerId); @@ -149,18 +147,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { producer = null; - return ResultCode.InvalidArguments; + return Vi.ResultCode.InvalidArguments; } layer.State = LayerState.ManagedOpened; producer = layer.Producer; - return ResultCode.Success; + return Vi.ResultCode.Success; } - public ResultCode CloseLayer(long layerId) + public Vi.ResultCode CloseLayer(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -168,18 +166,18 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to close layer {layerId}"); - return ResultCode.InvalidValue; + return Vi.ResultCode.InvalidValue; } CloseLayer(layerId, layer); - return ResultCode.Success; + return Vi.ResultCode.Success; } } - public ResultCode DestroyManagedLayer(long layerId) + public Vi.ResultCode DestroyManagedLayer(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -187,14 +185,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy managed layer {layerId} (not found)"); - return ResultCode.InvalidValue; + return Vi.ResultCode.InvalidValue; } if (layer.State != LayerState.ManagedClosed && layer.State != LayerState.ManagedOpened) { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy managed layer {layerId} (permission denied)"); - return ResultCode.PermissionDenied; + return Vi.ResultCode.PermissionDenied; } HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId); @@ -204,13 +202,13 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger CloseLayer(layerId, layer); } - return ResultCode.Success; + return Vi.ResultCode.Success; } } - public ResultCode DestroyStrayLayer(long layerId) + public Vi.ResultCode DestroyStrayLayer(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -218,14 +216,14 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (not found)"); - return ResultCode.InvalidValue; + return Vi.ResultCode.InvalidValue; } if (layer.State != LayerState.Stray) { Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (permission denied)"); - return ResultCode.PermissionDenied; + return Vi.ResultCode.PermissionDenied; } HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId); @@ -235,7 +233,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger CloseLayer(layerId, layer); } - return ResultCode.Success; + return Vi.ResultCode.Success; } } @@ -263,7 +261,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public void SetRenderLayer(long layerId) { - lock (Lock) + lock (_lock) { RenderLayerId = layerId; } @@ -284,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public IGraphicBufferProducer GetProducerByLayerId(long layerId) { - lock (Lock) + lock (_lock) { Layer layer = GetLayerByIdLocked(layerId); @@ -365,7 +363,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public void Compose() { - lock (Lock) + lock (_lock) { // TODO: support multilayers (& multidisplay ?) if (RenderLayerId == 0) @@ -403,7 +401,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private void PostFrameBuffer(Layer layer, BufferItem item) { - int frameBufferWidth = item.GraphicBuffer.Object.Width; + int frameBufferWidth = item.GraphicBuffer.Object.Width; int frameBufferHeight = item.GraphicBuffer.Object.Height; int nvMapHandle = item.GraphicBuffer.Object.Buffer.Surfaces[0].NvMapHandle; @@ -434,9 +432,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger bool flipY = item.Transform.HasFlag(NativeWindowTransform.FlipY); AspectRatio aspectRatio = _device.Configuration.AspectRatio; - bool isStretched = aspectRatio == AspectRatio.Stretched; + bool isStretched = aspectRatio == AspectRatio.Stretched; - ImageCrop crop = new ImageCrop( + ImageCrop crop = new( cropRect.Left, cropRect.Right, cropRect.Top, @@ -447,10 +445,10 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger aspectRatio.ToFloatX(), aspectRatio.ToFloatY()); - TextureCallbackInformation textureCallbackInformation = new TextureCallbackInformation + TextureCallbackInformation textureCallbackInformation = new() { Layer = layer, - Item = item + Item = item, }; if (_device.Gpu.Window.EnqueueFrameThreadSafe( @@ -543,6 +541,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger _device.Statistics.RecordGameFrameTime(); } - public void OnBuffersReleased() {} + public void OnBuffersReleased() { } } } |