Skip to content

Commit 8c76fc9

Browse files
committed
vector: bug fix: atlas size was not enough for antialias renderings
Closes #3377
1 parent e5c8863 commit 8c76fc9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

vector/atlas.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ func (a *atlas) setPaths(dstBounds image.Rectangle, paths []*Path, antialias boo
9090
a.pathIndexToAtlasRegionIndex[r.pathIndex] = i
9191
}
9292

93+
w, h := dstBounds.Dx(), dstBounds.Dy()
94+
// For antialiasing, doubled regions in the X direction are used.
95+
if antialias {
96+
w *= 2
97+
}
9398
// Use 2^n - 1, as a region in internal/atlas has 1px padding.
94-
maxImageSize := max(4093, dstBounds.Dx(), dstBounds.Dy())
99+
maxImageSize := max(4093, w, h)
95100

96101
// Pack the regions into an atlas with a very simple algorithm:
97102
// Order the regions by height and then place them in a row.

vector/util_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,23 @@ func TestFillRects(t *testing.T) {
225225
t.Errorf("got: %v, want: %v", got, want)
226226
}
227227
}
228+
229+
// Issue #3377
230+
func TestFillRectOnBigImage(t *testing.T) {
231+
dst := ebiten.NewImage(3000, 3000)
232+
defer dst.Deallocate()
233+
234+
vector.FillRect(dst, 0, 0, 3000, 3000, color.White, true)
235+
if got, want := dst.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
236+
t.Errorf("got: %v, want: %v", got, want)
237+
}
238+
if got, want := dst.At(2980, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
239+
t.Errorf("got: %v, want: %v", got, want)
240+
}
241+
if got, want := dst.At(0, 2980), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
242+
t.Errorf("got: %v, want: %v", got, want)
243+
}
244+
if got, want := dst.At(2980, 2980), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
245+
t.Errorf("got: %v, want: %v", got, want)
246+
}
247+
}

0 commit comments

Comments
 (0)