-
Notifications
You must be signed in to change notification settings - Fork 0
dmd: support DMD Studio colorization bypass #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| [assembly: InternalsVisibleTo("VisualPinball.Engine.DMD.Unity.Test")] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| using System; | ||
| using VisualPinball.Unity; | ||
|
|
||
| namespace VisualPinball.Engine.DMD.Unity | ||
| { | ||
| internal enum DmdColorizationPipelineAction | ||
| { | ||
| None, | ||
| Bypass, | ||
| Restore, | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Tracks whether the selected display must bypass a colorization source that cannot consume | ||
| /// the format emitted by its gamelogic engine. | ||
| /// </summary> | ||
| internal sealed class DmdColorizationPolicy | ||
| { | ||
| private DisplayConfig _display; | ||
| private bool _warningIssued; | ||
|
|
||
| public bool BypassColorization { get; private set; } | ||
| public bool AwaitingSupportedColorizedFrame { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Selects a display topology. An identical re-announcement deliberately preserves the | ||
| /// bypass latch; selecting a different id, geometry, or horizontal orientation resets it. | ||
| /// </summary> | ||
| public void SelectDisplay(DisplayConfig display) | ||
| { | ||
| if (SameTopology(_display, display)) { | ||
| return; | ||
| } | ||
|
|
||
| _display = display; | ||
| BypassColorization = false; | ||
| AwaitingSupportedColorizedFrame = false; | ||
| _warningIssued = false; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Decides whether the bridge must rebuild its pipeline. A Dmd8 frame may be the transient | ||
| /// pre-preference frame from a missed display announcement, so its bypass recovers when the | ||
| /// requested Dmd2/Dmd4 stream arrives. Dmd24 is RGB-authored and remains a sticky bypass. | ||
| /// </summary> | ||
| public DmdColorizationPipelineAction ObserveFrame(DisplayFrameFormat format, | ||
| bool pipelineUsesColorization, out bool shouldWarn) | ||
| { | ||
| if (!pipelineUsesColorization) { | ||
| if (BypassColorization && AwaitingSupportedColorizedFrame && SupportsColorization(format)) { | ||
| BypassColorization = false; | ||
| AwaitingSupportedColorizedFrame = false; | ||
| _warningIssued = false; | ||
| shouldWarn = false; | ||
| return DmdColorizationPipelineAction.Restore; | ||
| } | ||
| shouldWarn = false; | ||
| return DmdColorizationPipelineAction.None; | ||
| } | ||
|
|
||
| if (SupportsColorization(format)) { | ||
| shouldWarn = false; | ||
| return DmdColorizationPipelineAction.None; | ||
| } | ||
|
|
||
| BypassColorization = true; | ||
| AwaitingSupportedColorizedFrame = format == DisplayFrameFormat.Dmd8; | ||
| shouldWarn = !_warningIssued; | ||
| _warningIssued = true; | ||
| return DmdColorizationPipelineAction.Bypass; | ||
| } | ||
|
|
||
| public static bool SupportsColorization(DisplayFrameFormat format) | ||
| { | ||
| return format == DisplayFrameFormat.Dmd2 || format == DisplayFrameFormat.Dmd4; | ||
| } | ||
|
|
||
| private static bool SameTopology(DisplayConfig first, DisplayConfig second) | ||
| { | ||
| if (ReferenceEquals(first, second)) { | ||
| return true; | ||
| } | ||
| return first != null && second != null && | ||
| string.Equals(first.Id, second.Id, StringComparison.OrdinalIgnoreCase) && | ||
| first.Width == second.Width && first.Height == second.Height && first.FlipX == second.FlipX; | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.