gpu/internal/rendertest: add regression test for issue 331

References: https://todo.sr.ht/~eliasnaur/gio/331
Signed-off-by: Andy Balholm <andy@balholm.com>
This commit is contained in:
Andy Balholm
2022-01-11 11:24:53 -08:00
committed by Elias Naur
parent b2a99fddca
commit 456f22c986
3 changed files with 28 additions and 1 deletions
+6 -1
View File
@@ -195,7 +195,7 @@ func verifyRef(t *testing.T, img *image.RGBA, frame int) (ok bool) {
for y := bnd.Min.Y; y < bnd.Max.Y; y++ {
exp := ref.RGBAAt(x, y)
got := img.RGBAAt(x, y)
if !colorsClose(exp, got) {
if !colorsClose(exp, got) || !alphaClose(exp, got) {
t.Error("not equal to ref at", x, y, " ", got, exp)
return false
}
@@ -209,6 +209,11 @@ func colorsClose(c1, c2 color.RGBA) bool {
return yiqEqApprox(c1, c2, delta)
}
func alphaClose(c1, c2 color.RGBA) bool {
d := int8(c1.A - c2.A)
return d > -5 && d < 5
}
// yiqEqApprox compares the colors of 2 pixels, in the NTSC YIQ color space,
// as described in:
//