From 1a62017331b87c5397161d5242197398e1422b83 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 25 Oct 2026 12:16:38 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8F=E3=83=BC=E3=83=8D=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E3=82=B1=E3=83=BC=E3=82=B9=E3=81=A8=E5=9F=BA=E6=BA=96=E5=80=A4?= =?UTF-8?q?=E3=82=92=E5=8A=A0=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BrushPluginHost.cs | 27 +++ PartialInnerOutline.Harness/HarnessCases.cs | 79 ++++++- PartialInnerOutline.Harness/golden.json | 223 ++++++++++++++++++ 3 files changed, 322 insertions(+), 7 deletions(-) create mode 100644 PartialInnerOutline.Harness/BrushPluginHost.cs create mode 100644 PartialInnerOutline.Harness/golden.json diff --git a/PartialInnerOutline.Harness/BrushPluginHost.cs b/PartialInnerOutline.Harness/BrushPluginHost.cs new file mode 100644 index 0000000..0a59283 --- /dev/null +++ b/PartialInnerOutline.Harness/BrushPluginHost.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using YukkuriMovieMaker.Plugin; + +namespace PartialInnerOutline.Harness; + +internal static class BrushPluginHost +{ + const string HostAssemblyName = "YukkuriMovieMaker"; + const string SolidColorPluginTypeName = "YukkuriMovieMaker.Plugin.Brush.SolidColorBrushPlugin"; + + static readonly Lock Gate = new(); + static bool registered; + + public static void Register() + { + lock (Gate) + { + if (registered) + return; + + var type = Assembly.Load(HostAssemblyName).GetType(SolidColorPluginTypeName, throwOnError: true)!; + var plugin = (IPlugin)Activator.CreateInstance(type, nonPublic: true)!; + typeof(PluginLoader).GetProperty(nameof(PluginLoader.Plugins))!.SetValue(null, new[] { plugin }); + registered = true; + } + } +} diff --git a/PartialInnerOutline.Harness/HarnessCases.cs b/PartialInnerOutline.Harness/HarnessCases.cs index efb3edf..08fd632 100644 --- a/PartialInnerOutline.Harness/HarnessCases.cs +++ b/PartialInnerOutline.Harness/HarnessCases.cs @@ -1,21 +1,86 @@ -using YukkuriMovieMaker.Plugin.Effects; +using System.Globalization; +using YukkuriMovieMaker.Commons; +using YukkuriMovieMaker.Json; +using YukkuriMovieMaker.Project; namespace PartialInnerOutline.Harness; internal static class HarnessCases { - public static IEnumerable<(string Name, IVideoEffect Effect, IReadOnlyList Frames)> All() + public static IEnumerable<(string Name, PartialInnerOutlineEffect Effect, IReadOnlyList Frames)> All() { - yield break; + yield return ("default", Create(), [0]); + yield return ("thickness-animated-frames", Create(effect => effect.Thickness.CopyFrom(Linear(1d, 24d))), [0, 100, 200, 299]); + yield return ("band-direction-animated-frames", Create(effect => effect.BandDirection.CopyFrom(Linear(0d, 360d))), [0, 100, 200, 299]); + yield return ("band-position-animated-frames", Create(effect => effect.BandPosition.CopyFrom(Linear(-100d, 100d))), [0, 100, 200, 299]); + yield return ("blur-animated-frames", Create(effect => effect.Blur.CopyFrom(Linear(0d, 12d))), [0, 100, 200, 299]); + yield return ("thickness-1", Create(effect => effect.Thickness.Values[0].Value = 1), [0]); + yield return ("thickness-8", Create(effect => effect.Thickness.Values[0].Value = 8), [0]); + yield return ("thickness-24", Create(effect => effect.Thickness.Values[0].Value = 24), [0]); + yield return ("quality-3", Create(effect => effect.Quality.Values[0].Value = 3), [0]); + yield return ("quality-8", Create(effect => effect.Quality.Values[0].Value = 8), [0]); + yield return ("smoothness-0", Create(effect => effect.Smoothness.Values[0].Value = 0), [0]); + yield return ("smoothness-50", Create(effect => effect.Smoothness.Values[0].Value = 50), [0]); + yield return ("angular", Create(effect => { effect.Thickness.Values[0].Value = 12; effect.IsAngular = true; }), [0]); + yield return ("band-direction-0", Create(effect => effect.BandDirection.Values[0].Value = 0), [0]); + yield return ("band-direction-45", Create(effect => effect.BandDirection.Values[0].Value = 45), [0]); + yield return ("band-direction-180-position-60", Create(effect => { effect.BandDirection.Values[0].Value = 180; effect.BandPosition.Values[0].Value = 60; }), [0]); + yield return ("band-position-minus-60", Create(effect => effect.BandPosition.Values[0].Value = -60), [0]); + yield return ("band-position-60", Create(effect => effect.BandPosition.Values[0].Value = 60), [0]); + yield return ("band-width-30", Create(effect => effect.BandWidth.Values[0].Value = 30), [0]); + yield return ("band-width-200", Create(effect => effect.BandWidth.Values[0].Value = 200), [0]); + yield return ("band-softness-0", Create(effect => effect.BandSoftness.Values[0].Value = 0), [0]); + yield return ("band-softness-100", Create(effect => effect.BandSoftness.Values[0].Value = 100), [0]); + yield return ("opacity-0", Create(effect => effect.Opacity.Values[0].Value = 0), [0]); + yield return ("opacity-50", Create(effect => effect.Opacity.Values[0].Value = 50), [0]); + yield return ("blur-4", Create(effect => effect.Blur.Values[0].Value = 4), [0]); + yield return ("blur-12", Create(effect => effect.Blur.Values[0].Value = 12), [0]); + yield return ("blend-add", Create(effect => effect.Blend = Blend.Add), [0]); + yield return ("blend-multiply", Create(effect => effect.Blend = Blend.Multiply), [0]); + yield return ("outline-only", Create(effect => effect.IsOutlineOnly = true), [0]); } - public static IEnumerable<(string Name, Func Create, Action Change, int Frame)> Transitions() + public static IEnumerable<(string Name, Func Create, Action Change, int Frame)> Transitions() { - yield break; + yield return ("thickness-3-to-10", () => Create(), effect => effect.Thickness.Values[0].Value = 10, 0); + yield return ("thickness-10-to-3", () => Create(effect => effect.Thickness.Values[0].Value = 10), effect => effect.Thickness.Values[0].Value = 3, 0); + yield return ("thickness-3-to-0", () => Create(), effect => effect.Thickness.Values[0].Value = 0, 0); + yield return ("thickness-0-to-3", () => Create(effect => effect.Thickness.Values[0].Value = 0), effect => effect.Thickness.Values[0].Value = 3, 0); + yield return ("quality-64-to-8", () => Create(), effect => effect.Quality.Values[0].Value = 8, 0); + yield return ("smoothness-100-to-0", () => Create(), effect => effect.Smoothness.Values[0].Value = 0, 0); + yield return ("angular-off-to-on", () => Create(), effect => effect.IsAngular = true, 0); + yield return ("band-direction-90-to-0", () => Create(), effect => effect.BandDirection.Values[0].Value = 0, 0); + yield return ("band-position-0-to-50", () => Create(), effect => effect.BandPosition.Values[0].Value = 50, 0); + yield return ("band-width-100-to-30", () => Create(), effect => effect.BandWidth.Values[0].Value = 30, 0); + yield return ("band-softness-30-to-0", () => Create(), effect => effect.BandSoftness.Values[0].Value = 0, 0); + yield return ("opacity-100-to-50", () => Create(), effect => effect.Opacity.Values[0].Value = 50, 0); + yield return ("opacity-100-to-0", () => Create(), effect => effect.Opacity.Values[0].Value = 0, 0); + yield return ("opacity-0-to-100", () => Create(effect => effect.Opacity.Values[0].Value = 0), effect => effect.Opacity.Values[0].Value = 100, 0); + yield return ("blur-0-to-8", () => Create(), effect => effect.Blur.Values[0].Value = 8, 0); + yield return ("blend-normal-to-multiply", () => Create(), effect => effect.Blend = Blend.Multiply, 0); + yield return ("blend-multiply-to-add", () => Create(effect => effect.Blend = Blend.Multiply), effect => effect.Blend = Blend.Add, 0); + yield return ("outline-only-off-to-on", () => Create(), effect => effect.IsOutlineOnly = true, 0); + yield return ("outline-only-on-to-off", () => Create(effect => effect.IsOutlineOnly = true), effect => effect.IsOutlineOnly = false, 0); } - public static IEnumerable<(string Name, IVideoEffect Effect)> Benchmarks() + public static IEnumerable<(string Name, PartialInnerOutlineEffect Effect)> Benchmarks() { - yield break; + yield return ("default", Create()); + yield return ("thickness-24", Create(effect => effect.Thickness.Values[0].Value = 24)); + yield return ("thickness-animated", Create(effect => effect.Thickness.CopyFrom(Linear(1d, 24d)))); + yield return ("band-direction-animated", Create(effect => effect.BandDirection.CopyFrom(Linear(0d, 360d)))); + yield return ("blur-animated", Create(effect => effect.Blur.CopyFrom(Linear(0d, 12d)))); + } + + static Animation Linear(double from, double to) + => Json.LoadFromText(string.Create(CultureInfo.InvariantCulture, $$"""{"AnimationType":"直線移動","Values":[{"Value":{{from}}},{"Value":{{to}}}]}""")) ?? throw new HarnessException("アニメーションを読み込めません。"); + + public static PartialInnerOutlineEffect Create(Action? configure = null) + { + BrushPluginHost.Register(); + var effect = new PartialInnerOutlineEffect(); + ((dynamic)effect.Brush.Parameter).Color = System.Windows.Media.Colors.Crimson; + configure?.Invoke(effect); + return effect; } } diff --git a/PartialInnerOutline.Harness/golden.json b/PartialInnerOutline.Harness/golden.json new file mode 100644 index 0000000..9b3cba0 --- /dev/null +++ b/PartialInnerOutline.Harness/golden.json @@ -0,0 +1,223 @@ +{ + "adapter": "Intel(R) Iris(R) Xe Graphics", + "driver": "32.0.101.7085", + "input": "synthetic 640x480 89838D8976198E40", + "canvas": "1280x720", + "cases": [ + { + "name": "default", + "frames": [ + 0 + ], + "hash": "80E3F994F559192E3AAD3880D63A3DDCB082068369D980F7C5A3192C65805E85" + }, + { + "name": "thickness-animated-frames", + "frames": [ + 0, + 100, + 200, + 299 + ], + "hash": "52165447E3A9E4AB51C590CBCC4ED6D185DC39FD9923DE8543A96C7151F29874" + }, + { + "name": "band-direction-animated-frames", + "frames": [ + 0, + 100, + 200, + 299 + ], + "hash": "4B1EF8FB97FD55FAB81BF97F33738E6EBD2111465A68C26D2E9A33045B7A1AE0" + }, + { + "name": "band-position-animated-frames", + "frames": [ + 0, + 100, + 200, + 299 + ], + "hash": "06354627B871591F1E325FF2909D20CD2722CC94B81D7A1ED3E570C18916CD50" + }, + { + "name": "blur-animated-frames", + "frames": [ + 0, + 100, + 200, + 299 + ], + "hash": "C5ECB468FE6FAC1A82D0D30692AC78FCC7A1A5C3DF2F1C89982DCD50EA332466" + }, + { + "name": "thickness-1", + "frames": [ + 0 + ], + "hash": "AC13DC6F17724D83ECE9E8208D8BAA29BC42BBBA6EA684E719A31B312D7DC94E" + }, + { + "name": "thickness-8", + "frames": [ + 0 + ], + "hash": "0B39863016618CB5B4389D093F3B02975096F8419A86DBD1859C7F8AFBCE9D04" + }, + { + "name": "thickness-24", + "frames": [ + 0 + ], + "hash": "69F4BF304C947A9EA5FA374F1416DA3A5A29ED21F90BFA66C1A76331C4A5A5EC" + }, + { + "name": "quality-3", + "frames": [ + 0 + ], + "hash": "0ED5D81E3FB472ECFBF75FD26750DE9C7B0CEA9560F4A50B9E23BE45B70DB9B8" + }, + { + "name": "quality-8", + "frames": [ + 0 + ], + "hash": "B0CA4F4523342DE33EFFCB8B78D6994AB1F0D28DC019A34CAEAD8509A5803C07" + }, + { + "name": "smoothness-0", + "frames": [ + 0 + ], + "hash": "84A5C36E15A18A87954FC4D41A16C182B90F821177FFA08E641AA1B9FF476D20" + }, + { + "name": "smoothness-50", + "frames": [ + 0 + ], + "hash": "9A1DB3B2CE6E601DCE4339673F1FB6AA1A8B9217AE472E1FFF5793AEEEC4BBA3" + }, + { + "name": "angular", + "frames": [ + 0 + ], + "hash": "6489DFBEFA599C97A55360D2F46A52DF2E3945A535AD7C268BDBB67444C7280D" + }, + { + "name": "band-direction-0", + "frames": [ + 0 + ], + "hash": "78964B616B97CD1976CC90FCFFBAD55BC66A4F5429BE45A67DE59D74A1706924" + }, + { + "name": "band-direction-45", + "frames": [ + 0 + ], + "hash": "B0C94A6FAA93770A193F77D57E2DA08C6FBF8094A56A613CAA86C85DDFF391E1" + }, + { + "name": "band-direction-180-position-60", + "frames": [ + 0 + ], + "hash": "83B5D9E2EB4AF36B33AA75C8CBCCE081ACE51D501D937D313D6031CD44FDDD5F" + }, + { + "name": "band-position-minus-60", + "frames": [ + 0 + ], + "hash": "A9888B8BB3007ACABE5ACFF4C320624320CD10EB0069BB6D4B3795E8D41C544D" + }, + { + "name": "band-position-60", + "frames": [ + 0 + ], + "hash": "620295BF1C3195ACC9AFB07AF31D89C8BB697795C65B3747EADDCCF6C90C1138" + }, + { + "name": "band-width-30", + "frames": [ + 0 + ], + "hash": "25D5DE8E0D23037BEC72AC53ED7E18ECED0C7C7B44B12400A52E4668B5AA87AC" + }, + { + "name": "band-width-200", + "frames": [ + 0 + ], + "hash": "D894A40AB1E0AE4346BC23E66EB14BC524A23DAFA9F813580DEC10EBE9BC6B3E" + }, + { + "name": "band-softness-0", + "frames": [ + 0 + ], + "hash": "41EE8736988B19805724386B2FB7622504BF657DC5B60E7D638C8875B62A82F3" + }, + { + "name": "band-softness-100", + "frames": [ + 0 + ], + "hash": "34FDB5ABD0428D5868B34CD123913AAA19FEC848DFCAE77B92E383F83407E4EE" + }, + { + "name": "opacity-0", + "frames": [ + 0 + ], + "hash": "0A700F76CEDDBAD7C4B6A2C19D46939C1A93940E86C6EFEF1E5A53DB48D2A020" + }, + { + "name": "opacity-50", + "frames": [ + 0 + ], + "hash": "F641BC48C3096A104C12519EE2CA40BFCD77DA8359C648AA6BA9356958DC8782" + }, + { + "name": "blur-4", + "frames": [ + 0 + ], + "hash": "A707F6EFF0BC9AD4847B38C84541B056FA976782E3D857AEAD11535EC31C1393" + }, + { + "name": "blur-12", + "frames": [ + 0 + ], + "hash": "F94C5B356122C6ACE07BC52CAF72FB0F4D739861CCF9E028C0951B4DF13E8246" + }, + { + "name": "blend-add", + "frames": [ + 0 + ], + "hash": "CF6DA6B2E42DC7378F5EEA57BDA95A9ECCC375A023BA407313A7B99969F15FE0" + }, + { + "name": "blend-multiply", + "frames": [ + 0 + ], + "hash": "FFCCAD8DD4F0D73070070A3DA418C278D0D7A4EDCF4F36E1F422071FA0359381" + }, + { + "name": "outline-only", + "frames": [ + 0 + ], + "hash": "6FC7737B6FA5A62A4195299EF27BBF92058A1613D9F240B0C4E17F82CEBCC95A" + } + ] +} \ No newline at end of file