Fix ADV chrome one-shot blending
This commit is contained in:
@@ -35,17 +35,19 @@ public class OneShotColorTests
|
||||
gfx.SetAnimatedObjectColorResolved(0x100, 100, 400, 0xff, 0x90a0b0);
|
||||
|
||||
var start = gfx.SnapshotVisibleObjects(1000).Single();
|
||||
Assert.Equal(0, start.TintStrength);
|
||||
Assert.Equal(0, start.Alpha);
|
||||
Assert.True(start.MultiplyTint);
|
||||
Assert.Equal(0.0, start.ColorTransition!.Value.Progress);
|
||||
Assert.Equal(0, gfx.SnapshotVisibleObjects(1100).Single().TintStrength);
|
||||
Assert.Equal(0, gfx.SnapshotVisibleObjects(1100).Single().Alpha);
|
||||
|
||||
var half = gfx.SnapshotVisibleObjects(1300).Single();
|
||||
Assert.Equal(0x7f, half.TintStrength);
|
||||
Assert.Equal(0x7f, half.Alpha);
|
||||
Assert.Equal(0x506070, half.Tint);
|
||||
Assert.Equal(0.5, half.ColorTransition!.Value.Progress, 3);
|
||||
|
||||
var end = gfx.SnapshotVisibleObjects(1500).Single();
|
||||
Assert.Equal(0xff, end.TintStrength);
|
||||
Assert.Equal(0xff, end.Alpha);
|
||||
Assert.True(end.MultiplyTint); // committed endpoints keep the op-0x202 blend contract
|
||||
Assert.Equal(0x90a0b0, end.Tint);
|
||||
Assert.False(gfx.TryGet(0x100)!.OneShotColorEnabled);
|
||||
Assert.Equal(-1, gfx.TryGet(0x100)!.OneShotColorTarget);
|
||||
@@ -59,10 +61,10 @@ public class OneShotColorTests
|
||||
gfx.SetStaticObjectColorResolved(0x100, 0, 0xff, 0xffffff);
|
||||
|
||||
var start = gfx.SnapshotVisibleObjects(2000).Single();
|
||||
Assert.Equal(0xff, start.TintStrength);
|
||||
Assert.Equal(0xff, start.Alpha);
|
||||
Assert.Equal(0xffffff, start.Tint);
|
||||
var half = gfx.SnapshotVisibleObjects(2150).Single();
|
||||
Assert.Equal(0x7f, half.TintStrength);
|
||||
Assert.Equal(0x7f, half.Alpha);
|
||||
Assert.Equal(0xffffff, half.Tint);
|
||||
}
|
||||
|
||||
@@ -75,7 +77,7 @@ public class OneShotColorTests
|
||||
|
||||
gfx.SnapshotVisibleObjects(5000);
|
||||
var half = gfx.SnapshotVisibleObjects(5500).Single();
|
||||
Assert.Equal(0x7f, half.TintStrength);
|
||||
Assert.Equal(0x7f, half.Alpha);
|
||||
Assert.Equal(1.5, half.Transform.ScaleX, 3);
|
||||
Assert.Equal(5000, half.ColorTransition!.Value.StartMs);
|
||||
}
|
||||
|
||||
@@ -77,6 +77,21 @@ public class RenderObjectBlendTests
|
||||
Assert.Equal(BlendKind.Alpha, ro.Blend);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Mode0_OneShotColor_UsesOpacityAndMultiplicativeRgbAfterCommit()
|
||||
{
|
||||
var g = WithVisibleObject(0x100, resId: 5, colorKey: -1);
|
||||
g.SetAnimatedObjectColorResolved(0x100, 0, 100, 0x00, 0xffffff);
|
||||
g.SetStaticObjectColorResolved(0x100, 0, 0xff, 0xffffff);
|
||||
|
||||
g.SnapshotVisibleObjects(1000); // seed
|
||||
var hidden = g.SnapshotVisibleObjects(1100).Single();
|
||||
Assert.Equal(0, hidden.Alpha);
|
||||
Assert.Equal(0, hidden.TintStrength);
|
||||
Assert.True(hidden.MultiplyTint);
|
||||
Assert.False(g.TryGet(0x100)!.OneShotColorEnabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ColorKey_IsCarriedThrough()
|
||||
{
|
||||
|
||||
@@ -40,4 +40,20 @@ public class SoftwareAffineRasterizerTests
|
||||
Assert.InRange(dst[2], 5, 7);
|
||||
Assert.InRange(dst[3], 126, 127);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BlitRgba_WhiteModulationPreservesYellowAndZeroOpacityHidesIt()
|
||||
{
|
||||
byte[] src = { 240, 192, 16, 255 };
|
||||
byte[] visible = new byte[4];
|
||||
var identity = new Affine2D(1, 0, 0, 1, 0, 0);
|
||||
SoftwareAffineRasterizer.BlitRgba(visible, 1, 1, src, 1, 1, 0, 0, 1, 1,
|
||||
identity, 0xffffff, 0, 1, multiplyTint: true);
|
||||
Assert.Equal(new byte[] { 240, 192, 16, 255 }, visible);
|
||||
|
||||
byte[] hidden = new byte[4];
|
||||
SoftwareAffineRasterizer.BlitRgba(hidden, 1, 1, src, 1, 1, 0, 0, 1, 1,
|
||||
identity, 0xffffff, 0, 0, multiplyTint: true);
|
||||
Assert.Equal(new byte[4], hidden);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user