From 2eb5663ee909b1b6d28113e895846197e51c19f9 Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Thu, 11 Apr 2024 19:06:58 +0300 Subject: [PATCH] Renamed the classes in the command engine. --- Quik/CommandMachine/CommandEngine.cs | 6 +++--- Quik/CommandMachine/CommandHandler.cs | 2 +- Quik/CommandMachine/CommandList.cs | 22 ++++++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Quik/CommandMachine/CommandEngine.cs b/Quik/CommandMachine/CommandEngine.cs index e2d4c18..a414dfe 100644 --- a/Quik/CommandMachine/CommandEngine.cs +++ b/Quik/CommandMachine/CommandEngine.cs @@ -36,7 +36,7 @@ namespace Quik.CommandMachine public void ProcessCommands(QRectangle bounds, CommandList queue) { - CommandEnumerator iterator = queue.GetEnumerator(); + CommandQueue iterator = queue.GetEnumerator(); if (!iterator.Peek().IsCommand) throw new ArgumentException("The first element in the iterator must be a command frame."); @@ -103,7 +103,7 @@ namespace Quik.CommandMachine } } - protected virtual void ChildProcessCommand(Command name, CommandEnumerator queue) + protected virtual void ChildProcessCommand(Command name, CommandQueue queue) { } @@ -119,7 +119,7 @@ namespace Quik.CommandMachine _matrixStack.Push(QMat4.Identity); } - private void ConditionalHandler(CommandEnumerator iterator) + private void ConditionalHandler(CommandQueue iterator) { Frame frame = iterator.Dequeue(); diff --git a/Quik/CommandMachine/CommandHandler.cs b/Quik/CommandMachine/CommandHandler.cs index 2909385..62f31ac 100644 --- a/Quik/CommandMachine/CommandHandler.cs +++ b/Quik/CommandMachine/CommandHandler.cs @@ -4,5 +4,5 @@ namespace Quik.CommandMachine /// A delegate for a QUIK command. /// /// The current stack. - public delegate void QuikCommandHandler(CommandEngine state, CommandEnumerator queue); + public delegate void QuikCommandHandler(CommandEngine state, CommandQueue queue); } \ No newline at end of file diff --git a/Quik/CommandMachine/CommandList.cs b/Quik/CommandMachine/CommandList.cs index 8d43531..28007e2 100644 --- a/Quik/CommandMachine/CommandList.cs +++ b/Quik/CommandMachine/CommandList.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Reflection.Emit; namespace Quik.CommandMachine { @@ -233,10 +232,17 @@ namespace Quik.CommandMachine public void Image(QuikTexture texture, QRectangle[] rectangles, bool interleavedUV = false) { - ImageCommandFlags flags = interleavedUV ? ImageCommandFlags.UVs : ImageCommandFlags.None; + int count = rectangles.Length; + ImageCommandFlags flags = ImageCommandFlags.None; + + if (interleavedUV) + { + count /= 2; + flags |= ImageCommandFlags.UVs; + } Enqueue(Command.Image); - Enqueue(new Frame((int)flags, rectangles.Length / 2)); + Enqueue(new Frame(count)); Enqueue(new Frame(texture)); foreach (QRectangle rectangle in rectangles) @@ -259,20 +265,20 @@ namespace Quik.CommandMachine } } - public void Splice(CommandList queue) + public void Splice(CommandList list) { - foreach (Frame frame in queue) + foreach (Frame frame in list) { Enqueue(frame); } } - public CommandEnumerator GetEnumerator() => new CommandEnumerator(_frames); + public CommandQueue GetEnumerator() => new CommandQueue(_frames); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } - public class CommandEnumerator : IEnumerator + public class CommandQueue : IEnumerator { private readonly IReadOnlyList _frames; private int _current; @@ -281,7 +287,7 @@ namespace Quik.CommandMachine object IEnumerator.Current => Current; - public CommandEnumerator(IReadOnlyList frames) + public CommandQueue(IReadOnlyList frames) { _current = -1; _frames = frames;