Optimize static wait presentation
This commit is contained in:
@@ -39,6 +39,33 @@ public class GfxAnimationTests
|
||||
Assert.True(o.RotationEnabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ActiveVisualPresentation_ExcludesStaticWaits_ButIncludesAmbientChannels()
|
||||
{
|
||||
static GfxState VisibleObject()
|
||||
{
|
||||
var state = new GfxState();
|
||||
state.SetSurface(1, 5, -1);
|
||||
state.BindDraw(7, 1, 0, 0, 64, 64, 0, 0);
|
||||
return state;
|
||||
}
|
||||
|
||||
var unchanged = VisibleObject();
|
||||
Assert.False(unchanged.HasActiveVisualPresentation(1000));
|
||||
|
||||
var spritesheet = VisibleObject();
|
||||
spritesheet.SetSrcRect(7, 4, 1, 0, 800);
|
||||
Assert.True(spritesheet.HasActiveVisualPresentation(1000));
|
||||
|
||||
var color = VisibleObject();
|
||||
color.SetColorAnim(7, 1000, GfxState.PackColor(0x80, 0xff0000));
|
||||
Assert.True(color.HasActiveVisualPresentation(1000));
|
||||
|
||||
var rotation = VisibleObject();
|
||||
rotation.SetRotationCycle(7, 1000, (0, 0, 1));
|
||||
Assert.True(rotation.HasActiveVisualPresentation(1000));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OneShotRotation_SharesMatrixClockAndMatchesNativeSample()
|
||||
{
|
||||
|
||||
@@ -352,6 +352,21 @@ public sealed class GfxState
|
||||
o.RotationChannelEnabled || o.TranslationEnabled));
|
||||
}
|
||||
|
||||
/// <summary>Whether sampling the retained scene at a later frame can change its pixels without another
|
||||
/// VM mutation. Includes finite presentation work plus the ambient channels that may remain active while
|
||||
/// the interpreter is parked at an input wait. Static waits themselves are deliberately not animation.</summary>
|
||||
public bool HasActiveVisualPresentation(long nowMs)
|
||||
{
|
||||
lock (_lock)
|
||||
return _surfaceTransitions.Values.Any(t => TransitionProgress(t, nowMs) < 1.0) ||
|
||||
_objects.Values.Any(o => o.Visible &&
|
||||
(o.OneShotColorEnabled || o.ScaleEnabled || o.RotationChannelEnabled ||
|
||||
o.TranslationEnabled ||
|
||||
(o.SrcAnim && o.SrcPeriod > 0) ||
|
||||
(o.ColorAnim && o.ColorPeriod > 0) ||
|
||||
(o.RotationEnabled && o.RotationPeriodMs > 0)));
|
||||
}
|
||||
|
||||
/// <summary>Click completion affects only type-0 foreground transitions, never ambient object channels.</summary>
|
||||
public int CompleteForegroundTransitions(long nowMs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user