From 0d23240556ed9207766c058a6700474bd5cdb672 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 18 Feb 2025 14:55:46 +0000 Subject: [PATCH] gpu/internal/rendertest: allow nil pixel check functions Signed-off-by: Elias Naur --- gpu/internal/rendertest/clip_test.go | 12 ++++-------- gpu/internal/rendertest/render_test.go | 8 +++----- gpu/internal/rendertest/util_test.go | 4 +++- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/gpu/internal/rendertest/clip_test.go b/gpu/internal/rendertest/clip_test.go index 381e9784..53306f5e 100644 --- a/gpu/internal/rendertest/clip_test.go +++ b/gpu/internal/rendertest/clip_test.go @@ -132,8 +132,7 @@ func TestTexturedStrokeClipped(t *testing.T) { defer clip.RRect{Rect: image.Rect(-30, -30, 60, 60)}.Push(o).Pop() defer op.Offset(image.Pt(-10, -10)).Push(o).Pop() paint.PaintOp{}.Add(o) - }, func(r result) { - }) + }, nil) } func TestTexturedStroke(t *testing.T) { @@ -146,8 +145,7 @@ func TestTexturedStroke(t *testing.T) { }.Op().Push(o).Pop() defer op.Offset(image.Pt(-10, -10)).Push(o).Pop() paint.PaintOp{}.Add(o) - }, func(r result) { - }) + }, nil) } func TestPaintClippedTexture(t *testing.T) { @@ -252,8 +250,7 @@ func TestPathReuse(t *testing.T) { stroke := clip.Stroke{Path: spec, Width: 3}.Op().Push(o) paint.Fill(o, color.NRGBA{B: 0xFF, A: 0xFF}) stroke.Pop() - }, func(r result) { - }) + }, nil) } func TestPathInterleave(t *testing.T) { @@ -290,8 +287,7 @@ func TestStrokedRect(t *testing.T) { Width: 5, }.Op(), ) - }, func(r result) { - }) + }, nil) } func TestInstancedRects(t *testing.T) { diff --git a/gpu/internal/rendertest/render_test.go b/gpu/internal/rendertest/render_test.go index 41478319..35d025bc 100644 --- a/gpu/internal/rendertest/render_test.go +++ b/gpu/internal/rendertest/render_test.go @@ -124,8 +124,7 @@ func TestDeferredPaint(t *testing.T) { defer clip.Rect(image.Rect(0, 0, 80, 80)).Op().Push(o).Pop() paint.ColorOp{Color: color.NRGBA{A: 0x60, B: 0xff}}.Add(o) paint.PaintOp{}.Add(o) - }, func(r result) { - }) + }, nil) } func constSqPath() clip.Op { @@ -323,7 +322,7 @@ func TestLinearGradientAngled(t *testing.T) { cl = clip.Rect(image.Rect(0, 64, 64, 128)).Push(ops) paint.PaintOp{}.Add(ops) cl.Pop() - }, func(r result) {}) + }, nil) } func TestZeroImage(t *testing.T) { @@ -492,8 +491,7 @@ func TestOpacity(t *testing.T) { opc3 := paint.PushOpacity(ops, .6) paint.FillShape(ops, color.NRGBA{B: 255, A: 255}, clip.Ellipse(image.Rectangle{Min: image.Pt(20+20, 10), Max: image.Pt(50+64, 128)}).Op(ops)) opc3.Pop() - }, func(r result) { - }) + }, nil) } // lerp calculates linear interpolation with color b and p. diff --git a/gpu/internal/rendertest/util_test.go b/gpu/internal/rendertest/util_test.go index 5844deb0..c20e6b3d 100644 --- a/gpu/internal/rendertest/util_test.go +++ b/gpu/internal/rendertest/util_test.go @@ -90,7 +90,9 @@ func run(t *testing.T, f func(o *op.Ops), c func(r result)) { name := fmt.Sprintf("%s-%d-bad.png", t.Name(), i) saveImage(t, name, img) } - c(result{t: t, img: img}) + if c != nil { + c(result{t: t, img: img}) + } } }