vector: bug fix: atlas size was not enough for antialias renderings

Closes #3377
This commit is contained in:
Hajime Hoshi
2026-01-27 15:00:54 +09:00
parent f66fd7e5ee
commit f650b2acd6
2 changed files with 26 additions and 1 deletions
+6 -1
View File
@@ -90,8 +90,13 @@ func (a *atlas) setPaths(dstBounds image.Rectangle, paths []*Path, bounds []imag
a.pathIndexToAtlasRegionIndex[r.pathIndex] = i
}
w, h := dstBounds.Dx(), dstBounds.Dy()
// For antialiasing, doubled regions in the X direction are used.
if antialias {
w *= 2
}
// Use 2^n - 1, as a region in internal/atlas has 1px padding.
maxImageSize := max(4093, dstBounds.Dx(), dstBounds.Dy())
maxImageSize := max(4093, w, h)
// Pack the regions into an atlas with a very simple algorithm:
// Order the regions by height and then place them in a row.
+20
View File
@@ -126,3 +126,23 @@ func TestFillRects(t *testing.T) {
t.Errorf("got: %v, want: %v", got, want)
}
}
// Issue #3377
func TestFillRectOnBigImage(t *testing.T) {
dst := ebiten.NewImage(3000, 3000)
defer dst.Deallocate()
vector.FillRect(dst, 0, 0, 3000, 3000, color.White, true)
if got, want := dst.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
if got, want := dst.At(2980, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
if got, want := dst.At(0, 2980), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
if got, want := dst.At(2980, 2980), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}