Compare commits

...

2 Commits

Author SHA1 Message Date
50552914c1 Rename various types. 2024-07-28 14:19:13 +03:00
d959c42e99 Rename various objects. 2024-07-28 14:11:23 +03:00
45 changed files with 301 additions and 305 deletions

@ -12,13 +12,13 @@ namespace Dashboard.BlurgText
{ {
BlurgRect rect = result[i]; BlurgRect rect = result[i];
QRectangle pos = new QRectangle() Rectangle pos = new Rectangle()
{ {
Min = origin + new Vector2(rect.X, rect.Y), Min = origin + new Vector2(rect.X, rect.Y),
Size = new Vector2(rect.Width, rect.Height) Size = new Vector2(rect.Width, rect.Height)
}; };
QRectangle uv = new QRectangle(rect.U1, rect.V1, rect.U0, rect.V0); Rectangle uv = new Rectangle(rect.U1, rect.V1, rect.U0, rect.V0);
list.Image(blurg.Images[(int)rect.UserData], pos, uv); list.Image(blurg.Images[(int)rect.UserData], pos, uv);
} }

@ -20,7 +20,7 @@ namespace Dashboard.BlurgText
private nint TextureAllocationCallback(int width, int height) private nint TextureAllocationCallback(int width, int height)
{ {
QImageBuffer image = new QImageBuffer(QImageFormat.RgbaU8, width, height); QImageBuffer image = new QImageBuffer(ImageFormat.RgbaU8, width, height);
images.Add(image); images.Add(image);
return images.Count - 1; return images.Count - 1;
} }
@ -30,7 +30,7 @@ namespace Dashboard.BlurgText
if (width == 0 || height == 0) if (width == 0 || height == 0)
return; return;
QImageLock src = new QImageLock(QImageFormat.RgbaU8, width, height, 1, buffer); QImageLock src = new QImageLock(ImageFormat.RgbaU8, width, height, 1, buffer);
QImageBuffer image = images[(int)userData]; QImageBuffer image = images[(int)userData];
image.LockBits2d(out QImageLock dest, QImageLockOptions.Default); image.LockBits2d(out QImageLock dest, QImageLockOptions.Default);

@ -5,7 +5,7 @@ using System.Linq;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.Json; using System.Text.Json;
using ReFuel.FreeType; using ReFuel.FreeType;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
using Dashboard.PAL; using Dashboard.PAL;
using Dashboard.Media.Defaults.Linux; using Dashboard.Media.Defaults.Linux;

@ -6,7 +6,7 @@ using System.Text;
using ReFuel.FreeType; using ReFuel.FreeType;
using Dashboard.Media.Defaults.Fallback; using Dashboard.Media.Defaults.Fallback;
using Dashboard.Media.Defaults.Linux; using Dashboard.Media.Defaults.Linux;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
using Dashboard.PAL; using Dashboard.PAL;
namespace Dashboard.Media.Defaults namespace Dashboard.Media.Defaults

@ -3,19 +3,19 @@ using System.Buffers;
using System.IO; using System.IO;
using ReFuel.FreeType; using ReFuel.FreeType;
using Dashboard.Media.Color; using Dashboard.Media.Color;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
using OpenTK.Mathematics; using OpenTK.Mathematics;
namespace Dashboard.Media.Defaults namespace Dashboard.Media.Defaults
{ {
public class QFontFreeType : QFont public class FontFreeType : Font
{ {
private MemoryStream ms; private MemoryStream ms;
private FTFace face; private FTFace face;
public override FontFace Face => throw new NotImplementedException(); public override FontFace Face => throw new NotImplementedException();
public QFontFreeType(Stream stream) public FontFreeType(Stream stream)
{ {
ms = new MemoryStream(); ms = new MemoryStream();
stream.CopyTo(ms); stream.CopyTo(ms);
@ -32,7 +32,7 @@ namespace Dashboard.Media.Defaults
return FT.GetCharIndex(face, (ulong)rune) != 0; return FT.GetCharIndex(face, (ulong)rune) != 0;
} }
protected override QImage Render(out QGlyphMetrics metrics, int codepoint, float size, in FontRasterizerOptions options) protected override Image Render(out GlyphMetrics metrics, int codepoint, float size, in FontRasterizerOptions options)
{ {
FT.SetCharSize(face, 0, (long)Math.Round(64*size), 0, (uint)Math.Round(options.Resolution)); FT.SetCharSize(face, 0, (long)Math.Round(64*size), 0, (uint)Math.Round(options.Resolution));
@ -40,7 +40,7 @@ namespace Dashboard.Media.Defaults
FT.LoadGlyph(face, index, FTLoadFlags.Default); FT.LoadGlyph(face, index, FTLoadFlags.Default);
ref readonly FTGlyphMetrics ftmetrics = ref face.Glyph.Metrics; ref readonly FTGlyphMetrics ftmetrics = ref face.Glyph.Metrics;
metrics = new QGlyphMetrics(codepoint, metrics = new GlyphMetrics(codepoint,
new Vector2(ftmetrics.Width/64f, ftmetrics.Height/64f), new Vector2(ftmetrics.Width/64f, ftmetrics.Height/64f),
new Vector2(ftmetrics.HorizontalBearingX/64f, ftmetrics.HorizontalBearingY/64f), new Vector2(ftmetrics.HorizontalBearingX/64f, ftmetrics.HorizontalBearingY/64f),
new Vector2(ftmetrics.VerticalBearingX/64f, ftmetrics.VerticalBearingY/64f), new Vector2(ftmetrics.VerticalBearingX/64f, ftmetrics.VerticalBearingY/64f),
@ -55,7 +55,7 @@ namespace Dashboard.Media.Defaults
return null; return null;
} }
QImageBuffer image = new QImageBuffer(QImageFormat.AlphaU8, (int)bitmap.Width, (int)bitmap.Rows); QImageBuffer image = new QImageBuffer(ImageFormat.AlphaU8, (int)bitmap.Width, (int)bitmap.Rows);
image.LockBits2d(out QImageLock lk, QImageLockOptions.Default); image.LockBits2d(out QImageLock lk, QImageLockOptions.Default);
unsafe unsafe

@ -7,11 +7,11 @@ namespace Dashboard.Media.Defaults
{ {
public class FreeTypeFontFactory : IFontFactory public class FreeTypeFontFactory : IFontFactory
{ {
public bool TryOpen(Stream stream, [NotNullWhen(true)] out QFont font) public bool TryOpen(Stream stream, [NotNullWhen(true)] out Font font)
{ {
try try
{ {
font = new QFontFreeType(stream); font = new FontFreeType(stream);
return true; return true;
} }
catch catch

@ -5,7 +5,7 @@ using ReFuel.Stb;
namespace Dashboard.Media.Defaults namespace Dashboard.Media.Defaults
{ {
public unsafe class QImageStbi : QImage public unsafe class ImageStbi : Image
{ {
private readonly StbImage image; private readonly StbImage image;
private QImageBuffer buffer; private QImageBuffer buffer;
@ -17,9 +17,9 @@ namespace Dashboard.Media.Defaults
public override int Depth => 1; public override int Depth => 1;
public override bool IsSdf => isSdf; public override bool IsSdf => isSdf;
public override QImageFormat InternalFormat => Stb2QImageFormat(image.Format); public override ImageFormat InternalFormat => Stb2QImageFormat(image.Format);
public QImageStbi(Stream source) public ImageStbi(Stream source)
{ {
// According to the stbi documentation, only a specific type of PNG // According to the stbi documentation, only a specific type of PNG
// files are premultiplied out of the box (iPhone PNG). Take the // files are premultiplied out of the box (iPhone PNG). Take the
@ -30,15 +30,15 @@ namespace Dashboard.Media.Defaults
image = StbImage.Load(source); image = StbImage.Load(source);
} }
public static QImageFormat Stb2QImageFormat(StbiImageFormat src) public static ImageFormat Stb2QImageFormat(StbiImageFormat src)
{ {
switch (src) switch (src)
{ {
case StbiImageFormat.Grey: return QImageFormat.RedU8; case StbiImageFormat.Grey: return ImageFormat.RedU8;
case StbiImageFormat.Rgb: return QImageFormat.RgbU8; case StbiImageFormat.Rgb: return ImageFormat.RgbU8;
case StbiImageFormat.Rgba: return QImageFormat.RgbaU8; case StbiImageFormat.Rgba: return ImageFormat.RgbaU8;
case StbiImageFormat.GreyAlpha: return QImageFormat.RaU8; case StbiImageFormat.GreyAlpha: return ImageFormat.RaU8;
default: return QImageFormat.Undefined; default: return ImageFormat.Undefined;
} }
} }

@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using ReFuel.FreeType; using ReFuel.FreeType;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
using Dashboard.PAL; using Dashboard.PAL;
namespace Dashboard.Media.Defaults.Linux namespace Dashboard.Media.Defaults.Linux

@ -4,7 +4,7 @@ using System.Collections;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
// WebRequest is obsolete but runs on .NET framework. // WebRequest is obsolete but runs on .NET framework.
#pragma warning disable SYSLIB0014 #pragma warning disable SYSLIB0014

@ -10,13 +10,13 @@ using System.Collections.Generic;
namespace Dashboard.OpenTK namespace Dashboard.OpenTK
{ {
public class OpenTKPlatform : IDashboardPlatform public class OpenTKPlatform : IDbPlatform
{ {
private readonly List<OpenTKPort> _ports = new List<OpenTKPort>(); private readonly List<OpenTKPort> _ports = new List<OpenTKPort>();
// These shall remain a sad nop for now. // These shall remain a sad nop for now.
public string? Title { get; set; } public string? Title { get; set; }
public QImage? Icon { get; set; } = null; public Media.Image? Icon { get; set; } = null;
public event EventHandler? EventRaised; public event EventHandler? EventRaised;

@ -68,7 +68,7 @@ namespace Dashboard.OpenTK
public void Paint(DrawList queue) public void Paint(DrawList queue)
{ {
QRectangle view = new QRectangle(Size, new Vector2(0, 0)); Rectangle view = new Rectangle(Size, new Vector2(0, 0));
_vertexEngine.Reset(); _vertexEngine.Reset();
_vertexEngine.ProcessCommands(view, queue); _vertexEngine.ProcessCommands(view, queue);

@ -8,7 +8,7 @@ namespace Dashboard.Controls
public class Label : Control public class Label : Control
{ {
public string Text { get; set; } = string.Empty; public string Text { get; set; } = string.Empty;
public QFont? Font { get; set; } public Font? Font { get; set; }
public float TextSize { get; set; } public float TextSize { get; set; }
public bool AutoSize { get; set; } = true; public bool AutoSize { get; set; } = true;

@ -14,9 +14,9 @@ namespace Dashboard.Controls
public UIBase? Parent { get; protected set; } public UIBase? Parent { get; protected set; }
public string? Id { get; set; } public string? Id { get; set; }
public QRectangle Bounds public Rectangle Bounds
{ {
get => new QRectangle(Position + Size, Position); get => new Rectangle(Position + Size, Position);
set set
{ {
Size = value.Size; Size = value.Size;
@ -38,7 +38,7 @@ namespace Dashboard.Controls
} }
} }
public QRectangle AbsoluteBounds public Rectangle AbsoluteBounds
{ {
get get
{ {
@ -48,7 +48,7 @@ namespace Dashboard.Controls
} }
else else
{ {
return new QRectangle(Bounds.Max + Parent.Position, Bounds.Min + Parent.Position); return new Rectangle(Bounds.Max + Parent.Position, Bounds.Min + Parent.Position);
} }
} }
} }

@ -17,7 +17,7 @@ namespace Dashboard
/// <summary> /// <summary>
/// The application platform driver. /// The application platform driver.
/// </summary> /// </summary>
public IDashboardPlatform Platform { get; } public IDbPlatform Platform { get; }
/// <summary> /// <summary>
/// Title of the application. /// Title of the application.
@ -31,7 +31,7 @@ namespace Dashboard
/// <summary> /// <summary>
/// Application icon. /// Application icon.
/// </summary> /// </summary>
public QImage? Icon public Image? Icon
{ {
get => Platform.Icon; get => Platform.Icon;
set => Platform.Icon = value; set => Platform.Icon = value;
@ -46,7 +46,7 @@ namespace Dashboard
/// </summary> /// </summary>
public List<MediaLoader> MediaLoaders { get; } = new List<MediaLoader>(); public List<MediaLoader> MediaLoaders { get; } = new List<MediaLoader>();
public DbApplication(IDashboardPlatform platform) public DbApplication(IDbPlatform platform)
{ {
Platform = platform; Platform = platform;
FontProvider = new FontProvider(this); FontProvider = new FontProvider(this);

@ -8,7 +8,7 @@ namespace Dashboard
/// A bezier curve segment. /// A bezier curve segment.
/// </summary> /// </summary>
[DebuggerDisplay("{Start} -- {ControlA} -- {ControlB} -- {End}")] [DebuggerDisplay("{Start} -- {ControlA} -- {ControlB} -- {End}")]
public struct QBezier public struct Bezier
{ {
/// <summary> /// <summary>
/// Segment start point. /// Segment start point.
@ -37,7 +37,7 @@ namespace Dashboard
0.5f * (End - Start).Length + 0.5f * (End - Start).Length +
0.5f * ((ControlA - Start).Length + (ControlB - ControlA).Length + (End - ControlB).Length); 0.5f * ((ControlA - Start).Length + (ControlB - ControlA).Length + (End - ControlB).Length);
public QBezier(Vector2 start, Vector2 controlA, Vector2 controlB, Vector2 end) public Bezier(Vector2 start, Vector2 controlA, Vector2 controlB, Vector2 end)
{ {
Start = start; Start = start;
ControlA = controlA; ControlA = controlA;
@ -45,7 +45,7 @@ namespace Dashboard
End = end; End = end;
} }
public QBezier( public Bezier(
float startX, float startX,
float startY, float startY,
float controlAx, float controlAx,
@ -104,7 +104,7 @@ namespace Dashboard
/// A line segment. /// A line segment.
/// </summary> /// </summary>
[DebuggerDisplay("{Start} -- {End}")] [DebuggerDisplay("{Start} -- {End}")]
public struct QLine public struct Line
{ {
/// <summary> /// <summary>
/// Start point. /// Start point.
@ -116,13 +116,13 @@ namespace Dashboard
/// </summary> /// </summary>
public Vector2 End; public Vector2 End;
public QLine(Vector2 start, Vector2 end) public Line(Vector2 start, Vector2 end)
{ {
Start = start; Start = start;
End = end; End = end;
} }
public QLine(float startX, float startY, float endX, float endY) public Line(float startX, float startY, float endX, float endY)
{ {
Start.X = startX; Start.X = startX;
Start.Y = startY; Start.Y = startY;
@ -145,7 +145,7 @@ namespace Dashboard
/// A rectangle. /// A rectangle.
/// </summary> /// </summary>
[DebuggerDisplay("({Left}, {Top}, {Right}, {Bottom})")] [DebuggerDisplay("({Left}, {Top}, {Right}, {Bottom})")]
public struct QRectangle public struct Rectangle
{ {
/// <summary> /// <summary>
/// Position maximum point. /// Position maximum point.
@ -187,13 +187,13 @@ namespace Dashboard
set => Max = Min + value; set => Max = Min + value;
} }
public QRectangle(Vector2 max, Vector2 min) public Rectangle(Vector2 max, Vector2 min)
{ {
Max = max; Max = max;
Min = min; Min = min;
} }
public QRectangle(float r, float b, float l, float t) public Rectangle(float r, float b, float l, float t)
{ {
Max = new Vector2(r, b); Max = new Vector2(r, b);
Min = new Vector2(l, t); Min = new Vector2(l, t);
@ -212,8 +212,8 @@ namespace Dashboard
Max += offset; Max += offset;
} }
public static QRectangle Intersect(in QRectangle a, in QRectangle b) => public static Rectangle Intersect(in Rectangle a, in Rectangle b) =>
new QRectangle( new Rectangle(
Math.Max(a.Right, b.Right), Math.Max(a.Right, b.Right),
Math.Max(a.Bottom, b.Bottom) Math.Max(a.Bottom, b.Bottom)
, ,
@ -226,7 +226,7 @@ namespace Dashboard
/// </summary> /// </summary>
/// <remarks>It is undefined to have an ellipse with non-orthogonal axes.</remarks> /// <remarks>It is undefined to have an ellipse with non-orthogonal axes.</remarks>
[DebuggerDisplay("{Center} ellipse {AxisA}; {AxisB}")] [DebuggerDisplay("{Center} ellipse {AxisA}; {AxisB}")]
public struct QEllipse public struct Ellipse
{ {
/// <summary> /// <summary>
/// Ellipse center point. /// Ellipse center point.
@ -248,7 +248,7 @@ namespace Dashboard
/// A triangle. /// A triangle.
/// </summary> /// </summary>
[DebuggerDisplay("{A} -- {B} -- {C}")] [DebuggerDisplay("{A} -- {B} -- {C}")]
public struct QTriangle public struct Triangle
{ {
/// <summary> /// <summary>
/// First vertex. /// First vertex.

@ -10,14 +10,14 @@ namespace Dashboard.ImmediateDraw
private readonly Stack<int> _zStack = new Stack<int>(); private readonly Stack<int> _zStack = new Stack<int>();
public int ZIndex => _zIndex; public int ZIndex => _zIndex;
private QRectangle _viewport; private Rectangle _viewport;
private readonly Stack<QRectangle> _viewportStack = new Stack<QRectangle>(); private readonly Stack<Rectangle> _viewportStack = new Stack<Rectangle>();
private readonly Stack<Matrix4> _matrixStack = new Stack<Matrix4>(); private readonly Stack<Matrix4> _matrixStack = new Stack<Matrix4>();
private Command _customCommandBase = Command.CustomCommandBase; private Command _customCommandBase = Command.CustomCommandBase;
private readonly List<CommandHandler> _customCommands = new List<CommandHandler>(); private readonly List<CommandHandler> _customCommands = new List<CommandHandler>();
public QRectangle Viewport => _viewport; public Rectangle Viewport => _viewport;
public Matrix4 ActiveTransforms { get; } public Matrix4 ActiveTransforms { get; }
@ -35,7 +35,7 @@ namespace Dashboard.ImmediateDraw
return id; return id;
} }
public void ProcessCommands(QRectangle bounds, DrawList queue) public void ProcessCommands(Rectangle bounds, DrawList queue)
{ {
DrawQueue iterator = queue.GetEnumerator(); DrawQueue iterator = queue.GetEnumerator();
@ -74,13 +74,13 @@ namespace Dashboard.ImmediateDraw
_viewportStack.Push(_viewport); _viewportStack.Push(_viewport);
break; break;
case Command.IntersectViewport: case Command.IntersectViewport:
_viewport = QRectangle.Intersect((QRectangle)iterator.Dequeue(), _viewport); _viewport = Rectangle.Intersect((Rectangle)iterator.Dequeue(), _viewport);
break; break;
case Command.StoreViewport: case Command.StoreViewport:
_viewport = (QRectangle)iterator.Dequeue(); _viewport = (Rectangle)iterator.Dequeue();
break; break;
case Command.PopViewport: case Command.PopViewport:
_viewport = _viewportStack.TryPop(out QRectangle viewport) ? viewport : bounds; _viewport = _viewportStack.TryPop(out Rectangle viewport) ? viewport : bounds;
break; break;
case Command.PushZ: case Command.PushZ:
_zStack.Push(_zIndex); _zStack.Push(_zIndex);
@ -123,7 +123,7 @@ namespace Dashboard.ImmediateDraw
_zIndex = 0; _zIndex = 0;
_zStack.Clear(); _zStack.Clear();
_viewport = new QRectangle(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue); _viewport = new Rectangle(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue);
_viewportStack.Clear(); _viewportStack.Clear();
_matrixStack.Clear(); _matrixStack.Clear();

@ -49,13 +49,13 @@ namespace Dashboard.ImmediateDraw
Enqueue(Command.PushViewport); Enqueue(Command.PushViewport);
} }
public void IntersectViewport(in QRectangle viewport) public void IntersectViewport(in Rectangle viewport)
{ {
Enqueue(Command.IntersectViewport); Enqueue(Command.IntersectViewport);
Enqueue(viewport); Enqueue(viewport);
} }
public void StoreViewport(in QRectangle viewport) public void StoreViewport(in Rectangle viewport)
{ {
Enqueue(Command.StoreViewport); Enqueue(Command.StoreViewport);
Enqueue(viewport); Enqueue(viewport);
@ -126,21 +126,21 @@ namespace Dashboard.ImmediateDraw
Enqueue(Command.PopStyle); Enqueue(Command.PopStyle);
} }
public void Line(in QLine line) public void Line(in Line line)
{ {
Enqueue(Command.Line); Enqueue(Command.Line);
Enqueue(line); Enqueue(line);
} }
public void Line(params QLine[] lines) public void Line(params Line[] lines)
{ {
Enqueue(Command.Line); Enqueue(Command.Line);
Enqueue((Frame)lines.Length); Enqueue((Frame)lines.Length);
foreach (QLine line in lines) foreach (Line line in lines)
Enqueue(line); Enqueue(line);
} }
public void Bezier(in QBezier bezier) public void Bezier(in Bezier bezier)
{ {
Frame a, b; Frame a, b;
Frame.Create(bezier, out a, out b); Frame.Create(bezier, out a, out b);
@ -150,14 +150,14 @@ namespace Dashboard.ImmediateDraw
Enqueue(b); Enqueue(b);
} }
public void Bezier(params QBezier[] beziers) public void Bezier(params Bezier[] beziers)
{ {
Frame a, b; Frame a, b;
Enqueue(Command.Bezier); Enqueue(Command.Bezier);
Enqueue((Frame)beziers.Length); Enqueue((Frame)beziers.Length);
foreach (QBezier bezier in beziers) foreach (Bezier bezier in beziers)
{ {
Frame.Create(bezier, out a, out b); Frame.Create(bezier, out a, out b);
Enqueue(a); Enqueue(a);
@ -165,21 +165,21 @@ namespace Dashboard.ImmediateDraw
} }
} }
public void Rectangle(in QRectangle rectangle) public void Rectangle(in Rectangle rectangle)
{ {
Enqueue(Command.Rectangle); Enqueue(Command.Rectangle);
Enqueue(rectangle); Enqueue(rectangle);
} }
public void Rectangle(QRectangle[] rectangles) public void Rectangle(Rectangle[] rectangles)
{ {
Enqueue(Command.Rectangle); Enqueue(Command.Rectangle);
Enqueue((Frame)rectangles.Length); Enqueue((Frame)rectangles.Length);
foreach (QRectangle rectangle in rectangles) foreach (Rectangle rectangle in rectangles)
Enqueue(rectangle); Enqueue(rectangle);
} }
public void Ellipse(in QEllipse ellipse) public void Ellipse(in Ellipse ellipse)
{ {
Frame a, b; Frame a, b;
Frame.Create(ellipse, out a, out b); Frame.Create(ellipse, out a, out b);
@ -189,12 +189,12 @@ namespace Dashboard.ImmediateDraw
Enqueue(b); Enqueue(b);
} }
public void Ellipse(params QEllipse[] ellipses) public void Ellipse(params Ellipse[] ellipses)
{ {
Frame a, b; Frame a, b;
Enqueue(Command.Ellipse); Enqueue(Command.Ellipse);
Enqueue((Frame)ellipses.Length); Enqueue((Frame)ellipses.Length);
foreach (QEllipse ellipse in ellipses) foreach (Ellipse ellipse in ellipses)
{ {
Frame.Create(ellipse, out a, out b); Frame.Create(ellipse, out a, out b);
Enqueue(a); Enqueue(a);
@ -202,7 +202,7 @@ namespace Dashboard.ImmediateDraw
} }
} }
public void Triangle(in QTriangle triangle) public void Triangle(in Triangle triangle)
{ {
Enqueue(Command.Triangle); Enqueue(Command.Triangle);
Enqueue(triangle.A); Enqueue(triangle.A);
@ -210,11 +210,11 @@ namespace Dashboard.ImmediateDraw
Enqueue(triangle.C); Enqueue(triangle.C);
} }
public void Triangle(params QTriangle[] triangles) public void Triangle(params Triangle[] triangles)
{ {
Enqueue(Command.Triangle); Enqueue(Command.Triangle);
Enqueue((Frame)triangles.Length); Enqueue((Frame)triangles.Length);
foreach (QTriangle triangle in triangles) foreach (Triangle triangle in triangles)
{ {
Enqueue(triangle.A); Enqueue(triangle.A);
Enqueue(triangle.B); Enqueue(triangle.B);
@ -232,7 +232,7 @@ namespace Dashboard.ImmediateDraw
} }
} }
public void Image(QImage texture, in QRectangle rectangle) public void Image(Image texture, in Rectangle rectangle)
{ {
Enqueue(Command.Image); Enqueue(Command.Image);
Enqueue((Frame)(int)ImageCommandFlags.Single); Enqueue((Frame)(int)ImageCommandFlags.Single);
@ -240,7 +240,7 @@ namespace Dashboard.ImmediateDraw
Enqueue(rectangle); Enqueue(rectangle);
} }
public void Image(QImage texture, in QRectangle rectangle, in QRectangle uv) public void Image(Image texture, in Rectangle rectangle, in Rectangle uv)
{ {
Enqueue(Command.Image); Enqueue(Command.Image);
Enqueue((Frame)(int)(ImageCommandFlags.Single | ImageCommandFlags.UVs)); Enqueue((Frame)(int)(ImageCommandFlags.Single | ImageCommandFlags.UVs));
@ -249,7 +249,7 @@ namespace Dashboard.ImmediateDraw
Enqueue(uv); Enqueue(uv);
} }
public void Image(QImage texture, ReadOnlySpan<QRectangle> rectangles, bool interleavedUV = false) public void Image(Image texture, ReadOnlySpan<Rectangle> rectangles, bool interleavedUV = false)
{ {
int count = rectangles.Length; int count = rectangles.Length;
ImageCommandFlags flags = ImageCommandFlags.None; ImageCommandFlags flags = ImageCommandFlags.None;
@ -264,13 +264,13 @@ namespace Dashboard.ImmediateDraw
Enqueue(new Frame((int)flags, count)); Enqueue(new Frame((int)flags, count));
Enqueue(new Frame(texture)); Enqueue(new Frame(texture));
foreach (QRectangle rectangle in rectangles) foreach (Rectangle rectangle in rectangles)
{ {
Enqueue(rectangle); Enqueue(rectangle);
} }
} }
public void Image(QImage texture, ReadOnlySpan<QRectangle> rectangles, ReadOnlySpan<QRectangle> uvs) public void Image(Image texture, ReadOnlySpan<Rectangle> rectangles, ReadOnlySpan<Rectangle> uvs)
{ {
int count = Math.Min(rectangles.Length, uvs.Length); int count = Math.Min(rectangles.Length, uvs.Length);
Enqueue(Command.Image); Enqueue(Command.Image);
@ -284,7 +284,7 @@ namespace Dashboard.ImmediateDraw
} }
} }
public void Image3D(QImage texture, in Image3DCall call) public void Image3D(Image texture, in Image3DCall call)
{ {
Enqueue(Command.Image); Enqueue(Command.Image);
Enqueue(new Frame(ImageCommandFlags.Image3d | ImageCommandFlags.Single)); Enqueue(new Frame(ImageCommandFlags.Image3d | ImageCommandFlags.Single));
@ -294,7 +294,7 @@ namespace Dashboard.ImmediateDraw
Enqueue(new Frame(call.Layer)); Enqueue(new Frame(call.Layer));
} }
public void Image3D(QImage texture, ReadOnlySpan<Image3DCall> calls) public void Image3D(Image texture, ReadOnlySpan<Image3DCall> calls)
{ {
Enqueue(Command.Image); Enqueue(Command.Image);
Enqueue(new Frame((int)ImageCommandFlags.Image3d, calls.Length)); Enqueue(new Frame((int)ImageCommandFlags.Image3d, calls.Length));

@ -312,29 +312,29 @@ namespace Dashboard.ImmediateDraw
} }
} }
public static explicit operator QRectangle(in Frame frame) public static explicit operator Rectangle(in Frame frame)
{ {
switch (frame.Type) switch (frame.Type)
{ {
default: default:
throw new InvalidCastException(); throw new InvalidCastException();
case FrameType.IVec4: case FrameType.IVec4:
return new QRectangle(frame._i1, frame._i2, frame._i3, frame._i4); return new Rectangle(frame._i1, frame._i2, frame._i3, frame._i4);
case FrameType.Vec4: case FrameType.Vec4:
return new QRectangle(frame._f1, frame._f2, frame._f3, frame._f4); return new Rectangle(frame._f1, frame._f2, frame._f3, frame._f4);
} }
} }
public static explicit operator QLine(in Frame frame) public static explicit operator Line(in Frame frame)
{ {
switch (frame.Type) switch (frame.Type)
{ {
default: default:
throw new InvalidCastException(); throw new InvalidCastException();
case FrameType.IVec4: case FrameType.IVec4:
return new QLine(frame._i1, frame._i2, frame._i3, frame._i4); return new Line(frame._i1, frame._i2, frame._i3, frame._i4);
case FrameType.Vec4: case FrameType.Vec4:
return new QLine(frame._f1, frame._f2, frame._f3, frame._f4); return new Line(frame._f1, frame._f2, frame._f3, frame._f4);
} }
} }
#endregion #endregion
@ -344,16 +344,16 @@ namespace Dashboard.ImmediateDraw
public static implicit operator Frame(Command cmd) => new Frame(cmd); public static implicit operator Frame(Command cmd) => new Frame(cmd);
public static implicit operator Frame(in Vector2 vector) => new Frame(vector.X, vector.Y); public static implicit operator Frame(in Vector2 vector) => new Frame(vector.X, vector.Y);
public static implicit operator Frame(in Color4 color) => new Frame(color.R, color.G, color.B, color.A); public static implicit operator Frame(in Color4 color) => new Frame(color.R, color.G, color.B, color.A);
public static implicit operator Frame(in QRectangle rect) => new Frame(rect.Max.X, rect.Max.Y, rect.Min.X, rect.Min.Y); public static implicit operator Frame(in Rectangle rect) => new Frame(rect.Max.X, rect.Max.Y, rect.Min.X, rect.Min.Y);
public static implicit operator Frame(in QLine line) => new Frame(line.Start.X, line.Start.Y, line.End.X, line.Start.Y); public static implicit operator Frame(in Line line) => new Frame(line.Start.X, line.Start.Y, line.End.X, line.Start.Y);
public static void Create(in QBezier bezier, out Frame a, out Frame b) public static void Create(in Bezier bezier, out Frame a, out Frame b)
{ {
a = new Frame(bezier.Start.X, bezier.Start.Y, bezier.End.X, bezier.End.Y); a = new Frame(bezier.Start.X, bezier.Start.Y, bezier.End.X, bezier.End.Y);
b = new Frame(bezier.ControlA.X, bezier.ControlA.Y, bezier.ControlB.X, bezier.ControlB.Y); b = new Frame(bezier.ControlA.X, bezier.ControlA.Y, bezier.ControlB.X, bezier.ControlB.Y);
} }
public static void Create(in QEllipse ellipse, out Frame a, out Frame b) public static void Create(in Ellipse ellipse, out Frame a, out Frame b)
{ {
a = new Frame(ellipse.Center.X, ellipse.Center.Y); a = new Frame(ellipse.Center.X, ellipse.Center.Y);
b = new Frame(ellipse.AxisA.X, ellipse.AxisA.Y, ellipse.AxisB.X, ellipse.AxisB.Y); b = new Frame(ellipse.AxisA.X, ellipse.AxisA.Y, ellipse.AxisB.X, ellipse.AxisB.Y);

@ -11,8 +11,8 @@ namespace Dashboard.ImmediateDraw
public struct Image3DCall public struct Image3DCall
{ {
public QRectangle Rectangle; public Rectangle Rectangle;
public QRectangle UVs; public Rectangle UVs;
public int Layer; public int Layer;
} }
} }

@ -9,12 +9,12 @@ namespace Dashboard.Media.Color
{ {
switch (image.Format) switch (image.Format)
{ {
case QImageFormat.RaF: case ImageFormat.RaF:
case QImageFormat.RaU8: case ImageFormat.RaU8:
case QImageFormat.RgbF: case ImageFormat.RgbF:
case QImageFormat.RgbU8: case ImageFormat.RgbU8:
case QImageFormat.RgbaF: case ImageFormat.RgbaF:
case QImageFormat.RgbaU8: case ImageFormat.RgbaU8:
break; break;
default: default:
return; return;

@ -3,19 +3,19 @@ using System.Runtime.InteropServices;
namespace Dashboard.Media.Color namespace Dashboard.Media.Color
{ {
public class QImageBuffer : QImage public class QImageBuffer : Image
{ {
private byte[] buffer; private byte[] buffer;
GCHandle handle; GCHandle handle;
private bool isSdf = false; private bool isSdf = false;
public override QImageFormat InternalFormat { get; } public override ImageFormat InternalFormat { get; }
public override int Width { get; } public override int Width { get; }
public override int Height { get; } public override int Height { get; }
public override int Depth { get; } public override int Depth { get; }
public override bool IsSdf => isSdf; public override bool IsSdf => isSdf;
public QImageBuffer(QImageFormat format, int width, int height, int depth = 1) public QImageBuffer(ImageFormat format, int width, int height, int depth = 1)
{ {
InternalFormat = format; InternalFormat = format;
Width = width; Width = width;

@ -9,7 +9,7 @@ namespace Dashboard.Media.Color
public int Width => Lock.Width; public int Width => Lock.Width;
public int Height => Lock.Height; public int Height => Lock.Height;
public int Depth => Depth; public int Depth => Depth;
public QImageFormat Format => Lock.Format; public ImageFormat Format => Lock.Format;
public LockIO(QImageLock imageLock) public LockIO(QImageLock imageLock)
{ {
@ -29,11 +29,11 @@ namespace Dashboard.Media.Color
switch (Format) switch (Format)
{ {
default: default:
case QImageFormat.RedU8: return new Color4(ptr[0], 0, 0, 255); case ImageFormat.RedU8: return new Color4(ptr[0], 0, 0, 255);
case QImageFormat.AlphaU8: return new Color4(0, 0, 0, ptr[0]); case ImageFormat.AlphaU8: return new Color4(0, 0, 0, ptr[0]);
case QImageFormat.RaU8: return new Color4(ptr[0], 0, 0, ptr[1]); case ImageFormat.RaU8: return new Color4(ptr[0], 0, 0, ptr[1]);
case QImageFormat.RgbU8: return new Color4(ptr[0], ptr[1], ptr[2], 255); case ImageFormat.RgbU8: return new Color4(ptr[0], ptr[1], ptr[2], 255);
case QImageFormat.RgbaU8: return new Color4(ptr[0], ptr[1], ptr[2], ptr[3]); case ImageFormat.RgbaU8: return new Color4(ptr[0], ptr[1], ptr[2], ptr[3]);
} }
} }
@ -45,22 +45,22 @@ namespace Dashboard.Media.Color
switch (Format) switch (Format)
{ {
default: default:
case QImageFormat.RedU8: case ImageFormat.RedU8:
ptr[0] = (byte)(value.R * 255); ptr[0] = (byte)(value.R * 255);
break; break;
case QImageFormat.AlphaU8: case ImageFormat.AlphaU8:
ptr[0] = (byte)(value.A * 255); ptr[0] = (byte)(value.A * 255);
break; break;
case QImageFormat.RaU8: case ImageFormat.RaU8:
ptr[0] = (byte)(value.R * 255); ptr[0] = (byte)(value.R * 255);
ptr[1] = (byte)(value.A * 255); ptr[1] = (byte)(value.A * 255);
break; break;
case QImageFormat.RgbU8: case ImageFormat.RgbU8:
ptr[0] = (byte)(value.R * 255); ptr[0] = (byte)(value.R * 255);
ptr[1] = (byte)(value.G * 255); ptr[1] = (byte)(value.G * 255);
ptr[2] = (byte)(value.B * 255); ptr[2] = (byte)(value.B * 255);
break; break;
case QImageFormat.RgbaU8: case ImageFormat.RgbaU8:
ptr[0] = (byte)(value.R * 255); ptr[0] = (byte)(value.R * 255);
ptr[1] = (byte)(value.G * 255); ptr[1] = (byte)(value.G * 255);
ptr[2] = (byte)(value.B * 255); ptr[2] = (byte)(value.B * 255);
@ -82,7 +82,7 @@ namespace Dashboard.Media.Color
public int Width => Lock.Width; public int Width => Lock.Width;
public int Height => Lock.Height; public int Height => Lock.Height;
public int Depth => Depth; public int Depth => Depth;
public QImageFormat Format => Lock.Format; public ImageFormat Format => Lock.Format;
public LockIOF(QImageLock imageLock) public LockIOF(QImageLock imageLock)
{ {
@ -102,11 +102,11 @@ namespace Dashboard.Media.Color
switch (Format) switch (Format)
{ {
default: default:
case QImageFormat.RedU8: return new Color4(ptr[0], 0, 0, 1); case ImageFormat.RedU8: return new Color4(ptr[0], 0, 0, 1);
case QImageFormat.AlphaU8: return new Color4(0, 0, 0, ptr[0]); case ImageFormat.AlphaU8: return new Color4(0, 0, 0, ptr[0]);
case QImageFormat.RaU8: return new Color4(ptr[0], 0, 0, ptr[1]); case ImageFormat.RaU8: return new Color4(ptr[0], 0, 0, ptr[1]);
case QImageFormat.RgbU8: return new Color4(ptr[0], ptr[1], ptr[2], 1); case ImageFormat.RgbU8: return new Color4(ptr[0], ptr[1], ptr[2], 1);
case QImageFormat.RgbaU8: return new Color4(ptr[0], ptr[1], ptr[2], ptr[3]); case ImageFormat.RgbaU8: return new Color4(ptr[0], ptr[1], ptr[2], ptr[3]);
} }
} }
@ -118,22 +118,22 @@ namespace Dashboard.Media.Color
switch (Format) switch (Format)
{ {
default: default:
case QImageFormat.RedU8: case ImageFormat.RedU8:
ptr[0] = value.R; ptr[0] = value.R;
break; break;
case QImageFormat.AlphaU8: case ImageFormat.AlphaU8:
ptr[0] = value.A; ptr[0] = value.A;
break; break;
case QImageFormat.RaU8: case ImageFormat.RaU8:
ptr[0] = value.R; ptr[0] = value.R;
ptr[1] = value.A; ptr[1] = value.A;
break; break;
case QImageFormat.RgbU8: case ImageFormat.RgbU8:
ptr[0] = value.R; ptr[0] = value.R;
ptr[1] = value.G; ptr[1] = value.G;
ptr[2] = value.B; ptr[2] = value.B;
break; break;
case QImageFormat.RgbaU8: case ImageFormat.RgbaU8:
ptr[0] = value.R; ptr[0] = value.R;
ptr[1] = value.G; ptr[1] = value.G;
ptr[2] = value.B; ptr[2] = value.B;

@ -2,68 +2,68 @@ namespace Dashboard.Media
{ {
public static class Extensions public static class Extensions
{ {
public static bool IsU8(this QImageFormat format) public static bool IsU8(this ImageFormat format)
{ {
switch (format) switch (format)
{ {
case QImageFormat.AlphaU8: case ImageFormat.AlphaU8:
case QImageFormat.RedU8: case ImageFormat.RedU8:
case QImageFormat.RaU8: case ImageFormat.RaU8:
case QImageFormat.RgbU8: case ImageFormat.RgbU8:
case QImageFormat.RgbaU8: case ImageFormat.RgbaU8:
return true; return true;
default: default:
return false; return false;
} }
} }
public static bool IsFloat(this QImageFormat format) public static bool IsFloat(this ImageFormat format)
{ {
switch (format) switch (format)
{ {
case QImageFormat.AlphaF: case ImageFormat.AlphaF:
case QImageFormat.RedF: case ImageFormat.RedF:
case QImageFormat.RaF: case ImageFormat.RaF:
case QImageFormat.RgbF: case ImageFormat.RgbF:
case QImageFormat.RgbaF: case ImageFormat.RgbaF:
return true; return true;
default: default:
return false; return false;
} }
} }
public static int BytesPerPixel(this QImageFormat format) public static int BytesPerPixel(this ImageFormat format)
{ {
switch (format) switch (format)
{ {
case QImageFormat.AlphaU8: return sizeof(byte); case ImageFormat.AlphaU8: return sizeof(byte);
case QImageFormat.RedU8: return sizeof(byte); case ImageFormat.RedU8: return sizeof(byte);
case QImageFormat.RaU8: return 2 * sizeof(byte); case ImageFormat.RaU8: return 2 * sizeof(byte);
case QImageFormat.RgbU8: return 3 * sizeof(byte); case ImageFormat.RgbU8: return 3 * sizeof(byte);
case QImageFormat.RgbaU8: return 4 * sizeof(byte); case ImageFormat.RgbaU8: return 4 * sizeof(byte);
case QImageFormat.AlphaF: return sizeof(float); case ImageFormat.AlphaF: return sizeof(float);
case QImageFormat.RedF: return sizeof(float); case ImageFormat.RedF: return sizeof(float);
case QImageFormat.RaF: return 2 * sizeof(float); case ImageFormat.RaF: return 2 * sizeof(float);
case QImageFormat.RgbF: return 3 * sizeof(float); case ImageFormat.RgbF: return 3 * sizeof(float);
case QImageFormat.RgbaF: return 4 * sizeof(float); case ImageFormat.RgbaF: return 4 * sizeof(float);
default: return 0; default: return 0;
} }
} }
public static int Channels(this QImageFormat format) public static int Channels(this ImageFormat format)
{ {
switch (format) switch (format)
{ {
case QImageFormat.AlphaU8: return 1; case ImageFormat.AlphaU8: return 1;
case QImageFormat.RedU8: return 1; case ImageFormat.RedU8: return 1;
case QImageFormat.RaU8: return 2; case ImageFormat.RaU8: return 2;
case QImageFormat.RgbU8: return 3; case ImageFormat.RgbU8: return 3;
case QImageFormat.RgbaU8: return 4; case ImageFormat.RgbaU8: return 4;
case QImageFormat.AlphaF: return 1; case ImageFormat.AlphaF: return 1;
case QImageFormat.RedF: return 1; case ImageFormat.RedF: return 1;
case QImageFormat.RaF: return 2; case ImageFormat.RaF: return 2;
case QImageFormat.RgbF: return 3; case ImageFormat.RgbF: return 3;
case QImageFormat.RgbaF: return 4; case ImageFormat.RgbaF: return 4;
default: return 0; default: return 0;
} }
} }

@ -2,14 +2,14 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Dashboard.Media; using Dashboard.Media;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
namespace Dashboard.Media namespace Dashboard.Media
{ {
/// <summary> /// <summary>
/// Abstract class that represents a font. /// Abstract class that represents a font.
/// </summary> /// </summary>
public abstract class QFont : IDisposable public abstract class Font : IDisposable
{ {
public abstract FontFace Face { get; } public abstract FontFace Face { get; }
public string Family => Face.Family; public string Family => Face.Family;
@ -18,7 +18,7 @@ namespace Dashboard.Media
public FontStretch Stretch => Face.Stretch; public FontStretch Stretch => Face.Stretch;
public abstract bool HasRune(int rune); public abstract bool HasRune(int rune);
protected abstract QImage Render(out QGlyphMetrics metrics, int codepoint, float size, in FontRasterizerOptions options); protected abstract Image Render(out GlyphMetrics metrics, int codepoint, float size, in FontRasterizerOptions options);
private readonly Dictionary<float, SizedFontCollection> _atlasses = new Dictionary<float, SizedFontCollection>(); private readonly Dictionary<float, SizedFontCollection> _atlasses = new Dictionary<float, SizedFontCollection>();
@ -69,13 +69,13 @@ namespace Dashboard.Media
atlas = new FontAtlas(width, height, DbApplication.Current.FontProvider.RasterizerOptions.Sdf); atlas = new FontAtlas(width, height, DbApplication.Current.FontProvider.RasterizerOptions.Sdf);
} }
public void Get(int codepoint, out FontGlyph glyph, QFont font) public void Get(int codepoint, out FontGlyph glyph, Font font)
{ {
if (glyphs.TryGetValue(codepoint, out glyph)) if (glyphs.TryGetValue(codepoint, out glyph))
return; return;
QImage image = font.Render( Image image = font.Render(
out QGlyphMetrics metrics, out GlyphMetrics metrics,
codepoint, codepoint,
Size, Size,
DbApplication.Current.FontProvider.RasterizerOptions); DbApplication.Current.FontProvider.RasterizerOptions);
@ -102,11 +102,11 @@ namespace Dashboard.Media
public readonly struct FontGlyph public readonly struct FontGlyph
{ {
public readonly int CodePoint; public readonly int CodePoint;
public readonly QImage? Image; public readonly Image? Image;
public readonly QGlyphMetrics Metrics; public readonly GlyphMetrics Metrics;
public readonly QRectangle UVs; public readonly Rectangle UVs;
public FontGlyph(int codepoint, QImage? image, in QGlyphMetrics metrics, in QRectangle uvs) public FontGlyph(int codepoint, Image? image, in GlyphMetrics metrics, in Rectangle uvs)
{ {
CodePoint = codepoint; CodePoint = codepoint;
Image = image; Image = image;

@ -3,13 +3,13 @@ using System.Collections.Generic;
using Dashboard.Media.Color; using Dashboard.Media.Color;
using OpenTK.Mathematics; using OpenTK.Mathematics;
namespace Dashboard.Media.Font namespace Dashboard.Media.Fonts
{ {
public struct FontAtlasGlyphInfo public struct FontAtlasGlyphInfo
{ {
public int Codepoint; public int Codepoint;
public QImage Image; public Image Image;
public QRectangle UVs; public Rectangle UVs;
} }
public class FontAtlas public class FontAtlas
@ -109,7 +109,7 @@ namespace Dashboard.Media.Font
private class AtlasPage : IDisposable private class AtlasPage : IDisposable
{ {
public QImage Image; public Image Image;
public int PointerX, PointerY; public int PointerX, PointerY;
public int RowHeight; public int RowHeight;
public int Expansion; public int Expansion;
@ -118,7 +118,7 @@ namespace Dashboard.Media.Font
public AtlasPage(int width, int height, int expansion) public AtlasPage(int width, int height, int expansion)
{ {
Image = new QImageBuffer(QImageFormat.AlphaU8, width, height); Image = new QImageBuffer(ImageFormat.AlphaU8, width, height);
Expansion = expansion; Expansion = expansion;
Reset(); Reset();
} }
@ -136,7 +136,7 @@ namespace Dashboard.Media.Font
Vector2 size = new Vector2((float)src.Width/Image.Width, (float)src.Height/Image.Height); Vector2 size = new Vector2((float)src.Width/Image.Width, (float)src.Height/Image.Height);
prototype.Image = Image; prototype.Image = Image;
prototype.UVs = new QRectangle(min + size, min); prototype.UVs = new Rectangle(min + size, min);
AdvanceColumn(src.Width, src.Height); AdvanceColumn(src.Width, src.Height);
} }

@ -1,7 +1,7 @@
using System; using System;
using System.Text; using System.Text;
namespace Dashboard.Media.Font namespace Dashboard.Media.Fonts
{ {
public readonly struct FontFace : IEquatable<FontFace> public readonly struct FontFace : IEquatable<FontFace>
{ {

@ -1,4 +1,4 @@
namespace Dashboard.Media.Font namespace Dashboard.Media.Fonts
{ {
public enum FontSlant public enum FontSlant
{ {

@ -1,4 +1,4 @@
namespace Dashboard.Media.Font namespace Dashboard.Media.Fonts
{ {
/// <summary> /// <summary>
/// Enumeration of font stretch values. /// Enumeration of font stretch values.

@ -1,6 +1,6 @@
using System; using System;
namespace Dashboard.Media.Font namespace Dashboard.Media.Fonts
{ {
public enum FontWeight public enum FontWeight
{ {

@ -1,4 +1,4 @@
namespace Dashboard.Media.Font namespace Dashboard.Media.Fonts
{ {
public enum SystemFontFamily public enum SystemFontFamily
{ {

@ -5,7 +5,7 @@ namespace Dashboard.Media
/// <summary> /// <summary>
/// Glyph properties with metrics based on FreeType glyph metrics. /// Glyph properties with metrics based on FreeType glyph metrics.
/// </summary> /// </summary>
public struct QGlyphMetrics public struct GlyphMetrics
{ {
/// <summary> /// <summary>
/// The code point for the character. /// The code point for the character.
@ -32,7 +32,7 @@ namespace Dashboard.Media
/// </summary> /// </summary>
public Vector2 Advance { get; } public Vector2 Advance { get; }
public QGlyphMetrics( public GlyphMetrics(
int character, int character,
Vector2 size, Vector2 size,
Vector2 horizontalBearing, Vector2 horizontalBearing,

@ -1,12 +1,12 @@
using System; using System;
namespace Dashboard.Media namespace Dashboard.Media
{ {
public abstract class QImage : IDisposable public abstract class Image : IDisposable
{ {
public abstract int Width { get; } public abstract int Width { get; }
public abstract int Height { get; } public abstract int Height { get; }
public abstract int Depth { get; } public abstract int Depth { get; }
public abstract QImageFormat InternalFormat { get; } public abstract ImageFormat InternalFormat { get; }
public virtual int MipMapLevels => 0; public virtual int MipMapLevels => 0;
public virtual bool Premultiplied => false; public virtual bool Premultiplied => false;
public virtual bool IsSdf => false; public virtual bool IsSdf => false;
@ -32,12 +32,12 @@ namespace Dashboard.Media
public struct QImageLockOptions public struct QImageLockOptions
{ {
public QImageFormat Format { get; } public ImageFormat Format { get; }
public bool Premultiply { get; } public bool Premultiply { get; }
public int MipLevel { get; } public int MipLevel { get; }
public static QImageLockOptions Default { get; } = new QImageLockOptions(QImageFormat.RgbaU8, true, 0); public static QImageLockOptions Default { get; } = new QImageLockOptions(ImageFormat.RgbaU8, true, 0);
public QImageLockOptions(QImageFormat format, bool premultiply, int level) public QImageLockOptions(ImageFormat format, bool premultiply, int level)
{ {
Format = format; Format = format;
Premultiply = premultiply; Premultiply = premultiply;
@ -47,13 +47,13 @@ namespace Dashboard.Media
public struct QImageLock public struct QImageLock
{ {
public QImageFormat Format { get; } public ImageFormat Format { get; }
public int Width { get; } public int Width { get; }
public int Height { get; } public int Height { get; }
public int Depth { get; } public int Depth { get; }
public IntPtr ImagePtr { get; } public IntPtr ImagePtr { get; }
public QImageLock(QImageFormat format, int width, int height, int depth, IntPtr ptr) public QImageLock(ImageFormat format, int width, int height, int depth, IntPtr ptr)
{ {
Format = format; Format = format;
Width = width; Width = width;

@ -2,7 +2,7 @@ using System;
namespace Dashboard.Media namespace Dashboard.Media
{ {
public enum QImageFormat public enum ImageFormat
{ {
Undefined, Undefined,
RedU8, RedU8,

@ -87,7 +87,7 @@ namespace Dashboard.OpenGL
if (!IsInit) throw new InvalidOperationException("Initialize the driver first."); if (!IsInit) throw new InvalidOperationException("Initialize the driver first.");
} }
public void Draw(DrawCallQueue queue, in QRectangle view) public void Draw(DrawCallQueue queue, in Rectangle view)
{ {
AssertInit(); AssertInit();
@ -331,15 +331,15 @@ namespace Dashboard.OpenGL
internal class TextureManager : IDisposable internal class TextureManager : IDisposable
{ {
private readonly Dictionary<QImage, int> textures = new Dictionary<QImage, int>(); private readonly Dictionary<Image, int> textures = new Dictionary<Image, int>();
private readonly HashSet<QImage> imagesNotUsed = new HashSet<QImage>(); private readonly HashSet<Image> imagesNotUsed = new HashSet<Image>();
private bool isDisposed = false; private bool isDisposed = false;
public void BeginFrame() public void BeginFrame()
{ {
if (imagesNotUsed.Count > 0) if (imagesNotUsed.Count > 0)
{ {
foreach (QImage image in imagesNotUsed) foreach (Image image in imagesNotUsed)
{ {
GL.DeleteTexture(textures[image]); GL.DeleteTexture(textures[image]);
} }
@ -347,13 +347,13 @@ namespace Dashboard.OpenGL
imagesNotUsed.Clear(); imagesNotUsed.Clear();
} }
foreach (QImage image in textures.Keys) foreach (Image image in textures.Keys)
{ {
imagesNotUsed.Add(image); imagesNotUsed.Add(image);
} }
} }
public int GetTexture(QImage image) public int GetTexture(Image image)
{ {
if (textures.TryGetValue(image, out int texture)) if (textures.TryGetValue(image, out int texture))
{ {
@ -372,7 +372,7 @@ namespace Dashboard.OpenGL
return textures[image] = texture; return textures[image] = texture;
} }
public int UploadTexture3d(QImage image3d) public int UploadTexture3d(Image image3d)
{ {
int texture = GL.GenTexture(); int texture = GL.GenTexture();
@ -388,7 +388,7 @@ namespace Dashboard.OpenGL
return texture; return texture;
} }
public int UploadTexture2d(QImage image2d) public int UploadTexture2d(Image image2d)
{ {
int texture = GL.GenTexture(); int texture = GL.GenTexture();
@ -403,15 +403,15 @@ namespace Dashboard.OpenGL
switch (image2d.InternalFormat) switch (image2d.InternalFormat)
{ {
case QImageFormat.RedU8: case ImageFormat.RedU8:
case QImageFormat.RedF: case ImageFormat.RedF:
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, (int)All.Red); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, (int)All.Red);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, (int)All.Red); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, (int)All.Red);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleB, (int)All.Red); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleB, (int)All.Red);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleA, (int)All.One); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleA, (int)All.One);
break; break;
case QImageFormat.AlphaU8: case ImageFormat.AlphaU8:
case QImageFormat.AlphaF: case ImageFormat.AlphaF:
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, (int)All.One); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, (int)All.One);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, (int)All.One); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, (int)All.One);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleB, (int)All.One); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleB, (int)All.One);
@ -433,28 +433,28 @@ namespace Dashboard.OpenGL
GL.DeleteTextures(ids.Length, ref ids[0]); GL.DeleteTextures(ids.Length, ref ids[0]);
} }
private static readonly Dictionary<QImageFormat, PixelFormat> s_InternalFormat = new Dictionary<QImageFormat, PixelFormat>() private static readonly Dictionary<ImageFormat, PixelFormat> s_InternalFormat = new Dictionary<ImageFormat, PixelFormat>()
{ {
[QImageFormat.AlphaF] = PixelFormat.Alpha, [ImageFormat.AlphaF] = PixelFormat.Alpha,
[QImageFormat.AlphaU8] = PixelFormat.Alpha, [ImageFormat.AlphaU8] = PixelFormat.Alpha,
[QImageFormat.RedF] = PixelFormat.Red, [ImageFormat.RedF] = PixelFormat.Red,
[QImageFormat.RedU8] = PixelFormat.Red, [ImageFormat.RedU8] = PixelFormat.Red,
[QImageFormat.RgbF] = PixelFormat.Rgb, [ImageFormat.RgbF] = PixelFormat.Rgb,
[QImageFormat.RgbU8] = PixelFormat.Rgb, [ImageFormat.RgbU8] = PixelFormat.Rgb,
[QImageFormat.RgbaU8] = PixelFormat.Rgba, [ImageFormat.RgbaU8] = PixelFormat.Rgba,
[QImageFormat.RgbaF] = PixelFormat.Rgba, [ImageFormat.RgbaF] = PixelFormat.Rgba,
}; };
private static readonly Dictionary<QImageFormat, PixelType> s_PixelType = new Dictionary<QImageFormat, PixelType>() private static readonly Dictionary<ImageFormat, PixelType> s_PixelType = new Dictionary<ImageFormat, PixelType>()
{ {
[QImageFormat.AlphaF] = PixelType.Float, [ImageFormat.AlphaF] = PixelType.Float,
[QImageFormat.RedF] = PixelType.Float, [ImageFormat.RedF] = PixelType.Float,
[QImageFormat.RgbF] = PixelType.Float, [ImageFormat.RgbF] = PixelType.Float,
[QImageFormat.RgbaF] = PixelType.Float, [ImageFormat.RgbaF] = PixelType.Float,
[QImageFormat.AlphaU8] = PixelType.UnsignedByte, [ImageFormat.AlphaU8] = PixelType.UnsignedByte,
[QImageFormat.RedU8] = PixelType.UnsignedByte, [ImageFormat.RedU8] = PixelType.UnsignedByte,
[QImageFormat.RgbU8] = PixelType.UnsignedByte, [ImageFormat.RgbU8] = PixelType.UnsignedByte,
[QImageFormat.RgbaU8] = PixelType.UnsignedByte, [ImageFormat.RgbaU8] = PixelType.UnsignedByte,
}; };
} }
} }

@ -1,11 +1,7 @@
using OpenTK.Mathematics; using Dashboard.ImmediateDraw;
using Dashboard.ImmediateDraw;
using Dashboard.Controls; using Dashboard.Controls;
using OpenTK.Mathematics;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dashboard.PAL namespace Dashboard.PAL
{ {
@ -15,7 +11,7 @@ namespace Dashboard.PAL
public class Dash public class Dash
{ {
private readonly IDashHandle handle; private readonly IDashHandle handle;
private readonly IDashboardPlatform platform; private readonly IDbPlatform platform;
public string Title public string Title
{ {
@ -51,7 +47,7 @@ namespace Dashboard.PAL
} }
} }
public Dash(IDashboardPlatform platform) public Dash(IDbPlatform platform)
{ {
this.platform = platform; this.platform = platform;
handle = platform.CreatePort(); handle = platform.CreatePort();
@ -79,7 +75,7 @@ namespace Dashboard.PAL
list ??= new DrawList(); list ??= new DrawList();
list.Clear(); list.Clear();
UIElement.Bounds = new QRectangle(Size, new Vector2(0,0)); UIElement.Bounds = new Rectangle(Size, new Vector2(0,0));
UIElement.Paint(list); UIElement.Paint(list);
platform.PortPaint(handle, list); platform.PortPaint(handle, list);
} }

@ -15,7 +15,7 @@ namespace Dashboard.PAL
/// <summary> /// <summary>
/// The primary primary platform abstraction interface for dashboard hosts. /// The primary primary platform abstraction interface for dashboard hosts.
/// </summary> /// </summary>
public interface IDashboardPlatform : IDisposable public interface IDbPlatform : IDisposable
{ {
/// <summary> /// <summary>
/// The title of the application. /// The title of the application.
@ -25,7 +25,7 @@ namespace Dashboard.PAL
/// <summary> /// <summary>
/// The default icon for the application. /// The default icon for the application.
/// </summary> /// </summary>
QImage? Icon { get; set; } Image? Icon { get; set; }
/// <summary> /// <summary>
/// The event raised when an event is received. /// The event raised when an event is received.

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
namespace Dashboard.PAL namespace Dashboard.PAL
{ {

@ -7,6 +7,6 @@ namespace Dashboard.PAL
{ {
public interface IFontFactory public interface IFontFactory
{ {
bool TryOpen(Stream stream, [NotNullWhen(true)] out QFont font); bool TryOpen(Stream stream, [NotNullWhen(true)] out Font font);
} }
} }

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Dashboard.Media; using Dashboard.Media;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
using OpenTK.Mathematics; using OpenTK.Mathematics;
namespace Dashboard namespace Dashboard
@ -110,9 +110,9 @@ namespace Dashboard
set => this["list-marker-position"] = value; set => this["list-marker-position"] = value;
} }
public QImage? ListMarkerImage public Image? ListMarkerImage
{ {
get => (QImage?)this["list-marker-image"]; get => (Image?)this["list-marker-image"];
set => this["list-marker-image"] = value; set => this["list-marker-image"] = value;
} }
@ -209,7 +209,7 @@ namespace Dashboard
/// <summary> /// <summary>
/// A line stipple pattern. /// A line stipple pattern.
/// </summary> /// </summary>
public struct QuikStipplePattern public struct StipplePattern
{ {
/// <summary> /// <summary>
/// The stipple pitch value. /// The stipple pitch value.
@ -221,19 +221,19 @@ namespace Dashboard
/// </summary> /// </summary>
public float DutyCycle; public float DutyCycle;
public QuikStipplePattern(float pitch, float dutyCycle) public StipplePattern(float pitch, float dutyCycle)
{ {
Pitch = pitch; Pitch = pitch;
DutyCycle = dutyCycle; DutyCycle = dutyCycle;
} }
public static QuikStipplePattern None => new QuikStipplePattern(0.0f, 1.0f); public static StipplePattern None => new StipplePattern(0.0f, 1.0f);
} }
/// <summary> /// <summary>
/// Stroke style for lines and borders. /// Stroke style for lines and borders.
/// </summary> /// </summary>
public class QuikStrokeStyle public class StrokeStyle
{ {
/// <summary> /// <summary>
/// Stroke color. /// Stroke color.
@ -250,11 +250,11 @@ namespace Dashboard
// /// </summary> // /// </summary>
// public QuikStipplePattern StipplePattern { get; set; } // public QuikStipplePattern StipplePattern { get; set; }
public QuikStrokeStyle() public StrokeStyle()
{ {
} }
public QuikStrokeStyle(Color4 color, float width /*, QuikStipplePattern pattern*/) public StrokeStyle(Color4 color, float width /*, QuikStipplePattern pattern*/)
{ {
Color = color; Color = color;
Width = width; Width = width;
@ -269,7 +269,7 @@ namespace Dashboard
/// <summary> /// <summary>
/// Fill style for rectangles and the like. /// Fill style for rectangles and the like.
/// </summary> /// </summary>
public class QuikFillStyle public class FillStyle
{ {
public Color4 Color { get; set; } public Color4 Color { get; set; }
} }

@ -1,5 +1,5 @@
using Dashboard.Media; using Dashboard.Media;
using Dashboard.Media.Font; using Dashboard.Media.Fonts;
using Dashboard.PAL; using Dashboard.PAL;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -13,18 +13,18 @@ namespace Dashboard.Typography
/// </summary> /// </summary>
public class FontProvider : IDisposable public class FontProvider : IDisposable
{ {
private Dictionary<FontFace, QFont> Fonts { get; } = new Dictionary<FontFace, QFont>(); private Dictionary<FontFace, Font> Fonts { get; } = new Dictionary<FontFace, Font>();
private HashSet<QFont> UsedFonts { get; } = new HashSet<QFont>(); private HashSet<Font> UsedFonts { get; } = new HashSet<Font>();
public readonly FontRasterizerOptions RasterizerOptions; public readonly FontRasterizerOptions RasterizerOptions;
public IFontDataBase? Database { get; set; } public IFontDataBase? Database { get; set; }
public IFontFactory? FontFactory { get; set; } public IFontFactory? FontFactory { get; set; }
private readonly DbApplication App; private readonly DbApplication App;
public QFont this[FontFace info] public Font this[FontFace info]
{ {
get get
{ {
if (!Fonts.TryGetValue(info, out QFont? font)) if (!Fonts.TryGetValue(info, out Font? font))
{ {
using Stream str = Database?.Open(info) ?? throw new Exception("Font could not be found."); using Stream str = Database?.Open(info) ?? throw new Exception("Font could not be found.");
@ -43,7 +43,7 @@ namespace Dashboard.Typography
} }
} }
public QFont this[SystemFontFamily family] public Font this[SystemFontFamily family]
{ {
get get
{ {
@ -99,7 +99,7 @@ namespace Dashboard.Typography
if (isDisposed) return; if (isDisposed) return;
isDisposed = true; isDisposed = true;
foreach (QFont font in Fonts.Values) foreach (Font font in Fonts.Values)
{ {
font.Dispose(); font.Dispose();
} }

@ -227,7 +227,7 @@ namespace Dashboard.Typography
pen.Y -= PostSpace; pen.Y -= PostSpace;
group.BoundingBox = new QRectangle(width, pen.Y, 0, 0); group.BoundingBox = new Rectangle(width, pen.Y, 0, 0);
group.Translate(-pen); group.Translate(-pen);
} }
@ -354,15 +354,15 @@ namespace Dashboard.Typography
public struct TypesetCharacter public struct TypesetCharacter
{ {
public int Character; public int Character;
public QImage Texture; public Image Texture;
public QRectangle Position; public Rectangle Position;
public QRectangle UV; public Rectangle UV;
public TypesetCharacter( public TypesetCharacter(
int chr, int chr,
QImage texture, Image texture,
in QRectangle position, in Rectangle position,
in QRectangle uv) in Rectangle uv)
{ {
Character = chr; Character = chr;
Texture = texture; Texture = texture;
@ -376,7 +376,7 @@ namespace Dashboard.Typography
private int _count = 0; private int _count = 0;
private TypesetCharacter[] _array = Array.Empty<TypesetCharacter>(); private TypesetCharacter[] _array = Array.Empty<TypesetCharacter>();
public QRectangle BoundingBox; public Rectangle BoundingBox;
public int Count => _count; public int Count => _count;

@ -75,7 +75,7 @@ namespace Dashboard.Typography
} }
} }
public static Vector2 MeasureHorizontal(ReadOnlySpan<char> str, float size, QFont font) public static Vector2 MeasureHorizontal(ReadOnlySpan<char> str, float size, Font font)
{ {
var enumerator = new LineEnumerator(str); var enumerator = new LineEnumerator(str);
@ -103,9 +103,9 @@ namespace Dashboard.Typography
return new Vector2(width, height); return new Vector2(width, height);
} }
public static void TypesetHorizontalDirect(this DrawList list, ReadOnlySpan<char> str, Vector2 origin, float size, QFont font) public static void TypesetHorizontalDirect(this DrawList list, ReadOnlySpan<char> str, Vector2 origin, float size, Font font)
{ {
Dictionary<QImage, FontDrawInfo> drawInfo = new Dictionary<QImage, FontDrawInfo>(); Dictionary<Image, FontDrawInfo> drawInfo = new Dictionary<Image, FontDrawInfo>();
var enumerator = new LineEnumerator(str); var enumerator = new LineEnumerator(str);
Vector2 pen = origin; Vector2 pen = origin;
@ -135,8 +135,8 @@ namespace Dashboard.Typography
int codepoint = r.Value; int codepoint = r.Value;
font.Get(codepoint, size, out FontGlyph glyph); font.Get(codepoint, size, out FontGlyph glyph);
ref readonly QGlyphMetrics metrics = ref glyph.Metrics; ref readonly GlyphMetrics metrics = ref glyph.Metrics;
QImage? image = glyph.Image; Image? image = glyph.Image;
if (image == null) if (image == null)
{ {
@ -148,11 +148,11 @@ namespace Dashboard.Typography
{ {
info = new FontDrawInfo(); info = new FontDrawInfo();
info.Image = image; info.Image = image;
info.rectangles = new List<QRectangle>(); info.rectangles = new List<Rectangle>();
drawInfo[image] = info; drawInfo[image] = info;
} }
QRectangle dest = new QRectangle( Rectangle dest = new Rectangle(
pen + new Vector2(metrics.HorizontalBearing.X + metrics.Size.X, metrics.Size.Y - metrics.HorizontalBearing.Y), pen + new Vector2(metrics.HorizontalBearing.X + metrics.Size.X, metrics.Size.Y - metrics.HorizontalBearing.Y),
pen + new Vector2(metrics.HorizontalBearing.X, -metrics.HorizontalBearing.Y)); pen + new Vector2(metrics.HorizontalBearing.X, -metrics.HorizontalBearing.Y));
@ -175,8 +175,8 @@ namespace Dashboard.Typography
private struct FontDrawInfo private struct FontDrawInfo
{ {
public QImage Image; public Image Image;
public List<QRectangle> rectangles; public List<Rectangle> rectangles;
} }
} }
} }

@ -13,8 +13,8 @@ namespace Dashboard.VertexGenerator
private readonly List<DrawCall> _drawCalls = new List<DrawCall>(); private readonly List<DrawCall> _drawCalls = new List<DrawCall>();
private int _start; private int _start;
private int _baseOffset; private int _baseOffset;
private QRectangle _bounds; private Rectangle _bounds;
private QImage? _texture; private Image? _texture;
public int ZDepth { get; private set; } public int ZDepth { get; private set; }
public DbVertex[] VertexArray => _vertices.InternalArray; public DbVertex[] VertexArray => _vertices.InternalArray;
@ -33,7 +33,7 @@ namespace Dashboard.VertexGenerator
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void StartDrawCall(in QRectangle bounds, QImage? texture, int baseOffset) public void StartDrawCall(in Rectangle bounds, Image? texture, int baseOffset)
{ {
_start = ElementCount; _start = ElementCount;
_texture = texture; _texture = texture;
@ -42,13 +42,13 @@ namespace Dashboard.VertexGenerator
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void StartDrawCall(in QRectangle bounds) => StartDrawCall(bounds, null, _vertices.Count); public void StartDrawCall(in Rectangle bounds) => StartDrawCall(bounds, null, _vertices.Count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void StartDrawCall(in QRectangle bounds, int baseOffset) => StartDrawCall(bounds, null, baseOffset); public void StartDrawCall(in Rectangle bounds, int baseOffset) => StartDrawCall(bounds, null, baseOffset);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void StartDrawCall(in QRectangle bounds, QImage texture) => StartDrawCall(bounds, texture, _vertices.Count); public void StartDrawCall(in Rectangle bounds, Image texture) => StartDrawCall(bounds, texture, _vertices.Count);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AddVertex(in DbVertex vertex) public void AddVertex(in DbVertex vertex)
@ -99,10 +99,10 @@ namespace Dashboard.VertexGenerator
{ {
public int Start { get; } public int Start { get; }
public int Count { get; } public int Count { get; }
public QRectangle Bounds { get; } public Rectangle Bounds { get; }
public QImage? Texture { get; } public Image? Texture { get; }
public DrawCall(int start, int count, in QRectangle bounds, QImage? texture) public DrawCall(int start, int count, in Rectangle bounds, Image? texture)
{ {
Start = start; Start = start;
Count = count; Count = count;

@ -66,7 +66,7 @@ namespace Dashboard.VertexGenerator
return (int) Math.Ceiling(arc * radius * CurveGranularity); return (int) Math.Ceiling(arc * radius * CurveGranularity);
} }
private readonly List<QLine> LineList = new List<QLine>(); private readonly List<Line> LineList = new List<Line>();
private void LineProc(DrawQueue queue) private void LineProc(DrawQueue queue)
{ {
Frame frame = queue.Dequeue(); Frame frame = queue.Dequeue();
@ -79,12 +79,12 @@ namespace Dashboard.VertexGenerator
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
frame = queue.Dequeue(); frame = queue.Dequeue();
LineList.Add((QLine)frame); LineList.Add((Line)frame);
} }
} }
else else
{ {
LineList.Add((QLine)frame); LineList.Add((Line)frame);
} }
float width = Style.StrokeWidth ?? 1; float width = Style.StrokeWidth ?? 1;
@ -93,7 +93,7 @@ namespace Dashboard.VertexGenerator
LineInfo prevBase, nextBase = default; LineInfo prevBase, nextBase = default;
for (int i = 0; i < LineList.Count; i++) for (int i = 0; i < LineList.Count; i++)
{ {
QLine line = LineList[i]; Line line = LineList[i];
// A line segment needs a start cap if it is the first segment in // A line segment needs a start cap if it is the first segment in
// the list, or the last end point is not the current start point. // the list, or the last end point is not the current start point.
bool isStart = (i == 0 || line.Start != LineList[i - 1].End); bool isStart = (i == 0 || line.Start != LineList[i - 1].End);
@ -124,7 +124,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.EndDrawCall(); DrawQueue.EndDrawCall();
} }
private LineInfo GenerateLineSegment(in QLine line) private LineInfo GenerateLineSegment(in Line line)
{ {
DbVertex vertex = StrokeVertex; DbVertex vertex = StrokeVertex;
DbVertex a, b, c, d; DbVertex a, b, c, d;
@ -291,7 +291,7 @@ namespace Dashboard.VertexGenerator
} }
} }
private readonly List<QBezier> BezierList = new List<QBezier>(); private readonly List<Bezier> BezierList = new List<Bezier>();
private void BezierProc(DrawQueue queue) private void BezierProc(DrawQueue queue)
{ {
Frame a = queue.Dequeue(); Frame a = queue.Dequeue();
@ -308,7 +308,7 @@ namespace Dashboard.VertexGenerator
b = queue.Dequeue(); b = queue.Dequeue();
BezierList.Add( BezierList.Add(
new QBezier( new Bezier(
new Vector2(a.GetF(0), a.GetF(1)), new Vector2(a.GetF(0), a.GetF(1)),
new Vector2(b.GetF(0), b.GetF(1)), new Vector2(b.GetF(0), b.GetF(1)),
new Vector2(b.GetF(2), b.GetF(3)), new Vector2(b.GetF(2), b.GetF(3)),
@ -322,7 +322,7 @@ namespace Dashboard.VertexGenerator
b = queue.Dequeue(); b = queue.Dequeue();
BezierList.Add( BezierList.Add(
new QBezier( new Bezier(
new Vector2(a.GetF(0), a.GetF(1)), new Vector2(a.GetF(0), a.GetF(1)),
new Vector2(b.GetF(0), b.GetF(1)), new Vector2(b.GetF(0), b.GetF(1)),
new Vector2(b.GetF(2), b.GetF(3)), new Vector2(b.GetF(2), b.GetF(3)),
@ -337,7 +337,7 @@ namespace Dashboard.VertexGenerator
LineInfo prevBase, nextBase = default; LineInfo prevBase, nextBase = default;
for (int i = 0; i < LineList.Count; i++) for (int i = 0; i < LineList.Count; i++)
{ {
QBezier bezier = BezierList[i]; Bezier bezier = BezierList[i];
// A line segment needs a start cap if it is the first segment in // A line segment needs a start cap if it is the first segment in
// the list, or the last end point is not the current start point. // the list, or the last end point is not the current start point.
bool isStart = (i == 0 || bezier.Start != BezierList[i - 1].End); bool isStart = (i == 0 || bezier.Start != BezierList[i - 1].End);
@ -368,7 +368,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.EndDrawCall(); DrawQueue.EndDrawCall();
} }
private LineInfo GenerateBezierSegment(in QBezier bezier) private LineInfo GenerateBezierSegment(in Bezier bezier)
{ {
Vector2 startTangent = bezier.GetBezierTangent(0); Vector2 startTangent = bezier.GetBezierTangent(0);
Vector2 endTangent = bezier.GetBezierTangent(1); Vector2 endTangent = bezier.GetBezierTangent(1);
@ -408,7 +408,7 @@ namespace Dashboard.VertexGenerator
return new LineInfo(vbase, 0, 1, index - 2, index - 1); return new LineInfo(vbase, 0, 1, index - 2, index - 1);
} }
private readonly List<QRectangle> RectangleList = new List<QRectangle>(); private readonly List<Rectangle> RectangleList = new List<Rectangle>();
private void RectangleProc(DrawQueue queue) private void RectangleProc(DrawQueue queue)
{ {
Frame frame = queue.Dequeue(); Frame frame = queue.Dequeue();
@ -419,12 +419,12 @@ namespace Dashboard.VertexGenerator
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
frame = queue.Dequeue(); frame = queue.Dequeue();
RectangleList.Add((QRectangle)frame); RectangleList.Add((Rectangle)frame);
} }
} }
else else
{ {
RectangleList.Add((QRectangle)frame); RectangleList.Add((Rectangle)frame);
} }
float stroke = Style.StrokeWidth ?? 1.0f; float stroke = Style.StrokeWidth ?? 1.0f;
@ -432,8 +432,8 @@ namespace Dashboard.VertexGenerator
DrawQueue.StartDrawCall(Viewport); DrawQueue.StartDrawCall(Viewport);
for (int i = 0; i < RectangleList.Count; i++) for (int i = 0; i < RectangleList.Count; i++)
{ {
QRectangle outer = RectangleList[i]; Rectangle outer = RectangleList[i];
QRectangle inner = new QRectangle( Rectangle inner = new Rectangle(
outer.Right - stroke, outer.Bottom - stroke, outer.Right - stroke, outer.Bottom - stroke,
outer.Left + stroke, outer.Top + stroke); outer.Left + stroke, outer.Top + stroke);
@ -457,7 +457,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.EndDrawCall(); DrawQueue.EndDrawCall();
} }
private void GenerateRectangleBase(in QRectangle rectangle, float radius) private void GenerateRectangleBase(in Rectangle rectangle, float radius)
{ {
/* /*
+--j-------i--+ +--j-------i--+
@ -599,7 +599,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.AddElement(1); DrawQueue.AddElement(previous); DrawQueue.AddElement(6); DrawQueue.AddElement(1); DrawQueue.AddElement(previous); DrawQueue.AddElement(6);
} }
private void GenerateRectangleStripStraight(in QRectangle rectangle) private void GenerateRectangleStripStraight(in Rectangle rectangle)
{ {
/* /*
h---------g h---------g
@ -649,7 +649,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.AddElement(4); DrawQueue.AddElement(3); DrawQueue.AddElement(7); // SWW DrawQueue.AddElement(4); DrawQueue.AddElement(3); DrawQueue.AddElement(7); // SWW
} }
private void GenerateRectangleStripNarrow(in QRectangle rectangle, float radius) private void GenerateRectangleStripNarrow(in Rectangle rectangle, float radius)
{ {
/* /*
v-j---i-u v-j---i-u
@ -843,7 +843,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.AddElement(16); DrawQueue.AddElement(previous); DrawQueue.AddElement(17); DrawQueue.AddElement(16); DrawQueue.AddElement(previous); DrawQueue.AddElement(17);
} }
private void GenerateRectangleStripWide(in QRectangle rectangle, float radius) private void GenerateRectangleStripWide(in Rectangle rectangle, float radius)
{ {
/* /*
l---k l---k
@ -1016,7 +1016,7 @@ namespace Dashboard.VertexGenerator
{ {
Frame frame = queue.Dequeue(); Frame frame = queue.Dequeue();
ImageCommandFlags flags = (ImageCommandFlags)frame.I1; ImageCommandFlags flags = (ImageCommandFlags)frame.I1;
QImage image = queue.Dequeue().As<QImage>(); Image image = queue.Dequeue().As<Image>();
int count = flags.HasFlag(ImageCommandFlags.Single) ? 1 : frame.I2; int count = flags.HasFlag(ImageCommandFlags.Single) ? 1 : frame.I2;
if (flags.HasFlag(ImageCommandFlags.Image3d)) if (flags.HasFlag(ImageCommandFlags.Image3d))
@ -1029,22 +1029,22 @@ namespace Dashboard.VertexGenerator
} }
} }
private void Image2d(DrawQueue queue, QImage image, int count, bool uv) private void Image2d(DrawQueue queue, Image image, int count, bool uv)
{ {
DrawQueue.StartDrawCall(Viewport, image); DrawQueue.StartDrawCall(Viewport, image);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
QRectangle rect = (QRectangle)queue.Dequeue(); Rectangle rect = (Rectangle)queue.Dequeue();
QRectangle uvs; Rectangle uvs;
if (uv) if (uv)
{ {
uvs = (QRectangle)queue.Dequeue(); uvs = (Rectangle)queue.Dequeue();
} }
else else
{ {
uvs = new QRectangle(1, 1, 0, 0); uvs = new Rectangle(1, 1, 0, 0);
} }
DrawQueue.RestoreOffset(); DrawQueue.RestoreOffset();
@ -1073,14 +1073,14 @@ namespace Dashboard.VertexGenerator
DrawQueue.EndDrawCall(); DrawQueue.EndDrawCall();
} }
private void Image3d(DrawQueue queue, QImage image, int count) private void Image3d(DrawQueue queue, Image image, int count)
{ {
DrawQueue.StartDrawCall(Viewport, image); DrawQueue.StartDrawCall(Viewport, image);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
QRectangle rect = (QRectangle)queue.Dequeue(); Rectangle rect = (Rectangle)queue.Dequeue();
QRectangle uvs = (QRectangle)queue.Dequeue(); Rectangle uvs = (Rectangle)queue.Dequeue();
int layer = (int)queue.Dequeue(); int layer = (int)queue.Dequeue();
DrawQueue.RestoreOffset(); DrawQueue.RestoreOffset();

@ -20,7 +20,7 @@ namespace Dashboard.Demo
public class EmptyView : View public class EmptyView : View
{ {
private QFont? font; private Font? font;
DashboardBlurg dblurg = new DashboardBlurg(); DashboardBlurg dblurg = new DashboardBlurg();
BlurgResult? result; BlurgResult? result;
// private readonly Label Label = new Label() { Text = "Hello world!", Position = new QVec2(300, 300) }; // private readonly Label Label = new Label() { Text = "Hello world!", Position = new QVec2(300, 300) };
@ -43,7 +43,7 @@ namespace Dashboard.Demo
} }
cmd.PutBlurgText(dblurg, result!, new Vector2(300, 300)); cmd.PutBlurgText(dblurg, result!, new Vector2(300, 300));
cmd.Rectangle(new QRectangle(16, 16, 0, 0)); cmd.Rectangle(new Rectangle(16, 16, 0, 0));
// Label.Paint(cmd); // Label.Paint(cmd);
} }
} }