diff --git a/BizHawk.Common/HawkFile.cs b/BizHawk.Common/HawkFile.cs index b9a320cfb9..296ea5d888 100644 --- a/BizHawk.Common/HawkFile.cs +++ b/BizHawk.Common/HawkFile.cs @@ -8,8 +8,8 @@ using System.Linq; using BizHawk.Common.StringExtensions; // the HawkFile class is excessively engineered with the IHawkFileArchiveHandler to decouple the archive handling from the basic file handling. -// This is so we could drop in an unamanged dearchiver library optionally later as a performance optimization without ruining the portability of the code. -// Also, we want to be able to use HawkFiles in BizHawk.Common withuot bringing in a large 7-zip dependency +// This is so we could drop in an unmanaged dearchiver library optionally later as a performance optimization without ruining the portability of the code. +// Also, we want to be able to use HawkFiles in BizHawk.Common without bringing in a large 7-zip dependency namespace BizHawk.Common { // TODO: @@ -165,12 +165,10 @@ namespace BizHawk.Common /// public byte[] ReadAllBytes() { - using (Stream stream = GetStream()) - { - var ms = new MemoryStream((int)stream.Length); - stream.CopyTo(ms); - return ms.GetBuffer(); - } + using Stream stream = GetStream(); + var ms = new MemoryStream((int)stream.Length); + stream.CopyTo(ms); + return ms.GetBuffer(); } /// diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index e2932cf327..7272d47f55 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -376,9 +376,11 @@ True True True + True True True True + True True True True diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Art.cs b/Bizware/BizHawk.Bizware.BizwareGL/Art.cs index 13db7e68a6..fbfd3ea11a 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Art.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Art.cs @@ -20,7 +20,7 @@ namespace BizHawk.Bizware.BizwareGL Owner = owner; } - public ArtManager Owner { get; private set; } + public ArtManager Owner { get; } public Texture2d BaseTexture { get; internal set; } public float Width, Height; diff --git a/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs b/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs index 768c789a4b..2e0d2e88f6 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs @@ -44,8 +44,8 @@ namespace BizHawk.Bizware.BizwareGL /// public Art LoadArt(string path) { - using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) - return LoadArtInternal(new BitmapBuffer(path, new BitmapLoadOptions())); + using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); + return LoadArtInternal(new BitmapBuffer(path, new BitmapLoadOptions())); } Art LoadArtInternal(BitmapBuffer tex) @@ -70,23 +70,23 @@ namespace BizHawk.Bizware.BizwareGL IsOpened = false; IsClosedForever = forever; - //first, cleanup old stuff + // first, cleanup old stuff foreach (var tex in ManagedTextures) tex.Dispose(); ManagedTextures.Clear(); - //prepare input for atlas process and perform atlas - //add 2 extra pixels for padding on all sides - List atlasItems = new List(); + // prepare input for atlas process and perform atlas + // add 2 extra pixels for padding on all sides + var atlasItems = new List(); foreach (var kvp in ArtLooseTextureAssociation) atlasItems.Add(new TexAtlas.RectItem(kvp.Value.Width+2, kvp.Value.Height+2, kvp)); var results = TexAtlas.PackAtlas(atlasItems); - //this isnt supported yet: + // this isn't supported yet: if (results.Atlases.Count > 1) throw new InvalidOperationException("Art files too big for atlas"); - //prepare the output buffer + // prepare the output buffer BitmapBuffer bmpResult = new BitmapBuffer(results.Atlases[0].Size); //for each item, copy it into the output buffer and set the tex parameters on them @@ -142,7 +142,7 @@ namespace BizHawk.Bizware.BizwareGL /// private void AssertIsOpen(bool state) { if (IsOpened != state) throw new InvalidOperationException($"{nameof(ArtManager)} instance is not open!"); } - public IGL Owner { get; private set; } + public IGL Owner { get; } public bool IsOpened { get; private set; } public bool IsClosedForever { get; private set; } @@ -150,16 +150,16 @@ namespace BizHawk.Bizware.BizwareGL /// /// This is used to remember the original bitmap sources for art files. Once the ArtManager is closed forever, this will be purged /// - Dictionary ArtLooseTextureAssociation = new Dictionary(); + readonly Dictionary ArtLooseTextureAssociation = new Dictionary(); /// /// Physical texture resources, which exist after this ArtManager has been closed /// - List ManagedTextures = new List(); + readonly List ManagedTextures = new List(); /// /// All the Arts managed by this instance /// - List ManagedArts = new List(); + readonly List ManagedArts = new List(); } } \ No newline at end of file diff --git a/Bizware/BizHawk.Bizware.BizwareGL/AttributeInfo.cs b/Bizware/BizHawk.Bizware.BizwareGL/AttributeInfo.cs index dbcdb034e2..16f72dc6b7 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/AttributeInfo.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/AttributeInfo.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace BizHawk.Bizware.BizwareGL { diff --git a/Bizware/BizHawk.Bizware.BizwareGL/BitmapLoadOptions.cs b/Bizware/BizHawk.Bizware.BizwareGL/BitmapLoadOptions.cs index f0c2712ed8..7c1291d63e 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/BitmapLoadOptions.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/BitmapLoadOptions.cs @@ -1,6 +1,5 @@ using System; using System.Drawing; -using System.Text; namespace BizHawk.Bizware.BizwareGL { diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFont.cs b/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFont.cs index 1adde4cdec..80c4f6433d 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFont.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFont.cs @@ -165,10 +165,9 @@ namespace Cyotek.Drawing.BitmapFont public Size TextureSize { get; set; } - public Character this[char character] - { get { return this.Characters[character]; } } + public Character this[char character] => this.Characters[character]; - public bool Unicode { get; set; } + public bool Unicode { get; set; } #endregion  Public Properties diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFontLoader.cs b/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFontLoader.cs index a1dfb1f748..31dd1c80b2 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFontLoader.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Borrowed/BitmapFontParser/BitmapFontLoader.cs @@ -1,7 +1,6 @@ //public domain assumed from cyotek.com using System; -using System.Reflection; using System.Collections.Generic; using System.Drawing; using System.IO; diff --git a/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs b/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs index 3b0f0de6df..0f085bc8ed 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs @@ -32,7 +32,7 @@ namespace BizHawk.Bizware.BizwareGL public Dictionary MapNativeToCode = new Dictionary(); } - Regex rxHlslSamplerCrashWorkaround = new Regex(@"\((.*?)(in sampler2D)(.*?)\)", RegexOptions.Multiline | RegexOptions.IgnoreCase); + readonly Regex rxHlslSamplerCrashWorkaround = new Regex(@"\((.*?)(in sampler2D)(.*?)\)", RegexOptions.Multiline | RegexOptions.IgnoreCase); public Results Run(string code, string entry, string profile, bool hlslHacks) { @@ -48,93 +48,97 @@ namespace BizHawk.Bizware.BizwareGL } //http://stackoverflow.com/questions/139593/processstartinfo-hanging-on-waitforexit-why - using (Process proc = new Process()) + using var proc = new Process { - proc.StartInfo.UseShellExecute = false; - proc.StartInfo.CreateNoWindow = true; - proc.StartInfo.RedirectStandardInput = true; - proc.StartInfo.RedirectStandardOutput = true; - proc.StartInfo.RedirectStandardError = true; - proc.StartInfo.Arguments = sbCmdline.ToString(); - proc.StartInfo.FileName = CGCBinPath; - - StringBuilder output = new StringBuilder(), error = new StringBuilder(); - - using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false)) - using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false)) + StartInfo = { - proc.OutputDataReceived += (sender, e) => - { - if (e.Data == null) outputWaitHandle.Set(); - else output.AppendLine(e.Data); - }; - proc.ErrorDataReceived += (sender, e) => - { - if (e.Data == null) errorWaitHandle.Set(); - else error.AppendLine(e.Data); - }; - - - proc.Start(); - new Thread(() => - { - proc.StandardInput.AutoFlush = true; - proc.StandardInput.Write(code); - proc.StandardInput.Flush(); - proc.StandardInput.Close(); - }).Start(); - - proc.BeginOutputReadLine(); - proc.BeginErrorReadLine(); - proc.WaitForExit(); - outputWaitHandle.WaitOne(); - errorWaitHandle.WaitOne(); + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardInput = true, + RedirectStandardOutput = true, + RedirectStandardError = true, + Arguments = sbCmdline.ToString(), + FileName = CGCBinPath } + }; - bool ok = (proc.ExitCode == 0); + StringBuilder output = new StringBuilder(), error = new StringBuilder(); - var ret = new Results() + using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false)) + { + using var errorWaitHandle = new AutoResetEvent(false); + proc.OutputDataReceived += (sender, e) => { - Succeeded = ok, - Code = output.ToString(), - Errors = error.ToString() + if (e.Data == null) outputWaitHandle.Set(); + else output.AppendLine(e.Data); + }; + proc.ErrorDataReceived += (sender, e) => + { + if (e.Data == null) errorWaitHandle.Set(); + else error.AppendLine(e.Data); }; - if (!ok) - Console.WriteLine(ret.Errors); - if (hlslHacks) + proc.Start(); + new Thread(() => { - ret.Code = rxHlslSamplerCrashWorkaround.Replace(ret.Code, m => $"({m.Groups[1].Value}uniform sampler2D{m.Groups[3].Value})"); - } + proc.StandardInput.AutoFlush = true; + proc.StandardInput.Write(code); + proc.StandardInput.Flush(); + proc.StandardInput.Close(); + }).Start(); - //make variable name map - //loop until the first line that doesnt start with a comment - var reader = new StringReader(ret.Code); - for(;;) - { - var line = reader.ReadLine(); - if (line == null) break; - if (!line.StartsWith("//")) break; - if (!line.StartsWith("//var")) continue; - var parts = line.Split(':'); - var native_name = parts[0].Split(' ')[2]; - var code_name = parts[1].Trim(); - if (code_name.StartsWith("TEXUNIT")) code_name = ""; //need parsing differently - if (code_name == "") - code_name = parts[2].Trim(); - //remove some array indicators. example: `modelViewProj1[0], 4` - code_name = code_name.Split(',')[0]; - code_name = code_name.Split(' ')[0]; - if (code_name != "") - { - ret.MapCodeToNative[code_name] = native_name; - ret.MapNativeToCode[native_name] = code_name; - } - } - - return ret; + proc.BeginOutputReadLine(); + proc.BeginErrorReadLine(); + proc.WaitForExit(); + outputWaitHandle.WaitOne(); + errorWaitHandle.WaitOne(); } + + bool ok = (proc.ExitCode == 0); + + var ret = new Results + { + Succeeded = ok, + Code = output.ToString(), + Errors = error.ToString() + }; + + if (!ok) + Console.WriteLine(ret.Errors); + + if (hlslHacks) + { + ret.Code = rxHlslSamplerCrashWorkaround.Replace(ret.Code, m => $"({m.Groups[1].Value}uniform sampler2D{m.Groups[3].Value})"); + } + + //make variable name map + //loop until the first line that doesn't start with a comment + var reader = new StringReader(ret.Code); + for(;;) + { + var line = reader.ReadLine(); + if (line == null) break; + if (!line.StartsWith("//")) break; + if (!line.StartsWith("//var")) continue; + var parts = line.Split(':'); + var native_name = parts[0].Split(' ')[2]; + var code_name = parts[1].Trim(); + if (code_name.StartsWith("TEXUNIT")) code_name = ""; //need parsing differently + if (code_name == "") + code_name = parts[2].Trim(); + + // remove some array indicators. example: `modelViewProj1[0], 4` + code_name = code_name.Split(',')[0]; + code_name = code_name.Split(' ')[0]; + if (code_name != "") + { + ret.MapCodeToNative[code_name] = native_name; + ret.MapNativeToCode[native_name] = code_name; + } + } + + return ret; } } } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Extensions.cs b/Bizware/BizHawk.Bizware.BizwareGL/Extensions.cs index bf743e5f3c..aa3239a495 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Extensions.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Extensions.cs @@ -1,9 +1,5 @@ -using System; -using System.Drawing; -using System.Text; - +using System.Drawing; using OpenTK; -using OpenTK.Graphics; namespace BizHawk.Bizware.BizwareGL { diff --git a/Bizware/BizHawk.Bizware.BizwareGL/GdiPlusGuiRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/GdiPlusGuiRenderer.cs index 86acb7dbc8..f61c6952d7 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/GdiPlusGuiRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/GdiPlusGuiRenderer.cs @@ -1,9 +1,6 @@ //this is full of bugs probably, related to state from old rendering sessions being all messed up. its only barely good enough to work at all using System; -using System.Diagnostics; -using System.Collections; -using System.Collections.Generic; using System.Drawing.Imaging; using OpenTK; @@ -20,7 +17,7 @@ namespace BizHawk.Bizware.BizwareGL Owner = gl; } - OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] { + readonly OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] { new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f) }; @@ -41,8 +38,7 @@ namespace BizHawk.Bizware.BizwareGL public void Dispose() { - if (CurrentImageAttributes != null) - CurrentImageAttributes.Dispose(); + CurrentImageAttributes?.Dispose(); } @@ -273,7 +269,7 @@ namespace BizHawk.Bizware.BizwareGL var tw = tex.Opaque as GDIPTextureWrapper; g.PixelOffsetMode = sd.Drawing2D.PixelOffsetMode.Half; g.DrawImage(tw.SDBitmap, destPoints, new sd.RectangleF(sx, sy, sw, sh), sd.GraphicsUnit.Pixel, CurrentImageAttributes); - g.Transform = new sd.Drawing2D.Matrix(); //.Reset() doesnt work ? ? + g.Transform = new sd.Drawing2D.Matrix(); //.Reset() doesn't work ? ? } unsafe void DrawInternal(Art art, float x, float y, float w, float h, bool fx, bool fy) @@ -283,8 +279,7 @@ namespace BizHawk.Bizware.BizwareGL public bool IsActive { get; private set; } - public IGL Owner { get; private set; } + public IGL Owner { get; } public IGL Gdi => Owner; - } } \ No newline at end of file diff --git a/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs index 2bd01fab0d..2ebce1a3ea 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs @@ -3,10 +3,6 @@ //why this stupid assert on the blendstate. just set one by default, geeze. using System; -using System.Diagnostics; -using System.Collections; -using System.Collections.Generic; - using OpenTK; using OpenTK.Graphics.OpenGL; @@ -17,7 +13,7 @@ namespace BizHawk.Bizware.BizwareGL /// /// A simple renderer useful for rendering GUI stuff. /// When doing GUI rendering, run everything through here (if you need a GL feature not done through here, run it through here first) - /// Call Begin, then draw, then End, and dont use other Renderers or GL calls in the meantime, unless you know what youre doing. + /// Call Begin, then draw, then End, and don't use other Renderers or GL calls in the meantime, unless you know what you're doing. /// This can perform batching (well.. maybe not yet), which is occasionally necessary for drawing large quantities of things. /// public class GuiRenderer : IDisposable, IGuiRenderer @@ -53,7 +49,7 @@ namespace BizHawk.Bizware.BizwareGL CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true, "xgui"); } - OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] { + readonly OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] { new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f),new OpenTK.Graphics.Color4(1.0f,1.0f,1.0f,1.0f) }; @@ -343,10 +339,11 @@ namespace BizHawk.Bizware.BizwareGL } public bool IsActive { get; private set; } - public IGL Owner { get; private set; } + public IGL Owner { get; } - VertexLayout VertexLayout; - Pipeline CurrPipeline, DefaultPipeline; + readonly VertexLayout VertexLayout; + Pipeline CurrPipeline; + readonly Pipeline DefaultPipeline; //state cache Texture2d sTexture; diff --git a/Bizware/BizHawk.Bizware.BizwareGL/MatrixStack.cs b/Bizware/BizHawk.Bizware.BizwareGL/MatrixStack.cs index b86183cef3..0aeca0be6a 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/MatrixStack.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/MatrixStack.cs @@ -1,4 +1,3 @@ -using System; using System.Drawing; using System.Collections.Generic; @@ -21,7 +20,7 @@ namespace BizHawk.Bizware.BizwareGL public bool IsDirty; - Stack stack = new Stack(); + readonly Stack stack = new Stack(); /// /// This is made public for performance reasons, to avoid lame copies of the matrix when necessary. Don't mess it up! diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Pipeline.cs b/Bizware/BizHawk.Bizware.BizwareGL/Pipeline.cs index e27fc66a4c..d709885732 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Pipeline.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Pipeline.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Collections.Generic; namespace BizHawk.Bizware.BizwareGL @@ -59,15 +58,12 @@ namespace BizHawk.Bizware.BizwareGL return temp; } - internal set - { - base[key] = value; - } + internal set => base[key] = value; } } - SpecialWorkingDictionary UniformsDictionary; - IDictionary Uniforms { get { return UniformsDictionary; } } + readonly SpecialWorkingDictionary UniformsDictionary; + IDictionary Uniforms => UniformsDictionary; public IEnumerable GetUniforms() { return Uniforms.Values; } @@ -78,15 +74,12 @@ namespace BizHawk.Bizware.BizwareGL return ret; } - public PipelineUniform this[string key] - { - get { return UniformsDictionary[key]; } - } + public PipelineUniform this[string key] => UniformsDictionary[key]; - public IGL Owner { get; private set; } - public object Opaque { get; private set; } - public VertexLayout VertexLayout { get; private set; } - public bool Available { get; private set; } + public IGL Owner { get; } + public object Opaque { get; } + public VertexLayout VertexLayout { get; } + public bool Available { get; } public string Errors { get; set; } public void Dispose() diff --git a/Bizware/BizHawk.Bizware.BizwareGL/PipelineUniform.cs b/Bizware/BizHawk.Bizware.BizwareGL/PipelineUniform.cs index 0fe782c180..f612e0b757 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/PipelineUniform.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/PipelineUniform.cs @@ -23,8 +23,8 @@ namespace BizHawk.Bizware.BizwareGL _UniformInfos.Add(ui); } - public IEnumerable UniformInfos { get { return _UniformInfos; } } - List _UniformInfos = new List(); + public IEnumerable UniformInfos => _UniformInfos; + readonly List _UniformInfos = new List(); /// the first and only /// more than one exists @@ -37,54 +37,46 @@ namespace BizHawk.Bizware.BizwareGL } } - public Pipeline Owner { get; private set; } + public Pipeline Owner { get; } public void Set(Matrix4 mat, bool transpose = false) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniformMatrix(this, mat, transpose); + Owner?.Owner.SetPipelineUniformMatrix(this, mat, transpose); } public void Set(Vector4 vec) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniform(this, vec); + Owner?.Owner.SetPipelineUniform(this, vec); } public void Set(Vector2 vec) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniform(this, vec); + Owner?.Owner.SetPipelineUniform(this, vec); } public void Set(float f) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniform(this, f); + Owner?.Owner.SetPipelineUniform(this, f); } public void Set(Vector4[] vecs) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniform(this, vecs); + Owner?.Owner.SetPipelineUniform(this, vecs); } public void Set(ref Matrix4 mat, bool transpose = false) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniformMatrix(this, ref mat, transpose); + Owner?.Owner.SetPipelineUniformMatrix(this, ref mat, transpose); } public void Set(bool value) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniform(this, value); + Owner?.Owner.SetPipelineUniform(this, value); } public void Set(Texture2d tex) { - if (Owner == null) return; //uniform was optimized out - Owner.Owner.SetPipelineUniformSampler(this, tex); + Owner?.Owner.SetPipelineUniformSampler(this, tex); } } } \ No newline at end of file diff --git a/Bizware/BizHawk.Bizware.BizwareGL/RenderStates.cs b/Bizware/BizHawk.Bizware.BizwareGL/RenderStates.cs index 42417fcb4b..2df69d0888 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/RenderStates.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/RenderStates.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; - namespace BizHawk.Bizware.BizwareGL { public interface IBlendState { } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs b/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs index 7eb44d6f5e..999dd8e9bc 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace BizHawk.Bizware.BizwareGL { @@ -18,9 +17,9 @@ namespace BizHawk.Bizware.BizwareGL return $"GL RT: {Texture2d.Width}x{Texture2d.Height}"; } - public object Opaque { get; private set; } - public IGL Owner { get; private set; } - public Texture2d Texture2d { get; private set; } + public object Opaque { get; } + public IGL Owner { get; } + public Texture2d Texture2d { get; } public void Unbind() { diff --git a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs b/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs index b758006cf6..201719c050 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs @@ -11,9 +11,8 @@ namespace BizHawk.Bizware.BizwareGL /// public class RetroShader : IDisposable { - //NOTE: we may need to overhaul uniform-setting infrastructure later. - //maybe samplers will need to be set by index and not by name (I think the specs dont dictate what the sampler must be named) - + // NOTE: we may need to overhaul uniform-setting infrastructure later. + // maybe samplers will need to be set by index and not by name (I think the specs don't dictate what the sampler must be named) public RetroShader(IGL owner, string source, bool debug = false) { Owner = owner; @@ -37,9 +36,9 @@ namespace BizHawk.Bizware.BizwareGL return; } - //retroarch shaders will sometimes not have the right sampler name - //it's unclear whether we should bind to s_p or sampler0 - //lets bind to sampler0 in case we dont have s_p + // retroarch shaders will sometimes not have the right sampler name + // it's unclear whether we should bind to s_p or sampler0 + // lets bind to sampler0 in case we don't have s_p sampler0 = Pipeline.TryGetUniform("s_p"); if (sampler0 == null) { @@ -60,10 +59,10 @@ namespace BizHawk.Bizware.BizwareGL Available = true; } - public bool Available { get; private set; } - public string Errors { get { return Pipeline.Errors; } } + public bool Available { get; } + public string Errors => Pipeline.Errors; - PipelineUniform sampler0; + private readonly PipelineUniform sampler0; public void Dispose() { @@ -131,9 +130,9 @@ namespace BizHawk.Bizware.BizwareGL } - public IGL Owner { get; private set; } + public IGL Owner { get; } - VertexLayout VertexLayout; + readonly VertexLayout VertexLayout; public Pipeline Pipeline; } } \ No newline at end of file diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Shader.cs b/Bizware/BizHawk.Bizware.BizwareGL/Shader.cs index 7f8c275b74..12b18bb66a 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Shader.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Shader.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; - namespace BizHawk.Bizware.BizwareGL { /// /// Represents an individual (fragment,vertex) shader. - /// It isnt IDisposable because itll be lifecycle-managed by the IGL (disposed when all dependent pipelines are disposed) + /// It isn't IDisposable because it'll be lifecycle-managed by the IGL (disposed when all dependent pipelines are disposed) /// But if you want to be sure to save it for later, use AddRef /// public class Shader @@ -18,8 +15,8 @@ namespace BizHawk.Bizware.BizwareGL Errors = ""; } - public IGL Owner { get; private set; } - public object Opaque { get; private set; } + public IGL Owner { get; } + public object Opaque { get; } public bool Available { get; private set; } public string Errors { get; set; } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs index 9f2e75769e..6a68bfb439 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/StringRenderer.cs @@ -102,7 +102,7 @@ namespace BizHawk.Bizware.BizwareGL if (!FontInfo.Characters.TryGetValue((char)c, out bfc)) bfc = FontInfo.Characters[unchecked((char)-1)]; - //calculate texcoords (we shouldve already had this cached, but im speedcoding now) + // calculate texcoords (we shouldve already had this cached, but im speedcoding now) Texture2d tex = TexturePages[bfc.TexturePage]; float w = tex.Width; float h = tex.Height; @@ -119,9 +119,9 @@ namespace BizHawk.Bizware.BizwareGL } } - public IGL Owner { get; private set; } + public IGL Owner { get; } - Cyotek.Drawing.BitmapFont.BitmapFont FontInfo; + readonly Cyotek.Drawing.BitmapFont.BitmapFont FontInfo; List TexturePages = new List(); } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/TexAtlas.cs b/Bizware/BizHawk.Bizware.BizwareGL/TexAtlas.cs index 0a54e2a692..b64b04f3d8 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/TexAtlas.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/TexAtlas.cs @@ -1,9 +1,5 @@ using System; -using System.Text; -using System.Text.RegularExpressions; -using System.IO; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using System.Drawing; @@ -29,10 +25,11 @@ namespace BizHawk.Bizware.BizwareGL class TryFitParam { public TryFitParam(int _w, int _h) { this.w = _w; this.h = _h; } - public int w, h; + public readonly int w; + public readonly int h; public bool ok = true; - public RectangleBinPack rbp = new RectangleBinPack(); - public List nodes = new List(); + public readonly RectangleBinPack rbp = new RectangleBinPack(); + public readonly List nodes = new List(); } public class PackedAtlasResults diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs b/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs index 2f385ab56f..a399e23fe4 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs @@ -1,8 +1,5 @@ using System; using System.Drawing; - -using OpenTK; -using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; namespace BizHawk.Bizware.BizwareGL @@ -66,21 +63,21 @@ namespace BizHawk.Bizware.BizwareGL SetMagFilter(TextureMagFilter.Nearest); } - public IGL Owner { get; private set; } + public IGL Owner { get; } public object Opaque { get; private set; } - //note.. this was a lame idea. convenient, but weird. lets just change this back to ints. - public float Width { get; private set; } - public float Height { get; private set; } + // note.. this was a lame idea. convenient, but weird. lets just change this back to ints. + public float Width { get; } + public float Height { get; } - public int IntWidth { get { return (int)Width; } } - public int IntHeight { get { return (int)Height; } } - public Rectangle Rectangle { get { return new Rectangle(0, 0, IntWidth, IntHeight); } } - public Size Size { get { return new Size(IntWidth, IntHeight); } } + public int IntWidth => (int)Width; + public int IntHeight => (int)Height; + public Rectangle Rectangle => new Rectangle(0, 0, IntWidth, IntHeight); + public Size Size => new Size(IntWidth, IntHeight); /// /// opengl sucks, man. seriously, screw this (textures from render targets are upside down) - /// (couldnt we fix it up in the matrices somewhere?) + /// (couldn't we fix it up in the matrices somewhere?) /// public bool IsUpsideDown; } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/UniformInfo.cs b/Bizware/BizHawk.Bizware.BizwareGL/UniformInfo.cs index 5891667f00..3d749b6293 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/UniformInfo.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/UniformInfo.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; - namespace BizHawk.Bizware.BizwareGL { public class UniformInfo diff --git a/Bizware/BizHawk.Bizware.BizwareGL/VertexLayout.cs b/Bizware/BizHawk.Bizware.BizwareGL/VertexLayout.cs index 8cb18bd968..a9b6f5bae4 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/VertexLayout.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/VertexLayout.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; - using BizHawk.Common; using OpenTK.Graphics.OpenGL; @@ -9,12 +7,12 @@ namespace BizHawk.Bizware.BizwareGL { /// /// Represents a vertex layout, really a kind of a peer of the vertex and fragment shaders. - /// It isnt IDisposable because itll be lifecycle-managed by the IGL (disposed when all dependent pipelines are disposed) + /// It isn't IDisposable because it'll be lifecycle-managed by the IGL (disposed when all dependent pipelines are disposed) /// But if you want to be sure to save it for later, use AddRef /// public class VertexLayout { - //TODO - could refactor to use vertex array objects? check opengl profile requirements (answer: 3.0. dont want to do this.) + //TODO - could refactor to use vertex array objects? check opengl profile requirements (answer: 3.0. don't want to do this.) public VertexLayout(IGL owner, object opaque) { @@ -23,8 +21,8 @@ namespace BizHawk.Bizware.BizwareGL Items = new MyDictionary(); } - public object Opaque { get; private set; } - public IGL Owner { get; private set; } + public object Opaque { get; } + public IGL Owner { get; } int RefCount; @@ -74,19 +72,12 @@ namespace BizHawk.Bizware.BizwareGL { public new LayoutItem this[int key] { - get - { - return base[key]; - } - - internal set - { - base[key] = value; - } + get => base[key]; + internal set => base[key] = value; } } - public MyDictionary Items { get; private set; } + public MyDictionary Items { get; } bool Closed = false; }