mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-11-01 23:04:16 +01:00
Hide benchmark plugins in release build
This commit is contained in:
Binary file not shown.
@@ -7,6 +7,8 @@ using System.Drawing.Drawing2D;
|
|||||||
|
|
||||||
namespace DesktopMagic.BuiltInPlugins;
|
namespace DesktopMagic.BuiltInPlugins;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
|
||||||
internal class BenchmarkPlugin : Plugin
|
internal class BenchmarkPlugin : Plugin
|
||||||
{
|
{
|
||||||
private readonly Random rng = new(42);
|
private readonly Random rng = new(42);
|
||||||
@@ -125,3 +127,5 @@ internal class BenchmarkPlugin : Plugin
|
|||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -8,6 +8,8 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace DesktopMagic.BuiltInPlugins;
|
namespace DesktopMagic.BuiltInPlugins;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
|
||||||
internal class SkiaBenchmarkPlugin : SkiaPlugin
|
internal class SkiaBenchmarkPlugin : SkiaPlugin
|
||||||
{
|
{
|
||||||
private readonly Random rng = new(42);
|
private readonly Random rng = new(42);
|
||||||
@@ -28,8 +30,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
|
|
||||||
public override int UpdateInterval => 1;
|
public override int UpdateInterval => 1;
|
||||||
|
|
||||||
SKSurface surface;
|
private SKSurface? surface;
|
||||||
|
|
||||||
|
|
||||||
public override void Start()
|
public override void Start()
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
if (lastFrameMs > 0)
|
if (lastFrameMs > 0)
|
||||||
{
|
{
|
||||||
double elapsed = now - lastFrameMs;
|
double elapsed = now - lastFrameMs;
|
||||||
fps = fps * 0.9 + (1000.0 / Math.Max(elapsed, 1)) * 0.1;
|
fps = (fps * 0.9) + (1000.0 / Math.Max(elapsed, 1) * 0.1);
|
||||||
}
|
}
|
||||||
lastFrameMs = now;
|
lastFrameMs = now;
|
||||||
|
|
||||||
@@ -55,7 +56,6 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
int w = Math.Max(1, pixelSize.Width);
|
int w = Math.Max(1, pixelSize.Width);
|
||||||
int h = Math.Max(1, pixelSize.Height);
|
int h = Math.Max(1, pixelSize.Height);
|
||||||
|
|
||||||
|
|
||||||
SKCanvas canvas = surface.Canvas;
|
SKCanvas canvas = surface.Canvas;
|
||||||
|
|
||||||
canvas.Clear(SKColors.Transparent);
|
canvas.Clear(SKColors.Transparent);
|
||||||
@@ -81,7 +81,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte alpha = (byte)rng.Next(100, 255);
|
byte alpha = (byte)rng.Next(100, 255);
|
||||||
using var paint = new SKPaint
|
using SKPaint paint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = color.WithAlpha(alpha),
|
Color = color.WithAlpha(alpha),
|
||||||
IsAntialias = false,
|
IsAntialias = false,
|
||||||
@@ -94,7 +94,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
canvas.DrawRect(x, y, rw, rh, paint);
|
canvas.DrawRect(x, y, rw, rh, paint);
|
||||||
break;
|
break;
|
||||||
case "Ellipses":
|
case "Ellipses":
|
||||||
canvas.DrawOval(x + rw / 2f, y + rh / 2f, rw / 2f, rh / 2f, paint);
|
canvas.DrawOval(x + (rw / 2f), y + (rh / 2f), rw / 2f, rh / 2f, paint);
|
||||||
break;
|
break;
|
||||||
case "Lines":
|
case "Lines":
|
||||||
paint.Style = SKPaintStyle.Stroke;
|
paint.Style = SKPaintStyle.Stroke;
|
||||||
@@ -102,7 +102,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
canvas.DrawLine(x, y, x + rw, y + rh, paint);
|
canvas.DrawLine(x, y, x + rw, y + rh, paint);
|
||||||
break;
|
break;
|
||||||
case "Text":
|
case "Text":
|
||||||
using (var textFont = new SKFont(SKTypeface.Default, 16))
|
using (SKFont textFont = new SKFont(SKTypeface.Default, 16))
|
||||||
{
|
{
|
||||||
canvas.DrawText("Mg", x, y + 16, SKTextAlign.Left, textFont, paint);
|
canvas.DrawText("Mg", x, y + 16, SKTextAlign.Left, textFont, paint);
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
}
|
}
|
||||||
else if (shape == 1)
|
else if (shape == 1)
|
||||||
{
|
{
|
||||||
canvas.DrawOval(x + rw / 2f, y + rh / 2f, rw / 2f, rh / 2f, paint);
|
canvas.DrawOval(x + (rw / 2f), y + (rh / 2f), rw / 2f, rh / 2f, paint);
|
||||||
}
|
}
|
||||||
else if (shape == 2)
|
else if (shape == 2)
|
||||||
{
|
{
|
||||||
@@ -126,7 +126,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using var textFont2 = new SKFont(SKTypeface.Default, 16);
|
using SKFont textFont2 = new SKFont(SKTypeface.Default, 16);
|
||||||
canvas.DrawText("Mg", x, y + 16, SKTextAlign.Left, textFont2, paint);
|
canvas.DrawText("Mg", x, y + 16, SKTextAlign.Left, textFont2, paint);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -138,3 +138,5 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
|
|||||||
return surface.Snapshot();
|
return surface.Snapshot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -50,8 +50,10 @@ public sealed class Manager
|
|||||||
{new((string)App.LanguageDictionary["weather"], 5) { Author = "Stone_Red" }, typeof(WeatherPlugin)},
|
{new((string)App.LanguageDictionary["weather"], 5) { Author = "Stone_Red" }, typeof(WeatherPlugin)},
|
||||||
{new((string)App.LanguageDictionary["nextMeetingCountdown"], 6) { Author = "Stone_Red" }, typeof(NextMeetingCountdownPlugin)},
|
{new((string)App.LanguageDictionary["nextMeetingCountdown"], 6) { Author = "Stone_Red" }, typeof(NextMeetingCountdownPlugin)},
|
||||||
{new((string)App.LanguageDictionary["agenda"], 7) { Author = "Stone_Red" }, typeof(AgendaPlugin)},
|
{new((string)App.LanguageDictionary["agenda"], 7) { Author = "Stone_Red" }, typeof(AgendaPlugin)},
|
||||||
|
#if DEBUG
|
||||||
{new((string)App.LanguageDictionary["benchmark"], 8) { Author = "Stone_Red" }, typeof(BenchmarkPlugin)},
|
{new((string)App.LanguageDictionary["benchmark"], 8) { Author = "Stone_Red" }, typeof(BenchmarkPlugin)},
|
||||||
{new((string)App.LanguageDictionary["skiaBenchmark"], 9) { Author = "Stone_Red" }, typeof(SkiaBenchmarkPlugin)},
|
{new((string)App.LanguageDictionary["skiaBenchmark"], 9) { Author = "Stone_Red" }, typeof(SkiaBenchmarkPlugin)},
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Window management
|
// Window management
|
||||||
|
|||||||
Reference in New Issue
Block a user