Renamed the classes in the command engine.

This commit is contained in:
H. Utku Maden 2024-04-11 19:06:58 +03:00
parent 09ce8d3229
commit 2eb5663ee9
3 changed files with 18 additions and 12 deletions

@ -36,7 +36,7 @@ namespace Quik.CommandMachine
public void ProcessCommands(QRectangle bounds, CommandList queue) public void ProcessCommands(QRectangle bounds, CommandList queue)
{ {
CommandEnumerator iterator = queue.GetEnumerator(); CommandQueue iterator = queue.GetEnumerator();
if (!iterator.Peek().IsCommand) if (!iterator.Peek().IsCommand)
throw new ArgumentException("The first element in the iterator must be a command frame."); 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); _matrixStack.Push(QMat4.Identity);
} }
private void ConditionalHandler(CommandEnumerator iterator) private void ConditionalHandler(CommandQueue iterator)
{ {
Frame frame = iterator.Dequeue(); Frame frame = iterator.Dequeue();

@ -4,5 +4,5 @@ namespace Quik.CommandMachine
/// A delegate for a QUIK command. /// A delegate for a QUIK command.
/// </summary> /// </summary>
/// <param name="stack">The current stack.</param> /// <param name="stack">The current stack.</param>
public delegate void QuikCommandHandler(CommandEngine state, CommandEnumerator queue); public delegate void QuikCommandHandler(CommandEngine state, CommandQueue queue);
} }

@ -2,7 +2,6 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Reflection.Emit;
namespace Quik.CommandMachine namespace Quik.CommandMachine
{ {
@ -233,10 +232,17 @@ namespace Quik.CommandMachine
public void Image(QuikTexture texture, QRectangle[] rectangles, bool interleavedUV = false) 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(Command.Image);
Enqueue(new Frame((int)flags, rectangles.Length / 2)); Enqueue(new Frame(count));
Enqueue(new Frame(texture)); Enqueue(new Frame(texture));
foreach (QRectangle rectangle in rectangles) 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); Enqueue(frame);
} }
} }
public CommandEnumerator GetEnumerator() => new CommandEnumerator(_frames); public CommandQueue GetEnumerator() => new CommandQueue(_frames);
IEnumerator<Frame> IEnumerable<Frame>.GetEnumerator() => GetEnumerator(); IEnumerator<Frame> IEnumerable<Frame>.GetEnumerator() => GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
} }
public class CommandEnumerator : IEnumerator<Frame> public class CommandQueue : IEnumerator<Frame>
{ {
private readonly IReadOnlyList<Frame> _frames; private readonly IReadOnlyList<Frame> _frames;
private int _current; private int _current;
@ -281,7 +287,7 @@ namespace Quik.CommandMachine
object IEnumerator.Current => Current; object IEnumerator.Current => Current;
public CommandEnumerator(IReadOnlyList<Frame> frames) public CommandQueue(IReadOnlyList<Frame> frames)
{ {
_current = -1; _current = -1;
_frames = frames; _frames = frames;